~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to kopete/config/status/statustreeview.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    statustreeview.h
 
3
 
 
4
    Copyright (c) 2008       by Roman Jarosz           <kedgedev@centrum.cz>
 
5
    Kopete    (c) 2008       by the Kopete developers  <kopete-devel@kde.org>
 
6
 
 
7
    *************************************************************************
 
8
    *                                                                       *
 
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.                                   *
 
13
    *                                                                       *
 
14
    *************************************************************************
 
15
*/
 
16
 
 
17
#ifndef STATUSTREEVIEW_H
 
18
#define STATUSTREEVIEW_H
 
19
 
 
20
#include <QtGui/QTreeView>
 
21
#include <QtGui/QDrag>
 
22
 
 
23
class StatusTreeView : public QTreeView
 
24
{
 
25
public:
 
26
        StatusTreeView( QWidget * parent = 0 ) : QTreeView( parent ) {}
 
27
        
 
28
protected:
 
29
        // FIXME: is there an easier way to set default action of QDrag to Qt::MoveAction
 
30
        virtual void startDrag( Qt::DropActions supportedActions )
 
31
        {
 
32
                QModelIndexList indexes = selectedIndexes();
 
33
                if ( indexes.count() > 0 )
 
34
                {
 
35
                        QMimeData *data = model()->mimeData( indexes );
 
36
                        if ( !data )
 
37
                                return;
 
38
 
 
39
                        QDrag *drag = new QDrag( this );
 
40
                        drag->setMimeData( data );
 
41
                        if ( drag->exec( supportedActions, Qt::MoveAction ) == Qt::MoveAction )
 
42
                        {
 
43
                                const QItemSelection selection = selectionModel()->selection();
 
44
                                QList<QItemSelectionRange>::const_iterator it = selection.begin();
 
45
 
 
46
                                for ( ; it != selection.end(); ++it )
 
47
                                {
 
48
                                        QModelIndex parent = (*it).parent();
 
49
                                        if ( (*it).left() != 0 )
 
50
                                                continue;
 
51
                                        if ( (*it).right() != ( model()->columnCount(parent) - 1 ) )
 
52
                                                continue;
 
53
                                        int count = (*it).bottom() - (*it).top() + 1;
 
54
                                        model()->removeRows( (*it).top(), count, parent );
 
55
                                }
 
56
                        }
 
57
                }
 
58
        }
 
59
};
 
60
 
 
61
#endif