configurationdialog.h
1 //------------------------------------------------------------------------------
2 // configurationdialog.h
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 __CONFIGUREDIALOG_H_
24 #define __CONFIGUREDIALOG_H_
25 
26 #include "dptr.h"
27 
28 #include <QDialog>
29 
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* addConfigurationBox(QStandardItem* rootItem, ConfigurationBaseBox* pConfigurationBox, int position = -1);
60 
78  QStandardItem* addLabel(QStandardItem* rootItem, const QString& label, int position = -1);
79  bool isConfigurationBoxOnTheList(ConfigurationBaseBox* pConfigurationBox);
80 
81 
82  protected:
83  bool canConfigurationBoxBeAddedToList(ConfigurationBaseBox* pConfigurationBox);
84 
85  virtual void doSaveSettings() {};
86  virtual void keyPressEvent(QKeyEvent* e);
87 
88  bool isConfigurationBoxInfoValid(ConfigurationBaseBox* pConfigurationBox);
89 
94  QTreeView* optionsTree();
95 
100  void saveSettings();
101  void switchToItem(const QModelIndex&);
102 
103  virtual bool validate() { return true; }
104 
105  protected slots:
106  void btnClicked(QAbstractButton *button);
107  void onOptionListCurrentChanged(const QModelIndex &current, const QModelIndex &previous);
108 
109  private:
111 
112  bool hasItemOnList(QStandardItem* pItem) const;
113 };
114 
115 #endif
void showConfigurationBox(ConfigurationBaseBox *widget)
QTreeView * optionsTree()
Returns pointer to the tree widget that contains configuration sections list.
QStandardItem * addLabel(QStandardItem *rootItem, const QString &label, int position=-1)
Adds a label node to the options tree view.
virtual QStandardItem * addConfigurationBox(QStandardItem *rootItem, ConfigurationBaseBox *pConfigurationBox, int position=-1)
Adds a new configuration box to the options tree view.
Base class for configuration pages.