* use KUrl::List

svn path=/trunk/KDE/kdebase/workspace/lib/plasma/; revision=672119
This commit is contained in:
Aaron J. Seigo 2007-06-06 05:12:51 +00:00
parent df7bfdcfeb
commit 83eed9ccd4
2 changed files with 13 additions and 18 deletions

View File

@ -31,8 +31,7 @@
#include <KRun>
#include <KWindowSystem>
#include <KDebug>
#include <kmimetypetrader.h>
#include <kdesktopfile.h>
#include <KMimeType>
#include "applet.h"
#include "dataengine.h"
@ -243,23 +242,18 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event)
d->applets.last()->setPos(event->pos());
event->acceptProposedAction();
}
else if (event->mimeData()->hasFormat("text/plain"))
{
QList<QUrl> list;
list = event->mimeData()->urls();
KDesktopFile * desktop = new KDesktopFile(list[0].path());
QStringList data = event->mimeData()->formats();
for (int i = 0; i < data.size(); ++i)
Plasma::Icon * icon = new Plasma::Icon(0);
icon->setIcon(desktop->readIcon());
icon->setSize(128,128);
icon->show();
addItem(icon);
delete desktop;
} else if (KUrl::List::canDecode(event->mimeData())) {
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
foreach (const KUrl& url, urls) {
Plasma::Icon *icon = new Plasma::Icon(0);
icon->setIcon(KMimeType::iconNameForUrl(url));
icon->setSize(128,128);
//TODO: associate the url with the icon, use the Button plasmoid here
icon->show();
addItem(icon);
}
event->acceptProposedAction();
}
}
}
void Corona::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)

View File

@ -100,6 +100,7 @@ Icon::Icon(QGraphicsItem *parent)
setAcceptedMouseButtons(Qt::LeftButton);
setAcceptsHoverEvents(true);
setEnabled(true);
setFlags(ItemIsMovable);
setPos(QPointF(0.0,0.0));
}