You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/examples/demo/dnd/iconview.cpp

43 lines
1.0 KiB

#include <ntqdragobject.h>
#include "dnd.h"
#include "iconview.h"
IconView::IconView( TQWidget* parent, const char* name )
: TQIconView( parent, name )
{
connect( this, TQ_SIGNAL(dropped(TQDropEvent*, const TQValueList<TQIconDragItem>&)),
TQ_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();
}