updated to modern VTK
[engrid-github.git] / src / libengrid / guisettingsviewer.h
blob0873c44ef2e99c7fc26080920e243750a346881a
1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // + +
3 // + This file is part of enGrid. +
4 // + +
5 // + Copyright 2008-2014 enGits GmbH +
6 // + +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
11 // + +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
16 // + +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
19 // + +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #ifndef SETTINGSVIEWER_H
22 #define SETTINGSVIEWER_H
24 #include <QDialog>
25 #include <QtGui>
26 #include <QTabWidget>
28 #include "guisettingstab.h"
30 // class QPushButton;
31 // class QSettings;
32 // class QTreeWidget;
33 // class QTreeWidgetItem;
35 // IMPORTANT:
36 // Setting keys can contain any Unicode characters. The Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive keys. To avoid portability problems, follow these two simple rules:
37 // Always refer to the same key using the same case. For example, if you refer to a key as "text fonts" in one place in your code, don't refer to it as "Text Fonts" somewhere else.
38 // Avoid key names that are identical except for the case. For example, if you have a key called "MainWindow", don't try to save another key as "mainwindow".
39 // Do not use slashes ('/' and '\') in key names; the backslash character is used to separate sub keys (see below). On windows '\' are converted by QSettings to '/', which makes them identical.
41 /**
42 * Creates a QWidget with one tab per main group found in the specified QSettings file. Each of those tabs is a SettingsTab.
44 class GuiSettingsViewer : public QDialog
46 Q_OBJECT
48 public:
50 // constructors
51 /**
52 * Constructor using the (org,app) pair to determine QSettings
53 * @param org organization
54 * @param app application
55 * @param parent Parent QWidget
57 GuiSettingsViewer(QString org, QString app, QWidget *parent = 0);
59 /**
60 * Constructor taking a QSettings argument to build the widget.
61 * @param Set QSettings to use
62 * @param parent Parent QWidget
64 GuiSettingsViewer(QSettings* Set, QWidget *parent = 0);
66 public:
67 void CreateViewer();
69 private slots:
70 void open();
71 void save();///< save the settings
72 void readSettings();
74 /** add child settings
75 * @todo Delete the tabs for real. Or make sure they have the correct parent.
77 void addChildSettings();
79 private:
81 QPushButton *openButton;///< Button for the open() action
82 QPushButton *saveButton;///< Button for the save() action
83 QPushButton *closeButton;///< Button for the close() action
85 QTabWidget tabWidget;///< a QTabWidget
86 QVector<GuiSettingsTab> tabs;///< a vector containing the tabs
88 QString organization;///< organization: cf QSettings documentation for more info
89 QString application;///< application: cf QSettings documentation for more info
90 QSettings* m_settings;///< The settings used
92 public:
93 /**
94 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
95 * Version for int variables
96 * @param group group
97 * @param key key
98 * @param value value
100 int getSet(QString group, QString key, int value);
103 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
104 * Version for double variables
105 * @param group group
106 * @param key key
107 * @param value value
109 double getSet(QString group, QString key, double value);
112 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
113 * Version for bool variables
114 * @param group group
115 * @param key key
116 * @param value value
118 bool getSet(QString group, QString key, bool value);
121 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
122 * Version for path variables
123 * @param group group
124 * @param key key
125 * @param value value
126 * @param type type \n
127 * type = 0 : standard string \n
128 * type = 1 : filename \n
129 * type = 2 : directory
131 QString getSet(QString group, QString key, QString value, int type);
134 #endif