1/*
2 Copyright (c) 2002 Marc Mutz <mutz@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 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 the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19/**
20 @file
21 This file is part of the API for handling user identities and defines the
22 IdentityCombo class.
23
24 @brief
25 A combo box that always shows the up-to-date identity list.
26
27 @author Marc Mutz \<mutz@kde.org\>
28 */
29
30#ifndef KPIMIDENTITIES_IDENTITYCOMBO_H
31#define KPIMIDENTITIES_IDENTITYCOMBO_H
32
33#include "kpimidentities_export.h"
34#include <QComboBox>
35
36class QString;
37
38namespace KPIMIdentities
39{
40
41 class IdentityManager;
42 class Identity;
43
44 //KDE5: subclass from a KComboBox
45 class KPIMIDENTITIES_EXPORT IdentityCombo : public QComboBox //krazy:exclude=qclasses
46 {
47 Q_OBJECT
48 public:
49 explicit IdentityCombo( IdentityManager *manager, QWidget *parent=0 );
50
51 ~IdentityCombo();
52 QString currentIdentityName() const;
53 uint currentIdentity() const;
54 void setCurrentIdentity( const QString &identityName );
55 void setCurrentIdentity( const Identity &identity );
56 void setCurrentIdentity( uint uoid );
57 /**
58 Returns the IdentityManager used in this combo box.
59 @since 4.5
60 */
61 IdentityManager* identityManager() const;
62
63 Q_SIGNALS:
64
65 /**
66 @em Really emitted whenever the current identity changes. Either
67 by user intervention or on setCurrentIdentity() or if the
68 current identity disappears.
69
70 You might also want to listen to IdentityManager::changed,
71 IdentityManager::deleted and IdentityManager::added.
72 */
73 void identityChanged( uint uoid );
74
75 public Q_SLOTS:
76 /**
77 Connected to IdentityManager::changed(). Reloads the list of identities.
78 */
79 void slotIdentityManagerChanged();
80
81 protected Q_SLOTS:
82 void slotEmitChanged( int );
83 void slotUpdateTooltip( uint uoid );
84
85 protected:
86 void reloadCombo();
87 void reloadUoidList();
88 QList<uint> mUoidList;
89 IdentityManager *mIdentityManager;
90
91 private:
92 //@cond PRIVATE
93 class Private;
94 Private *const d;
95 //@endcond
96 };
97
98}
99
100#endif
101