From: David Faure Date: Mon, 5 May 2008 00:42:33 +0000 (+0000) Subject: Re-enable name filtering (e.g. /home/dfaure/*.txt) in konqueror X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/ba509a3be33e6221406c91d0c0be208acf75d82a Re-enable name filtering (e.g. /home/dfaure/*.txt) in konqueror svn path=/trunk/KDE/kdebase/apps/; revision=804094 --- diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 2277ca1db..4f378fe6d 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -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" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 3ef654039..cca1d7135 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -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) };