[rkward/work/generalized_preview] /: Implicitly save code preview visibility and size (instead of the former explicit settings)
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Sat Jan 9 10:44:26 UTC 2016
Git commit 2b9a8a839711e1079c67c4b1d74e98a9f3ae7b14 by Thomas Friedrichsmeier.
Committed on 09/01/2016 at 10:44.
Pushed by tfry into branch 'work/generalized_preview'.
Implicitly save code preview visibility and size (instead of the former explicit settings)
M +1 -0 ChangeLog
M +16 -2 rkward/plugin/rkstandardcomponentgui.cpp
M +1 -1 rkward/plugins/00saveload/import/import_csv.js
M +1 -1 rkward/plugins/00saveload/import/import_csv.rkh
M +5 -25 rkward/settings/rksettingsmoduleplugins.cpp
M +6 -3 rkward/settings/rksettingsmoduleplugins.h
http://commits.kde.org/rkward/2b9a8a839711e1079c67c4b1d74e98a9f3ae7b14
diff --git a/ChangeLog b/ChangeLog
index 43f7d1e..ca44afc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Implicitly save code preview visibility and size (instead of the former explicit settings)
- data.frame objects outside of globalenv() can be opened read-only in an editor window
- Show a warning screen when invoking plugins from the command line (or from clicking an rkward://-link in an external application)
diff --git a/rkward/plugin/rkstandardcomponentgui.cpp b/rkward/plugin/rkstandardcomponentgui.cpp
index 2c09048..33ad4b7 100644
--- a/rkward/plugin/rkstandardcomponentgui.cpp
+++ b/rkward/plugin/rkstandardcomponentgui.cpp
@@ -78,6 +78,19 @@ RKStandardComponentGUI::RKStandardComponentGUI (RKStandardComponent *component,
RKStandardComponentGUI::~RKStandardComponentGUI () {
RK_TRACE (PLUGIN);
+
+ if (!enslaved && toggle_code_box && splitter) { // A top-level dialog-style UI
+ for (int i = 0; i < previews.size (); ++i) {
+ bool visible = previews[i].controller->boolValue ();
+ int size = visible ? previews[i].area->height () : previews[i].sizehint;
+ if (i == previews.size () - 1) { // code preview
+ RKSettingsModulePlugins::setShowCodeByDefault (visible);
+ if (size > 0) RKSettingsModulePlugins::setDefaultCodeHeight (size);
+ } else {
+ if (size > 0) RKSettingsModulePlugins::setDefaultOtherPreviewHeight (size);
+ }
+ }
+ }
}
void RKStandardComponentGUI::createDialog (bool switchable) {
@@ -267,10 +280,11 @@ void RKStandardComponentGUI::previewVisibilityChanged (RKComponentPropertyBase*
if (visible) {
int h = area.sizehint;
- if (h <= 0) h = RKSettingsModulePlugins::defaultCodeHeight ();
+ if (h <= 0) h = (pos == previews.size () - 1) ? RKSettingsModulePlugins::defaultCodeHeight () : RKSettingsModulePlugins::defaultOtherPreviewHeight ();
+ if (h < 40) h = 40;
new_height += h;
area.area->show ();
- sizes[pos+1] = RKSettingsModulePlugins::defaultCodeHeight ();
+ sizes[pos+1] = h;
} else {
area.sizehint = sizes[pos + 1];
new_height -= area.sizehint;
diff --git a/rkward/plugins/00saveload/import/import_csv.js b/rkward/plugins/00saveload/import/import_csv.js
index c3aee1e..505e967 100644
--- a/rkward/plugins/00saveload/import/import_csv.js
+++ b/rkward/plugins/00saveload/import/import_csv.js
@@ -40,7 +40,7 @@ function doCalculate (is_preview) {
echo (' na.strings = "' + getValue("na") + '", ' + nrows + ', skip = ' + getValue("skip") + ', check.names = ' + getValue("checkname") + ', strip.white = ' + getValue("stripwhite") + ', blank.lines.skip = ' + getValue("blanklinesskip") + getValue("allow_escapes") + getValue("flush") + getValue("strings_as_factors") + ')\n');
echo ('\n');
if (is_preview) {
- echo ('preview_data <- imported\n');
+ echo ('preview_data <- imported[1:min(50,length(imported))]\n'); // limit preview to first 50 columns for efficiency
} else {
comment ('copy from the local environment to globalenv()');
echo ('.GlobalEnv$' + getValue("name") + ' <- imported\n');
diff --git a/rkward/plugins/00saveload/import/import_csv.rkh b/rkward/plugins/00saveload/import/import_csv.rkh
index a4d09d6..ab09dbb 100644
--- a/rkward/plugins/00saveload/import/import_csv.rkh
+++ b/rkward/plugins/00saveload/import/import_csv.rkh
@@ -19,7 +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>
+ <setting id="preview">Show a preview of the imported data. At most the first 50 rows and columns 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>
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 926fd62..ca3a98c 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -2,7 +2,7 @@
rksettingsmoduleplugins - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004-2014 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2016 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -49,6 +49,7 @@ QList<RKSettingsModulePlugins::PluginMapStoredInfo> RKSettingsModulePlugins::kno
RKSettingsModulePlugins::PluginPrefs RKSettingsModulePlugins::interface_pref;
bool RKSettingsModulePlugins::show_code;
int RKSettingsModulePlugins::code_size;
+int RKSettingsModulePlugins::other_preview_height;
RKSettingsModulePlugins::RKSettingsModulePlugins (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
RK_TRACE (SETTINGS);
@@ -81,28 +82,6 @@ RKSettingsModulePlugins::RKSettingsModulePlugins (RKSettings *gui, QWidget *pare
connect (button_group, SIGNAL (buttonClicked(int)), this, SLOT (settingChanged()));
main_vbox->addWidget (button_box);
-
- main_vbox->addSpacing (2*RKGlobals::spacingHint ());
-
-
- QGroupBox *code_frame = new QGroupBox (i18n ("R syntax display (in dialogs)"), this);
- group_layout = new QVBoxLayout (code_frame);
-
- show_code_box = new QCheckBox (i18n ("Code shown by default"), code_frame);
- show_code_box->setChecked (show_code);
- connect (show_code_box, SIGNAL (stateChanged(int)), this, SLOT (settingChanged()));
- group_layout->addWidget (show_code_box);
-
- KHBox *code_size_hbox = new KHBox (code_frame);
- new QLabel (i18n ("Default height of code display (pixels)"), code_size_hbox);
- code_size_box = new RKSpinBox (code_size_hbox);
- code_size_box->setIntMode (20, 5000, code_size);
- connect (code_size_box, SIGNAL (valueChanged(int)), this, SLOT (settingChanged()));
- group_layout->addWidget (code_size_hbox);
-
- main_vbox->addWidget (code_frame);
-
-
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
QPushButton *pluginmap_config_button = new QPushButton (i18n ("Configure Active Plugins"), this);
@@ -130,8 +109,6 @@ void RKSettingsModulePlugins::applyChanges () {
RK_TRACE (SETTINGS);
interface_pref = static_cast<PluginPrefs> (button_group->checkedId ());
- show_code = show_code_box->isChecked ();
- code_size = code_size_box->intValue ();
}
RKSettingsModulePlugins::PluginMapList RKSettingsModulePlugins::setPluginMaps (const RKSettingsModulePlugins::PluginMapList new_list) {
@@ -178,6 +155,7 @@ void RKSettingsModulePlugins::saveSettings (KConfig *config) {
cg.writeEntry ("Interface Preferences", static_cast<int> (interface_pref));
cg.writeEntry ("Code display default", show_code);
cg.writeEntry ("Code display size", code_size);
+ cg.writeEntry ("Other preview size", other_preview_height);
}
void RKSettingsModulePlugins::loadSettings (KConfig *config) {
@@ -223,6 +201,8 @@ void RKSettingsModulePlugins::loadSettings (KConfig *config) {
interface_pref = static_cast<PluginPrefs> (cg.readEntry ("Interface Preferences", static_cast<int> (PreferRecommended)));
show_code = cg.readEntry ("Code display default", false);
code_size = cg.readEntry ("Code display size", 250);
+ other_preview_height = cg.readEntry ("Other preview size", code_size);
+
if (RKSettingsModuleGeneral::storedConfigVersion () <= RKSettingsModuleGeneral::RKWardConfig_Pre0_5_7) {
if (code_size == 40) code_size = 250; // previous default untouched.
}
diff --git a/rkward/settings/rksettingsmoduleplugins.h b/rkward/settings/rksettingsmoduleplugins.h
index e3c07f7..5ef950e 100644
--- a/rkward/settings/rksettingsmoduleplugins.h
+++ b/rkward/settings/rksettingsmoduleplugins.h
@@ -2,7 +2,7 @@
rksettingsmoduleplugins - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004-2014 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2016 by Thomas Friedrichsmeier
email : thomas.friedrichsmeier at kdemail.net
***************************************************************************/
@@ -53,7 +53,11 @@ public:
static QStringList pluginMaps ();
static PluginPrefs getInterfacePreference () { return interface_pref; };
static bool showCodeByDefault () { return show_code; };
+ static void setShowCodeByDefault (bool shown) { show_code = shown; };
static int defaultCodeHeight () { return code_size; };
+ static void setDefaultCodeHeight (int new_height) { code_size = new_height; }
+ static int defaultOtherPreviewHeight () { return other_preview_height; };
+ static void setDefaultOtherPreviewHeight (int new_height) { other_preview_height = new_height; }
/** register a list of available plugin-maps (which may or may not already be known). New maps are activated, automatically.
* @param maps Plugin maps (filenames) to add
* @param force_add If true, maps are added, even if they are not "new", and had previously been disabled by the user
@@ -90,8 +94,6 @@ public slots:
void configurePluginmaps ();
private:
QButtonGroup *button_group;
- QCheckBox *show_code_box;
- RKSpinBox *code_size_box;
/** plugin maps which are not necessarily active, but have been encountered, before. @see plugin_maps */
static PluginMapList known_plugin_maps;
@@ -99,6 +101,7 @@ private:
static PluginPrefs interface_pref;
static bool show_code;
static int code_size;
+ static int other_preview_height;
/* TODO: This one is currently unused (leftover of GHNS-based plugin installation), but might still be of interest */
static QStringList findPluginMapsRecursive (const QString &basedir);
More information about the rkward-tracker
mailing list