diff options
Diffstat (limited to 'rbutil/rbutilqt/base/encttssettings.h')
-rw-r--r-- | rbutil/rbutilqt/base/encttssettings.h | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/encttssettings.h b/rbutil/rbutilqt/base/encttssettings.h new file mode 100644 index 0000000000..843829a815 --- /dev/null +++ b/rbutil/rbutilqt/base/encttssettings.h | |||
@@ -0,0 +1,129 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef ENCTTSSETTINGS_H | ||
23 | #define ENCTTSSETTINGS_H | ||
24 | |||
25 | #include <QtCore> | ||
26 | |||
27 | //! \brief This class stores everything needed to display a Setting. | ||
28 | //! | ||
29 | class EncTtsSetting : public QObject | ||
30 | { | ||
31 | Q_OBJECT | ||
32 | public: | ||
33 | enum ESettingType | ||
34 | { | ||
35 | eBASE, | ||
36 | eBOOL, | ||
37 | eDOUBLE, | ||
38 | eINT, | ||
39 | eSTRING, | ||
40 | eREADONLYSTRING, | ||
41 | eSTRINGLIST, | ||
42 | }; | ||
43 | enum EButton | ||
44 | { | ||
45 | eNOBTN, | ||
46 | eBROWSEBTN, | ||
47 | eREFRESHBTN | ||
48 | }; | ||
49 | |||
50 | //! constructor for a String or Bool setting | ||
51 | EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,EButton btn = eNOBTN); | ||
52 | //! contructor for a Stringlist setting, ie a enumeration | ||
53 | EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn = eNOBTN); | ||
54 | //! constructor for a setting with a min-max range | ||
55 | EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max,EButton = eNOBTN); | ||
56 | |||
57 | //! get currentValue | ||
58 | QVariant current() {return m_currentValue;} | ||
59 | //! set currentValue | ||
60 | void setCurrent(QVariant current,bool noticeGui=true); | ||
61 | |||
62 | //! get name of the Setting | ||
63 | QString name() {return m_name;} | ||
64 | //! get the type of the setting | ||
65 | ESettingType type() {return m_type;} | ||
66 | //! get what type of button this setting needs | ||
67 | EButton button() {return m_btn;} | ||
68 | //! get the minValue (only valid for a range setting, ie eDOUBLE or eINT) | ||
69 | QVariant min() {return m_minValue; } | ||
70 | //! get the maxValue (only valid for a range setting, ie eDOUBLE or eINT) | ||
71 | QVariant max() {return m_maxValue; } | ||
72 | //! get the enumerationlist (only valid for eSTRINGLIST settings) | ||
73 | QStringList list() {return m_list;} | ||
74 | //! set the enumeration list | ||
75 | void setList(QStringList list){m_list = list;} | ||
76 | |||
77 | signals: | ||
78 | //! connect to this signal if you want to get noticed when the data changes | ||
79 | void dataChanged(); | ||
80 | //! connect to this if you want to react on refresh button | ||
81 | void refresh(); | ||
82 | //! will be emited when the gui should update this setting | ||
83 | void updateGui(); | ||
84 | |||
85 | private: | ||
86 | ESettingType m_type; | ||
87 | EButton m_btn; | ||
88 | QString m_name; | ||
89 | QVariant m_currentValue; | ||
90 | QVariant m_minValue; | ||
91 | QVariant m_maxValue; | ||
92 | QStringList m_list; | ||
93 | }; | ||
94 | |||
95 | |||
96 | //! \brief this class is the Interface for Encoder and TTS engines, to display settings | ||
97 | //! It wraps nearly everything needed, only updateModel() and commitModel() needs to be reimplemented | ||
98 | //! | ||
99 | class EncTtsSettingInterface : public QObject | ||
100 | { | ||
101 | Q_OBJECT | ||
102 | public: | ||
103 | EncTtsSettingInterface(QObject* parent) : QObject(parent) {} | ||
104 | |||
105 | //! get the Settings list | ||
106 | QList<EncTtsSetting*> getSettings() {generateSettings(); return settingsList;} | ||
107 | |||
108 | //! Chlid class should commit the from SettingsList to permanent storage | ||
109 | virtual void saveSettings() = 0; | ||
110 | |||
111 | signals: | ||
112 | void busy(); // emit this if a operation takes time | ||
113 | void busyEnd(); // emit this at the end of a busy section | ||
114 | |||
115 | protected: | ||
116 | //! Child class should fill in the setttingsList | ||
117 | virtual void generateSettings() = 0; | ||
118 | |||
119 | //! insert a setting | ||
120 | void insertSetting(int id,EncTtsSetting* setting); | ||
121 | //! retrieve a specific setting | ||
122 | EncTtsSetting* getSetting(int id); | ||
123 | |||
124 | private: | ||
125 | //! The setting storage. | ||
126 | QList<EncTtsSetting*> settingsList; | ||
127 | |||
128 | }; | ||
129 | #endif | ||