summaryrefslogtreecommitdiffstats
path: root/examples/demo/dnd/listview.h
blob: 507e594940cacf381d9f1ba131547aeec4d24687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <qlistview.h>

class ListViewItem : public QListViewItem
{
public:
    ListViewItem ( QListView * parent, const QString& name, const QString& tag )
        : QListViewItem( parent, name ), _tag( tag ) {}
    ListViewItem ( QListView * parent, QListViewItem * after, const QString& name, const QString& tag )
        : QListViewItem( parent, after, name ), _tag( tag ) {}
    virtual ~ListViewItem() {}

    QString tag() { return _tag; }

private:
    QString _tag;
};

class ListView : public QListView
{
    Q_OBJECT

public:
    ListView( QWidget* parent = 0, const char* name = 0 );
    ~ListView();

    void dragEnterEvent( QDragEnterEvent * );
    void dropEvent( QDropEvent * );
    void contentsMousePressEvent( QMouseEvent * );
    void contentsMouseMoveEvent( QMouseEvent * );
    void contentsMouseReleaseEvent( QMouseEvent * );

private:
    QPoint pressPos;
    bool dragging;
};