Make button to edit identities from networks settings work
[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   Q_OBJECT
37
38   public:
39     NetworksSettingsPage(QWidget *parent = 0);
40
41     bool aboutToSave();
42
43   public slots:
44     void save();
45     void load();
46
47   private slots:
48     void widgetHasChanged();
49     void setWidgetStates();
50     void coreConnectionStateChanged(bool);
51     void networkConnectionStateChanged(Network::ConnectionState state);
52     void networkConnectionError(const QString &msg);
53
54     void displayNetwork(NetworkId);
55     void setItemState(NetworkId, QListWidgetItem *item = 0);
56
57     void clientNetworkAdded(NetworkId);
58     void clientNetworkRemoved(NetworkId);
59     void clientNetworkUpdated();
60
61     void clientIdentityAdded(IdentityId);
62     void clientIdentityRemoved(IdentityId);
63     void clientIdentityUpdated();
64
65     void on_networkList_itemSelectionChanged();
66     void on_addNetwork_clicked();
67     void on_deleteNetwork_clicked();
68     void on_renameNetwork_clicked();
69     void on_editIdentities_clicked();
70
71     // void on_connectNow_clicked();
72
73     void on_serverList_itemSelectionChanged();
74     void on_addServer_clicked();
75     void on_deleteServer_clicked();
76     void on_editServer_clicked();
77     void on_upServer_clicked();
78     void on_downServer_clicked();
79
80   private:
81     Ui::NetworksSettingsPage ui;
82
83     NetworkId currentId;
84     QHash<NetworkId, NetworkInfo> networkInfos;
85     bool _ignoreWidgetChanges;
86
87     QPixmap connectedIcon, connectingIcon, disconnectedIcon;
88
89     void reset();
90     bool testHasChanged();
91     QListWidgetItem *insertNetwork(NetworkId);
92     QListWidgetItem *insertNetwork(const NetworkInfo &info);
93     QListWidgetItem *networkItem(NetworkId) const;
94     void saveToNetworkInfo(NetworkInfo &);
95 };
96
97
98 class NetworkAddDlg : public QDialog {
99   Q_OBJECT
100
101   public:
102     NetworkAddDlg(const QStringList &existing = QStringList(), QWidget *parent = 0);
103
104     NetworkInfo networkInfo() const;
105
106   private slots:
107     void setButtonStates();
108
109   private:
110     Ui::NetworkAddDlg ui;
111
112     QString networksFilePath;
113     QStringList existing;
114 };
115
116
117 class NetworkEditDlg : public QDialog {
118   Q_OBJECT
119
120   public:
121     NetworkEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
122
123     QString networkName() const;
124
125   private slots:
126     void on_networkEdit_textChanged(const QString &);
127
128   private:
129     Ui::NetworkEditDlg ui;
130
131     QStringList existing;
132 };
133
134
135 class ServerEditDlg : public QDialog {
136   Q_OBJECT
137
138 public:
139   ServerEditDlg(const Network::Server &server = Network::Server(), QWidget *parent = 0);
140
141   Network::Server serverData() const;
142
143 private slots:
144   void on_host_textChanged();
145
146 private:
147   Ui::ServerEditDlg ui;
148 };
149
150
151 class SaveNetworksDlg : public QDialog {
152   Q_OBJECT
153
154   public:
155     SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
156
157   private slots:
158     void clientEvent();
159
160   private:
161     Ui::SaveIdentitiesDlg ui;
162
163     int numevents, rcvevents;
164 };
165
166 #endif