]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
Initial ServiceMenu-KHotNewStuff-stuff
[dolphin.git] / src / dolphiniconsview.cpp
index 81b5c18d961c3ba2baab74ee59c63df51b2a7108..e7448ed6d5bf606c6afb36fb92dfaf0b1052864c 100644 (file)
 #include "dolphincontroller.h"
 #include "settings/dolphinsettings.h"
 #include "dolphinsortfilterproxymodel.h"
-#include "dolphinviewautoscroller.h"
 #include "dolphin_iconsmodesettings.h"
 #include "dolphin_generalsettings.h"
 #include "draganddrophelper.h"
 #include "selectionmanager.h"
+#include "viewextensionsfactory.h"
 #include "zoomlevelinfo.h"
 
 #include <kcategorizedsortfilterproxymodel.h>
 #include <kdialog.h>
-#include <kdirmodel.h>
 #include <kfileitemdelegate.h>
 
 #include <QAbstractProxyModel>
 #include <QApplication>
 #include <QScrollBar>
 
-DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
+DolphinIconsView::DolphinIconsView(QWidget* parent,
+                                   DolphinController* controller,
+                                   DolphinSortFilterProxyModel* proxyModel) :
     KCategorizedView(parent),
     m_controller(controller),
-    m_selectionManager(0),
-    m_autoScroller(0),
     m_categoryDrawer(0),
+    m_extensionsFactory(0),
     m_font(),
     m_decorationSize(),
     m_decorationPosition(QStyleOptionViewItem::Top),
@@ -53,6 +53,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     m_dropRect()
 {
     Q_ASSERT(controller != 0);
+    setModel(proxyModel);
     setLayoutDirection(Qt::LeftToRight);
     setViewMode(QListView::IconMode);
     setResizeMode(QListView::Adjust);
@@ -62,7 +63,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     viewport()->setAcceptDrops(true);
 
     setMouseTracking(true);
-    m_autoScroller = new DolphinViewAutoScroller(this);
 
     connect(this, SIGNAL(clicked(const QModelIndex&)),
             controller, SLOT(requestTab(const QModelIndex&)));
@@ -74,20 +74,10 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
                 controller, SLOT(triggerItem(const QModelIndex&)));
     }
 
-    if (DolphinSettings::instance().generalSettings()->showSelectionToggle()) {
-        m_selectionManager = new SelectionManager(this);
-        connect(m_selectionManager, SIGNAL(selectionChanged()),
-                this, SLOT(requestActivation()));
-        connect(m_controller, SIGNAL(urlChanged(const KUrl&)),
-                m_selectionManager, SLOT(reset()));
-    }
-
     connect(this, SIGNAL(entered(const QModelIndex&)),
             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)));
 
@@ -111,7 +101,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     }
 
     setWordWrap(settings->numberOfTextlines() > 1);
-    updateGridSize(view->showPreview(), 0);
 
     if (settings->arrangement() == QListView::TopToBottom) {
         setFlow(QListView::LeftToRight);
@@ -130,6 +119,9 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
 
     connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
             this, SLOT(slotGlobalSettingsChanged(int)));
+
+    updateGridSize(view->showPreview(), 0);
+    m_extensionsFactory = new ViewExtensionsFactory(this, controller);
 }
 
 DolphinIconsView::~DolphinIconsView()
@@ -322,16 +314,6 @@ void DolphinIconsView::keyPressEvent(QKeyEvent* event)
 
 void DolphinIconsView::wheelEvent(QWheelEvent* event)
 {
-    if (m_selectionManager != 0) {
-        m_selectionManager->reset();
-    }
-
-    // let Ctrl+wheel events propagate to the DolphinView for icon zooming
-    if (event->modifiers() & Qt::ControlModifier) {
-        event->ignore();
-        return;
-    }
-
     horizontalScrollBar()->setSingleStep(m_itemSize.width() / 10);
     verticalScrollBar()->setSingleStep(m_itemSize.height() / 10);
 
@@ -371,7 +353,7 @@ void DolphinIconsView::leaveEvent(QEvent* event)
 void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
 {
     KCategorizedView::currentChanged(current, previous);
-    m_autoScroller->handleCurrentIndexChange(current, previous);
+    m_extensionsFactory->handleCurrentIndexChange(current, previous);
 }
 
 void DolphinIconsView::resizeEvent(QResizeEvent* event)
@@ -394,12 +376,6 @@ 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();
@@ -515,10 +491,6 @@ void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
     if (delegate != 0) {
         delegate->setMaximumSize(m_itemSize);
     }
-
-    if (m_selectionManager != 0) {
-        m_selectionManager->reset();
-    }
 }
 
 int DolphinIconsView::additionalInfoCount() const