Diffstat (limited to 'noncore/multimedia/tonleiter/tonleiterdata.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdata.cpp | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/noncore/multimedia/tonleiter/tonleiterdata.cpp b/noncore/multimedia/tonleiter/tonleiterdata.cpp index e1ecb5a..946d4e3 100644 --- a/noncore/multimedia/tonleiter/tonleiterdata.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdata.cpp | |||
@@ -1,119 +1,102 @@ | |||
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; | ||
6 | |||
7 | |||
5 | TonleiterData::TonleiterData(QObject* parent) | 8 | TonleiterData::TonleiterData(QObject* parent) |
6 | :QObject(parent) | 9 | :QObject(parent) |
7 | { | 10 | { |
8 | drawnames=true; | 11 | drawnames=true; |
9 | loadData(); | 12 | loadData(); |
10 | } | 13 | } |
11 | //**************************************************************************** | 14 | //**************************************************************************** |
12 | TonleiterData::~TonleiterData() | 15 | TonleiterData::~TonleiterData() |
13 | { | 16 | { |
14 | saveData(); | 17 | saveData(); |
15 | } | 18 | } |
16 | //**************************************************************************** | 19 | //**************************************************************************** |
17 | void TonleiterData::setCurrentInstrumetID(int id) | 20 | void TonleiterData::setCurrentInstrumetID(int id) |
18 | { | 21 | { |
19 | if(id>=0 && id<noOfInstruments()) | 22 | if(id>=0 && id<noOfInstruments()) |
20 | { | 23 | { |
21 | currentInstrumentID=id; | 24 | currentInstrumentID=id; |
22 | emit dataChange(); | 25 | emit dataChange(); |
23 | } | 26 | } |
24 | } | 27 | } |
25 | //**************************************************************************** | 28 | //**************************************************************************** |
26 | void TonleiterData::setCurrentScaleID(int id) | 29 | void TonleiterData::setCurrentScaleID(int id) |
27 | { | 30 | { |
28 | if(id>=0 && id<noOfScales()) | 31 | if(id>=0 && id<noOfScales()) |
29 | { | 32 | { |
30 | currentScaleID=id; | 33 | currentScaleID=id; |
31 | emit dataChange(); | 34 | emit dataChange(); |
32 | } | 35 | } |
33 | } | 36 | } |
34 | //**************************************************************************** | 37 | //**************************************************************************** |
35 | void TonleiterData::setCurrentNote(int id) | 38 | void TonleiterData::setCurrentNote(int id) |
36 | { | 39 | { |
37 | if(id>=0 && id<12) | 40 | if(id>=0 && id<12) |
38 | { | 41 | { |
39 | currentNote=id; | 42 | currentNote=id; |
40 | emit dataChange(); | 43 | emit dataChange(); |
41 | } | 44 | } |
42 | } | 45 | } |
43 | //**************************************************************************** | 46 | //**************************************************************************** |
44 | void TonleiterData::setDrawNames(bool dn) | 47 | void TonleiterData::setDrawNames(bool dn) |
45 | { | 48 | { |
46 | drawnames=dn; | 49 | drawnames=dn; |
47 | emit dataChange(); | 50 | emit dataChange(); |
48 | } | 51 | } |
49 | //**************************************************************************** | 52 | //**************************************************************************** |
50 | void TonleiterData::loadData() | 53 | void TonleiterData::loadData() |
51 | { | 54 | { |
52 | /* | 55 | Config load("Tonleiter"); |
53 | QValueList<int> strings1; | 56 | if(!load.isValid()) |
54 | strings1.append(Note::getNoteFromName("B",0)); | 57 | { |
55 | strings1.append(Note::getNoteFromName("E",1)); | 58 | //write some default values |
56 | strings1.append(Note::getNoteFromName("A",1)); | 59 | load.setGroup("General"); |
57 | strings1.append(Note::getNoteFromName("D",2)); | 60 | load.writeEntry("currentInstrumentID",1); |
58 | strings1.append(Note::getNoteFromName("G",2)); | 61 | load.writeEntry("currentNote",0); |
59 | strings1.append(Note::getNoteFromName("C",3)); | 62 | load.writeEntry("currentScaleID",1); |
60 | instruments.append(Instrument("Thumb6",26,strings1)); | 63 | load.writeEntry("drawnames",1); |
61 | 64 | load.setGroup("Instrument"); | |
62 | QValueList<int> strings2; | 65 | load.writeEntry("Inst0","Thumb6;26;11;16;21;26;31;36;"); |
63 | strings2.append(Note::getNoteFromName("E",1)); | 66 | load.writeEntry("Inst1","Bass 4;12;16;21;26;31;"); |
64 | strings2.append(Note::getNoteFromName("A",1)); | 67 | load.writeEntry("noOfInstruments",2); |
65 | strings2.append(Note::getNoteFromName("D",2)); | 68 | load.setGroup("Scale"); |
66 | strings2.append(Note::getNoteFromName("G",2)); | 69 | load.writeEntry("Scale0","ionian;0;2;4;5;7;9;11;"); |
67 | instruments.append(Instrument("Bass 4",12,strings2)); | 70 | load.writeEntry("Scale1","aeolian;0;2;3;5;7;8;10;"); |
68 | 71 | load.writeEntry("Scale2","dorian;0;2;3;5;7;9;10;"); | |
69 | currentInstrumentID=1; | 72 | load.writeEntry("Scale3","phrygian;0;1;3;5;7;8;10;"); |
70 | 73 | load.writeEntry("Scale4","lydian;0;2;4;6;7;9;11;"); | |
71 | QValueList<int> scale1; | 74 | load.writeEntry("Scale5","mixolyd.;0;2;4;5;7;9;10;"); |
72 | scale1.append(0); | 75 | load.writeEntry("noOfScales",6); |
73 | scale1.append(2); | ||
74 | scale1.append(3); | ||
75 | scale1.append(5); | ||
76 | scale1.append(7); | ||
77 | scale1.append(8); | ||
78 | scale1.append(10); | ||
79 | scales.append(Scale("Minor",scale1)); | ||
80 | |||
81 | QValueList<int> scale2; | ||
82 | scale2.append(0); | ||
83 | scale2.append(2); | ||
84 | scale2.append(4); | ||
85 | scale2.append(5); | ||
86 | scale2.append(7); | ||
87 | scale2.append(9); | ||
88 | scale2.append(10); | ||
89 | scales.append(Scale("Major",scale2)); | ||
90 | 76 | ||
91 | currentScaleID=0; | 77 | } |
92 | 78 | ||
93 | currentNote=Note::getNoteFromName("A",0); | ||
94 | */ | ||
95 | Config load("Tonleiter"); | ||
96 | load.setGroup("General"); | 79 | load.setGroup("General"); |
97 | currentNote=load.readNumEntry("currentNote"); | 80 | currentNote=load.readNumEntry("currentNote"); |
98 | drawnames=load.readBoolEntry("drawnames"); | 81 | drawnames=load.readBoolEntry("drawnames"); |
99 | currentInstrumentID=load.readNumEntry("currentInstrumentID"); | 82 | currentInstrumentID=load.readNumEntry("currentInstrumentID"); |
100 | currentScaleID=load.readNumEntry("currentScaleID"); | 83 | currentScaleID=load.readNumEntry("currentScaleID"); |
101 | 84 | ||
102 | load.setGroup("Instrument"); | 85 | load.setGroup("Instrument"); |
103 | int noOfInstr=load.readNumEntry("noOfInstruments",0); | 86 | int noOfInstr=load.readNumEntry("noOfInstruments",0); |
104 | for(int i=0;i<noOfInstr;i++) | 87 | for(int i=0;i<noOfInstr;i++) |
105 | { | 88 | { |
106 | QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); | 89 | QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); |
107 | QValueList<int> strings; | 90 | QValueList<int> strings; |
108 | for(int st=2;st<(int)instlist.count();st++) | 91 | for(int st=2;st<(int)instlist.count();st++) |
109 | strings.append(instlist[st].toInt()); | 92 | strings.append(instlist[st].toInt()); |
110 | instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); | 93 | instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); |
111 | } | 94 | } |
112 | 95 | ||
113 | load.setGroup("Scale"); | 96 | load.setGroup("Scale"); |
114 | int scaleno=load.readNumEntry("noOfScales",0); | 97 | int scaleno=load.readNumEntry("noOfScales",0); |
115 | for(int s=0;s<scaleno;s++) | 98 | for(int s=0;s<scaleno;s++) |
116 | { | 99 | { |
117 | QStringList scalelist=load.readListEntry("Scale"+QString::number(s),';'); | 100 | QStringList scalelist=load.readListEntry("Scale"+QString::number(s),';'); |
118 | QValueList<int> halftones; | 101 | QValueList<int> halftones; |
119 | for(int ht=1;ht<(int)scalelist.count();ht++) | 102 | for(int ht=1;ht<(int)scalelist.count();ht++) |