ircnetworkselectionbox.h
1 //------------------------------------------------------------------------------
2 // ircnetworkselectionbox.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __IRCNETWORKSELECTIONBOX_H__
24 #define __IRCNETWORKSELECTIONBOX_H__
25 
26 #include "dptr.h"
27 
28 #include <QDialog>
29 
31 class IRCNetworkEntity;
32 
33 class IRCNetworkSelectionBox : public QDialog
34 {
35  Q_OBJECT
36 
37 public:
38  IRCNetworkSelectionBox(QWidget *parent = nullptr);
39  ~IRCNetworkSelectionBox() override;
40 
41  void accept() override;
42 
50  IRCNetworkEntity network() const;
51 
52  IRCNetworkConnectionInfo networkConnectionInfo() const;
53 
54 private:
55  void fetchNetworks();
56  void initWidgets();
57 
58  void addNetworkToComboBox(const IRCNetworkEntity &network);
59  QString buildTitle(const IRCNetworkEntity &network) const;
63  IRCNetworkEntity networkCurrent() const;
64  IRCNetworkEntity networkAtRow(int row) const;
65  bool replaceNetworkInConfig(const IRCNetworkEntity &oldNetwork, const IRCNetworkEntity &newNetwork);
66  void setNetworkMatchingDescriptionAsCurrent(const QString &description);
67  void updateCurrentNetwork(const IRCNetworkEntity &network);
68  void updateNetworkInfo();
69  bool validate();
70 
72 
73 private slots:
74  void createNewNetwork();
75  void editCurrentNetwork();
76  void networkChanged(int index);
77  void removeCurrentNetwork();
78 };
79 
80 #endif