0e21662a10caf498d47da5b829a446dd33da6e84
[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
31 class QAbstractItemModel;
32
33 class IdentitiesSettingsPage : public SettingsPage {
34   Q_OBJECT
35
36   public:
37     IdentitiesSettingsPage(QWidget *parent = 0);
38
39     bool aboutToSave();
40
41   public slots:
42     void save();
43     void load();
44     void defaults();
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     void on_identityList_editTextChanged(const QString &);
54
55     void on_addIdentity_clicked();
56     void on_deleteIdentity_clicked();
57
58     void widgetHasChanged();
59
60   private:
61     Ui::IdentitiesSettingsPage ui;
62
63     QHash<IdentityId, Identity *> identities;
64     IdentityId currentId;
65
66     QList<IdentityId> changedIdentities;  // for setting the widget changed state
67     QList<IdentityId> deletedIdentities;
68
69     void insertIdentity(Identity *identity);
70     void removeIdentity(Identity *identity);
71     void displayIdentity(Identity *, bool dontsave = false);
72     void saveToIdentity(Identity *);
73
74     bool testHasChanged();
75 };
76
77 class CreateIdentityDlg : public QDialog {
78   Q_OBJECT
79
80   public:
81     CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent = 0);
82
83     QString identityName() const;
84     IdentityId duplicateId() const;
85
86   private slots:
87     void on_identityName_textChanged(const QString &text);
88
89   private:
90     Ui::CreateIdentityDlg ui;
91 };
92
93 class SaveIdentitiesDlg : public QDialog {
94   Q_OBJECT
95
96   public:
97     SaveIdentitiesDlg(QList<Identity *> toCreate, QList<Identity *> toUpdate, QList<IdentityId> toRemove, QWidget *parent = 0);
98
99   private slots:
100     void clientEvent();
101
102   private:
103     Ui::SaveIdentitiesDlg ui;
104
105     QList<Identity *> toCreate, toUpdate;
106     QList<IdentityId> toRemove;
107
108     int numevents, rcvevents;
109
110 };
111
112 #endif