Last change
on this file since 208 was 160, checked in by dmik, 19 years ago |
Imported table and iconview modules and a bunch of dependent examples from the official release 3.3.1 from Trolltech.
|
-
Property svn:keywords
set to
Id
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <qdragobject.h>
|
---|
2 |
|
---|
3 | #include "dnd.h"
|
---|
4 | #include "iconview.h"
|
---|
5 |
|
---|
6 |
|
---|
7 | IconView::IconView( QWidget* parent, const char* name )
|
---|
8 | : QIconView( parent, name )
|
---|
9 | {
|
---|
10 | connect( this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)),
|
---|
11 | SLOT(slotNewItem(QDropEvent*, const QValueList<QIconDragItem>&)));
|
---|
12 | }
|
---|
13 |
|
---|
14 | IconView::~IconView()
|
---|
15 | {
|
---|
16 |
|
---|
17 | }
|
---|
18 |
|
---|
19 |
|
---|
20 | QDragObject *IconView::dragObject()
|
---|
21 | {
|
---|
22 | if ( !currentItem() ) return 0;
|
---|
23 |
|
---|
24 | QTextDrag * drg = new QTextDrag( ((IconViewItem*)currentItem())->tag(), this );
|
---|
25 | drg->setSubtype("dragdemotag");
|
---|
26 | drg->setPixmap( *currentItem()->pixmap() );
|
---|
27 |
|
---|
28 | return drg;
|
---|
29 | }
|
---|
30 |
|
---|
31 | void IconView::slotNewItem( QDropEvent *e, const QValueList<QIconDragItem>& )
|
---|
32 | {
|
---|
33 | QString tag;
|
---|
34 | if ( !e->provides( "text/dragdemotag" ) ) return;
|
---|
35 |
|
---|
36 | if ( QTextDrag::decode( e, tag ) ) {
|
---|
37 | IconItem item = ((DnDDemo*) parentWidget())->findItem( tag );
|
---|
38 | IconViewItem *iitem = new IconViewItem( this, item.name(), *item.pixmap(), tag );
|
---|
39 | iitem->setRenameEnabled( TRUE );
|
---|
40 | }
|
---|
41 | e->acceptAction();
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.