cfgircnetworks.h
1 //------------------------------------------------------------------------------
2 // cfgircnetworks.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 __CFGIRCNETWORKS_H__
24 #define __CFGIRCNETWORKS_H__
25 
26 #include "dptr.h"
27 #include "gui/configuration/configpage.h"
28 #include <QIcon>
29 #include <QtContainerFwd>
30 
31 class IRCNetworkEntity;
32 class QModelIndex;
33 class QStandardItem;
34 
35 class CFGIRCNetworks : public ConfigPage
36 {
37  Q_OBJECT
38 
39 public:
40  CFGIRCNetworks(QWidget *parent = nullptr);
41  ~CFGIRCNetworks() override;
42 
43  QIcon icon() const override
44  {
45  return QIcon(":/flags/lan-small");
46  }
47  QString name() const override
48  {
49  return tr("Networks");
50  }
51  QVector<IRCNetworkEntity *> networks();
52  void readSettings() override;
53  QString title() const override
54  {
55  return tr("IRC - Networks");
56  }
57 
58 protected:
59  void saveSettings() override;
60 
61 private:
62  void addRecord(IRCNetworkEntity *pNetworkEntity);
63  void cleanUpTable();
64  QList<QStandardItem *> generateTableRecord(IRCNetworkEntity *pNetworkEntity);
65  IRCNetworkEntity *network(int row) const;
66  QList<IRCNetworkEntity> networksAsQList() const;
67 
71  IRCNetworkEntity *obtainNetworkEntity(QStandardItem *pItem) const;
72 
73  void prepareTable();
74  void saveNetworks();
75  IRCNetworkEntity *selectedNetwork();
76  int selectedRow();
77  void updateRecord(int row);
78 
80 private slots:
81  void addButtonClicked();
82  void editButtonClicked();
83  void removeButtonClicked();
84  void tableDoubleClicked();
85 };
86 
87 #endif