head 1.4;
access;
symbols
AS_AFTER_RESTRUCTURING:1.2;
locks; strict;
comment @ * @;
1.4
date 2003.02.07.16.37.55; author ms; state Exp;
branches;
next 1.3;
1.3
date 2003.01.28.16.41.16; author ms; state Exp;
branches;
next 1.2;
1.2
date 2002.11.24.18.09.21; author ms; state Exp;
branches;
next 1.1;
1.1
date 2002.11.24.17.56.54; author ms; state Exp;
branches;
next ;
desc
@@
1.4
log
@Added new preferences panel class, made consistent destructor signatures.
@
text
@/***************************************************************************
preferences.h
-------------------
A class to access persistant preferences for an application. Utilizes XML/DOM.
Basic format is:
-------------------
begin Tue Sep 12 2000
author David Johnson, david@@usermode.org
-------------------
Copyright 2000, David Johnson
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither name of the copyright holders nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
// version 2
#ifndef PREFERENCES_H
#define PREFERENCES_H
#include
#include
#include
class QDomElement;
class Preferences {
public:
// constructor
Preferences(const QString& filename, const QString& format, const QString& version);
// destructor
virtual ~Preferences(void);
// preference file information
const QString& file();
const QString& format();
const QString& version();
// did file open successfully?
bool fileState();
// is this a proper preferences file for format?
bool formatState();
// group settings
const QString& getGroup();
void setGroup(const QString& group);
// boolean data storage
bool getBool(const QString& key, bool def = false);
void setBool(const QString& key, bool value);
// integer data storage
long getNumber(const QString& key, long def = 0);
void setNumber(const QString& key, long value);
// double data storage
double getDouble(const QString& key, double def = 0.0);
void setDouble(const QString& key, double value);
// string data storage
QString getString(const QString& key, const QString& def = "NULL");
void setString(const QString& key, const QString& value);
// remove a key/value from the preferences
void removeKey(const QString& key);
// remove the current group from the preferences
void removeGroup();
// flush the preferences out to file
void flush();
protected:
// serialization
void readData();
void writeData();
void processGroup(QDomElement group);
private:
bool dirty_;
QString currentgroup_;
QString file_;
QString format_;
QString version_;
QString buffer_;
bool filestate_;
bool formatstate_;
typedef QMap PrefMap;
QMap groups_;
};
//////////////////////////////////////////////////////////////////////////////
// Inline methods
inline const QString& Preferences::file() { return file_; };
inline const QString& Preferences::format() { return format_; }
inline bool Preferences::fileState() { return filestate_; }
inline bool Preferences::formatState() { return formatstate_; }
inline void Preferences::setGroup(const QString& group) { currentgroup_ = group; }
inline const QString& Preferences::getGroup() { return currentgroup_; }
#endif // PREFERENCES
@
1.3
log
@Implemented initial file loading by shell argument, and cleaned up some
other small problems.
@
text
@d63 1
a63 1
virtual ~Preferences();
@
1.2
log
@Remove unimplemented markers.
@
text
@a55 1
class QColor;
@
1.1
log
@Add a DOM based configuration file.
@
text
@d67 3
a69 3
const QString& file(); // Not implemented
const QString& format(); // Not implemented
const QString& version(); // Not implemented
d71 1
a71 1
bool fileState(); // Not implemented
d73 1
a73 1
bool formatState(); // Not implemented
d76 2
a77 2
const QString& getGroup(); // Not implemented
void setGroup(const QString& group); // Not implemented
@