diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:24:15 -0500 |
commit | bd0f3345a938b35ce6a12f6150373b0955b8dd12 (patch) | |
tree | 7a520322212d48ebcb9fbe1087e7fca28b76185c /examples/demo/dnd/iconview.cpp | |
download | qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.tar.gz qt3-bd0f3345a938b35ce6a12f6150373b0955b8dd12.zip |
Add Qt3 development HEAD version
Diffstat (limited to 'examples/demo/dnd/iconview.cpp')
-rw-r--r-- | examples/demo/dnd/iconview.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/demo/dnd/iconview.cpp b/examples/demo/dnd/iconview.cpp new file mode 100644 index 0000000..c7c184e --- /dev/null +++ b/examples/demo/dnd/iconview.cpp @@ -0,0 +1,42 @@ +#include <qdragobject.h> + +#include "dnd.h" +#include "iconview.h" + + +IconView::IconView( QWidget* parent, const char* name ) + : QIconView( parent, name ) +{ + connect( this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), + SLOT(slotNewItem(QDropEvent*, const QValueList<QIconDragItem>&))); +} + +IconView::~IconView() +{ + +} + + +QDragObject *IconView::dragObject() +{ + if ( !currentItem() ) return 0; + + QTextDrag * drg = new QTextDrag( ((IconViewItem*)currentItem())->tag(), this ); + drg->setSubtype("dragdemotag"); + drg->setPixmap( *currentItem()->pixmap() ); + + return drg; +} + +void IconView::slotNewItem( QDropEvent *e, const QValueList<QIconDragItem>& ) +{ + QString tag; + if ( !e->provides( "text/dragdemotag" ) ) return; + + if ( QTextDrag::decode( e, tag ) ) { + IconItem item = ((DnDDemo*) parentWidget())->findItem( tag ); + IconViewItem *iitem = new IconViewItem( this, item.name(), *item.pixmap(), tag ); + iitem->setRenameEnabled( TRUE ); + } + e->acceptAction(); +} |