diff options
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 000000000..c8ce01b87 --- /dev/null +++ b/examples/demo/dnd/iconview.cpp @@ -0,0 +1,42 @@ +#include <qdragobject.h> + +#include "dnd.h" +#include "iconview.h" + + +IconView::IconView( TQWidget* parent, const char* name ) + : TQIconView( parent, name ) +{ + connect( this, SIGNAL(dropped(TQDropEvent*, const TQValueList<TQIconDragItem>&)), + SLOT(slotNewItem(TQDropEvent*, const TQValueList<TQIconDragItem>&))); +} + +IconView::~IconView() +{ + +} + + +TQDragObject *IconView::dragObject() +{ + if ( !currentItem() ) return 0; + + TQTextDrag * drg = new TQTextDrag( ((IconViewItem*)currentItem())->tag(), this ); + drg->setSubtype("dragdemotag"); + drg->setPixmap( *currentItem()->pixmap() ); + + return drg; +} + +void IconView::slotNewItem( TQDropEvent *e, const TQValueList<TQIconDragItem>& ) +{ + TQString tag; + if ( !e->provides( "text/dragdemotag" ) ) return; + + if ( TQTextDrag::decode( e, tag ) ) { + IconItem item = ((DnDDemo*) parentWidget())->findItem( tag ); + IconViewItem *iitem = new IconViewItem( this, item.name(), *item.pixmap(), tag ); + iitem->setRenameEnabled( TRUE ); + } + e->acceptAction(); +} |