]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/tooltipmanager.cpp
remove the asynchronous update of the zooming again, it decreases the "feeled" perfor...
[dolphin.git] / src / tooltipmanager.cpp
index 6debb0ca88d351a6dab1964d1409fc90e45110ae..ad1dbe5d3d7776ee6cdb640402a619abcd174c05 100644 (file)
@@ -51,11 +51,11 @@ ToolTipManager::ToolTipManager(QAbstractItemView* parent,
     m_waitOnPreviewTimer(0),
     m_item(),
     m_itemRect(),
-    m_preview(),
-    m_generatingPreview(),
-    m_previewIsLate(),
-    m_previewPass(),
-    m_emptyRenderedKToolTipItem(),
+    m_preview(false),
+    m_generatingPreview(false),
+    m_previewIsLate(false),
+    m_previewPass(0),
+    m_emptyRenderedKToolTipItem(0),
     m_pix()
 {
     KToolTip::setToolTipDelegate(g_delegate);
@@ -82,12 +82,6 @@ ToolTipManager::ToolTipManager(QAbstractItemView* parent,
             this, SLOT(prepareToolTip()));
 
     m_view->viewport()->installEventFilter(this);
-
-    m_preview = false;
-    m_generatingPreview = false;
-    m_previewIsLate = false;
-    m_previewPass = 0;
-    m_pix = QPixmap();
 }
 
 ToolTipManager::~ToolTipManager()
@@ -111,6 +105,7 @@ bool ToolTipManager::eventFilter(QObject* watched, QEvent* event)
 void ToolTipManager::requestToolTip(const QModelIndex& index)
 {
     if (index.column() == DolphinModel::Name) {
+        m_waitOnPreviewTimer->stop();
         KToolTip::hideTip();
 
         m_itemRect = m_view->visualRect(index);
@@ -138,6 +133,8 @@ void ToolTipManager::hideToolTip()
 {
     m_timer->stop();
     m_previewTimer->stop();
+    m_waitOnPreviewTimer->stop();
+    m_previewIsLate = false;
     KToolTip::hideTip();
 }
 
@@ -224,20 +221,18 @@ void ToolTipManager::showToolTip(KToolTipItem* tip)
         return;
     }
 
-    int x = 0;
-    if (hasRoomToLeft || hasRoomToRight) {
-        x = hasRoomToRight ? m_itemRect.right() : m_itemRect.left() - size.width();
-    } else {
-        // Put the tooltip at the far right of the screen. The item will be overlapped
-        // horizontally, but the y-coordinate will be adjusted afterwards so that no overlapping
-        // occurs vertically.
-        x = desktop.right() - size.width();
-    }
-    
+    int x = 0;   
     int y = 0;
     if (hasRoomBelow || hasRoomAbove) {
+        x = QCursor::pos().x() + 16; // TODO: use mouse pointer width instead of the magic value of 16
+        if (x + size.width() >= desktop.right()) {
+            x = desktop.right() - size.width();
+        }
         y = hasRoomBelow ? m_itemRect.bottom() : m_itemRect.top() - size.height();
     } else {
+        Q_ASSERT(hasRoomToLeft || hasRoomToRight);
+        x = hasRoomToRight ? m_itemRect.right() : m_itemRect.left() - size.width();
+        
         // Put the tooltip at the bottom of the screen. The x-coordinate has already
         // been adjusted, so that no overlapping with m_itemRect occurs.
         y = desktop.bottom() - size.height();
@@ -267,6 +262,7 @@ void ToolTipManager::setPreviewPix(const KFileItem& item,
                                    const QPixmap& pixmap)
 {
     if (m_item.url() != item.url()) {
+        m_generatingPreview = false;
         return;
     }