~ubuntu-branches/ubuntu/natty/kdemultimedia/natty-proposed

« back to all changes in this revision

Viewing changes to kmix/guiprofile.h

  • Committer: Bazaar Package Importer
  • Author(s): Debian Qt/KDE Maintainers
  • Date: 2011-05-26 02:41:36 UTC
  • mfrom: (0.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: james.westby@ubuntu.com-20110526024136-jjwsigfy402jhupm
Tags: upstream-4.6.3
ImportĀ upstreamĀ versionĀ 4.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * KMix -- KDE's full featured mini mixer
3
 
 *
4
 
 * Copyright 2006-2007 Christian Esken <esken@kde.org>
5
 
 *
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.
10
 
 *
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.
15
 
 *
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.
19
 
 */
20
 
 
21
 
#ifndef _GUIPROFILE_H_
22
 
#define _GUIPROFILE_H_
23
 
 
24
 
class Mixer;
25
 
 
26
 
#include <qxml.h>
27
 
#include <QColor>
28
 
#include <QTextStream>
29
 
#include <QString>
30
 
 
31
 
#include <string>
32
 
#include <map>
33
 
#include <set>
34
 
#include <vector>
35
 
#include <ostream>
36
 
 
37
 
#include <KDebug>
38
 
 
39
 
struct SortedStringComparator
40
 
{
41
 
  bool operator()(const std::string&, const std::string&) const;
42
 
};
43
 
 
44
 
 
45
 
struct ProfProduct
46
 
{
47
 
        QString vendor;
48
 
        QString productName;
49
 
        // In case the vendor ships different products under the same productName
50
 
        QString productRelease;
51
 
        QString comment;
52
 
};
53
 
 
54
 
class ProfControl
55
 
{
56
 
public:
57
 
        ProfControl(); // default constructor
58
 
        ProfControl(const ProfControl &ctl); // copy constructor
59
 
        // ID as returned by the Mixer Backend, e.g. Master:0
60
 
 
61
 
/*
62
 
        bool operator==(QString& other ) const
63
 
        {
64
 
                return other == id;
65
 
        }
66
 
 
67
 
        bool operator==(QString other ) const
68
 
        {
69
 
                return other == id;
70
 
        }
71
 
 
72
 
        bool operator==(const QString& other ) const
73
 
        {
74
 
                return other == id;
75
 
        }
76
 
*/
77
 
        QString id;
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.
80
 
        QString subcontrols;
81
 
        // In case the vendor ships different products under the same productName
82
 
        QString tab;
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.
85
 
        QString name;
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
89
 
   QString regexp;
90
 
        // show or hide (contains the GUI type: simple, extended, all)
91
 
        QString show;
92
 
      // For applying custom colors
93
 
      QColor backgroundColor;
94
 
      // For defining the switch type when it is not a standard palyback or capture switch
95
 
      QString switchtype;
96
 
};
97
 
 
98
 
struct ProfTab
99
 
{
100
 
        // Name of the Tab, in english
101
 
        QString name;
102
 
        // Type of the Tab, either "play", "record" or "switches"
103
 
        QString type;
104
 
};
105
 
 
106
 
struct ProductComparator
107
 
{
108
 
  bool operator()(const ProfProduct*, const ProfProduct*) const;
109
 
};
110
 
 
111
 
class GUIProfile
112
 
{
113
 
public:
114
 
        GUIProfile();
115
 
        virtual ~GUIProfile();
116
 
 
117
 
        void increaseRefcount() { ++_refcount; } ;
118
 
        void decreaseRefcount() { if (_refcount > 0) --_refcount; else kError() << "_refcount already 0"; } ;
119
 
        unsigned int refcount() {return _refcount; } ;
120
 
 
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);
127
 
 
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;
137
 
 
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;
146
 
private:
147
 
        QString _fileNameWithoutFullPath;
148
 
        unsigned int _refcount;
149
 
};
150
 
 
151
 
std::ostream& operator<<(std::ostream& os, const GUIProfile& vol);
152
 
QTextStream& operator<<(QTextStream &outStream, const GUIProfile& guiprof);
153
 
 
154
 
class GUIProfileParser : public QXmlDefaultHandler
155
 
{
156
 
public:
157
 
                GUIProfileParser(GUIProfile& ref_gp);
158
 
                // Enumeration for the scope
159
 
                enum ProfileScope { NONE, SOUNDCARD };
160
 
                
161
 
                bool startDocument();
162
 
                bool startElement( const QString&, const QString&, const QString& , const QXmlAttributes& );
163
 
                bool endElement( const QString&, const QString&, const QString& );
164
 
                
165
 
private:
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);
172
 
 
173
 
                ProfileScope _scope;
174
 
                GUIProfile& _guiProfile;
175
 
};
176
 
 
177
 
#endif //_GUIPROFILE_H_