1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
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. +
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. +
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/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #ifndef SETTINGSVIEWER_H
22 #define SETTINGSVIEWER_H
27 #include "guisettingstab.h"
32 // class QTreeWidgetItem;
35 // 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:
36 // 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.
37 // 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".
38 // 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 * Creates a QWidget with one tab per main group found in the specified QSettings file. Each of those tabs is a SettingsTab.
43 class GuiSettingsViewer
: public QDialog
51 * Constructor using the (org,app) pair to determine QSettings
52 * @param org organization
53 * @param app application
54 * @param parent Parent QWidget
56 GuiSettingsViewer(QString org
, QString app
, QWidget
*parent
= 0);
59 * Constructor taking a QSettings argument to build the widget.
60 * @param Set QSettings to use
61 * @param parent Parent QWidget
63 GuiSettingsViewer(QSettings
* Set
, QWidget
*parent
= 0);
70 void save();///< save the settings
73 /** add child settings
74 * @todo Delete the tabs for real. Or make sure they have the correct parent.
76 void addChildSettings();
80 QPushButton
*openButton
;///< Button for the open() action
81 QPushButton
*saveButton
;///< Button for the save() action
82 QPushButton
*closeButton
;///< Button for the close() action
84 QTabWidget tabWidget
;///< a QTabWidget
85 QVector
<GuiSettingsTab
> tabs
;///< a vector containing the tabs
87 QString organization
;///< organization: cf QSettings documentation for more info
88 QString application
;///< application: cf QSettings documentation for more info
89 QSettings
* m_settings
;///< The settings used
93 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
94 * Version for int variables
99 int getSet(QString group
, QString key
, int value
);
102 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
103 * Version for double variables
108 double getSet(QString group
, QString key
, double value
);
111 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
112 * Version for bool variables
117 bool getSet(QString group
, QString key
, bool value
);
120 * if key=value pair not found in m_settings file, write it + read key value from m_settings file and return it.
121 * Version for path variables
125 * @param type type \n
126 * type = 0 : standard string \n
127 * type = 1 : filename \n
128 * type = 2 : directory
130 QString
getSet(QString group
, QString key
, QString value
, int type
);