]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontroller.cpp
A few changes...
[dolphin.git] / src / dolphincontroller.cpp
index fe8c426f33acb544173441406ac883f46fa3196b..b128c90335e2c89804458b7a0ac88f1b86f9b47d 100644 (file)
 #include <QClipboard>
 #include <QDir>
 
+Qt::MouseButtons DolphinController::m_mouseButtons = Qt::NoButton;
+
 DolphinController::DolphinController(DolphinView* dolphinView) :
     QObject(dolphinView),
     m_zoomLevel(0),
-    m_mouseButtons(Qt::NoButton),
     m_url(),
     m_dolphinView(dolphinView),
     m_itemView(0)
@@ -59,7 +60,7 @@ void DolphinController::setItemView(QAbstractItemView* view)
 
     if (m_itemView != 0) {
         m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(m_itemView->iconSize());
-        
+
         // TODO: this is a workaround until  Qt-issue 176832 has been fixed
         connect(m_itemView, SIGNAL(pressed(const QModelIndex&)),
                 this, SLOT(updateMouseButtonState()));
@@ -73,10 +74,11 @@ void DolphinController::triggerUrlChangeRequest(const KUrl& url)
     }
 }
 
-void DolphinController::triggerContextMenuRequest(const QPoint& pos)
+void DolphinController::triggerContextMenuRequest(const QPoint& pos,
+                                                  const QList<QAction*>& customActions)
 {
     emit activated();
-    emit requestContextMenu(pos);
+    emit requestContextMenu(pos, customActions);
 }
 
 void DolphinController::requestActivation()
@@ -129,12 +131,13 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event)
     const QItemSelectionModel* selModel = m_itemView->selectionModel();
     const QModelIndex currentIndex = selModel->currentIndex();
     const bool trigger = currentIndex.isValid()
-                         && (event->key() == Qt::Key_Return)
+                         && ((event->key() == Qt::Key_Return)
+                            || (event->key() == Qt::Key_Enter))
                          && (selModel->selectedIndexes().count() > 0);
     if (trigger) {
         const QModelIndexList indexList = selModel->selectedIndexes();
         foreach (const QModelIndex& index, indexList) {
-            triggerItem(index);
+            emit itemTriggered(itemForIndex(index));
         }
     }
 }
@@ -158,6 +161,11 @@ void DolphinController::emitHideToolTip()
     emit hideToolTip();
 }
 
+void DolphinController::emitItemTriggered(const KFileItem& item)
+{
+    emit itemTriggered(item);
+}
+
 KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
 {
     Q_ASSERT(m_itemView != 0);
@@ -178,9 +186,6 @@ void DolphinController::triggerItem(const QModelIndex& index)
             m_itemView->clearSelection();
             emit itemEntered(KFileItem());
         }
-        m_mouseButtons = Qt::NoButton;
-    } else if (m_mouseButtons & Qt::RightButton) {
-        m_mouseButtons = Qt::NoButton;
     }
 }
 
@@ -194,9 +199,6 @@ void DolphinController::requestTab(const QModelIndex& index)
         if (validRequest) {
             emit tabRequested(item.url());
         }
-        m_mouseButtons = Qt::NoButton;
-    } else if (m_mouseButtons & Qt::RightButton) {
-        m_mouseButtons = Qt::NoButton;
     }
 }