2010/5/22 Chani <chan...@gmail.com>

> On May 22, 2010 09:03:53 Alessandro Diaferia wrote:
> > Hullo,
> > it seems reviewboard cannot connect to anonsvn (at least from here) so
> i'm
> > attaching the patch here as it is really small.
> >
> > Having a look at https://bugs.kde.org/show_bug.cgi?id=231791 you can see
> > how easy is reproducing the bug.
> > It seems that kickoff does not allow adding favorites via D&D. D&D is
> only
> > used to move items in the list.
> > This little patch allows adding favorites via D&D dragging from the
> > application view to the favorites one.
> > I just don't know if this is considered as a new feature. It seems to me
> > that this patch just makes kickoff behaving as it is expected to behave.
> >
> > Anyway the last word is yours of course, plasma-friends :)
> >
> > Regards.
>
> hmm. no comment on whether it's a feature..  code looks sensible, although
> wouldn't it be more future-proof to iterate over data->urls() instead of
> only
> taking the first?
>

you're just right.. so here comes the updated patch :)


> --
> This message brought to you by eevil bananas and the number 3.
> www.chani3.com
>
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
>


-- 
Alessandro Diaferia
KDE Developer
KDE e.V. member
Index: core/favoritesmodel.cpp
===================================================================
--- core/favoritesmodel.cpp	(revision 1129455)
+++ core/favoritesmodel.cpp	(local copy)
@@ -29,6 +29,7 @@
 // KDE
 #include <KConfigGroup>
 #include <KService>
+#include <KDesktopFile>
 #include <kdebug.h>
 
 using namespace Kickoff;
@@ -265,9 +266,9 @@ bool FavoritesModel::dropMimeData(const 
     if (action == Qt::MoveAction) {
         QModelIndex modelIndex;
         QStandardItem *startItem;
-        int startRow = 0, destRow;
+        int startRow = -1;
 
-        destRow = row;
+        int destRow = row;
 
         // look for the favorite that was dragged
         for (int i = 0; i < d->headerItem->rowCount(); i++) {
@@ -279,6 +280,25 @@ bool FavoritesModel::dropMimeData(const 
             }
         }
 
+        if (startRow < 0) {
+            bool dropped = false;
+            foreach (const QUrl &url, data->urls()) {
+                if (!url.isValid()) {
+                    continue;
+                }
+                const QString path = url.toLocalFile();
+                if (!KDesktopFile::isDesktopFile(path)) {
+                    continue;
+                }
+                KDesktopFile dFile(path);
+                if (dFile.hasApplicationType() && !dFile.noDisplay()) {
+                    FavoritesModel::add(path);
+                    dropped = true;
+                }
+            }
+            return dropped;
+        }
+
         if (destRow < 0)
             return false;
 
Index: ui/urlitemview.cpp
===================================================================
--- ui/urlitemview.cpp	(revision 1129455)
+++ ui/urlitemview.cpp	(local copy)
@@ -23,6 +23,7 @@
 // Qt
 #include <QtCore/QHash>
 #include <QtCore/QPersistentModelIndex>
+#include <QtCore/QUrl>
 
 #include <QtGui/QMouseEvent>
 #include <QtGui/QPainter>
@@ -30,6 +31,7 @@
 #include <QtGui/QScrollBar>
 #include <QtGui/QToolTip>
 
+
 // KDE
 #include <KDebug>
 #include <KGlobalSettings>
@@ -675,6 +677,10 @@ void UrlItemView::dropEvent(QDropEvent *
         int row;
         QPoint pos = event->pos();
         QModelIndex parent = indexAt(pos);
+
+        if (!parent.isValid()) {
+            return;
+        }
         const QRect rect = visualRect(parent);
 
         row = parent.row();
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to