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
28 #include "guisettingstab.h"
33 // class QTreeWidgetItem;
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.
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
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);
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);
71 void save();///< save the settings
74 /** add child settings
75 * @todo Delete the tabs for real. Or make sure they have the correct parent.
77 void addChildSettings();
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
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
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
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
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
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
);