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/configurationbasebox.h"
27 #include "dptr.h"
28 #include <QIcon>
29 
30 class ConfigurationBoxInfo;
31 class CustomServerInfo;
32 class EnginePlugin;
33 class QModelIndex;
34 class QStandardItem;
35 class QStandardItemModel;
36 
38 {
39  Q_OBJECT
40 
41  public:
42  CFGCustomServers(QWidget *parent=NULL);
44 
45  QIcon icon() const { return QIcon(":/flags/localhost-small"); }
46  QString name() const { return tr("Custom Servers"); }
47  void readSettings();
48 
49  protected:
50  enum CheckAndFixPorts
51  {
52  AllOk,
53  AtLeastOneFixed
54  };
55 
56  enum ColumnIndices
57  {
58  EngineColumnIndex = 0,
59  AddressColumnIndex = 1,
60  PortColumnIndex = 2
61  };
62 
63  QStandardItemModel* model;
64 
72  CheckAndFixPorts checkAndFixPorts(int firstRow, int lastRow);
73  const EnginePlugin* getPluginInfoForRow(int rowIndex);
74  bool isPortColumnWithingRange(int leftmostColumnIndex, int rightmostColumnIndex);
75  bool isPortCorrect(int rowIndex);
76 
77  void prepareEnginesComboBox();
78  void prepareTable();
79  void saveSettings();
80  void setEngineOnItem(QStandardItem*, const QString& engineName);
81  void setPortToDefault(int rowIndex);
82 
83 
84  QVector<CustomServerInfo> tableGetServers();
85 
86  protected slots:
87  void add();
88  void add(const QString& engineName, const QString& host, unsigned short port);
89  void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
90  void remove();
91  void setEngine();
92 
93  private:
95 };
96 
97 #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 ConfigurationBaseBox. ...
QIcon icon() const
Reimplement this to return a displayable icon for the ConfigurationBaseBox.
Base class for configuration pages.