Syncing my current state, Network settings still not fully functional, so don't use...
[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 <QIcon>
25
26 #include "settingspage.h"
27 #include "ui_networkssettingspage.h"
28 #include "ui_networkeditdlgnew.h"
29 #include "ui_servereditdlgnew.h"
30 #include "ui_saveidentitiesdlg.h"
31
32 #include "network.h"
33 #include "types.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
52     void displayNetwork(NetworkId, bool dontsave = false);
53
54     void clientNetworkAdded(NetworkId);
55     void clientNetworkUpdated();
56
57     void clientIdentityAdded(IdentityId);
58     void clientIdentityRemoved(IdentityId);
59     void clientIdentityUpdated();
60
61     void on_networkList_itemSelectionChanged();
62     void on_addNetwork_clicked();
63     void on_deleteNetwork_clicked();
64     void on_renameNetwork_clicked();
65
66     void on_serverList_itemSelectionChanged();
67     void on_addServer_clicked();
68     void on_deleteServer_clicked();
69     void on_editServer_clicked();
70     void on_upServer_clicked();
71     void on_downServer_clicked();
72
73   private:
74     Ui::NetworksSettingsPage ui;
75
76     NetworkId currentId;
77     QHash<NetworkId, NetworkInfo> networkInfos;
78
79     QIcon connectedIcon, disconnectedIcon;
80
81     void reset();
82     bool testHasChanged();
83     QListWidgetItem *insertNetwork(NetworkId);
84     QListWidgetItem *insertNetwork(const NetworkInfo &info);
85     QListWidgetItem *networkItem(NetworkId) const;
86     void saveToNetworkInfo(NetworkInfo &);
87 };
88
89 class NetworkEditDlgNew : public QDialog {
90   Q_OBJECT
91
92   public:
93     NetworkEditDlgNew(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
94
95     QString networkName() const;
96
97   private slots:
98     void on_networkEdit_textChanged(const QString &);
99
100   private:
101     Ui::NetworkEditDlgNew ui;
102
103     QStringList existing;
104 };
105
106
107
108 class ServerEditDlgNew : public QDialog {
109   Q_OBJECT
110
111   public:
112     ServerEditDlgNew(const QVariantMap &serverData = QVariantMap(), QWidget *parent = 0);
113
114     QVariantMap serverData() const;
115
116   private slots:
117     void on_host_textChanged();
118
119   private:
120     Ui::ServerEditDlgNew ui;
121 };
122
123
124 class SaveNetworksDlg : public QDialog {
125   Q_OBJECT
126
127   public:
128     SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
129
130   private:
131     Ui::SaveIdentitiesDlg ui;
132 };
133
134 #endif