]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Re-enable name filtering (e.g. /home/dfaure/*.txt) in konqueror
authorDavid Faure <faure@kde.org>
Mon, 5 May 2008 00:42:33 +0000 (00:42 +0000)
committerDavid Faure <faure@kde.org>
Mon, 5 May 2008 00:42:33 +0000 (00:42 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=804094

src/dolphinpart.cpp
src/dolphinpart.h

index 2277ca1db6cceb8e8bb18313a9e74a46bca37ae3..4f378fe6d857fcf0910d299fd792d21d5ac250b2 100644 (file)
@@ -216,15 +216,24 @@ KAboutData* DolphinPart::createAboutData()
 
 bool DolphinPart::openUrl(const KUrl& url)
 {
-    const bool reload = arguments().reload();
+    bool reload = arguments().reload();
+    // A bit of a workaround so that changing the namefilter works: force reload.
+    // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
+    if (m_nameFilter != m_dirLister->nameFilter())
+        reload = true;
     if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started
         return true;
     }
     setUrl(url); // remember it at the KParts level
-    const QString prettyUrl = url.pathOrUrl();
+    KUrl visibleUrl(url);
+    if (!m_nameFilter.isEmpty()) {
+        visibleUrl.addPath(m_nameFilter);
+    }
+    QString prettyUrl = visibleUrl.pathOrUrl();
     emit setWindowCaption(prettyUrl);
     emit m_extension->setLocationBarUrl(prettyUrl);
     emit started(0); // get the wheel to spin
+    m_dirLister->setNameFilter(m_nameFilter);
     m_view->setUrl(url);
     emit aboutToOpenURL();
     if (reload)
@@ -409,4 +418,12 @@ QString DolphinPart::currentViewMode() const
     return m_actionHandler->currentViewModeActionName();
 }
 
+void DolphinPart::setNameFilter(const QString& nameFilter)
+{
+    // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
+    // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
+    m_nameFilter = nameFilter;
+    // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
+}
+
 #include "dolphinpart.moc"
index 3ef654039d81f7bb3806ded898aade75e208ad76..cca1d7135838ecca3587da4149fd78d3dc435797 100644 (file)
@@ -45,6 +45,9 @@ class DolphinPart : public KParts::ReadOnlyPart
 
     Q_PROPERTY( QString currentViewMode READ currentViewMode WRITE setCurrentViewMode )
 
+    // Used by konqueror when typing something like /home/dfaure/*.diff in the location bar
+    Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
+
 public:
     explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
     ~DolphinPart();
@@ -77,6 +80,16 @@ public:
     /// Returns the view owned by this part; used by DolphinPartBrowserExtension
     DolphinView* view() { return m_view; }
 
+    /**
+     * Sets a name filter, like *.diff
+     */
+    void setNameFilter(const QString& nameFilter);
+
+    /**
+     * Returns the current name filter. Used by konqueror to show it in the URL.
+     */
+    QString nameFilter() const { return m_nameFilter; }
+
 protected:
     /**
      * We reimplement openUrl so no need to implement openFile.
@@ -167,6 +180,7 @@ private:
     DolphinModel* m_dolphinModel;
     DolphinSortFilterProxyModel* m_proxyModel;
     DolphinPartBrowserExtension* m_extension;
+    QString m_nameFilter;
     Q_DISABLE_COPY(DolphinPart)
 };