cfgcustomservers.h
1 //------------------------------------------------------------------------------
2 // cfgcustomservers.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
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 Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __CFGCUSTOMSERVERS_H_
24 #define __CFGCUSTOMSERVERS_H_
25 
26 #include "gui/configuration/configpage.h"
27 #include "dptr.h"
28 #include <QIcon>
29 
30 class CustomServerInfo;
31 class EnginePlugin;
32 class QModelIndex;
33 class QStandardItem;
34 class QStandardItemModel;
35 
37 {
38  Q_OBJECT
39 
40  public:
41  CFGCustomServers(QWidget *parent=NULL);
43 
44  QIcon icon() const { return QIcon(":/flags/localhost-small"); }
45  QString name() const { return tr("Custom Servers"); }
46  void readSettings();
47 
48  protected:
49  enum CheckAndFixPorts
50  {
51  AllOk,
52  AtLeastOneFixed
53  };
54 
55  enum ColumnIndices
56  {
57  EngineColumnIndex = 0,
58  AddressColumnIndex = 1,
59  PortColumnIndex = 2
60  };
61 
62  QStandardItemModel* model;
63 
71  CheckAndFixPorts checkAndFixPorts(int firstRow, int lastRow);
72  const EnginePlugin* getPluginInfoForRow(int rowIndex);
73  bool isPortColumnWithingRange(int leftmostColumnIndex, int rightmostColumnIndex);
74  bool isPortCorrect(int rowIndex);
75 
76  void prepareEnginesComboBox();
77  void prepareTable();
78  void saveSettings();
79  void setEngineOnItem(QStandardItem*, const QString& engineName);
80  void setPortToDefault(int rowIndex);
81 
82 
83  QVector<CustomServerInfo> tableGetServers();
84 
85  protected slots:
86  void add();
87  void add(const QString& engineName, const QString& host, unsigned short port);
88  void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
89  void remove();
90  void setEngine();
91 
92  private:
94 };
95 
96 #endif
void readSettings()
Reimplement this to read settings from config into widgets.
CheckAndFixPorts checkAndFixPorts(int firstRow, int lastRow)
Moves through rows and checks if network port information is correct.
void saveSettings()
Reimplement this to write settings to config from widgets.
QString name() const
Reimplement this to return a list-displayable name for this ConfigPage.
QIcon icon() const
Reimplement this to return a displayable icon for the ConfigPage.
Base class for configuration pages.
Definition: configpage.h:43