This is it, the long-awaited huge commit with the new Network handling.
[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 "identity.h"
25 #include "settingspage.h"
26
27 #include "ui_identitiessettingspage.h"
28 #include "ui_createidentitydlg.h"
29 #include "ui_saveidentitiesdlg.h"
30 #include "ui_nickeditdlgnew.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 widgetHasChanged();
65     void setWidgetStates();
66
67   private:
68     Ui::IdentitiesSettingsPage ui;
69
70     QHash<IdentityId, Identity *> identities;
71     IdentityId currentId;
72
73     QList<IdentityId> changedIdentities;  // for setting the widget changed state
74     QList<IdentityId> deletedIdentities;
75
76     void insertIdentity(Identity *identity);
77     void removeIdentity(Identity *identity);
78     void renameIdentity(IdentityId id, const QString &newName);
79     void displayIdentity(Identity *, bool dontsave = false);
80     void saveToIdentity(Identity *);
81
82     bool testHasChanged();
83 };
84
85 class CreateIdentityDlg : public QDialog {
86   Q_OBJECT
87
88   public:
89     CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent = 0);
90
91     QString identityName() const;
92     IdentityId duplicateId() const;
93
94   private slots:
95     void on_identityName_textChanged(const QString &text);
96
97   private:
98     Ui::CreateIdentityDlg ui;
99 };
100
101 class SaveIdentitiesDlg : public QDialog {
102   Q_OBJECT
103
104   public:
105     SaveIdentitiesDlg(const QList<Identity *> &toCreate, const QList<Identity *> &toUpdate, const QList<IdentityId> &toRemove, QWidget *parent = 0);
106
107   private slots:
108     void clientEvent();
109
110   private:
111     Ui::SaveIdentitiesDlg ui;
112
113     //QList<Identity *> toCreate, toUpdate;
114     //QList<IdentityId> toRemove;
115
116     int numevents, rcvevents;
117
118 };
119
120 class NickEditDlgNew : public QDialog {
121   Q_OBJECT
122
123   public:
124     NickEditDlgNew(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0);
125
126     QString nick() const;
127
128   private slots:
129     void on_nickEdit_textChanged(const QString &);
130
131   private:
132     Ui::NickEditDlgNew ui;
133
134     QString oldNick;
135     QStringList existing;
136
137 };
138
139 #endif