[rkward/work/generalized_preview] rkward: Initialize area for docked previews (with an empty data.frame).
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Jan 7 12:17:42 UTC 2016
Git commit 6040a8c86133a44a084a1e83e8eeaf1c361cef58 by Thomas Friedrichsmeier.
Committed on 07/01/2016 at 12:17.
Pushed by tfry into branch 'work/generalized_preview'.
Initialize area for docked previews (with an empty data.frame).
M +10 -7 rkward/plugin/rkpreviewbox.cpp
M +2 -0 rkward/plugin/rkpreviewbox.h
M +1 -0 rkward/plugins/00saveload/import/import_csv.rkh
http://commits.kde.org/rkward/6040a8c86133a44a084a1e83e8eeaf1c361cef58
diff --git a/rkward/plugin/rkpreviewbox.cpp b/rkward/plugin/rkpreviewbox.cpp
index d8aca6e..34f3ea2 100644
--- a/rkward/plugin/rkpreviewbox.cpp
+++ b/rkward/plugin/rkpreviewbox.cpp
@@ -66,12 +66,22 @@ RKPreviewBox::RKPreviewBox (const QDomElement &element, RKComponent *parent_comp
status_label = new QLabel (QString (), this);
vbox->addWidget (status_label);
+ // prepare placement
+ placement_command = ".rk.with.window.hints ({";
+ placement_end = "\n}, ";
+ if (placement == AttachedPreview) placement_end.append ("\"attached\"");
+ else if (placement == DetachedPreview) placement_end.append ("\"detached\"");
+ else placement_end.append ("\"\"");
+ placement_end.append (", " + RObject::rQuote (idprop) + ", style=\"preview\")");
if (placement == DockedPreview) {
RKStandardComponent *uicomp = topmostStandardComponent ();
if (uicomp) {
QWidget *container = new KVBox ();
RKWorkplace::mainWorkplace ()->registerNamedWindow (idprop, this, container);
uicomp->addDockedPreview (container, state, toggle_preview_box->text ());
+ // create an empty data.frame as dummy. This is only really appropriate for data-previews, but even for other docked previews it has the effect of initializing the preview area
+ // with _something_.
+ RKGlobals::rInterface ()->issueCommand ("local ({\nrk.assign.preview.data(" + idprop + ", data.frame ())\n})\n" + placement_command + "rk.edit(rkward::.rk.variables$.rk.preview.data[[" + idprop + "]])" + placement_end, RCommand::Plugin | RCommand::Sync);
}
}
@@ -162,13 +172,6 @@ void RKPreviewBox::tryPreviewNow () {
preview_active = true;
- QString placement_command = ".rk.with.window.hints ({";
- QString placement_end = "\n}, ";
- if (placement == AttachedPreview) placement_end.append ("\"attached\"");
- else if (placement == DetachedPreview) placement_end.append ("\"detached\"");
- else placement_end.append ("\"\"");
- placement_end.append (", " + RObject::rQuote (idprop) + ", style=\"preview\")");
-
setStatusMessage (i18n ("Preview updating"));
if (preview_mode == PlotPreview) {
RKGlobals::rInterface ()->issueCommand (placement_command + ".rk.startPreviewDevice (" + idprop + ')' + placement_end, RCommand::Plugin | RCommand::Sync, QString ());
diff --git a/rkward/plugin/rkpreviewbox.h b/rkward/plugin/rkpreviewbox.h
index fa74f4a..400ba40 100644
--- a/rkward/plugin/rkpreviewbox.h
+++ b/rkward/plugin/rkpreviewbox.h
@@ -74,6 +74,8 @@ private:
QLabel *status_label;
RKComponentPropertyCode *code_property;
QString idprop;
+ QString placement_command;
+ QString placement_end;
};
#endif
diff --git a/rkward/plugins/00saveload/import/import_csv.rkh b/rkward/plugins/00saveload/import/import_csv.rkh
index 03d89ab..a4d09d6 100644
--- a/rkward/plugins/00saveload/import/import_csv.rkh
+++ b/rkward/plugins/00saveload/import/import_csv.rkh
@@ -19,6 +19,7 @@ Choose the CSV file to import. An R object containing the data will be created.
<setting id="custom_sep">If you selected "other" above, specify the character, here.</setting>
<setting id="name">The name of an R object to store the imported data in. If you choose an existing symbol name, you will be prompted, whether to overwrite this object.</setting>
<setting id="doedit">Whether the object should be opened for editing after it was imported</setting>
+ <setting id="preview">Show a preview of the imported data. At most the first 50 rows will be shown.</setting>
<caption id="tab_rows"/>
<setting id="rowname">How to determine row names? Either the rows can be numbered 1...n. Or you can specify a single column containing the row names (typically the first). Or you can provide a character vector of names.</setting>
More information about the rkward-tracker
mailing list