configurationdialog.h
1 //------------------------------------------------------------------------------
2 // configurationdialog.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) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __CONFIGUREDIALOG_H_
24 #define __CONFIGUREDIALOG_H_
25 
26 #include "gui/configuration/configpage.h"
27 #include "dptr.h"
28 
29 #include <QDialog>
30 
31 class QAbstractButton;
32 class QModelIndex;
33 class QStandardItem;
34 class QTreeView;
35 
36 class ConfigurationDialog : public QDialog
37 {
38  Q_OBJECT
39 
40  public:
41  ConfigurationDialog(QWidget* parent = NULL);
43 
59  virtual QStandardItem* addConfigPage(QStandardItem* rootItem, ConfigPage* configPage, int position = -1);
60 
79  QStandardItem* addLabel(QStandardItem* rootItem, const QString& label, int position = -1);
80 
81  public slots:
82  virtual void reject();
83 
84  protected:
85  virtual void doSaveSettings() {};
86  virtual void keyPressEvent(QKeyEvent* e);
87 
92  QTreeView* optionsTree();
93 
97  void showConfigPage(ConfigPage* widget);
98 
99  virtual bool validate() { return true; }
100 
101  private:
103 
104  bool canConfigPageBeAdded(ConfigPage* configPage);
105  bool isConfigPageValid(ConfigPage* configPage);
106  bool hasConfigPage(ConfigPage* configPage);
107  bool hasItemOnList(QStandardItem* pItem) const;
108  QModelIndex findPageModelIndex(ConfigPage *page);
109  void saveSettings();
110  void validatePage(ConfigPage *page);
111 
112  private slots:
113  void btnClicked(QAbstractButton *button);
114  void onPageValidationRequested();
115  void switchToItem(const QModelIndex &current, const QModelIndex &previous);
116 };
117 
118 #endif
QTreeView * optionsTree()
Returns pointer to the tree widget that contains configuration sections list.
virtual QStandardItem * addConfigPage(QStandardItem *rootItem, ConfigPage *configPage, int position=-1)
Adds a new configuration page to the options tree view.
QStandardItem * addLabel(QStandardItem *rootItem, const QString &label, int position=-1)
Adds a label node to the options tree view.
Base class for configuration pages.
Definition: configpage.h:44
void showConfigPage(ConfigPage *widget)