1/* This file is part of the KDE project
2 Copyright (C) 2009 Dag Andersen <danders@get2net.dk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KPTTREECOMBOBOX_H
21#define KPTTREECOMBOBOX_H
22
23#include "kplatomodels_export.h"
24
25#include <kcombobox.h>
26
27#include <QAbstractItemView>
28#include <QEvent>
29
30class QModelIndex;
31class QPersistentModelIndex;
32class QPaintEvent;
33class QTreeView;
34class QAbstractItemModel;
35
36namespace KPlato
37{
38
39class KPLATOMODELS_EXPORT TreeComboBox : public KComboBox
40{
41 Q_OBJECT
42public:
43 explicit TreeComboBox(QWidget *parent = 0);
44
45 QTreeView *view() const;
46 void setModel( QAbstractItemModel *model );
47 QAbstractItemModel *model() const;
48
49 QList<QPersistentModelIndex> currentIndexes() const { return m_currentIndexes; }
50
51 void setSelectionMode( QAbstractItemView::SelectionMode mode );
52
53 void showPopup();
54
55signals:
56 void changed();
57
58public slots:
59 void setCurrentIndexes( const QModelIndexList &lst );
60 void setCurrentIndexes( const QList<QPersistentModelIndex> &lst );
61
62protected:
63 void paintEvent( QPaintEvent *event );
64
65protected slots:
66 void updateCurrentIndexes( const QModelIndexList &lst );
67 void slotSelectionChanged();
68
69private:
70 void updateView();
71
72private:
73 QAbstractItemView::SelectionMode m_selectionmode;
74 QList<int> m_showcolumns;
75 bool m_showheader;
76 QList<QPersistentModelIndex> m_currentIndexes;
77};
78
79
80} //namespace KPlato
81
82#endif
83
84