4
Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5
Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
7
*************************************************************************
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
14
*************************************************************************
17
#ifndef STATUSTREEVIEW_H
18
#define STATUSTREEVIEW_H
20
#include <QtGui/QTreeView>
21
#include <QtGui/QDrag>
23
class StatusTreeView : public QTreeView
26
StatusTreeView( QWidget * parent = 0 ) : QTreeView( parent ) {}
29
// FIXME: is there an easier way to set default action of QDrag to Qt::MoveAction
30
virtual void startDrag( Qt::DropActions supportedActions )
32
QModelIndexList indexes = selectedIndexes();
33
if ( indexes.count() > 0 )
35
QMimeData *data = model()->mimeData( indexes );
39
QDrag *drag = new QDrag( this );
40
drag->setMimeData( data );
41
if ( drag->exec( supportedActions, Qt::MoveAction ) == Qt::MoveAction )
43
const QItemSelection selection = selectionModel()->selection();
44
QList<QItemSelectionRange>::const_iterator it = selection.begin();
46
for ( ; it != selection.end(); ++it )
48
QModelIndex parent = (*it).parent();
49
if ( (*it).left() != 0 )
51
if ( (*it).right() != ( model()->columnCount(parent) - 1 ) )
53
int count = (*it).bottom() - (*it).top() + 1;
54
model()->removeRows( (*it).top(), count, parent );