| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qsettings.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QSettings class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 000626
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
|
|---|
| 9 | **
|
|---|
| 10 | ** This file is part of the tools module of the Qt GUI Toolkit.
|
|---|
| 11 | **
|
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
|---|
| 15 | **
|
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 19 | ** packaging of this file.
|
|---|
| 20 | **
|
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
|---|
| 23 | ** Agreement provided with the Software.
|
|---|
| 24 | **
|
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 27 | **
|
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|---|
| 29 | ** information about Qt Commercial License Agreements.
|
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|---|
| 32 | **
|
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
|---|
| 34 | ** not clear to you.
|
|---|
| 35 | **
|
|---|
| 36 | **********************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | #ifndef QSETTINGS_H
|
|---|
| 39 | #define QSETTINGS_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qdatetime.h"
|
|---|
| 43 | #include "qstringlist.h"
|
|---|
| 44 | #endif // QT_H
|
|---|
| 45 |
|
|---|
| 46 | #ifndef QT_NO_SETTINGS
|
|---|
| 47 |
|
|---|
| 48 | class QSettingsPrivate;
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | class Q_EXPORT QSettings
|
|---|
| 52 | {
|
|---|
| 53 | public:
|
|---|
| 54 | enum Format {
|
|---|
| 55 | Native = 0,
|
|---|
| 56 | Ini
|
|---|
| 57 | };
|
|---|
| 58 | enum System {
|
|---|
| 59 | Unix = 0,
|
|---|
| 60 | Windows,
|
|---|
| 61 | Mac
|
|---|
| 62 | };
|
|---|
| 63 | enum Scope {
|
|---|
| 64 | User,
|
|---|
| 65 | Global
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | QSettings();
|
|---|
| 69 | QSettings( Format format );
|
|---|
| 70 |
|
|---|
| 71 | ~QSettings();
|
|---|
| 72 |
|
|---|
| 73 | #if !defined(Q_NO_BOOL_TYPE)
|
|---|
| 74 | bool writeEntry( const QString &, bool );
|
|---|
| 75 | #endif
|
|---|
| 76 | bool writeEntry( const QString &, double );
|
|---|
| 77 | bool writeEntry( const QString &, int );
|
|---|
| 78 | bool writeEntry( const QString &, const char * );
|
|---|
| 79 | bool writeEntry( const QString &, const QString & );
|
|---|
| 80 | bool writeEntry( const QString &, const QStringList & );
|
|---|
| 81 | bool writeEntry( const QString &, const QStringList &, const QChar& sep );
|
|---|
| 82 |
|
|---|
| 83 | QStringList entryList(const QString &) const;
|
|---|
| 84 | QStringList subkeyList(const QString &) const;
|
|---|
| 85 |
|
|---|
| 86 | //### remove non const versions in 4.0
|
|---|
| 87 | QStringList readListEntry( const QString &, bool * = 0 );
|
|---|
| 88 | QStringList readListEntry( const QString &, const QChar& sep, bool * = 0 );
|
|---|
| 89 | QString readEntry( const QString &, const QString &def = QString::null, bool * = 0 );
|
|---|
| 90 | int readNumEntry( const QString &, int def = 0, bool * = 0 );
|
|---|
| 91 | double readDoubleEntry( const QString &, double def = 0, bool * = 0 );
|
|---|
| 92 | bool readBoolEntry( const QString &, bool def = FALSE, bool * = 0 );
|
|---|
| 93 |
|
|---|
| 94 | //### make those non-inlined in 4.0
|
|---|
| 95 | QStringList readListEntry( const QString &key, bool *ok = 0 ) const
|
|---|
| 96 | {
|
|---|
| 97 | QSettings *that = (QSettings*)this;
|
|---|
| 98 | return that->readListEntry( key, ok );
|
|---|
| 99 | }
|
|---|
| 100 | QStringList readListEntry( const QString &key, const QChar& sep, bool *ok = 0 ) const
|
|---|
| 101 | {
|
|---|
| 102 | QSettings *that = (QSettings*)this;
|
|---|
| 103 | return that->readListEntry( key, sep, ok );
|
|---|
| 104 | }
|
|---|
| 105 | QString readEntry( const QString &key, const QString &def = QString::null,
|
|---|
| 106 | bool *ok = 0 ) const
|
|---|
| 107 | {
|
|---|
| 108 | QSettings *that = (QSettings*)this;
|
|---|
| 109 | return that->readEntry( key, def, ok );
|
|---|
| 110 | }
|
|---|
| 111 | int readNumEntry( const QString &key, int def = 0, bool *ok = 0 ) const
|
|---|
| 112 | {
|
|---|
| 113 | QSettings *that = (QSettings*)this;
|
|---|
| 114 | return that->readNumEntry( key, def, ok );
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | double readDoubleEntry( const QString &key, double def = 0, bool *ok = 0 ) const
|
|---|
| 118 | {
|
|---|
| 119 | QSettings *that = (QSettings*)this;
|
|---|
| 120 | return that->readDoubleEntry( key, def, ok );
|
|---|
| 121 | }
|
|---|
| 122 | bool readBoolEntry( const QString &key, bool def = FALSE, bool *ok = 0 ) const
|
|---|
| 123 | {
|
|---|
| 124 | QSettings *that = (QSettings*)this;
|
|---|
| 125 | return that->readBoolEntry( key, def, ok );
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | bool removeEntry( const QString & );
|
|---|
| 129 |
|
|---|
| 130 | void insertSearchPath( System, const QString & );
|
|---|
| 131 | void removeSearchPath( System, const QString & );
|
|---|
| 132 |
|
|---|
| 133 | void setPath( const QString &domain, const QString &product, Scope = Global );
|
|---|
| 134 |
|
|---|
| 135 | void beginGroup( const QString &group );
|
|---|
| 136 | void endGroup();
|
|---|
| 137 | void resetGroup();
|
|---|
| 138 | QString group() const;
|
|---|
| 139 |
|
|---|
| 140 | bool sync();
|
|---|
| 141 |
|
|---|
| 142 | private:
|
|---|
| 143 | QSettingsPrivate *d;
|
|---|
| 144 |
|
|---|
| 145 | #if defined(Q_DISABLE_COPY)
|
|---|
| 146 | QSettings(const QSettings &);
|
|---|
| 147 | QSettings &operator=(const QSettings &);
|
|---|
| 148 | #endif
|
|---|
| 149 |
|
|---|
| 150 | QDateTime lastModificationTime( const QString & );
|
|---|
| 151 |
|
|---|
| 152 | friend class QApplication;
|
|---|
| 153 | };
|
|---|
| 154 |
|
|---|
| 155 | #endif // QT_NO_SETTINGS
|
|---|
| 156 | #endif // QSETTINGS_H
|
|---|