support multiple drag from applet browser and multiple drop on containment
someone went to all the trouble to make the pixmap painting cute for the multiple situation, but didn't do the actual drag bit =P BUG:164342 svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=821594
This commit is contained in:
parent
97be4fc11b
commit
aa733dd6ee
@ -33,7 +33,9 @@ void CustomDragTreeView::startDrag ( Qt::DropActions supportedActions )
|
||||
// TODO: calculate real size for pixmap - using the icon sizes, not fixed
|
||||
// like now
|
||||
|
||||
if (!m_view) return;
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndexList indexes = selectedIndexes();
|
||||
if (indexes.count() > 0) {
|
||||
@ -48,7 +50,7 @@ void CustomDragTreeView::startDrag ( Qt::DropActions supportedActions )
|
||||
off = (MAX_OFFSET * MAX_COUNT) / indexes.count();
|
||||
}
|
||||
|
||||
kDebug() << "Size: " << size << " Off: " << off << "\n";
|
||||
//kDebug() << "Size: " << size << " Off: " << off << "\n";
|
||||
|
||||
QPixmap pixmap(size, size);
|
||||
pixmap.fill(QColor(255, 255, 255, 0)); // TODO: Transparent. Now it flickers when it's transparent
|
||||
@ -56,7 +58,9 @@ void CustomDragTreeView::startDrag ( Qt::DropActions supportedActions )
|
||||
QRect rect(0, 0, PIX_SIZE, PIX_SIZE);
|
||||
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
if (index.column() != 0) continue;
|
||||
if (index.column() != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KCategorizedItemsViewModels::AbstractItem * item =
|
||||
m_view->getItemByProxyIndex(index);
|
||||
|
@ -181,12 +181,20 @@ QMimeData* PlasmaAppletItemModel::mimeData(const QModelIndexList & indexes) cons
|
||||
|
||||
QString format = types.at(0);
|
||||
|
||||
PlasmaAppletItem
|
||||
* selectedItem = (PlasmaAppletItem *) itemFromIndex(indexes[0]);
|
||||
QByteArray appletName(selectedItem->pluginName().toUtf8());
|
||||
QByteArray appletNames;
|
||||
int lastRow = -1;
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
if (index.row() == lastRow) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->setData(format, appletName);
|
||||
lastRow = index.row();
|
||||
PlasmaAppletItem *selectedItem = (PlasmaAppletItem *) itemFromIndex(index);
|
||||
appletNames += '\n' + selectedItem->pluginName().toUtf8();
|
||||
//kDebug() << selectedItem->pluginName() << index.column() << index.row();
|
||||
}
|
||||
|
||||
data->setData(format, appletNames);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -716,10 +716,14 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||
QString mimetype(static_cast<Corona*>(scene())->appletMimeType());
|
||||
|
||||
if (event->mimeData()->hasFormat(mimetype) && scene()) {
|
||||
QString plasmoidName;
|
||||
plasmoidName = event->mimeData()->data(mimetype);
|
||||
QRectF geom(mapFromScene(event->scenePos()), QSize(0, 0));
|
||||
addApplet(plasmoidName, QVariantList(), geom);
|
||||
QString data = event->mimeData()->data(mimetype);
|
||||
QStringList appletNames = data.split('\n', QString::SkipEmptyParts);
|
||||
|
||||
foreach (const QString &appletName, appletNames) {
|
||||
//kDebug() << "doing" << appletName;
|
||||
QRectF geom(mapFromScene(event->scenePos()), QSize(0, 0));
|
||||
addApplet(appletName, QVariantList(), geom);
|
||||
}
|
||||
event->acceptProposedAction();
|
||||
} else if (KUrl::List::canDecode(event->mimeData())) {
|
||||
//TODO: collect the mimetypes of available script engines and offer
|
||||
|
Loading…
x
Reference in New Issue
Block a user