[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.6/kdebase/workspace/plasma/desktop/applets/tasks
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2011-01-12 2:44:59
Message-ID: 20110112024459.68066AC8B3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1213907 by aseigo:

only accept drops of executables for launcher creation
CCBUG:261443


 M  +36 -6     abstracttaskitem.cpp  
 M  +1 -0      abstracttaskitem.h  
 M  +2 -5      taskgroupitem.cpp  


--- branches/KDE/4.6/kdebase/workspace/plasma/desktop/applets/tasks/abstracttaskitem.cpp #1213906:1213907
@@ -24,6 +24,7 @@
 
 // Qt
 #include <QApplication>
+#include <QFileInfo>
 #include <QGraphicsLinearLayout>
 #include <QGraphicsSceneContextMenuEvent>
 #include <QGraphicsView>
@@ -38,12 +39,12 @@
 
 // KDE
 #include <KAuthorized>
+#include <KColorUtils>
 #include <KDebug>
+#include <KGlobalSettings>
 #include <KIcon>
 #include <KIconEffect>
-#include <KGlobalSettings>
 #include <KIconLoader>
-#include <KColorUtils>
 
 #include <NETWinInfo>
 
@@ -869,12 +870,41 @@
     update();
 }
 
+bool AbstractTaskItem::shouldIgnoreDragEvent(QGraphicsSceneDragDropEvent *event)
+{
+   if (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) ||
+       event->mimeData()->hasFormat(TaskManager::Task::groupMimetype())) {
+        return true;
+    }
+
+    if (event->mimeData()->hasFormat("text/uri-list")) {
+        // we want to check if we have executables; if so, then we treat it as a possible
+        // drop for a launcher
+        const KUrl::List uris = KUrl::List::fromMimeData(event->mimeData());
+        if (!uris.isEmpty()) {
+            foreach (const QUrl &uri, uris) {
+                KUrl url(uri);
+                if (url.isLocalFile()) {
+                    const QString path = url.toLocalFile();
+                    QFileInfo info(path);
+                    if (info.isDir() || !info.isExecutable()) {
+                        return false;
+                        break;
+                    }
+                }
+            }
+
+            return true;
+        }
+    }
+
+    return false;
+}
+
 void AbstractTaskItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
 {
-    if (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) ||
-        event->mimeData()->hasFormat(TaskManager::Task::groupMimetype()) ||
-        event->mimeData()->hasFormat("text/uri-list")) {
-        event->ignore(); //ignore it so the taskbar gets the event
+    if (shouldIgnoreDragEvent(event)) {
+        event->ignore();
         return;
     }
 
--- branches/KDE/4.6/kdebase/workspace/plasma/desktop/applets/tasks/abstracttaskitem.h #1213906:1213907
@@ -192,6 +192,7 @@
     virtual void updateToolTip() = 0; // pure virtual function
     QString expanderElement() const;
     void stopWindowHoverEffect();
+    bool shouldIgnoreDragEvent(QGraphicsSceneDragDropEvent *event);
 
 protected Q_SLOTS:
     /** Event compression **/
--- branches/KDE/4.6/kdebase/workspace/plasma/desktop/applets/tasks/taskgroupitem.cpp #1213906:1213907
@@ -1047,11 +1047,8 @@
 void TaskGroupItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
 {
     //kDebug()<<"Drag enter";
-    if (collapsed() &&
-        (event->mimeData()->hasFormat(TaskManager::Task::mimetype()) ||
-         event->mimeData()->hasFormat(TaskManager::Task::groupMimetype()) ||
-         event->mimeData()->hasFormat("text/uri-list"))) {
-        event->acceptProposedAction();
+    if (collapsed() && shouldIgnoreDragEvent(event)) {
+        event->ignore();
         //kDebug()<<"Drag enter accepted";
     } else {
         event->accept();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic