2
* KMix -- KDE's full featured mini mixer
4
* Copyright 2006-2007 Christian Esken <esken@kde.org>
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this program; if not, write to the Free
18
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#ifndef _GUIPROFILE_H_
22
#define _GUIPROFILE_H_
28
#include <QTextStream>
39
struct SortedStringComparator
41
bool operator()(const std::string&, const std::string&) const;
49
// In case the vendor ships different products under the same productName
50
QString productRelease;
57
ProfControl(); // default constructor
58
ProfControl(const ProfControl &ctl); // copy constructor
59
// ID as returned by the Mixer Backend, e.g. Master:0
62
bool operator==(QString& other ) const
67
bool operator==(QString other ) const
72
bool operator==(const QString& other ) const
78
// List of controls, e.g: "rec:1-2,recswitch"
79
// When we start using it, it might be changed into a std::vector in the future.
81
// In case the vendor ships different products under the same productName
83
// Visible name for the User ( if name.isNull(), id will be used - And in the future a default lookup table will be consulted ).
84
// Because the name is visible, some kind of i18n() will be used.
86
// Pattern (REGEXP) for matching the control names.
87
// If you set no pattern, the name will be used instead.
88
// If you use a pattern, you normally should not define a name, as it will apply to all matching controls
90
// show or hide (contains the GUI type: simple, extended, all)
92
// For applying custom colors
93
QColor backgroundColor;
94
// For defining the switch type when it is not a standard palyback or capture switch
100
// Name of the Tab, in english
102
// Type of the Tab, either "play", "record" or "switches"
106
struct ProductComparator
108
bool operator()(const ProfProduct*, const ProfProduct*) const;
115
virtual ~GUIProfile();
117
void increaseRefcount() { ++_refcount; } ;
118
void decreaseRefcount() { if (_refcount > 0) --_refcount; else kError() << "_refcount already 0"; } ;
119
unsigned int refcount() {return _refcount; } ;
121
bool readProfile(QString& ref_fileNamestring, QString ref_fileNameWithoutFullPath);
122
bool finalizeProfile();
123
bool writeProfile(QString& fname);
124
unsigned long match(Mixer* mixer);
125
friend std::ostream& operator<<(std::ostream& os, const GUIProfile& vol);
126
friend QTextStream& operator<<(QTextStream &outStream, const GUIProfile& guiprof);
128
// key, value, comparator
129
//typedef std::map<std::string, std::string, SortedStringComparator> SortedStringMap;
130
typedef std::set<ProfProduct*, ProductComparator> ProductSet;
131
typedef std::vector<ProfControl*> ControlSet;
132
//typedef std::map<std::string, std::string, SortedStringComparator> SortedStringSet;
133
//typedef std::map<std::string, std::string> StringMap;
134
ControlSet _controls;
135
std::vector<ProfTab*> _tabs; // shouldn't be sorted
136
ProductSet _products;
138
// The values from the <soundcard> tag
139
QString _soundcardDriver;
140
// The driver version: 1000*1000*MAJOR + 1000*MINOR + PATCHLEVEL
141
unsigned long _driverVersionMin;
142
unsigned long _driverVersionMax;
143
QString _soundcardName;
144
QString _soundcardType;
145
unsigned long _generation;
147
QString _fileNameWithoutFullPath;
148
unsigned int _refcount;
151
std::ostream& operator<<(std::ostream& os, const GUIProfile& vol);
152
QTextStream& operator<<(QTextStream &outStream, const GUIProfile& guiprof);
154
class GUIProfileParser : public QXmlDefaultHandler
157
GUIProfileParser(GUIProfile& ref_gp);
158
// Enumeration for the scope
159
enum ProfileScope { NONE, SOUNDCARD };
161
bool startDocument();
162
bool startElement( const QString&, const QString&, const QString& , const QXmlAttributes& );
163
bool endElement( const QString&, const QString&, const QString& );
166
void addControl(const QXmlAttributes& attributes);
167
void addProduct(const QXmlAttributes& attributes);
168
void addSoundcard(const QXmlAttributes& attributes);
169
void addTab(const QXmlAttributes& attributes);
170
void printAttributes(const QXmlAttributes& attributes);
171
void splitPair(const QString& pairString, std::pair<QString,QString>& result, char delim);
174
GUIProfile& _guiProfile;
177
#endif //_GUIPROFILE_H_