dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
ipconnectionoptionspage.h
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef IPconnectionOPTIONSPAGE_H
29 #define IPconnectionOPTIONSPAGE_H
30 
32 #include <QStyledItemDelegate>
33 #include <QAbstractTableModel>
35 
37 
38 namespace Core {
40 }
41 
42 namespace Ui {
43 class IPconnectionOptionsPage;
44 }
45 
46 using namespace Core;
47 
49 
51 {
52  Q_OBJECT
53 public:
54  explicit IPConnectionOptionsPage(IPConnectionConfiguration *config, QObject *parent = nullptr);
55  virtual ~IPConnectionOptionsPage();
56 
57  QString id() const { return QLatin1String("settings"); }
58  QString trName() const { return tr("settings"); }
59  QString category() const { return "IP Network Telemetry"; };
60  QString trCategory() const { return "IP Network Telemetry"; };
61 
62  QWidget *createPage(QWidget *parent);
63  void apply();
64  void finish();
65 
66  enum Columns { ColumnProtocol = 0, ColumnHostname, ColumnPort, ColumnCount };
67 
68 signals:
69  void availableDevChanged();
70 
71 public slots:
72 private:
73  IPConnectionConfiguration *m_config;
74  Ui::IPconnectionOptionsPage *m_page;
75  IPConnectionOptionsModel *m_model;
76 };
77 
78 class IPConnectionOptionsDelegate : public QStyledItemDelegate
79 {
80  Q_OBJECT
81 
82 public:
83  explicit IPConnectionOptionsDelegate(QObject *parent = nullptr)
84  : QStyledItemDelegate(parent)
85  {
86  }
87 
88  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
89  const QModelIndex &index) const override;
90  void setEditorData(QWidget *editor, const QModelIndex &index) const override;
91  void setModelData(QWidget *editor, QAbstractItemModel *model,
92  const QModelIndex &index) const override;
93  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
94  const QModelIndex &index) const override;
95 };
96 
97 class IPConnectionOptionsModel : public QAbstractTableModel
98 {
99  Q_OBJECT
100 
101 public:
102  explicit IPConnectionOptionsModel(QObject *parent = nullptr)
103  : QAbstractTableModel(parent)
104  {
105  }
106 
107  int rowCount(const QModelIndex &parent = QModelIndex()) const;
108  int columnCount(const QModelIndex &parent = QModelIndex()) const;
109  QVariant data(const QModelIndex &index, int role = Qt::EditRole) const;
110  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
111  Qt::ItemFlags flags(const QModelIndex &index) const;
112  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
113  bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
114  bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
115 
116  QVector<IPConnectionConfiguration::Host> &hosts() { return m_hosts; }
117 
118 private:
119  QVector<IPConnectionConfiguration::Host> m_hosts;
120 };
121 
122 #endif // IPconnectionOPTIONSPAGE_H
IPConnectionOptionsModel(QObject *parent=nullptr)
DataFields data
IPConnectionOptionsDelegate(QObject *parent=nullptr)
void setData(const DataFields &data)
QVector< IPConnectionConfiguration::Host > & hosts()
The IOptionsPage is an interface for providing options pages.
Definition: ioptionspage.h:42