9b750e277be240ff896af0ed49982be66d18f0dd
[quassel.git] / src / qtui / settingspages / identitiessettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef IDENTITIESSETTINGSPAGE_H
22 #define IDENTITIESSETTINGSPAGE_H
23
24 #include "clientidentity.h"
25 #include "settingspage.h"
26
27 #include "ui_identitiessettingspage.h"
28 #include "ui_createidentitydlg.h"
29 #include "ui_saveidentitiesdlg.h"
30 #include "ui_nickeditdlg.h"
31
32 class QAbstractItemModel;
33
34 class IdentitiesSettingsPage : public SettingsPage {
35   Q_OBJECT
36
37 public:
38   IdentitiesSettingsPage(QWidget *parent = 0);
39
40   bool aboutToSave();
41
42 public slots:
43   void save();
44   void load();
45
46 private slots:
47   void coreConnectionStateChanged(bool);
48   void clientIdentityCreated(IdentityId);
49   void clientIdentityUpdated();
50   void clientIdentityRemoved(IdentityId);
51
52   void on_identityList_currentIndexChanged(int index);
53
54   void on_addIdentity_clicked();
55   void on_deleteIdentity_clicked();
56   void on_renameIdentity_clicked();
57
58   void on_addNick_clicked();
59   void on_deleteNick_clicked();
60   void on_renameNick_clicked();
61   void on_nickUp_clicked();
62   void on_nickDown_clicked();
63
64   void on_continueUnsecured_clicked();
65   void on_clearOrLoadKeyButton_clicked();
66   void on_clearOrLoadCertButton_clicked();
67   void widgetHasChanged();
68   void setWidgetStates();
69
70 private:
71   Ui::IdentitiesSettingsPage ui;
72
73   QHash<IdentityId, CertIdentity *> identities;
74   IdentityId currentId;
75
76   QList<IdentityId> changedIdentities;  // for setting the widget changed state
77   QList<IdentityId> deletedIdentities;
78
79   bool _editSsl;
80
81   void insertIdentity(CertIdentity *identity);
82   void removeIdentity(Identity *identity);
83   void renameIdentity(IdentityId id, const QString &newName);
84   void displayIdentity(CertIdentity *, bool dontsave = false);
85   void saveToIdentity(CertIdentity *);
86
87   void showKeyState(const QSslKey &key);
88   void showCertState(const QSslCertificate &cert);
89
90   bool testHasChanged();
91 };
92
93 class CreateIdentityDlg : public QDialog {
94   Q_OBJECT
95
96 public:
97   CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent = 0);
98
99   QString identityName() const;
100   IdentityId duplicateId() const;
101
102 private slots:
103   void on_identityName_textChanged(const QString &text);
104
105 private:
106   Ui::CreateIdentityDlg ui;
107 };
108
109 class SaveIdentitiesDlg : public QDialog {
110   Q_OBJECT
111
112 public:
113   SaveIdentitiesDlg(const QList<CertIdentity *> &toCreate, const QList<CertIdentity *> &toUpdate, const QList<IdentityId> &toRemove, QWidget *parent = 0);
114
115 private slots:
116   void clientEvent();
117
118 private:
119   Ui::SaveIdentitiesDlg ui;
120
121   int numevents, rcvevents;
122 };
123
124 class NickEditDlg : public QDialog {
125   Q_OBJECT
126
127 public:
128   NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0);
129
130   QString nick() const;
131
132 private slots:
133   void on_nickEdit_textChanged(const QString &);
134
135 private:
136   Ui::NickEditDlg ui;
137
138   QString oldNick;
139   QStringList existing;
140
141 };
142
143 #endif