]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/selectionmanager.cpp
Zoom in and out the icon view on Ctrl+Mouse wheel.
[dolphin.git] / src / selectionmanager.cpp
index 1f9d99b85db7a9e5eab1ba48713e3dc1665a381c..bdb4c5368f20c6a2aed3fbfb9073b8ee3d566e8a 100644 (file)
@@ -47,20 +47,27 @@ SelectionManager::SelectionManager(QAbstractItemView* parent) :
     m_button->hide();
     connect(m_button, SIGNAL(clicked(bool)),
             this, SLOT(setItemSelected(bool)));
-    connect(m_view->selectionModel(), SIGNAL(selectionChanged()),
-            this, SLOT(slotSelectionChanged()));
 }
 
 SelectionManager::~SelectionManager()
 {
 }
 
+void SelectionManager::reset()
+{
+    m_button->hide();
+    m_item = KFileItem();
+}
+
 void SelectionManager::slotEntered(const QModelIndex& index)
 {
     m_button->hide();
     if (index.isValid() && (index.column() == DolphinModel::Name)) {
         m_item = itemForIndex(index);
 
+        connect(m_view->model(), SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
+                this, SLOT(slotRowsRemoved(const QModelIndex&, int, int)));
+
         const QRect rect = m_view->visualRect(index);
         const int gap = 2;
         const int x = rect.right() - m_button->width() - gap;
@@ -79,22 +86,14 @@ void SelectionManager::slotEntered(const QModelIndex& index)
         m_button->show();
     } else {
         m_item = KFileItem();
+        disconnect(m_view->model(), SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
+                   this, SLOT(slotRowsRemoved(const QModelIndex&, int, int)));
     }
 }
 
 void SelectionManager::slotViewportEntered()
 {
     m_button->hide();
-    m_item = KFileItem();
-}
-
-void SelectionManager::slotSelectionChanged()
-{
-    const QModelIndex index = indexForItem(m_item);
-    if (index.isValid()) {
-        QItemSelectionModel* selModel = m_view->selectionModel();
-        m_button->setChecked(selModel->isSelected(index));
-    }
 }
 
 void SelectionManager::setItemSelected(bool selected)
@@ -113,6 +112,14 @@ void SelectionManager::setItemSelected(bool selected)
     }
 }
 
+void SelectionManager::slotRowsRemoved(const QModelIndex& parent, int start, int end)
+{
+    Q_UNUSED(parent);
+    Q_UNUSED(start);
+    Q_UNUSED(end);
+    m_button->hide();
+}
+
 KFileItem SelectionManager::itemForIndex(const QModelIndex& index) const
 {
     QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(m_view->model());