author | waspe <waspe> | 2003-11-17 20:34:17 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-11-17 20:34:17 (UTC) |
commit | fef70b95241f814328678e422bc9b9027e142386 (patch) (side-by-side diff) | |
tree | 1baa88dbb52451253040d0d4ecc90d96d18aeb5d | |
parent | ede1a10411dd859c6473aadbc7fa54bf2419380d (diff) | |
download | opie-fef70b95241f814328678e422bc9b9027e142386.zip opie-fef70b95241f814328678e422bc9b9027e142386.tar.gz opie-fef70b95241f814328678e422bc9b9027e142386.tar.bz2 |
load and save added -> data needs still be edited in conf file
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdata.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/noncore/multimedia/tonleiter/tonleiterdata.cpp b/noncore/multimedia/tonleiter/tonleiterdata.cpp index 8a9fdca..e1ecb5a 100644 --- a/noncore/multimedia/tonleiter/tonleiterdata.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdata.cpp @@ -1,14 +1,16 @@ #include "tonleiterdata.h" +#include <qpe/config.h> + TonleiterData::TonleiterData(QObject* parent) :QObject(parent) { drawnames=true; loadData(); } //**************************************************************************** TonleiterData::~TonleiterData() { saveData(); } //**************************************************************************** @@ -38,24 +40,25 @@ void TonleiterData::setCurrentNote(int id) emit dataChange(); } } //**************************************************************************** void TonleiterData::setDrawNames(bool dn) { drawnames=dn; emit dataChange(); } //**************************************************************************** void TonleiterData::loadData() { +/* QValueList<int> strings1; strings1.append(Note::getNoteFromName("B",0)); strings1.append(Note::getNoteFromName("E",1)); strings1.append(Note::getNoteFromName("A",1)); strings1.append(Note::getNoteFromName("D",2)); strings1.append(Note::getNoteFromName("G",2)); strings1.append(Note::getNoteFromName("C",3)); instruments.append(Instrument("Thumb6",26,strings1)); QValueList<int> strings2; strings2.append(Note::getNoteFromName("E",1)); strings2.append(Note::getNoteFromName("A",1)); @@ -79,28 +82,89 @@ void TonleiterData::loadData() scale2.append(0); scale2.append(2); scale2.append(4); scale2.append(5); scale2.append(7); scale2.append(9); scale2.append(10); scales.append(Scale("Major",scale2)); currentScaleID=0; currentNote=Note::getNoteFromName("A",0); +*/ + Config load("Tonleiter"); + load.setGroup("General"); + currentNote=load.readNumEntry("currentNote"); + drawnames=load.readBoolEntry("drawnames"); + currentInstrumentID=load.readNumEntry("currentInstrumentID"); + currentScaleID=load.readNumEntry("currentScaleID"); + + load.setGroup("Instrument"); + int noOfInstr=load.readNumEntry("noOfInstruments",0); + for(int i=0;i<noOfInstr;i++) + { + QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); + QValueList<int> strings; + for(int st=2;st<(int)instlist.count();st++) + strings.append(instlist[st].toInt()); + instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); + } + + load.setGroup("Scale"); + int scaleno=load.readNumEntry("noOfScales",0); + for(int s=0;s<scaleno;s++) + { + QStringList scalelist=load.readListEntry("Scale"+QString::number(s),';'); + QValueList<int> halftones; + for(int ht=1;ht<(int)scalelist.count();ht++) + halftones.append(scalelist[ht].toInt()); + scales.append(Scale(scalelist[0],halftones)); + } + } //**************************************************************************** void TonleiterData::saveData() { + Config save("Tonleiter"); + save.setGroup("General"); + save.writeEntry("currentNote",currentNote); + save.writeEntry("drawnames",drawnames); + save.writeEntry("currentInstrumentID",currentInstrumentID); + save.writeEntry("currentScaleID",currentScaleID); + + save.setGroup("Instrument"); + save.writeEntry("noOfInstruments",noOfInstruments()); + for(int i=0;i<noOfInstruments();i++) + { + QStringList instlist; + Instrument inst=getInstrument(i); + instlist.append(inst.instName()); + instlist.append(QString::number(inst.noOfFrets())); + for(int st=0;st<inst.noOfStrings();st++) + instlist.append(QString::number(inst.string(st))); + save.writeEntry("Inst"+QString::number(i),instlist,';'); + } + + save.setGroup("Scale"); + save.writeEntry("noOfScales",noOfScales()); + for(int s=0;s<noOfScales();s++) + { + QStringList scalelist; + Scale scale=getScale(s); + scalelist.append(scale.scaleName()); + for(int ht=0;ht<scale.noOfHaltones();ht++) + scalelist.append(QString::number(scale.getHalfTone(ht))); + save.writeEntry("Scale"+QString::number(s),scalelist,';'); + } } //**************************************************************************** int TonleiterData::noOfInstruments() { return (int)instruments.count(); } //**************************************************************************** Instrument TonleiterData::getInstrument(int id) { if(id>=0 && id<noOfInstruments()) return instruments[id]; else |