Better wording
[kdepim.git] / kleopatra / view / keylistcontroller.h
blob085dd469532b41ffa0df28988670e488d9211a46
1 /* -*- mode: c++; c-basic-offset:4 -*-
2 controllers/keylistcontroller.h
4 This file is part of Kleopatra, the KDE keymanager
5 Copyright (c) 2007 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.
32 #ifndef __KLEOPATRA_CONTROLLERS_KEYLISTCONTROLLER_H__
33 #define __KLEOPATRA_CONTROLLERS_KEYLISTCONTROLLER_H__
35 #include <QObject>
37 #include <commands/command.h>
39 #include <utils/pimpl_ptr.h>
41 #include <vector>
43 class QAbstractItemView;
44 class QAction;
45 class QPoint;
46 class QItemSelectionModel;
47 class KActionCollection;
49 namespace Kleo {
51 class AbstractKeyListModel;
52 class Command;
53 class TabWidget;
55 class KeyListController : public QObject {
56 Q_OBJECT
57 public:
58 explicit KeyListController( QObject * parent=0 );
59 ~KeyListController();
61 std::vector<QAbstractItemView*> views() const;
63 void setFlatModel( AbstractKeyListModel * model );
64 AbstractKeyListModel * flatModel() const;
66 void setHierarchicalModel( AbstractKeyListModel * model );
67 AbstractKeyListModel * hierarchicalModel() const;
69 void setParentWidget( QWidget * parent );
70 QWidget * parentWidget() const;
72 QAbstractItemView * currentView() const;
74 void setTabWidget( TabWidget * tabs );
75 TabWidget * tabWidget() const;
77 void registerCommand( Command * cmd );
79 void createActions( KActionCollection * collection );
81 template <typename T_Command>
82 void registerActionForCommand( QAction * action ) {
83 this->registerAction( action, T_Command::restrictions(), &KeyListController::template create<T_Command> );
86 void enableDisableActions( const QItemSelectionModel * sm ) const;
88 bool hasRunningCommands() const;
89 bool shutdownWarningRequired() const;
91 private:
92 void registerAction( QAction * action, Command::Restrictions restrictions , Command * (*create)( QAbstractItemView*, KeyListController* ) );
94 template <typename T_Command>
95 static Command * create( QAbstractItemView * v, KeyListController * c ) { return new T_Command( v, c ); }
97 public Q_SLOTS:
98 void addView( QAbstractItemView * view );
99 void removeView( QAbstractItemView * view );
100 void setCurrentView( QAbstractItemView * view );
102 void cancelCommands();
103 void updateConfig();
105 Q_SIGNALS:
106 void progress( int current, int total );
107 void message( const QString & msg, int timeout=0 );
109 void commandsExecuting( bool );
111 void contextMenuRequested( QAbstractItemView * view, const QPoint & p );
113 private:
114 class Private;
115 kdtools::pimpl_ptr<Private> d;
117 Q_PRIVATE_SLOT( d, void slotDestroyed(QObject*) )
118 Q_PRIVATE_SLOT( d, void slotDoubleClicked(QModelIndex) )
119 Q_PRIVATE_SLOT( d, void slotActivated(QModelIndex) )
120 Q_PRIVATE_SLOT( d, void slotSelectionChanged(QItemSelection,QItemSelection) )
121 Q_PRIVATE_SLOT( d, void slotContextMenu(QPoint) )
122 Q_PRIVATE_SLOT( d, void slotCommandFinished() )
123 Q_PRIVATE_SLOT( d, void slotAddKey(GpgME::Key) )
124 Q_PRIVATE_SLOT( d, void slotAboutToRemoveKey(GpgME::Key) )
125 Q_PRIVATE_SLOT( d, void slotProgress(QString,int,int) )
126 Q_PRIVATE_SLOT( d, void slotActionTriggered() )
127 Q_PRIVATE_SLOT( d, void slotCurrentViewChanged(QAbstractItemView*) )
132 #endif /* __KLEOPATRA_CONTROLLERS_KEYLISTCONTROLLER_H__ */