]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Hide tooltips when dragging items
authorPeter Penz <peter.penz19@gmail.com>
Sun, 18 Dec 2011 19:28:47 +0000 (20:28 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 18 Dec 2011 19:29:34 +0000 (20:29 +0100)
src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/kitemlistcontroller.h
src/views/dolphinview.cpp

index 2ff8068ab11610753625074836d12eeac0fd469b..79dffd41be3b19b1797124da7cad18aede526e88 100644 (file)
@@ -361,6 +361,9 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
 
     m_pressedMousePos = transform.map(event->pos());
     m_pressedIndex = m_view->itemAt(m_pressedMousePos);
+    if (m_pressedIndex >= 0) {
+        emit itemPressed(m_pressedIndex, event->button());
+    }
 
     if (m_view->isAboveExpansionToggle(m_pressedIndex, m_pressedMousePos)) {
         m_selectionManager->setCurrentItem(m_pressedIndex);
@@ -527,6 +530,10 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
         return false;
     }
 
+    if (m_pressedIndex >= 0) {
+        emit itemReleased(m_pressedIndex, event->button());
+    }
+
     const bool isAboveSelectionToggle = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos);
     if (isAboveSelectionToggle) {
         m_selectionTogglePressed = false;
index 29ab6be63a58be0678789fc8c3118a0d8745b5d9..e0e8b0a9ba5291a2086618942d4e5bdd6fb70898 100644 (file)
@@ -166,6 +166,17 @@ signals:
      */
     void itemUnhovered(int index);
 
+    /**
+     * Is emitted if a mouse-button has been pressed above an item.
+     */
+    void itemPressed(int index, Qt::MouseButton button);
+
+    /**
+     * Is emitted if a mouse-button has been released above an item.
+     * It is assured that the signal itemPressed() has been emitted before.
+     */
+    void itemReleased(int index, Qt::MouseButton button);
+
     void itemExpansionToggleClicked(int index);
 
     /**
index b728397f3e330d0f16a163e86ba83f51de959ff1..0edcb2894462923fa868d7fce06da47afe84a31e 100644 (file)
@@ -146,6 +146,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
     connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
     connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
     connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF)));
+    connect(controller, SIGNAL(itemPressed(int,Qt::MouseButton)), this, SLOT(hideToolTip()));
     connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
     connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
     connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
@@ -553,9 +554,7 @@ void DolphinView::setUrl(const KUrl& url)
     emit urlAboutToBeChanged(url);
     m_url = url;
 
-    if (GeneralSettings::showToolTips()) {
-        m_toolTipManager->hideToolTip();
-    }
+    hideToolTip();
 
     // It is important to clear the items from the model before
     // applying the view properties, otherwise expensive operations
@@ -733,18 +732,12 @@ void DolphinView::slotItemMiddleClicked(int index)
 
 void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos)
 {
-    if (GeneralSettings::showToolTips()) {
-        m_toolTipManager->hideToolTip();
-    }
     const KFileItem item = fileItemModel()->fileItem(index);
     emit requestContextMenu(pos.toPoint(), item, url(), QList<QAction*>());
 }
 
 void DolphinView::slotViewContextMenuRequested(const QPointF& pos)
 {
-    if (GeneralSettings::showToolTips()) {
-        m_toolTipManager->hideToolTip();
-    }
     emit requestContextMenu(pos.toPoint(), KFileItem(), url(), QList<QAction*>());
 }
 
@@ -802,7 +795,7 @@ void DolphinView::slotItemHovered(int index)
 {
     const KFileItem item = fileItemModel()->fileItem(index);
 
-    if (GeneralSettings::showToolTips()) {
+    if (GeneralSettings::showToolTips() && QApplication::mouseButtons() == Qt::NoButton) {
         QRectF itemRect = m_container->controller()->view()->itemContextRect(index);
         const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint());
         itemRect.moveTo(pos);
@@ -816,9 +809,7 @@ void DolphinView::slotItemHovered(int index)
 void DolphinView::slotItemUnhovered(int index)
 {
     Q_UNUSED(index);
-    if (GeneralSettings::showToolTips()) {
-        m_toolTipManager->hideToolTip();
-    }
+    hideToolTip();
     emit requestItemInfo(KFileItem());
 }
 
@@ -1050,7 +1041,6 @@ void DolphinView::updateViewState()
     }
 }
 
-
 void DolphinView::hideToolTip()
 {
     if (GeneralSettings::showToolTips()) {