]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Restore filtering of items. The DolphinView just tells the controller about the filte...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 28 Aug 2009 21:53:18 +0000 (21:53 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 28 Aug 2009 21:53:18 +0000 (21:53 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1016782

12 files changed:
src/dolphincolumnview.cpp
src/dolphincolumnview.h
src/dolphincolumnviewcontainer.cpp
src/dolphincolumnviewcontainer.h
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphindetailsview.h
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinview.cpp
src/dolphinview.h

index 14ee18bef739fed628a66b84bda4e58b97947827..5d52a62c495b4ed31a60da7aadad7d3a4e88e867 100644 (file)
@@ -172,6 +172,13 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
     connect(controller, SIGNAL(zoomLevelChanged(int)),
             this, SLOT(setZoomLevel(int)));
 
+    const QString nameFilter = controller->nameFilter();
+    if (!nameFilter.isEmpty()) {
+        m_proxyModel->setFilterRegExp(nameFilter);
+    }
+    connect(controller, SIGNAL(nameFilterChanged(const QString&)),
+            this, SLOT(setNameFilter(const QString&)));
+
     updateDecorationSize(dolphinView->showPreview());
 }
 
@@ -458,6 +465,10 @@ void DolphinColumnView::currentChanged(const QModelIndex& current, const QModelI
     m_autoScroller->handleCurrentIndexChange(current, previous);
 }
 
+void DolphinColumnView::setNameFilter(const QString& nameFilter)
+{
+    m_proxyModel->setFilterRegExp(nameFilter);
+}
 
 void DolphinColumnView::setZoomLevel(int level)
 {
index 642dfaeaf8648f639675a7f598b9bda4142b7bb5..0a601b7fae4e400f1d12fd60c39afe63e777d3f1 100644 (file)
@@ -104,6 +104,7 @@ protected:
     virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
 
 private slots:
+    void setNameFilter(const QString& nameFilter);
     void setZoomLevel(int level);
 
     void slotEntered(const QModelIndex& index);
index 2428213012465a40e4db48aee68bb12fde8e5cb8..80c4ff7a0cbe2397fb115074eb866c3eea8f3ad3 100644 (file)
@@ -40,8 +40,7 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent, DolphinC
     m_contentX(0),
     m_columns(),
     m_emptyViewport(0),
-    m_animation(0),
-    m_nameFilter()
+    m_animation(0)
 {
     Q_ASSERT(controller != 0);
 
@@ -75,22 +74,6 @@ DolphinColumnViewContainer::~DolphinColumnViewContainer()
 {
 }
 
-void DolphinColumnViewContainer::setNameFilter(const QString& nameFilter)
-{
-    if (nameFilter != m_nameFilter) {
-        m_nameFilter = nameFilter;
-        foreach (DolphinColumnView* column, m_columns) {
-            DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(column->model());
-            proxyModel->setFilterRegExp(nameFilter);
-        }
-    }
-}
-
-QString DolphinColumnViewContainer::nameFilter() const
-{
-    return m_nameFilter;
-}
-
 KUrl DolphinColumnViewContainer::rootUrl() const
 {
     return m_columns[0]->url();
@@ -167,10 +150,6 @@ bool DolphinColumnViewContainer::showColumn(const KUrl& url)
             columnIndex++;
 
             DolphinColumnView* column = new DolphinColumnView(viewport(), this, childUrl);
-            if (!m_nameFilter.isEmpty()) {
-                DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(column->model());
-                proxyModel->setFilterRegExp(m_nameFilter);
-            }
             column->setActive(false);
 
             m_columns.append(column);
index c4030657a79214e3afe40e4907642ea1458f1223..93a0c30fe38bc4eca85cfe04bdda82641ac1d8b4 100644 (file)
@@ -47,18 +47,6 @@ public:
     explicit DolphinColumnViewContainer(QWidget* parent, DolphinController* controller);
     virtual ~DolphinColumnViewContainer();
 
-    /**
-     * Filters the currently shown items by \a nameFilter. All items
-     * which contain the given filter string will be shown.
-     */
-    void setNameFilter(const QString& nameFilter);
-
-    /**
-     * Returns the currently used name filter. All items
-     * which contain the name filter will be shown.
-     */
-    QString nameFilter() const;
-
     KUrl rootUrl() const;
 
     QAbstractItemView* activeColumn() const;
@@ -142,7 +130,6 @@ private:
     QList<DolphinColumnView*> m_columns;
     QFrame* m_emptyViewport;
     QTimeLine* m_animation;
-    QString m_nameFilter;
 
     friend class DolphinColumnView;
 };
index eaa27c0f468e7802bcad5c434573d738efb126e4..47c661e83ee623d8ed65d391ee20beb0da780130 100644 (file)
@@ -31,6 +31,7 @@ Qt::MouseButtons DolphinController::m_mouseButtons = Qt::NoButton;
 DolphinController::DolphinController(DolphinView* dolphinView) :
     QObject(dolphinView),
     m_zoomLevel(0),
+    m_nameFilter(),
     m_url(),
     m_dolphinView(dolphinView),
     m_itemView(0)
@@ -119,6 +120,19 @@ void DolphinController::indicateActivationChange(bool active)
     emit activationChanged(active);
 }
 
+void DolphinController::setNameFilter(const QString& nameFilter)
+{
+    if (nameFilter != m_nameFilter) {
+        m_nameFilter = nameFilter;
+        emit nameFilterChanged(nameFilter);
+    }
+}
+
+QString DolphinController::nameFilter() const
+{
+    return m_nameFilter;
+}
+
 void DolphinController::setZoomLevel(int level)
 {
     Q_ASSERT(level >= ZoomLevelInfo::minimumLevel());
index 71e6159101ae390d4529e6a397f97d2df9cd0160..c87aaa43a15f88eaa35198bf3770be92d624c96b 100644 (file)
@@ -70,6 +70,7 @@ class QPoint;
  * - setShowHiddenFiles()
  * - setShowPreview()
  * - indicateActivationChange()
+ * - setNameFilter()
  * - setZoomLevel()
  */
 class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
@@ -196,6 +197,12 @@ public:
     void setZoomLevel(int level);
     int zoomLevel() const;
 
+    /**
+     * Sets the name filter to \a and emits the signal nameFilterChanged().
+     */
+    void setNameFilter(const QString& nameFilter);
+    QString nameFilter() const;
+
     /**
      * Tells the view implementation to zoom out by emitting the signal zoomOut()
      * and is invoked by the abstract Dolphin view.
@@ -373,6 +380,12 @@ signals:
      */
     void viewportEntered();
 
+    /**
+     * Is emitted if the view should respect the name filter \a nameFilter. The view
+     * implementation must connect to this signal if it supports name filters.
+     */
+    void nameFilterChanged(const QString& nameFilter);
+
     /**
      * Is emitted if the view should change the zoom to \a level. The view implementation
      * must connect to this signal if it supports zooming.
@@ -389,6 +402,7 @@ private slots:
 
 private:
     int m_zoomLevel;
+    QString m_nameFilter;
     static Qt::MouseButtons m_mouseButtons; // TODO: this is a workaround until  Qt-issue 176832 has been fixed
     KUrl m_url;
     DolphinView* m_dolphinView;
index 7f75fdda639bd3e5b228c0c3fe58578fe9bd4b73..92ffd5e1f44bf02b501d85bdb0693444193eed13 100644 (file)
@@ -38,7 +38,6 @@
 #include <klocale.h>
 #include <kmenu.h>
 
-#include <QAbstractProxyModel>
 #include <QAction>
 #include <QApplication>
 #include <QHeaderView>
@@ -122,6 +121,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
             this, SLOT(slotEntered(const QModelIndex&)));
     connect(this, SIGNAL(viewportEntered()),
             controller, SLOT(emitViewportEntered()));
+    connect(controller, SIGNAL(nameFilterChanged(const QString&)),
+            this, SLOT(setNameFilter(const QString&)));
     connect(controller, SIGNAL(zoomLevelChanged(int)),
             this, SLOT(setZoomLevel(int)));
     connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()),
@@ -531,6 +532,12 @@ QRect DolphinDetailsView::elasticBandRect() const
     return QRect(topLeft, bottomRight).normalized();
 }
 
+void DolphinDetailsView::setNameFilter(const QString& nameFilter)
+{
+    DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(model());
+    proxyModel->setFilterRegExp(nameFilter);
+}
+
 void DolphinDetailsView::setZoomLevel(int level)
 {
     const int size = ZoomLevelInfo::iconSizeForZoomLevel(level);
index 25a60911e4795cd3281c645bfafcd6c82e2b0f0a..483d57dd8efdf15eb164b8db6a331c5787b4ab35 100644 (file)
@@ -111,6 +111,8 @@ private slots:
      */
     QRect elasticBandRect() const;
 
+    void setNameFilter(const QString& nameFilter);
+
     void setZoomLevel(int level);
 
     void slotShowPreviewChanged();
index c48497e828538c5b45e48fc80c92173375270b9a..81b5c18d961c3ba2baab74ee59c63df51b2a7108 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
+ *   Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at>             *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -22,6 +22,7 @@
 #include "dolphincategorydrawer.h"
 #include "dolphincontroller.h"
 #include "settings/dolphinsettings.h"
+#include "dolphinsortfilterproxymodel.h"
 #include "dolphinviewautoscroller.h"
 #include "dolphin_iconsmodesettings.h"
 #include "dolphin_generalsettings.h"
@@ -85,6 +86,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
             controller, SLOT(emitItemEntered(const QModelIndex&)));
     connect(this, SIGNAL(viewportEntered()),
             controller, SLOT(emitViewportEntered()));
+    connect(controller, SIGNAL(nameFilterChanged(const QString&)),
+            this, SLOT(setNameFilter(const QString&)));
     connect(controller, SIGNAL(zoomLevelChanged(int)),
             this, SLOT(setZoomLevel(int)));
 
@@ -391,6 +394,12 @@ void DolphinIconsView::slotAdditionalInfoChanged()
     updateGridSize(showPreview, view->additionalInfo().count());
 }
 
+void DolphinIconsView::setNameFilter(const QString& nameFilter)
+{
+    DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(model());
+    proxyModel->setFilterRegExp(nameFilter);
+}
+
 void DolphinIconsView::setZoomLevel(int level)
 {
     IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
index 70552a413aa89d8e06fe32e8df093b01d7276108..f4eb5e2609f60ae9fac00f77711d1ab8a252fdf3 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
+ *   Copyright (C) 2006-2009 by Peter Penz <peter.penz@gmx.at>             *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -73,6 +73,7 @@ protected:
 private slots:
     void slotShowPreviewChanged();
     void slotAdditionalInfoChanged();
+    void setNameFilter(const QString& nameFilter);
     void setZoomLevel(int level);
     void requestActivation();
     void slotGlobalSettingsChanged(int category);
index e9b33e9a14535912a1c11c95ded960bae05a45ff..2e41b4aa4818e3ed8283119330b49032b5c974a8 100644 (file)
@@ -500,7 +500,7 @@ void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl)
 
 void DolphinView::setNameFilter(const QString& nameFilter)
 {
-    m_viewAccessor.setNameFilter(nameFilter);
+    m_controller->setNameFilter(nameFilter);
 }
 
 void DolphinView::calculateItemCount(int& fileCount,
@@ -1555,15 +1555,6 @@ QWidget* DolphinView::ViewAccessor::layoutTarget() const
     return itemView();
 }
 
-void DolphinView::ViewAccessor::setNameFilter(const QString& nameFilter)
-{
-    if (m_columnsContainer == 0) {
-        m_columnsContainer->setNameFilter(nameFilter);
-    } else {
-        proxyModel()->setFilterRegExp(nameFilter);
-    }
-}
-
 KUrl DolphinView::ViewAccessor::rootUrl() const
 {
     return (m_columnsContainer != 0) ? m_columnsContainer->rootUrl() : KUrl();
index 93299b4301b2491bd5adb39cd1d5f945efcf8b0c..b9a7ff9cea9786fedfcfa3aef08943244a481905 100644 (file)
@@ -779,8 +779,6 @@ private:
          */
         QWidget* layoutTarget() const;
 
-        void setNameFilter(const QString& nameFilter);
-
         KUrl rootUrl() const;
 
         bool supportsCategorizedSorting() const;