changeset 209:6576a208e8e7

* Add Open Location... * Add support for URLs in Recent Files * Do the right thing with the last location for file open dialogs when opening a URL (i.e. don't change it to the temporary file directory)
author Chris Cannam
date Wed, 10 Jan 2007 12:27:55 +0000
parents 8a3d68910b37
children a06afefe45ee
files base/RecentFiles.cpp base/RecentFiles.h
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/base/RecentFiles.cpp	Mon Jan 08 17:04:35 2007 +0000
+++ b/base/RecentFiles.cpp	Wed Jan 10 12:27:55 2007 +0000
@@ -17,6 +17,7 @@
 
 #include <QFileInfo>
 #include <QSettings>
+#include <QRegExp>
 
 RecentFiles::RecentFiles(QString settingsGroup, size_t maxCount) :
     m_settingsGroup(settingsGroup),
@@ -115,7 +116,12 @@
 void
 RecentFiles::addFile(QString name)
 {
-    add(QFileInfo(name).absoluteFilePath());
+    static QRegExp schemeRE("^[a-zA-Z]{2,5}://");
+    if (schemeRE.indexIn(name) == 0) {
+        add(name);
+    } else {
+        add(QFileInfo(name).absoluteFilePath());
+    }
 }
 
 
--- a/base/RecentFiles.h	Mon Jan 08 17:04:35 2007 +0000
+++ b/base/RecentFiles.h	Wed Jan 10 12:27:55 2007 +0000
@@ -53,8 +53,9 @@
     void add(QString name);
     
     /**
-     * Add a name that should be treated as a file path and
-     * canonicalised appropriately.
+     * Add a name that is known to be either a file path or a URL.  If
+     * it looks like a URL, add it literally; otherwise treat it as a
+     * file path and canonicalise it appropriately.
      */
     void addFile(QString name);