Branch: master

6d8d7bc0 2014-09-20 22:21:29 Timothy Pearson
Fix unwanted drag and drop continuation when file modification dialog was shown and mouse cursor subsequently moved back over the file list
M kate/app/katefilelist.cpp
M kate/app/katefilelist.h
diff --git a/kate/app/katefilelist.cpp b/kate/app/katefilelist.cpp
index 98857b3..9cf4b17 100644
--- a/kate/app/katefilelist.cpp
+++ b/kate/app/katefilelist.cpp
@@ -176,6 +176,8 @@
 // returning
 void KateFileList::contentsMousePressEvent( TQMouseEvent *e )
 {
+  m_lastMouseDownPos = e->pos();
+
   if ( ! itemAt( contentsToViewport( e->pos() ) ) )
   return;
 
@@ -259,7 +261,17 @@
   if ( ! item || item->rtti() != RTTI_KateFileListItem )
     return;
 
-  viewManager->activateView( ((KateFileListItem *)item)->documentNumber() );
+  KateFileListItem *i = ((KateFileListItem*)item);
+  const KateDocumentInfo *info = KateDocManager::self()->documentInfo(i->document());
+
+  if (info && info->modifiedOnDisc) {
+    // Simulate mouse button release, otherwise the paused DND operation
+    // will reactivate as soon as the mouse re-enters the list view!
+    TQMouseEvent e(TQEvent::MouseButtonRelease, m_lastMouseDownPos, Qt::LeftButton, 0);
+    contentsMouseReleaseEvent(&e);
+  }
+
+  viewManager->activateView( i->documentNumber() );
 }
 
 void KateFileList::slotModChanged (Kate::Document *doc)
diff --git a/kate/app/katefilelist.h b/kate/app/katefilelist.h
index 49987ed..75d9391 100644
--- a/kate/app/katefilelist.h
+++ b/kate/app/katefilelist.h
@@ -166,6 +166,8 @@
 
     TQListViewItem *m_clickedMenuItem;
 
+    TQPoint m_lastMouseDownPos;
+
     class ToolTip *m_tooltip;
 };