Big, big, major commit this time:
[quassel.git] / gui / serverlist.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by The Quassel Team                                *
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 _SERVERLIST_H_
22 #define _SERVERLIST_H_
23
24 #include <QtGui>
25 #include <QMap>
26 #include <QList>
27 #include <QVariant>
28
29 #include "ui_serverlistdlg.h"
30 #include "ui_identitiesdlg.h"
31 #include "ui_identitieseditdlg.h"
32 #include "ui_nickeditdlg.h"
33 #include "ui_networkeditdlg.h"
34
35 typedef QMap<QString, QVariant> VarMap;
36
37 class ServerListDlg : public QDialog {
38   Q_OBJECT
39
40   public:
41     ServerListDlg(QWidget *parent);
42     virtual ~ServerListDlg();
43
44     bool showOnStartup();
45
46   public slots:
47     void editIdentities();
48
49   private slots:
50     void updateButtons();
51     void on_showOnStartup_stateChanged(int);
52     void on_addButton_clicked();
53
54   private:
55     Ui::ServerListDlg ui;
56
57     void loadNetworks();
58     void storeNetworks();
59     void loadIdentities();
60     void storeIdentities();
61
62     VarMap networks;
63     VarMap identities;
64 };
65
66 class NetworkEditDlg : public QDialog {
67   Q_OBJECT
68
69   public:
70     NetworkEditDlg(QWidget *parent, VarMap network, VarMap identities);
71
72   private:
73     Ui::NetworkEditDlg ui;
74
75     VarMap network;
76     VarMap identities;
77
78     VarMap createDefaultNetwork();
79 };
80
81 class IdentitiesDlg : public QDialog {
82   Q_OBJECT
83
84   public:
85     IdentitiesDlg(QWidget *parent, VarMap identities);
86
87     VarMap getIdentities() { return identities; }
88     QMap<QString, QString> getNameMapping() { return nameMapping; }
89
90   public slots:
91     virtual void accept();
92
93   private slots:
94     void autoAwayChecked();
95     void identityChanged(QString);
96     void nickSelectionChanged();
97
98     void addNick();
99     void editNick();
100     void delNick();
101     void upNick();
102     void downNick();
103
104     void editIdentities();
105
106     void globalDataUpdated(QString);
107
108   private:
109     Ui::IdentitiesDlg ui;
110     VarMap identities;
111     QMap<QString, QString> nameMapping;
112     QString lastIdentity;
113
114     QString checkValidity();
115     VarMap createDefaultIdentity();
116     QString getCurIdentity();
117     void updateWidgets();
118     void updateIdentity(QString);
119 };
120
121 class NickEditDlg : public QDialog {
122   Q_OBJECT
123
124   public:
125     NickEditDlg(QWidget *parent, QString nick = QString());
126
127     QString getNick();
128
129   private slots:
130     void textChanged(QString);
131
132   private:
133     Ui::NickEditDlg ui;
134
135 };
136
137 class IdentitiesEditDlg : public QDialog {
138   Q_OBJECT
139
140   public:
141     IdentitiesEditDlg(QWidget *parent, VarMap identities, QMap<QString, QString> mapping, VarMap templ);
142
143     VarMap getIdentities() { return identities; }
144     QMap<QString, QString> getMapping() { return mapping; }
145
146   private slots:
147     void selectionChanged();
148
149     void addIdentity();
150     void duplicateIdentity();
151     void renameIdentity();
152     void deleteIdentity();
153
154   private:
155     Ui::IdentitiesEditDlg ui;
156
157     VarMap identities;
158     VarMap identTemplate;
159     QMap<QString, QString> mapping;
160
161     void sortList();
162 };
163
164 class RenameIdentityDlg : public QDialog {
165   Q_OBJECT
166
167   public:
168     RenameIdentityDlg(QWidget *parent, QList<QString> reserved, QString name = QString());
169
170     QString getName();
171
172   private slots:
173     void textChanged(QString);
174
175   private:
176     Ui::NickEditDlg ui;
177     QList<QString> reserved;
178 };
179  
180 #endif