Better wording
[kdepim.git] / kleopatra / view / keytreeview.h
blob115a0562abae4032d5aeaa4f2c2e3a67a8df6fb9
1 /* -*- mode: c++; c-basic-offset:4 -*-
2 view/keytreeview.h
4 This file is part of Kleopatra, the KDE keymanager
5 Copyright (c) 2009 Klarälvdalens Datakonsult AB
7 Kleopatra is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Kleopatra is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 In addition, as a special exception, the copyright holders give
22 permission to link the code of this program with any edition of
23 the Qt library by Trolltech AS, Norway (or with modified versions
24 of Qt that use the same license as Qt), and distribute linked
25 combinations including the two. You must obey the GNU General
26 Public License in all respects for all of the code used other than
27 Qt. If you modify this file, you may extend this exception to
28 your version of the file, but you are not obligated to do so. If
29 you do not wish to do so, delete this exception statement from
30 your version.
33 #ifndef __KLEOPATRA_VIEW_KEYTREEVIEW_H__
34 #define __KLEOPATRA_VIEW_KEYTREEVIEW_H__
36 #include <QWidget>
38 #include <QString>
40 #include <gpgme++/key.h>
42 #include <boost/shared_ptr.hpp>
43 #include <vector>
45 class QTreeView;
47 namespace Kleo {
49 class KeyFilter;
50 class AbstractKeyListModel;
51 class AbstractKeyListSortFilterProxyModel;
52 class KeyListSortFilterProxyModel;
54 class KeyTreeView : public QWidget {
55 Q_OBJECT
56 public:
57 explicit KeyTreeView( QWidget * parent=0 );
58 KeyTreeView( const QString & stringFilter, const boost::shared_ptr<KeyFilter> & keyFilter,
59 AbstractKeyListSortFilterProxyModel * additionalProxy, QWidget * parent );
60 ~KeyTreeView();
62 QTreeView * view() const { return m_view; }
64 AbstractKeyListModel * model() const { return m_isHierarchical ? hierarchicalModel() : flatModel() ; }
66 AbstractKeyListModel * flatModel() const { return m_flatModel; }
67 AbstractKeyListModel * hierarchicalModel() const { return m_hierarchicalModel; }
69 void setFlatModel( AbstractKeyListModel * model );
70 void setHierarchicalModel( AbstractKeyListModel * model );
72 void setKeys( const std::vector<GpgME::Key> & keys );
73 const std::vector<GpgME::Key> & keys() const { return m_keys; }
75 void selectKeys( const std::vector<GpgME::Key> & keys );
76 std::vector<GpgME::Key> selectedKeys() const;
78 void addKeysUnselected( const std::vector<GpgME::Key> & keys );
79 void addKeysSelected( const std::vector<GpgME::Key> & keys );
80 void removeKeys( const std::vector<GpgME::Key> & keys );
82 #if 0
83 void setToolTipOptions( int options );
84 int toolTipOptions() const;
85 #endif
87 QString stringFilter() const { return m_stringFilter; }
88 const boost::shared_ptr<KeyFilter> & keyFilter() const { return m_keyFilter; }
89 bool isHierarchicalView() const { return m_isHierarchical; }
91 void setColumnSizes( const std::vector<int> & sizes );
92 std::vector<int> columnSizes() const;
94 void setSortColumn( int sortColumn, Qt::SortOrder sortOrder );
95 int sortColumn() const;
96 Qt::SortOrder sortOrder() const;
98 virtual KeyTreeView * clone() const { return new KeyTreeView( *this ); }
100 void disconnectSearchBar( const QObject * bar );
101 bool connectSearchBar( const QObject * bar );
103 public Q_SLOTS:
104 virtual void setStringFilter( const QString & text );
105 virtual void setKeyFilter( const boost::shared_ptr<Kleo::KeyFilter> & filter );
106 virtual void setHierarchicalView( bool on );
108 Q_SIGNALS:
109 void stringFilterChanged( const QString & filter );
110 void keyFilterChanged( const boost::shared_ptr<Kleo::KeyFilter> & filter );
111 void hierarchicalChanged( bool on );
113 protected:
114 KeyTreeView( const KeyTreeView & );
116 private:
117 void init();
118 void addKeysImpl( const std::vector<GpgME::Key> &, bool );
120 private:
121 std::vector<GpgME::Key> m_keys;
123 KeyListSortFilterProxyModel * m_proxy;
124 AbstractKeyListSortFilterProxyModel * m_additionalProxy;
126 QTreeView * m_view;
128 AbstractKeyListModel * m_flatModel;
129 AbstractKeyListModel * m_hierarchicalModel;
131 QString m_stringFilter;
132 boost::shared_ptr<KeyFilter> m_keyFilter;
134 bool m_isHierarchical : 1;
139 #endif // __KLEOPATRA_VIEW_KEYTREEVIEW_H__