Make custom highlights work again
[quassel.git] / src / qtui / settingspages / networkssettingspage.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel IRC 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) 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_networkeditdlg.h"
31 #include "ui_servereditdlg.h"
32 #include "ui_saveidentitiesdlg.h"
33
34 class NetworksSettingsPage : public SettingsPage {
35   Q_OBJECT
36
37   public:
38     NetworksSettingsPage(QWidget *parent = 0);
39
40     bool aboutToSave();
41
42   public slots:
43     void save();
44     void load();
45
46   private slots:
47     void widgetHasChanged();
48     void setWidgetStates();
49     void coreConnectionStateChanged(bool);
50     void networkConnectionStateChanged(Network::ConnectionState state);
51     void networkConnectionError(const QString &msg);
52
53     void displayNetwork(NetworkId);
54     void setItemState(NetworkId, QListWidgetItem *item = 0);
55
56     void clientNetworkAdded(NetworkId);
57     void clientNetworkRemoved(NetworkId);
58     void clientNetworkUpdated();
59
60     void clientIdentityAdded(IdentityId);
61     void clientIdentityRemoved(IdentityId);
62     void clientIdentityUpdated();
63
64     void on_networkList_itemSelectionChanged();
65     void on_addNetwork_clicked();
66     void on_deleteNetwork_clicked();
67     void on_renameNetwork_clicked();
68
69     void on_connectNow_clicked();
70
71     void on_serverList_itemSelectionChanged();
72     void on_addServer_clicked();
73     void on_deleteServer_clicked();
74     void on_editServer_clicked();
75     void on_upServer_clicked();
76     void on_downServer_clicked();
77
78   private:
79     Ui::NetworksSettingsPage ui;
80
81     NetworkId currentId;
82     QHash<NetworkId, NetworkInfo> networkInfos;
83     bool _ignoreWidgetChanges;
84
85     QPixmap connectedIcon, connectingIcon, disconnectedIcon;
86
87     void reset();
88     bool testHasChanged();
89     QListWidgetItem *insertNetwork(NetworkId);
90     QListWidgetItem *insertNetwork(const NetworkInfo &info);
91     QListWidgetItem *networkItem(NetworkId) const;
92     void saveToNetworkInfo(NetworkInfo &);
93 };
94
95 class NetworkEditDlg : public QDialog {
96   Q_OBJECT
97
98   public:
99     NetworkEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
100
101     QString networkName() const;
102
103   private slots:
104     void on_networkEdit_textChanged(const QString &);
105
106   private:
107     Ui::NetworkEditDlg ui;
108
109     QStringList existing;
110 };
111
112
113
114 class ServerEditDlg : public QDialog {
115   Q_OBJECT
116
117   public:
118     ServerEditDlg(const QVariant &serverData = QVariant(), QWidget *parent = 0);
119
120     QVariant serverData() const;
121
122   private slots:
123     void on_host_textChanged();
124
125   private:
126     Ui::ServerEditDlg ui;
127 };
128
129
130 class SaveNetworksDlg : public QDialog {
131   Q_OBJECT
132
133   public:
134     SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
135
136   private slots:
137     void clientEvent();
138
139   private:
140     Ui::SaveIdentitiesDlg ui;
141
142     int numevents, rcvevents;
143 };
144
145 #endif