~ubuntu-branches/ubuntu/wily/kid3/wily-proposed

« back to all changes in this revision

Viewing changes to kid3/generalconfig.h

  • Committer: Package Import Robot
  • Author(s): Ana Beatriz Guerrero Lopez, Patrick Matthäi, Ana Beatriz Guerrero Lopez
  • Date: 2011-11-13 16:34:13 UTC
  • mfrom: (1.1.13) (2.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20111113163413-5y0anlc4dqf511uh
Tags: 2.0.1-1
* New upstream release.

[ Patrick Matthäi ]
* Adjust build system.
* Add build dependency xsltproc.

[ Ana Beatriz Guerrero Lopez ]
* Some more adjustments to the build system taken from upstream's deb/
* directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * \file generalconfig.h
3
 
 * General configuration.
4
 
 *
5
 
 * \b Project: Kid3
6
 
 * \author Urs Fleisch
7
 
 * \date 17 Sep 2003
8
 
 *
9
 
 * Copyright (C) 2003-2007  Urs Fleisch
10
 
 *
11
 
 * This file is part of Kid3.
12
 
 *
13
 
 * Kid3 is free software; you can redistribute it and/or modify
14
 
 * it under the terms of the GNU General Public License as published by
15
 
 * the Free Software Foundation; either version 2 of the License, or
16
 
 * (at your option) any later version.
17
 
 *
18
 
 * Kid3 is distributed in the hope that it will be useful,
19
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
 * GNU General Public License for more details.
22
 
 *
23
 
 * You should have received a copy of the GNU General Public License
24
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
 */
26
 
 
27
 
#ifndef GENERALCONFIG_H
28
 
#define GENERALCONFIG_H
29
 
 
30
 
#include "config.h"
31
 
#include <qstring.h>
32
 
 
33
 
#ifdef CONFIG_USE_KDE
34
 
class KConfig;
35
 
#else
36
 
#if QT_VERSION >= 0x030100
37
 
#include <qsettings.h>
38
 
typedef QSettings Kid3Settings;
39
 
#else
40
 
#include <qmap.h>
41
 
#include <qstringlist.h>
42
 
 
43
 
/** Quick and dirty replacement for QSettings */
44
 
class Kid3Settings {
45
 
public:
46
 
        enum Scope { User, Global };
47
 
        Kid3Settings();
48
 
        ~Kid3Settings();
49
 
        void setPath(const QString&, const QString&, Scope = Global);
50
 
        void beginGroup(const QString& grp);
51
 
        void endGroup();
52
 
        void writeEntry(const QString& key, int val);
53
 
        void writeEntry(const QString& key, bool val);
54
 
        void writeEntry(const QString& key, const QString& val);
55
 
        void writeEntry(const QString& key, const QStringList& val);
56
 
        void writeEntry(const QString& key, const QMap<QString, QString>& val);
57
 
        QString readEntry(const QString& key, const QString& dflt = QString::null);
58
 
        int readNumEntry(const QString& key, int dflt = 0);
59
 
        bool readBoolEntry(const QString& key, bool dflt = 0);
60
 
        QStringList readListEntry(const QString& key);
61
 
        QMap<QString, QString> readMapEntry(const QString& key, const QMap<QString, QString>& dflt);
62
 
        bool removeEntry(const QString& key);
63
 
private:
64
 
        QMap<QString, QString> m_map;
65
 
        QString m_group;
66
 
};
67
 
#endif
68
 
#endif
69
 
 
70
 
/**
71
 
 * Abstract base class for configurations.
72
 
 */
73
 
class GeneralConfig {
74
 
public:
75
 
        /**
76
 
         * Constructor.
77
 
         * Set default configuration.
78
 
         *
79
 
         * @param grp configuration group
80
 
         */
81
 
        GeneralConfig(const QString& grp);
82
 
 
83
 
        /**
84
 
         * Destructor.
85
 
         */
86
 
        virtual ~GeneralConfig();
87
 
 
88
 
        /**
89
 
         * Persist configuration.
90
 
         *
91
 
         * @param config KDE configuration
92
 
         */
93
 
        virtual void writeToConfig(
94
 
#ifdef CONFIG_USE_KDE
95
 
                KConfig* config
96
 
#else
97
 
                Kid3Settings* config
98
 
#endif
99
 
                ) const = 0;
100
 
 
101
 
        /**
102
 
         * Read persisted configuration.
103
 
         *
104
 
         * @param config KDE configuration
105
 
         */
106
 
        virtual void readFromConfig(
107
 
#ifdef CONFIG_USE_KDE
108
 
                KConfig* config
109
 
#else
110
 
                Kid3Settings* config
111
 
#endif
112
 
                ) = 0;
113
 
 
114
 
protected:
115
 
        /** Configuration group. */
116
 
        QString m_group;
117
 
};
118
 
 
119
 
#endif