1 // Baulk - Common - Baulk XML Configuration Reader/Writer
3 // Baulk - Copyright (C) 2008 - Jacob Alexander
5 // Baulk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version, including version 3 of the License.
10 // Baulk 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.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include <QDomDocument>
24 #include <QDomElement>
28 #include <QTextStream>
31 //! Reads/Writes custom XML Configuration files for Baulk.
33 * Custom XML Configuration class for reading and writing configuration files in Baulk and its sub-projects
35 class BaulkXML
: public QObject
{
39 BaulkXML( QString configName
, QObject
*parent
= 0 );
42 //! Save Config to Disk
45 //! Checks for successful XML load
46 bool loadSuccessful();
49 QVariant
option( QString settingName
, QString propertyKey
= "", QVariant property
= QVariant(""), bool warnOnNotFound
= true );
51 void setOption( QString settingName
, QVariant value
, QString propertyKey
= "", QVariant properties
= QVariant("") );
55 * Profiles allow for different sets of options in the same configuration file.
58 //! Set options profile to use
59 void setProfile( QString profileName
);
62 bool loadConfig( QString configName
);
65 QString
errorName() const { return tr("BaulkXML"); }
67 bool settingSearch( QString settingName
, QString propertyKey
= "", QVariant property
= QVariant("") );
70 QDomAttr xmlDocElementProperty
;
72 QDomElement xmlDocElementProfile
;
73 QDomElement xmlDocElementRoot
;
74 QDomElement xmlDocElementSetting
;
75 QDomText xmlDocElementSettingText
;
77 QString currentProfile
;