[rkward-cvs] SF.net SVN: rkward:[2668] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Fri Sep 25 12:07:06 UTC 2009
Revision: 2668
http://rkward.svn.sourceforge.net/rkward/?rev=2668&view=rev
Author: tfry
Date: 2009-09-25 12:07:05 +0000 (Fri, 25 Sep 2009)
Log Message:
-----------
Add option to allow (non-local) urls in the <browser>. Also disallow selection of non-local files in some other uses of GetFileNameWidget.
Modified Paths:
--------------
trunk/rkward/doc/rkward/writing_plugins_introduction.docbook
trunk/rkward/rkward/misc/getfilenamewidget.cpp
trunk/rkward/rkward/misc/getfilenamewidget.h
trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml
trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
trunk/rkward/rkward/settings/rksettingsmodulephp.cpp
Modified: trunk/rkward/doc/rkward/writing_plugins_introduction.docbook
===================================================================
--- trunk/rkward/doc/rkward/writing_plugins_introduction.docbook 2009-09-25 11:59:10 UTC (rev 2667)
+++ trunk/rkward/doc/rkward/writing_plugins_introduction.docbook 2009-09-25 12:07:05 UTC (rev 2668)
@@ -1771,6 +1771,10 @@
<listitem>One of "file", "dir", or "savefile". To select an existing file, existing directory, or non-existing file, respectively (optional, defaults to "file")</listitem>
</varlistentry>
<varlistentry>
+ <term><allow_urls></term>
+ <listitem>Whether (non-local) urls can be selected (optional, defaults to "false")</listitem>
+ </varlistentry>
+ <varlistentry>
<term><filter></term>
<listitem>File type filter, e.g. ("*.txt *.csv" for .txt and .csv files. Try not to induce limits unless absolutely needed, though) (optional, defaults to "", i.e. all files)</listitem>
</varlistentry>
Modified: trunk/rkward/rkward/misc/getfilenamewidget.cpp
===================================================================
--- trunk/rkward/rkward/misc/getfilenamewidget.cpp 2009-09-25 11:59:10 UTC (rev 2667)
+++ trunk/rkward/rkward/misc/getfilenamewidget.cpp 2009-09-25 12:07:05 UTC (rev 2668)
@@ -2,7 +2,7 @@
getfilenamewidget - description
-------------------
begin : Tue Aug 24 2004
- copyright : (C) 2004, 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -25,7 +25,7 @@
#include "../debug.h"
-GetFileNameWidget::GetFileNameWidget (QWidget *parent, FileType mode, const QString &label, const QString &caption, const QString &initial) : QWidget (parent) {
+GetFileNameWidget::GetFileNameWidget (QWidget *parent, FileType mode, bool only_local, const QString &label, const QString &caption, const QString &initial) : QWidget (parent) {
RK_TRACE (MISC);
QVBoxLayout *vbox = new QVBoxLayout (this);
vbox->setContentsMargins (0, 0, 0, 0);
@@ -38,15 +38,19 @@
vbox->addWidget (edit);
edit->setUrl (initial);
+
+ KFile::Modes mode_flags;
if (mode == ExistingDirectory) {
- edit->setMode (KFile::Directory | KFile::ExistingOnly);
+ mode_flags = KFile::Directory | KFile::ExistingOnly;
} else if (mode == ExistingFile) {
- edit->setMode (KFile::File | KFile::ExistingOnly);
+ mode_flags = KFile::File | KFile::ExistingOnly;
} else if (mode == SaveFile) {
- edit->setMode (KFile::File);
+ mode_flags = KFile::File;
} else {
RK_ASSERT (false);
}
+ if (only_local) mode_flags |= KFile::LocalOnly;
+ edit->setMode (mode_flags);
if (caption.isEmpty ()) edit->setWindowTitle (label);
else edit->setWindowTitle (caption);
@@ -75,7 +79,8 @@
}
QString GetFileNameWidget::getLocation () {
- return (edit->url ().toLocalFile ());
+ if (edit->url ().isLocalFile ()) return (edit->url ().toLocalFile ());
+ return (edit->url ().url ());
}
void GetFileNameWidget::setBackgroundColor (const QColor & color) {
Modified: trunk/rkward/rkward/misc/getfilenamewidget.h
===================================================================
--- trunk/rkward/rkward/misc/getfilenamewidget.h 2009-09-25 11:59:10 UTC (rev 2667)
+++ trunk/rkward/rkward/misc/getfilenamewidget.h 2009-09-25 12:07:05 UTC (rev 2668)
@@ -32,7 +32,7 @@
public:
enum FileType { ExistingFile=0, ExistingDirectory=1, SaveFile=2 };
- GetFileNameWidget (QWidget *parent, FileType mode, const QString &label, const QString &caption, const QString &initial);
+ GetFileNameWidget (QWidget *parent, FileType mode, bool only_local, const QString &label, const QString &caption, const QString &initial);
~GetFileNameWidget ();
/** set filename pattern filter, e.g. "*.cpp *.cc *.C|C++ Source Files\n*.h *.H|Header files" */
Modified: trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginbrowser.cpp 2009-09-25 11:59:10 UTC (rev 2667)
+++ trunk/rkward/rkward/plugin/rkpluginbrowser.cpp 2009-09-25 12:07:05 UTC (rev 2668)
@@ -2,7 +2,7 @@
rkpluginbrowser - description
-------------------
begin : Sat Mar 10 2005
- copyright : (C) 2005, 2006, 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2005, 2006, 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -48,7 +48,9 @@
else if (intmode == 1) mode = GetFileNameWidget::ExistingDirectory;
else mode = GetFileNameWidget::SaveFile;
- selector = new GetFileNameWidget (this, mode, xml->getStringAttribute (element, "label", i18n ("Enter filename"), DL_INFO), i18n ("Select"), xml->getStringAttribute (element, "initial", QString::null, DL_INFO));
+ bool only_local = !xml->getBoolAttribute (element, "allow_urls", false, DL_INFO);
+
+ selector = new GetFileNameWidget (this, mode, only_local, xml->getStringAttribute (element, "label", i18n ("Enter filename"), DL_INFO), i18n ("Select"), xml->getStringAttribute (element, "initial", QString::null, DL_INFO));
selector->setFilter (xml->getStringAttribute (element, "filter", QString::null, DL_INFO));
connect (selector, SIGNAL (locationChanged ()), SLOT (textChanged ()));
Modified: trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml 2009-09-25 11:59:10 UTC (rev 2667)
+++ trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml 2009-09-25 12:07:05 UTC (rev 2668)
@@ -20,7 +20,7 @@
<dialog label="Import STATA file">
<tabbook>
<tab id="tab_general" label="General">
- <browser type="file" id="file" label="File name" />
+ <browser type="file" allow_urls="true" id="file" label="File name" />
<stretch/>
<row>
<saveobject id="saveto" initial="my.stata.data" label="Object to save to"/>
Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp 2009-09-25 11:59:10 UTC (rev 2667)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp 2009-09-25 12:07:05 UTC (rev 2668)
@@ -55,7 +55,7 @@
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
- files_choser = new GetFileNameWidget (this, GetFileNameWidget::ExistingDirectory, i18n ("Directory where the logfiles should be kept (*)"), QString::null, new_files_path);
+ files_choser = new GetFileNameWidget (this, GetFileNameWidget::ExistingDirectory, true, i18n ("Directory where the logfiles should be kept (*)"), QString::null, new_files_path);
connect (files_choser, SIGNAL (locationChanged ()), this, SLOT (pathChanged ()));
main_vbox->addWidget (files_choser);
Modified: trunk/rkward/rkward/settings/rksettingsmodulephp.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulephp.cpp 2009-09-25 11:59:10 UTC (rev 2667)
+++ trunk/rkward/rkward/settings/rksettingsmodulephp.cpp 2009-09-25 12:07:05 UTC (rev 2668)
@@ -42,7 +42,7 @@
main_vbox->addSpacing (2*RKGlobals::spacingHint ());
- bin_choser = new GetFileNameWidget (this, GetFileNameWidget::ExistingFile, i18n ("File-location of the PHP binary"), QString (), php_bin);
+ bin_choser = new GetFileNameWidget (this, GetFileNameWidget::ExistingFile, true, i18n ("File-location of the PHP binary"), QString (), php_bin);
connect (bin_choser, SIGNAL (locationChanged ()), this, SLOT (pathChanged ()));
main_vbox->addWidget (bin_choser);
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