-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdata.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/multimedia/tonleiter/tonleiterdata.cpp b/noncore/multimedia/tonleiter/tonleiterdata.cpp index bf7b32c..33b3c49 100644 --- a/noncore/multimedia/tonleiter/tonleiterdata.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdata.cpp | |||
@@ -1,194 +1,194 @@ | |||
1 | #include "tonleiterdata.h" | 1 | #include "tonleiterdata.h" |
2 | 2 | ||
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | 4 | ||
5 | using namespace Data; | 5 | using namespace Data; |
6 | 6 | ||
7 | 7 | ||
8 | TonleiterData::TonleiterData(QObject* parent) | 8 | TonleiterData::TonleiterData(QObject* parent) |
9 | :QObject(parent) | 9 | :QObject(parent) |
10 | { | 10 | { |
11 | drawnames=true; | 11 | drawnames=true; |
12 | loadData(); | 12 | loadData(); |
13 | } | 13 | } |
14 | //**************************************************************************** | 14 | //**************************************************************************** |
15 | TonleiterData::~TonleiterData() | 15 | TonleiterData::~TonleiterData() |
16 | { | 16 | { |
17 | saveData(); | 17 | saveData(); |
18 | } | 18 | } |
19 | //**************************************************************************** | 19 | //**************************************************************************** |
20 | void TonleiterData::setCurrentInstrumetID(int id) | 20 | void TonleiterData::setCurrentInstrumetID(int id) |
21 | { | 21 | { |
22 | if(id>=0 && id<noOfInstruments()) | 22 | if(id>=0 && id<noOfInstruments()) |
23 | { | 23 | { |
24 | currentInstrumentID=id; | 24 | currentInstrumentID=id; |
25 | emit dataChange(); | 25 | emit dataChange(); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | //**************************************************************************** | 28 | //**************************************************************************** |
29 | void TonleiterData::setCurrentScaleID(int id) | 29 | void TonleiterData::setCurrentScaleID(int id) |
30 | { | 30 | { |
31 | if(id>=0 && id<noOfScales()) | 31 | if(id>=0 && id<noOfScales()) |
32 | { | 32 | { |
33 | currentScaleID=id; | 33 | currentScaleID=id; |
34 | emit dataChange(); | 34 | emit dataChange(); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | //**************************************************************************** | 37 | //**************************************************************************** |
38 | void TonleiterData::setCurrentNote(int id) | 38 | void TonleiterData::setCurrentNote(int id) |
39 | { | 39 | { |
40 | if(id>=0 && id<12) | 40 | if(id>=0 && id<12) |
41 | { | 41 | { |
42 | currentNote=id; | 42 | currentNote=id; |
43 | emit dataChange(); | 43 | emit dataChange(); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | //**************************************************************************** | 46 | //**************************************************************************** |
47 | void TonleiterData::setDrawNames(bool dn) | 47 | void TonleiterData::setDrawNames(bool dn) |
48 | { | 48 | { |
49 | drawnames=dn; | 49 | drawnames=dn; |
50 | emit dataChange(); | 50 | emit dataChange(); |
51 | } | 51 | } |
52 | //**************************************************************************** | 52 | //**************************************************************************** |
53 | void TonleiterData::loadData() | 53 | void TonleiterData::loadData() |
54 | { | 54 | { |
55 | Config load("Tonleiter"); | 55 | Config load("Tonleiter"); |
56 | if(!load.isValid()) | 56 | if(!load.isValid()) |
57 | { | 57 | { |
58 | //write some default values | 58 | //write some default values |
59 | load.setGroup("General"); | 59 | load.setGroup("General"); |
60 | load.writeEntry("currentInstrumentID",1); | 60 | load.writeEntry("currentInstrumentID",1); |
61 | load.writeEntry("currentNote",0); | 61 | load.writeEntry("currentNote",3); |
62 | load.writeEntry("currentScaleID",1); | 62 | load.writeEntry("currentScaleID",0); |
63 | load.writeEntry("drawnames",1); | 63 | load.writeEntry("drawnames",1); |
64 | load.setGroup("Instrument"); | 64 | load.setGroup("Instrument"); |
65 | load.writeEntry("Inst0","Thumb6;26;11;16;21;26;31;36;"); | 65 | load.writeEntry("Inst0","Thumb6;26;14;19;24;29;34;39;"); |
66 | load.writeEntry("Inst1","Bass 4;12;16;21;26;31;"); | 66 | load.writeEntry("Inst1","Bass 4;12;19;24;29;34;"); |
67 | load.writeEntry("noOfInstruments",2); | 67 | load.writeEntry("noOfInstruments",2); |
68 | load.setGroup("Scale"); | 68 | load.setGroup("Scale"); |
69 | load.writeEntry("Scale0","ionian;0;2;4;5;7;9;11;"); | 69 | load.writeEntry("Scale0","ionian;0;2;4;5;7;9;11;"); |
70 | load.writeEntry("Scale1","aeolian;0;2;3;5;7;8;10;"); | 70 | load.writeEntry("Scale1","aeolian;0;2;3;5;7;8;10;"); |
71 | load.writeEntry("Scale2","dorian;0;2;3;5;7;9;10;"); | 71 | load.writeEntry("Scale2","dorian;0;2;3;5;7;9;10;"); |
72 | load.writeEntry("Scale3","phrygian;0;1;3;5;7;8;10;"); | 72 | load.writeEntry("Scale3","phrygian;0;1;3;5;7;8;10;"); |
73 | load.writeEntry("Scale4","lydian;0;2;4;6;7;9;11;"); | 73 | load.writeEntry("Scale4","lydian;0;2;4;6;7;9;11;"); |
74 | load.writeEntry("Scale5","mixolydian;0;2;4;5;7;9;10;"); | 74 | load.writeEntry("Scale5","mixolydian;0;2;4;5;7;9;10;"); |
75 | load.writeEntry("noOfScales",6); | 75 | load.writeEntry("noOfScales",6); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | load.setGroup("General"); | 79 | load.setGroup("General"); |
80 | currentNote=load.readNumEntry("currentNote"); | 80 | currentNote=load.readNumEntry("currentNote"); |
81 | drawnames=load.readBoolEntry("drawnames"); | 81 | drawnames=load.readBoolEntry("drawnames"); |
82 | currentInstrumentID=load.readNumEntry("currentInstrumentID"); | 82 | currentInstrumentID=load.readNumEntry("currentInstrumentID"); |
83 | currentScaleID=load.readNumEntry("currentScaleID"); | 83 | currentScaleID=load.readNumEntry("currentScaleID"); |
84 | 84 | ||
85 | load.setGroup("Instrument"); | 85 | load.setGroup("Instrument"); |
86 | int noOfInstr=load.readNumEntry("noOfInstruments",0); | 86 | int noOfInstr=load.readNumEntry("noOfInstruments",0); |
87 | for(int i=0;i<noOfInstr;i++) | 87 | for(int i=0;i<noOfInstr;i++) |
88 | { | 88 | { |
89 | QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); | 89 | QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); |
90 | QValueList<int> strings; | 90 | QValueList<int> strings; |
91 | for(int st=2;st<(int)instlist.count();st++) | 91 | for(int st=2;st<(int)instlist.count();st++) |
92 | strings.append(instlist[st].toInt()); | 92 | strings.append(instlist[st].toInt()); |
93 | instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); | 93 | instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); |
94 | } | 94 | } |
95 | 95 | ||
96 | load.setGroup("Scale"); | 96 | load.setGroup("Scale"); |
97 | int scaleno=load.readNumEntry("noOfScales",0); | 97 | int scaleno=load.readNumEntry("noOfScales",0); |
98 | for(int s=0;s<scaleno;s++) | 98 | for(int s=0;s<scaleno;s++) |
99 | { | 99 | { |
100 | QStringList scalelist=load.readListEntry("Scale"+QString::number(s),';'); | 100 | QStringList scalelist=load.readListEntry("Scale"+QString::number(s),';'); |
101 | QValueList<int> halftones; | 101 | QValueList<int> halftones; |
102 | for(int ht=1;ht<(int)scalelist.count();ht++) | 102 | for(int ht=1;ht<(int)scalelist.count();ht++) |
103 | halftones.append(scalelist[ht].toInt()); | 103 | halftones.append(scalelist[ht].toInt()); |
104 | scales.append(Scale(scalelist[0],halftones)); | 104 | scales.append(Scale(scalelist[0],halftones)); |
105 | } | 105 | } |
106 | 106 | ||
107 | } | 107 | } |
108 | //**************************************************************************** | 108 | //**************************************************************************** |
109 | void TonleiterData::saveData() | 109 | void TonleiterData::saveData() |
110 | { | 110 | { |
111 | Config save("Tonleiter"); | 111 | Config save("Tonleiter"); |
112 | save.setGroup("General"); | 112 | save.setGroup("General"); |
113 | save.writeEntry("currentNote",currentNote); | 113 | save.writeEntry("currentNote",currentNote); |
114 | save.writeEntry("drawnames",drawnames); | 114 | save.writeEntry("drawnames",drawnames); |
115 | save.writeEntry("currentInstrumentID",currentInstrumentID); | 115 | save.writeEntry("currentInstrumentID",currentInstrumentID); |
116 | save.writeEntry("currentScaleID",currentScaleID); | 116 | save.writeEntry("currentScaleID",currentScaleID); |
117 | 117 | ||
118 | save.setGroup("Instrument"); | 118 | save.setGroup("Instrument"); |
119 | save.writeEntry("noOfInstruments",noOfInstruments()); | 119 | save.writeEntry("noOfInstruments",noOfInstruments()); |
120 | for(int i=0;i<noOfInstruments();i++) | 120 | for(int i=0;i<noOfInstruments();i++) |
121 | { | 121 | { |
122 | QStringList instlist; | 122 | QStringList instlist; |
123 | Instrument inst=getInstrument(i); | 123 | Instrument inst=getInstrument(i); |
124 | instlist.append(inst.instName()); | 124 | instlist.append(inst.instName()); |
125 | instlist.append(QString::number(inst.noOfFrets())); | 125 | instlist.append(QString::number(inst.noOfFrets())); |
126 | for(int st=0;st<inst.noOfStrings();st++) | 126 | for(int st=0;st<inst.noOfStrings();st++) |
127 | instlist.append(QString::number(inst.string(st))); | 127 | instlist.append(QString::number(inst.string(st))); |
128 | save.writeEntry("Inst"+QString::number(i),instlist,';'); | 128 | save.writeEntry("Inst"+QString::number(i),instlist,';'); |
129 | } | 129 | } |
130 | 130 | ||
131 | save.setGroup("Scale"); | 131 | save.setGroup("Scale"); |
132 | save.writeEntry("noOfScales",noOfScales()); | 132 | save.writeEntry("noOfScales",noOfScales()); |
133 | for(int s=0;s<noOfScales();s++) | 133 | for(int s=0;s<noOfScales();s++) |
134 | { | 134 | { |
135 | QStringList scalelist; | 135 | QStringList scalelist; |
136 | Scale scale=getScale(s); | 136 | Scale scale=getScale(s); |
137 | scalelist.append(scale.scaleName()); | 137 | scalelist.append(scale.scaleName()); |
138 | for(int ht=0;ht<scale.noOfHaltones();ht++) | 138 | for(int ht=0;ht<scale.noOfHaltones();ht++) |
139 | scalelist.append(QString::number(scale.getHalfTone(ht))); | 139 | scalelist.append(QString::number(scale.getHalfTone(ht))); |
140 | save.writeEntry("Scale"+QString::number(s),scalelist,';'); | 140 | save.writeEntry("Scale"+QString::number(s),scalelist,';'); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | //**************************************************************************** | 143 | //**************************************************************************** |
144 | int TonleiterData::noOfInstruments() | 144 | int TonleiterData::noOfInstruments() |
145 | { | 145 | { |
146 | return (int)instruments.count(); | 146 | return (int)instruments.count(); |
147 | } | 147 | } |
148 | //**************************************************************************** | 148 | //**************************************************************************** |
149 | Instrument TonleiterData::getInstrument(int id) | 149 | Instrument TonleiterData::getInstrument(int id) |
150 | { | 150 | { |
151 | if(id>=0 && id<noOfInstruments()) | 151 | if(id>=0 && id<noOfInstruments()) |
152 | return instruments[id]; | 152 | return instruments[id]; |
153 | else | 153 | else |
154 | { | 154 | { |
155 | qDebug("undefined insrtument %d of %d",id,instruments.count()); | 155 | qDebug("undefined insrtument %d of %d",id,instruments.count()); |
156 | return Instrument(); | 156 | return Instrument(); |
157 | } | 157 | } |
158 | 158 | ||
159 | } | 159 | } |
160 | //**************************************************************************** | 160 | //**************************************************************************** |
161 | int TonleiterData::getCurrentInstrumentID() | 161 | int TonleiterData::getCurrentInstrumentID() |
162 | { | 162 | { |
163 | return currentInstrumentID; | 163 | return currentInstrumentID; |
164 | } | 164 | } |
165 | //**************************************************************************** | 165 | //**************************************************************************** |
166 | int TonleiterData::noOfScales() | 166 | int TonleiterData::noOfScales() |
167 | { | 167 | { |
168 | return (int)scales.count(); | 168 | return (int)scales.count(); |
169 | } | 169 | } |
170 | //**************************************************************************** | 170 | //**************************************************************************** |
171 | Scale TonleiterData::getScale(int id) | 171 | Scale TonleiterData::getScale(int id) |
172 | { | 172 | { |
173 | if(id>=0 && id<noOfScales()) | 173 | if(id>=0 && id<noOfScales()) |
174 | return scales[id]; | 174 | return scales[id]; |
175 | else | 175 | else |
176 | { | 176 | { |
177 | qDebug("Undefined scale"); | 177 | qDebug("Undefined scale"); |
178 | return Scale(); | 178 | return Scale(); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | //**************************************************************************** | 181 | //**************************************************************************** |
182 | int TonleiterData::getCurrentScaleID() | 182 | int TonleiterData::getCurrentScaleID() |
183 | { | 183 | { |
184 | return currentScaleID; | 184 | return currentScaleID; |
185 | } | 185 | } |
186 | //**************************************************************************** | 186 | //**************************************************************************** |
187 | int TonleiterData::getCurrentBaseNote() | 187 | int TonleiterData::getCurrentBaseNote() |
188 | { | 188 | { |
189 | return currentNote; | 189 | return currentNote; |
190 | } | 190 | } |
191 | //**************************************************************************** | 191 | //**************************************************************************** |
192 | bool TonleiterData::isDrawNames() | 192 | bool TonleiterData::isDrawNames() |
193 | { | 193 | { |
194 | return drawnames; | 194 | return drawnames; |