1 /* -*- mode: c++; c-basic-offset:4 -*-
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
33 #ifndef __KLEOPATRA_VIEW_KEYTREEVIEW_H__
34 #define __KLEOPATRA_VIEW_KEYTREEVIEW_H__
40 #include <gpgme++/key.h>
42 #include <boost/shared_ptr.hpp>
51 class AbstractKeyListModel
;
52 class AbstractKeyListSortFilterProxyModel
;
53 class KeyListSortFilterProxyModel
;
55 class KeyTreeView
: public QWidget
59 explicit KeyTreeView(QWidget
*parent
= Q_NULLPTR
);
60 KeyTreeView(const QString
&stringFilter
, const boost::shared_ptr
<KeyFilter
> &keyFilter
,
61 AbstractKeyListSortFilterProxyModel
*additionalProxy
, QWidget
*parent
);
64 QTreeView
*view() const
69 AbstractKeyListModel
*model() const
71 return m_isHierarchical
? hierarchicalModel() : flatModel();
74 AbstractKeyListModel
*flatModel() const
78 AbstractKeyListModel
*hierarchicalModel() const
80 return m_hierarchicalModel
;
83 void setFlatModel(AbstractKeyListModel
*model
);
84 void setHierarchicalModel(AbstractKeyListModel
*model
);
86 void setKeys(const std::vector
<GpgME::Key
> &keys
);
87 const std::vector
<GpgME::Key
> &keys() const
92 void selectKeys(const std::vector
<GpgME::Key
> &keys
);
93 std::vector
<GpgME::Key
> selectedKeys() const;
95 void addKeysUnselected(const std::vector
<GpgME::Key
> &keys
);
96 void addKeysSelected(const std::vector
<GpgME::Key
> &keys
);
97 void removeKeys(const std::vector
<GpgME::Key
> &keys
);
100 void setToolTipOptions(int options
);
101 int toolTipOptions() const;
104 QString
stringFilter() const
106 return m_stringFilter
;
108 const boost::shared_ptr
<KeyFilter
> &keyFilter() const
112 bool isHierarchicalView() const
114 return m_isHierarchical
;
117 void setColumnSizes(const std::vector
<int> &sizes
);
118 std::vector
<int> columnSizes() const;
120 void setSortColumn(int sortColumn
, Qt::SortOrder sortOrder
);
121 int sortColumn() const;
122 Qt::SortOrder
sortOrder() const;
124 virtual KeyTreeView
*clone() const
126 return new KeyTreeView(*this);
129 void disconnectSearchBar(const QObject
*bar
);
130 bool connectSearchBar(const QObject
*bar
);
133 virtual void setStringFilter(const QString
&text
);
134 virtual void setKeyFilter(const boost::shared_ptr
<Kleo::KeyFilter
> &filter
);
135 virtual void setHierarchicalView(bool on
);
138 void stringFilterChanged(const QString
&filter
);
139 void keyFilterChanged(const boost::shared_ptr
<Kleo::KeyFilter
> &filter
);
140 void hierarchicalChanged(bool on
);
143 KeyTreeView(const KeyTreeView
&);
147 void addKeysImpl(const std::vector
<GpgME::Key
> &, bool);
150 std::vector
<GpgME::Key
> m_keys
;
152 KeyListSortFilterProxyModel
*m_proxy
;
153 AbstractKeyListSortFilterProxyModel
*m_additionalProxy
;
157 AbstractKeyListModel
*m_flatModel
;
158 AbstractKeyListModel
*m_hierarchicalModel
;
160 QString m_stringFilter
;
161 boost::shared_ptr
<KeyFilter
> m_keyFilter
;
163 bool m_isHierarchical
: 1;
168 #endif // __KLEOPATRA_VIEW_KEYTREEVIEW_H__