diff options
| author | Peter Penz <[email protected]> | 2012-05-18 23:21:49 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-05-18 23:31:44 +0200 |
| commit | e9d29bcf30ccbd7c76ba37ce9efcfac1649fc46e (patch) | |
| tree | 954ea3c1e8f7204c5e51353f444333496988ae1e /src/kitemviews/kstandarditemlistwidget.cpp | |
| parent | d9eab08fcb8bfc56470a7f418465607888b5f1ba (diff) | |
Enable basic drag and drop support for the Places Panel
The dropping has not been implemented yet, however in the context of
this step the creating of the drag-pixmap is now forwarded to
the item-widgets. This allows creating some optimized dragging-pixmaps
e.g. for the details-view, where only the name and icon should
be provided as drag-pixmap.
Diffstat (limited to 'src/kitemviews/kstandarditemlistwidget.cpp')
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 3f470b8cf..0cd11d363 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -405,6 +405,32 @@ QRectF KStandardItemListWidget::selectionToggleRect() const return QRectF(pos, QSizeF(toggleSize, toggleSize)); } +QPixmap KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option, + QWidget* widget) +{ + QPixmap pixmap = KItemListWidget::createDragPixmap(option, widget); + if (m_layout != DetailsLayout || styleOption().extendedSelectionRegion) { + return pixmap; + } + + // Only return the content of the text-column as pixmap + const int leftClip = m_pixmapPos.x(); + + const TextInfo* textInfo = m_textInfo.value("text"); + const int rightClip = textInfo->pos.x() + + textInfo->staticText.size().width() + + 2 * styleOption().padding; + + QPixmap clippedPixmap(rightClip - leftClip + 1, pixmap.height()); + clippedPixmap.fill(Qt::transparent); + + QPainter painter(&clippedPixmap); + painter.drawPixmap(-leftClip, 0, pixmap); + + return clippedPixmap; +} + + KItemListWidgetInformant* KStandardItemListWidget::createInformant() { return new KStandardItemListWidgetInformant(); |
