Reformat ALL the source!
[quassel.git] / src / qtui / settingspages / networkssettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 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) version 3.                                           *
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 NETWORKSSETTINGSPAGE_H
22 #define NETWORKSSETTINGSPAGE_H
23
24 #include <QPixmap>
25
26 #include "network.h"
27 #include "settingspage.h"
28
29 #include "ui_networkssettingspage.h"
30 #include "ui_networkadddlg.h"
31 #include "ui_networkeditdlg.h"
32 #include "ui_servereditdlg.h"
33 #include "ui_saveidentitiesdlg.h"
34
35 class NetworksSettingsPage : public SettingsPage
36 {
37     Q_OBJECT
38
39 public:
40     NetworksSettingsPage(QWidget *parent = 0);
41
42     virtual inline bool needsCoreConnection() const { return true; }
43
44     bool aboutToSave();
45
46 public slots:
47     void save();
48     void load();
49
50 private slots:
51     void widgetHasChanged();
52     void setWidgetStates();
53     void coreConnectionStateChanged(bool);
54     void networkConnectionStateChanged(Network::ConnectionState state);
55     void networkConnectionError(const QString &msg);
56
57     void displayNetwork(NetworkId);
58     void setItemState(NetworkId, QListWidgetItem *item = 0);
59
60     void clientNetworkAdded(NetworkId);
61     void clientNetworkRemoved(NetworkId);
62     void clientNetworkUpdated();
63
64     void clientIdentityAdded(IdentityId);
65     void clientIdentityRemoved(IdentityId);
66     void clientIdentityUpdated();
67
68     void on_networkList_itemSelectionChanged();
69     void on_addNetwork_clicked();
70     void on_deleteNetwork_clicked();
71     void on_renameNetwork_clicked();
72     void on_editIdentities_clicked();
73
74     // void on_connectNow_clicked();
75
76     void on_serverList_itemSelectionChanged();
77     void on_addServer_clicked();
78     void on_deleteServer_clicked();
79     void on_editServer_clicked();
80     void on_upServer_clicked();
81     void on_downServer_clicked();
82
83 private:
84     Ui::NetworksSettingsPage ui;
85
86     NetworkId currentId;
87     QHash<NetworkId, NetworkInfo> networkInfos;
88     bool _ignoreWidgetChanges;
89
90     QPixmap connectedIcon, connectingIcon, disconnectedIcon;
91
92     void reset();
93     bool testHasChanged();
94     QListWidgetItem *insertNetwork(NetworkId);
95     QListWidgetItem *insertNetwork(const NetworkInfo &info);
96     QListWidgetItem *networkItem(NetworkId) const;
97     void saveToNetworkInfo(NetworkInfo &);
98     IdentityId defaultIdentity() const;
99 };
100
101
102 class NetworkAddDlg : public QDialog
103 {
104     Q_OBJECT
105
106 public:
107     NetworkAddDlg(const QStringList &existing = QStringList(), QWidget *parent = 0);
108
109     NetworkInfo networkInfo() const;
110
111 private slots:
112     void setButtonStates();
113
114 private:
115     Ui::NetworkAddDlg ui;
116
117     QStringList existing;
118 };
119
120
121 class NetworkEditDlg : public QDialog
122 {
123     Q_OBJECT
124
125 public:
126     NetworkEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
127
128     QString networkName() const;
129
130 private slots:
131     void on_networkEdit_textChanged(const QString &);
132
133 private:
134     Ui::NetworkEditDlg ui;
135
136     QStringList existing;
137 };
138
139
140 class ServerEditDlg : public QDialog
141 {
142     Q_OBJECT
143
144 public:
145     ServerEditDlg(const Network::Server &server = Network::Server(), QWidget *parent = 0);
146
147     Network::Server serverData() const;
148
149 private slots:
150     void on_host_textChanged();
151
152 private:
153     Ui::ServerEditDlg ui;
154 };
155
156
157 class SaveNetworksDlg : public QDialog
158 {
159     Q_OBJECT
160
161 public:
162     SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
163
164 private slots:
165     void clientEvent();
166
167 private:
168     Ui::SaveIdentitiesDlg ui;
169
170     int numevents, rcvevents;
171 };
172
173
174 #endif