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)
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"
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();
/// 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.
DolphinModel* m_dolphinModel;
DolphinSortFilterProxyModel* m_proxyModel;
DolphinPartBrowserExtension* m_extension;
+ QString m_nameFilter;
Q_DISABLE_COPY(DolphinPart)
};