[rkward-cvs] SF.net SVN: rkward:[3787] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Fri Sep 16 10:02:31 UTC 2011
Revision: 3787
http://rkward.svn.sourceforge.net/rkward/?rev=3787&view=rev
Author: tfry
Date: 2011-09-16 10:02:30 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
Make R script file filters configurable.
Make length of recent script files action configurable.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/misc/rkcommonfunctions.cpp
trunk/rkward/rkward/misc/rkcommonfunctions.h
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.cpp
trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.h
trunk/rkward/rkward/windows/rkworkplace.cpp
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2011-09-16 07:58:45 UTC (rev 3786)
+++ trunk/rkward/ChangeLog 2011-09-16 10:02:30 UTC (rev 3787)
@@ -1,3 +1,4 @@
+- The file filter for R script files is now configurable, and includes *.Rhistory, by default
- More obvious coloring of variable entry fields requiring user input in plugins
- Default size of the code display in plugin dialogs has been increased TODO: bump config version enum
- Added support for RKWard plugins shipped inside R packages
Modified: trunk/rkward/rkward/misc/rkcommonfunctions.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkcommonfunctions.cpp 2011-09-16 07:58:45 UTC (rev 3786)
+++ trunk/rkward/rkward/misc/rkcommonfunctions.cpp 2011-09-16 10:02:30 UTC (rev 3787)
@@ -197,4 +197,16 @@
return out;
}
+
+ void setTips (const QString tip, QWidget *first, QWidget *second, QWidget *third) {
+ for (int i=0; i < 3; ++i) {
+ QWidget *w = first;
+ if (i == 1) w = second;
+ if (i == 2) w = third;
+ if (!w) return;
+
+ w->setToolTip (tip);
+ w->setWhatsThis (tip);
+ }
+ }
} // namespace
Modified: trunk/rkward/rkward/misc/rkcommonfunctions.h
===================================================================
--- trunk/rkward/rkward/misc/rkcommonfunctions.h 2011-09-16 07:58:45 UTC (rev 3786)
+++ trunk/rkward/rkward/misc/rkcommonfunctions.h 2011-09-16 10:02:30 UTC (rev 3787)
@@ -2,7 +2,7 @@
rkcommonfunctions - description
-------------------
begin : Mon Oct 17 2005
- copyright : (C) 2005, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
+ copyright : (C) 2005, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -51,6 +51,9 @@
QString escape (const QString &in);
/** reverse of escape () */
QString unescape (const QString &in);
+
+/** simultaneously sets tool tips and what's this tips on up to three QWidgets */
+ void setTips (const QString tip, QWidget *first, QWidget *second=0, QWidget *third=0);
};
#endif
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2011-09-16 07:58:45 UTC (rev 3786)
+++ trunk/rkward/rkward/rkward.cpp 2011-09-16 10:02:30 UTC (rev 3787)
@@ -57,6 +57,7 @@
#include "settings/rksettingsmoduleplugins.h"
#include "settings/rksettingsmodulegeneral.h"
#include "settings/rksettingsmoduleoutput.h"
+#include "settings/rksettingsmodulecommandeditor.h"
#include "rbackend/rinterface.h"
#include "core/robjectlist.h"
#include "core/renvironmentobject.h"
@@ -627,12 +628,13 @@
}
resize (size);
+ RKSettings::loadSettings (config);
+ RK_ASSERT (config == KGlobal::config ().data ()); // not messing with config groups
+
// initialize the recent file list
fileOpenRecentWorkspace->loadEntries (config->group ("Recent Files"));
+ fileOpenRecent->setMaxItems (RKSettingsModuleCommandEditor::maxNumRecentFiles ());
fileOpenRecent->loadEntries (config->group ("Recent Command Files"));
-
- // do this last, since we may be setting some different config-group(s) in the process
- RKSettings::loadSettings (config);
}
bool RKWardMainWindow::doQueryQuit () {
@@ -851,9 +853,9 @@
#ifdef Q_WS_WIN
// getOpenUrls(KUrl("kfiledialog:///<rfiles>"), ...) causes a hang on windows (KDElibs 4.2.3).
# warning Track this bug down and/or report it
- res = KEncodingFileDialog::getOpenUrlsAndEncoding (QString (), QString (), "*.R *.r *.S *.s *.q|R Script Files (*.R *.r *.S *.s *.q)\n*|All Files (*)", this, i18n ("Open script file(s)"));
+ res = KEncodingFileDialog::getOpenUrlsAndEncoding (QString (), QString (), QString ("%1|R Script Files (%1)\n*|All Files (*)").arg (RKSettingsModuleCommandEditor::scriptFileFilter ()), this, i18n ("Open script file(s)"));
#else
- res = KEncodingFileDialog::getOpenUrlsAndEncoding (QString (), "kfiledialog:///<rfiles>", "*.R *.r *.S *.s *.q|R Script Files (*.R *.r *.S *.s *.q)\n*|All Files (*)", this, i18n ("Open script file(s)"));
+ res = KEncodingFileDialog::getOpenUrlsAndEncoding (QString (), "kfiledialog:///<rfiles>", QString ("%1|R Script Files (%1)\n*|All Files (*)").arg (RKSettingsModuleCommandEditor::scriptFileFilter ()), this, i18n ("Open script file(s)"));
#endif
for (it = res.URLs.begin() ; it != res.URLs.end() ; ++it) {
slotOpenCommandEditor (*it, res.encoding);
Modified: trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.cpp 2011-09-16 07:58:45 UTC (rev 3786)
+++ trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.cpp 2011-09-16 10:02:30 UTC (rev 3787)
@@ -2,7 +2,7 @@
rksettingsmodulecommandeditor - description
-------------------
begin : Tue Oct 23 2007
- copyright : (C) 2007, 2010 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2010, 2011 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -28,6 +28,7 @@
#include <QLineEdit>
#include "../misc/rkspinbox.h"
+#include "../misc/rkcommonfunctions.h"
#include "../rkglobals.h"
#include "../debug.h"
@@ -39,12 +40,17 @@
bool RKSettingsModuleCommandEditor::autosave_enabled;
bool RKSettingsModuleCommandEditor::autosave_keep;
int RKSettingsModuleCommandEditor::autosave_interval;
-//QString RKSettingsModuleCommandEditor::autosave_suffix;
+int RKSettingsModuleCommandEditor::num_recent_files;
+QString RKSettingsModuleCommandEditor::script_file_filter;
RKSettingsModuleCommandEditor::RKSettingsModuleCommandEditor (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
RK_TRACE (SETTINGS);
QVBoxLayout* main_vbox = new QVBoxLayout (this);
+ QLabel *label = new QLabel (i18n ("Settings marked with (*) do not take effect until you restart RKWard"), this);
+ label->setWordWrap (true);
+ main_vbox->addWidget (label);
+ main_vbox->addSpacing (2 * RKGlobals::spacingHint ());
QGroupBox* group = new QGroupBox (i18n ("Code Completion"), this);
QVBoxLayout* box_layout = new QVBoxLayout (group);
@@ -56,7 +62,7 @@
box_layout->addSpacing (RKGlobals::spacingHint ());
- QLabel* label = new QLabel (i18n ("Minimum number of characters before completion is attempted"), group);
+ label = new QLabel (i18n ("Minimum number of characters before completion is attempted"), group);
label->setWordWrap (true);
completion_min_chars_box = new RKSpinBox (group);
completion_min_chars_box->setIntMode (1, INT_MAX, completion_min_chars);
@@ -99,13 +105,6 @@
box_layout->addWidget (autosave_interval_box);
box_layout->addSpacing (RKGlobals::spacingHint ());
-/* label = new QLabel (i18n ("Filename suffix for autosave files"), group);
- autosave_suffix_edit = new QLineEdit (autosave_suffix, group);
- connect (autosave_suffix_edit, SIGNAL (textChanged(const QString&)), this, SLOT (settingChanged()));
- box_layout->addWidget (label);
- box_layout->addWidget (autosave_suffix_edit);
- box_layout->addSpacing (RKGlobals::spacingHint ()); */
-
autosave_keep_box = new QCheckBox (i18n ("Keep autosave file after manual save"), group);
autosave_keep_box->setChecked (autosave_keep);
connect (autosave_keep_box, SIGNAL (stateChanged(int)), this, SLOT (settingChanged()));
@@ -113,6 +112,29 @@
main_vbox->addWidget (group);
+ main_vbox->addSpacing (2 * RKGlobals::spacingHint ());
+
+ group = new QGroupBox (i18n ("Opening script files"), this);
+ box_layout = new QVBoxLayout (group);
+ label = new QLabel (i18n ("Number of scripts in recent file lists (*)"), group);
+ num_recent_files_box = new RKSpinBox (group);
+ num_recent_files_box->setIntMode (1, INT_MAX, num_recent_files);
+ connect (num_recent_files_box, SIGNAL (valueChanged(int)), this, SLOT (settingChanged()));
+ box_layout->addWidget (label);
+ box_layout->addWidget (num_recent_files_box);
+ box_layout->addSpacing (RKGlobals::spacingHint ());
+
+ label = new QLabel (i18n ("R script file filters (separated by spaces)"), group);
+ script_file_filter_box = new QLineEdit (group);
+ RKCommonFunctions::setTips (i18n ("A list of filters (file name extensions) that should be treated as R script files. Most importantly, files matching one of these filters will always be opened with R syntax highlighting.<br>Filters are case insensitive."), script_file_filter_box, label);
+ label->setToolTip (script_file_filter_box->toolTip ());
+ connect (script_file_filter_box, SIGNAL (textChanged(QString)), this, SLOT (settingChanged()));
+ box_layout->addWidget (label);
+ box_layout->addWidget (script_file_filter_box);
+ box_layout->addSpacing (RKGlobals::spacingHint ());
+
+ main_vbox->addWidget (group);
+
main_vbox->addStretch ();
}
@@ -149,9 +171,9 @@
autosave_enabled = autosave_enabled_box->isChecked ();
autosave_keep = autosave_keep_box->isChecked ();
autosave_interval = autosave_interval_box->intValue ();
-/* autosave_suffix = autosave_suffix_edit->text ();
- // prevent user from shooting themselves in the foot
- if (autosave_suffix.isEmpty ()) autosave_suffix = ".autosave"; */
+
+ num_recent_files = num_recent_files_box->intValue ();
+ script_file_filter = script_file_filter_box->text ();
}
void RKSettingsModuleCommandEditor::save (KConfig *config) {
@@ -171,7 +193,9 @@
cg.writeEntry ("Autosave enabled", autosave_enabled);
cg.writeEntry ("Autosave keep saves", autosave_keep);
cg.writeEntry ("Autosave interval", autosave_interval);
-// cg.writeEntry ("Autosave suffix", autosave_suffix);
+
+ cg.writeEntry ("Max number of recent files", num_recent_files);
+ cg.writeEntry ("Script file filter", script_file_filter);
}
void RKSettingsModuleCommandEditor::loadSettings (KConfig *config) {
@@ -186,7 +210,21 @@
autosave_enabled = cg.readEntry ("Autosave enabled", true);
autosave_keep = cg.readEntry ("Autosave keep saves", false);
autosave_interval = cg.readEntry ("Autosave interval", 5);
-// autosave_suffix = cg.readEntry ("Autosave suffix", ".rkward_autosave");
+
+ num_recent_files = cg.readEntry ("Max number of recent files", 10);
+ script_file_filter = cg.readEntry ("Script file filter", "*.R *.S *.q *.Rhistory");
}
+// static
+bool RKSettingsModuleCommandEditor::matchesScriptFileFilter (const QString &filename) {
+ RK_TRACE (SETTINGS);
+
+ const QStringList exts = script_file_filter.split (' ');
+ foreach (const QString ext, exts) {
+ QRegExp reg (ext, Qt::CaseInsensitive, QRegExp::Wildcard);
+ if (reg.exactMatch (filename)) return true;
+ }
+ return false;
+}
+
#include "rksettingsmodulecommandeditor.moc"
Modified: trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.h 2011-09-16 07:58:45 UTC (rev 3786)
+++ trunk/rkward/rkward/settings/rksettingsmodulecommandeditor.h 2011-09-16 10:02:30 UTC (rev 3787)
@@ -2,7 +2,7 @@
rksettingsmodulecommandeditor - description
-------------------
begin : Tue Oct 23 2007
- copyright : (C) 2007, 2010 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2010, 2011 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -55,6 +55,10 @@
static bool autosaveKeep () { return autosave_keep; };
static int autosaveInterval () { return autosave_interval; };
static QString autosaveSuffix () { return ".rkward_autosave"; };
+
+ static int maxNumRecentFiles () { return num_recent_files; };
+ static QString scriptFileFilter () { return script_file_filter; };
+ static bool matchesScriptFileFilter (const QString &filename);
public slots:
void settingChanged ();
private:
@@ -71,12 +75,15 @@
static bool autosave_enabled;
static bool autosave_keep;
static int autosave_interval;
-// static QString autosave_suffix;
QGroupBox* autosave_enabled_box;
QCheckBox* autosave_keep_box;
RKSpinBox* autosave_interval_box;
-// QLineEdit* autosave_suffix_edit;
+
+ RKSpinBox* num_recent_files_box;
+ QLineEdit* script_file_filter_box;
+ static int num_recent_files;
+ static QString script_file_filter;
};
#endif
Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp 2011-09-16 07:58:45 UTC (rev 3786)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2011-09-16 10:02:30 UTC (rev 3787)
@@ -43,6 +43,7 @@
#include "../dataeditor/rkeditordataframe.h"
#include "../robjectviewer.h"
#include "../settings/rksettingsmodulegeneral.h"
+#include "../settings/rksettingsmodulecommandeditor.h"
#include "../rbackend/rinterface.h"
#include "../windows/rkwindowcatcher.h"
#include "../rbackend/rcommand.h"
@@ -225,7 +226,7 @@
return true; // TODO
}
if (mimetype->name ().startsWith ("text")) {
- return (openScriptEditor (url, QString (), false));
+ return (openScriptEditor (url, QString (), RKSettingsModuleCommandEditor::matchesScriptFileFilter (url.fileName())));
}
if (KMessageBox::questionYesNo (this, i18n ("The url you are trying to open ('%1') is not a local file or the filetype is not supported by RKWard. Do you want to open the url in the default application?", url.prettyUrl ()), i18n ("Open in default application?")) != KMessageBox::Yes) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list