summaryrefslogtreecommitdiff
authorwaspe <waspe>2003-11-20 19:34:08 (UTC)
committer waspe <waspe>2003-11-20 19:34:08 (UTC)
commite6a5ed6de7e821a070d571045ff063f8c41b0b79 (patch) (unidiff)
tree8455d7bf537cf804337b6c03b28f891ee3f286ce
parentf43e28fe8f226039d96ebda4e6c4d26e4f3320ba (diff)
downloadopie-e6a5ed6de7e821a070d571045ff063f8c41b0b79.zip
opie-e6a5ed6de7e821a070d571045ff063f8c41b0b79.tar.gz
opie-e6a5ed6de7e821a070d571045ff063f8c41b0b79.tar.bz2
added preliminary edit dialogs
default config added
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/tonleiter/editinst.cpp14
-rw-r--r--noncore/multimedia/tonleiter/editinst.h23
-rw-r--r--noncore/multimedia/tonleiter/editscale.cpp14
-rw-r--r--noncore/multimedia/tonleiter/editscale.h23
-rw-r--r--noncore/multimedia/tonleiter/fretboard.cpp20
-rw-r--r--noncore/multimedia/tonleiter/fretboard.h80
-rw-r--r--noncore/multimedia/tonleiter/mainwidget.cpp6
-rw-r--r--noncore/multimedia/tonleiter/mainwidget.h6
-rw-r--r--noncore/multimedia/tonleiter/menuwidget.cpp23
-rw-r--r--noncore/multimedia/tonleiter/menuwidget.h37
-rw-r--r--noncore/multimedia/tonleiter/tonleiter.pro4
-rw-r--r--noncore/multimedia/tonleiter/tonleiterdata.cpp67
-rw-r--r--noncore/multimedia/tonleiter/tonleiterdata.h73
-rw-r--r--noncore/multimedia/tonleiter/tonleiterdatahelper.cpp2
-rw-r--r--noncore/multimedia/tonleiter/tonleiterdatahelper.h86
15 files changed, 284 insertions, 194 deletions
diff --git a/noncore/multimedia/tonleiter/editinst.cpp b/noncore/multimedia/tonleiter/editinst.cpp
new file mode 100644
index 0000000..1eba4dc
--- a/dev/null
+++ b/noncore/multimedia/tonleiter/editinst.cpp
@@ -0,0 +1,14 @@
1#include "editinst.h"
2
3Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name)
4:QDialog(parent,name,true,0),data(data)
5{
6 setCaption("Tonleiter::"+tr("Instrument"));
7 showMaximized();
8}
9//****************************************************************************
10Menu::InstEditDialog::~InstEditDialog()
11{
12}
13//****************************************************************************
14//****************************************************************************
diff --git a/noncore/multimedia/tonleiter/editinst.h b/noncore/multimedia/tonleiter/editinst.h
new file mode 100644
index 0000000..e7eba15
--- a/dev/null
+++ b/noncore/multimedia/tonleiter/editinst.h
@@ -0,0 +1,23 @@
1#ifndef TONLEITER_EDIT_INSTRUMENT_DIALOG_H
2#define TONLEITER_EDIT_INSTRUMENT_DIALOG_H
3
4#include <qdialog.h>
5
6#include "tonleiterdata.h"
7
8using namespace Data;
9
10namespace Menu
11{
12 class InstEditDialog : public QDialog
13 {
14 Q_OBJECT
15 private:
16 TonleiterData* data;
17 public:
18 InstEditDialog(TonleiterData* data,QWidget* parent,const char* name="InstEditDialog");
19 ~InstEditDialog();
20 };
21};
22
23#endif //TONLEITER_EDIT_INSTRUMENT_DIALOG_H
diff --git a/noncore/multimedia/tonleiter/editscale.cpp b/noncore/multimedia/tonleiter/editscale.cpp
new file mode 100644
index 0000000..593a150
--- a/dev/null
+++ b/noncore/multimedia/tonleiter/editscale.cpp
@@ -0,0 +1,14 @@
1#include "editscale.h"
2
3Menu::ScaleEditDialog::ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name)
4:QDialog(parent,name,true,0),data(data)
5{
6 setCaption("Tonleiter::"+tr("Scale"));
7 showMaximized();
8}
9//****************************************************************************
10Menu::ScaleEditDialog::~ScaleEditDialog()
11{
12}
13//****************************************************************************
14//****************************************************************************
diff --git a/noncore/multimedia/tonleiter/editscale.h b/noncore/multimedia/tonleiter/editscale.h
new file mode 100644
index 0000000..0e5eb1c
--- a/dev/null
+++ b/noncore/multimedia/tonleiter/editscale.h
@@ -0,0 +1,23 @@
1#ifndef TONLEITER_EDIT_SCALE_DIALOG_H
2#define TONLEITER_EDIT_SCALE_DIALOG_H
3
4#include <qdialog.h>
5
6#include "tonleiterdata.h"
7
8using namespace Data;
9
10namespace Menu
11{
12 class ScaleEditDialog : public QDialog
13 {
14 Q_OBJECT
15 private:
16 TonleiterData* data;
17 public:
18 ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name="ScaleEditDialog");
19 ~ScaleEditDialog();
20 };
21};
22
23#endif //TONLEITER_EDIT_SCALE_DIALOG_H
diff --git a/noncore/multimedia/tonleiter/fretboard.cpp b/noncore/multimedia/tonleiter/fretboard.cpp
index 57806be..7936c83 100644
--- a/noncore/multimedia/tonleiter/fretboard.cpp
+++ b/noncore/multimedia/tonleiter/fretboard.cpp
@@ -1,159 +1,159 @@
1#include "fretboard.h" 1#include "fretboard.h"
2 2
3#include <qpainter.h> 3#include <qpainter.h>
4 4
5FretBoard::FretBoard(TonleiterData* data,QWidget* parent,const char* name,WFlags f) 5Graph::FretBoard::FretBoard(TonleiterData* data,QWidget* parent,const char* name,WFlags f)
6:QWidget(parent,name,f),data(data) 6:QWidget(parent,name,f),data(data)
7{ 7{
8 setBackgroundColor(QColor(0,0,0)); 8 setBackgroundColor(QColor(0,0,0));
9 fretpen=QPen(QColor(155,155,155),0); 9 fretpen=QPen(QColor(155,155,155),0);
10 markerbrush=QBrush(QColor(155,155,155)); 10 markerbrush=QBrush(QColor(155,155,155));
11 stringpen=QPen(QColor(255,255,255),3); 11 stringpen=QPen(QColor(255,255,255),3);
12 connect(data,SIGNAL(dataChange()),this,SLOT(dataChange())); 12 connect(data,SIGNAL(dataChange()),this,SLOT(dataChange()));
13} 13}
14//**************************************************************************** 14//****************************************************************************
15FretBoard::~FretBoard() 15Graph::FretBoard::~FretBoard()
16{ 16{
17} 17}
18//**************************************************************************** 18//****************************************************************************
19void FretBoard::dataChange() 19void Graph::FretBoard::dataChange()
20{ 20{
21 repaint(true); 21 repaint(true);
22} 22}
23//**************************************************************************** 23//****************************************************************************
24void FretBoard::paintEvent(QPaintEvent* pe) 24void Graph::FretBoard::paintEvent(QPaintEvent* pe)
25{ 25{
26 Q_UNUSED(pe); 26 Q_UNUSED(pe);
27 27
28 int instid=data->getCurrentInstrumentID(); 28 int instid=data->getCurrentInstrumentID();
29 inst=data->getInstrument(instid); 29 inst=data->getInstrument(instid);
30 //qDebug("inst %d is %s",instid,inst.instName().data()); 30 //qDebug("inst %d is %s",instid,inst.instName().data());
31 31
32 QRect mysize=rect(); 32 QRect mysize=rect();
33 33
34 xmargin=(int)(mysize.width()*0.05); 34 xmargin=(int)(mysize.width()*0.05);
35 xmin=2*xmargin; 35 xmin=2*xmargin;
36 xmax=mysize.width()-xmargin; 36 xmax=mysize.width()-xmargin;
37 xwidth=xmax-xmin; 37 xwidth=xmax-xmin;
38 38
39 ymargin=(int)(mysize.height()*0.1); 39 ymargin=(int)(mysize.height()*0.1);
40 ymin=ymargin; 40 ymin=ymargin;
41 ymax=mysize.height()-2*ymargin; 41 ymax=mysize.height()-2*ymargin;
42 yheight=ymax-ymin; 42 yheight=ymax-ymin;
43 43
44 QPainter p(this); 44 QPainter p(this);
45 paintBoard(&p); 45 paintBoard(&p);
46 paintFrets(&p); 46 paintFrets(&p);
47 paintStrings(&p); 47 paintStrings(&p);
48 paintScale(&p); 48 paintScale(&p);
49} 49}
50//**************************************************************************** 50//****************************************************************************
51void FretBoard::resizeEvent(QResizeEvent* re) 51void Graph::FretBoard::resizeEvent(QResizeEvent* re)
52{ 52{
53 Q_UNUSED(re); 53 Q_UNUSED(re);
54} 54}
55//**************************************************************************** 55//****************************************************************************
56void FretBoard::paintBoard(QPainter* p) 56void Graph::FretBoard::paintBoard(QPainter* p)
57{ 57{
58 //debug 58 //debug
59 QColor bgc=QColor(142,138,120); 59 QColor bgc=QColor(142,138,120);
60 p->setPen(QPen(bgc,5)); 60 p->setPen(QPen(bgc,5));
61 p->setBrush(QBrush(bgc)); 61 p->setBrush(QBrush(bgc));
62 p->drawRect(xmin,ymin,xwidth,yheight); 62 p->drawRect(xmin,ymin,xwidth,yheight);
63 63
64} 64}
65//**************************************************************************** 65//****************************************************************************
66void FretBoard::paintFrets(QPainter* p) 66void Graph::FretBoard::paintFrets(QPainter* p)
67{ 67{
68 //draw frets 68 //draw frets
69 p->setPen(fretpen); 69 p->setPen(fretpen);
70 p->setBrush(markerbrush); 70 p->setBrush(markerbrush);
71 fretdist=(double)(xwidth)/(double)(inst.noOfFrets()); 71 fretdist=(double)(xwidth)/(double)(inst.noOfFrets());
72 72
73 int markerwidth = (int)(fretdist/4.0); 73 int markerwidth = (int)(fretdist/4.0);
74 if(markerwidth>5) 74 if(markerwidth>5)
75 markerwidth=5; 75 markerwidth=5;
76 else if(markerwidth<2) 76 else if(markerwidth<2)
77 markerwidth=2; 77 markerwidth=2;
78 78
79 for(int f=0;f<=inst.noOfFrets();f++) 79 for(int f=0;f<=inst.noOfFrets();f++)
80 { 80 {
81 int fretpos=(int)(fretdist*f); 81 int fretpos=(int)(fretdist*f);
82 p->drawLine(fretpos+xmin,ymin,fretpos+xmin,ymax); 82 p->drawLine(fretpos+xmin,ymin,fretpos+xmin,ymax);
83 83
84 int above_octave=f%12; 84 int above_octave=f%12;
85 int octave=(f-above_octave)/12; 85 int octave=(f-above_octave)/12;
86 int marker=f-12*octave; 86 int marker=f-12*octave;
87 87
88 88
89 if(marker==5 || marker==7 || marker==9) 89 if(marker==5 || marker==7 || marker==9)
90 { 90 {
91 p->drawEllipse(fretpos+xmin,ymax+ymargin,markerwidth,markerwidth); 91 p->drawEllipse(fretpos+xmin,ymax+ymargin,markerwidth,markerwidth);
92 } 92 }
93 else if(marker==0 && f!=0) 93 else if(marker==0 && f!=0)
94 { 94 {
95 p->drawEllipse(fretpos+xmin,ymax+ymargin+2*markerwidth,markerwidth,markerwidth); 95 p->drawEllipse(fretpos+xmin,ymax+ymargin+2*markerwidth,markerwidth,markerwidth);
96 p->drawEllipse(fretpos+xmin,ymax+ymargin-2*markerwidth,markerwidth,markerwidth); 96 p->drawEllipse(fretpos+xmin,ymax+ymargin-2*markerwidth,markerwidth,markerwidth);
97 } 97 }
98 98
99 } 99 }
100} 100}
101//**************************************************************************** 101//****************************************************************************
102void FretBoard::paintStrings(QPainter* p) 102void Graph::FretBoard::paintStrings(QPainter* p)
103{ 103{
104 //draw strings 104 //draw strings
105 p->setPen(stringpen); 105 p->setPen(stringpen);
106 106
107 stringdist=(double)(yheight)/(double)(inst.noOfStrings()-1); 107 stringdist=(double)(yheight)/(double)(inst.noOfStrings()-1);
108 for(int s=0;s<inst.noOfStrings();s++) 108 for(int s=0;s<inst.noOfStrings();s++)
109 { 109 {
110 int stringpos=(int)(stringdist*s); 110 int stringpos=(int)(stringdist*s);
111 p->drawLine(xmin,stringpos+ymin,xmax,stringpos+ymin); 111 p->drawLine(xmin,stringpos+ymin,xmax,stringpos+ymin);
112 112
113 int stinglabelid=inst.noOfStrings()-(s+1); 113 int stinglabelid=inst.noOfStrings()-(s+1);
114 QString label=Note::getNameOfNote(inst.string(stinglabelid)); 114 QString label=Note::getNameOfNote(inst.string(stinglabelid));
115 p->drawText(xmargin/2,stringpos+ymin,label); 115 p->drawText(xmargin/2,stringpos+ymin,label);
116 } 116 }
117} 117}
118//**************************************************************************** 118//****************************************************************************
119void FretBoard::paintScale(QPainter* p) 119void Graph::FretBoard::paintScale(QPainter* p)
120{ 120{
121 int dotsize=10; 121 int dotsize=10;
122 int scaleid=data->getCurrentScaleID(); 122 int scaleid=data->getCurrentScaleID();
123 Scale scale=data->getScale(scaleid); 123 Scale scale=data->getScale(scaleid);
124 124
125 int colorstart=255%inst.noOfOctaves(); 125 int colorstart=255%inst.noOfOctaves();
126 int colorintervall=(255-colorstart)/inst.noOfOctaves(); 126 int colorintervall=(255-colorstart)/inst.noOfOctaves();
127 127
128 for(int s=0;s<inst.noOfStrings();s++) 128 for(int s=0;s<inst.noOfStrings();s++)
129 { 129 {
130 int y=(int)(stringdist*s)+ymin; 130 int y=(int)(stringdist*s)+ymin;
131 int stingid=inst.noOfStrings()-(s+1); 131 int stingid=inst.noOfStrings()-(s+1);
132 for(int f=0;f<=inst.noOfFrets();f++) 132 for(int f=0;f<=inst.noOfFrets();f++)
133 { 133 {
134 int note=inst.string(stingid)+f; 134 int note=inst.string(stingid)+f;
135 if(scale.noteInScale(data->getCurrentBaseNote(),note)) 135 if(scale.noteInScale(data->getCurrentBaseNote(),note))
136 { 136 {
137 int x=(int)(fretdist*f)+xmin; 137 int x=(int)(fretdist*f)+xmin;
138 138
139 int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note); 139 int octave=Note::octaveOfBaseNote(data->getCurrentBaseNote(),note);
140 if(octave>5) octave=5; 140 if(octave>5) octave=5;
141 p->setPen(QColor(255,0,0)); 141 p->setPen(QColor(255,0,0));
142 int c=colorstart+octave*colorintervall; 142 int c=colorstart+octave*colorintervall;
143 QColor dotcolor(c,c,255); 143 QColor dotcolor(c,c,255);
144 p->setBrush(dotcolor); 144 p->setBrush(dotcolor);
145 145
146 p->drawEllipse(x-dotsize/2,y-dotsize/2,dotsize,dotsize); 146 p->drawEllipse(x-dotsize/2,y-dotsize/2,dotsize,dotsize);
147 147
148 if(data->isDrawNames()) 148 if(data->isDrawNames())
149 { 149 {
150 p->setPen(QColor(255,155,0)); 150 p->setPen(QColor(255,155,0));
151 p->drawText(x-dotsize/2,y-dotsize/2,Note::getNameOfNote(note)); 151 p->drawText(x-dotsize/2,y-dotsize/2,Note::getNameOfNote(note));
152 } 152 }
153 153
154 } 154 }
155 } 155 }
156 } 156 }
157} 157}
158//**************************************************************************** 158//****************************************************************************
159//**************************************************************************** 159//****************************************************************************
diff --git a/noncore/multimedia/tonleiter/fretboard.h b/noncore/multimedia/tonleiter/fretboard.h
index eb509b0..458c733 100644
--- a/noncore/multimedia/tonleiter/fretboard.h
+++ b/noncore/multimedia/tonleiter/fretboard.h
@@ -1,54 +1,56 @@
1#ifndef TONLEITER_FRET_BOARD_H 1#ifndef TONLEITER_FRET_BOARD_H
2#define TONLEITER_FRET_BOARD_H 2#define TONLEITER_FRET_BOARD_H
3 3
4#include <qbrush.h> 4#include <qbrush.h>
5#include <qpen.h> 5#include <qpen.h>
6#include <qvaluelist.h> 6#include <qvaluelist.h>
7#include <qwidget.h> 7#include <qwidget.h>
8 8
9 9
10#include "tonleiterdata.h" 10#include "tonleiterdata.h"
11 11
12class FretBoard : public QWidget 12using namespace Data;
13
14namespace Graph
13{ 15{
14 Q_OBJECT 16 class FretBoard : public QWidget
15private: 17 {
16 TonleiterData* data; 18 Q_OBJECT
17 19 private:
18 QPen fretpen; 20 TonleiterData* data;
19 QBrush markerbrush; 21
20 QPen stringpen; 22 QPen fretpen;
21 23 QBrush markerbrush;
22 Instrument inst; 24 QPen stringpen;
23 25
24 int xmargin; 26 Instrument inst;
25 int xmin; 27
26 int xmax; 28 int xmargin;
27 int xwidth; 29 int xmin;
28 30 int xmax;
29 int ymargin; 31 int xwidth;
30 int ymin; 32
31 int ymax; 33 int ymargin;
32 int yheight; 34 int ymin;
33 35 int ymax;
34 double fretdist; 36 int yheight;
35 double stringdist; 37
36 38 double fretdist;
37public: 39 double stringdist;
38 FretBoard(TonleiterData* data,QWidget* parent,const char* name="FretBoard",WFlags f=0); 40
39 virtual ~FretBoard(); 41 public:
40private slots: 42 FretBoard(TonleiterData* data,QWidget* parent,const char* name="FretBoard",WFlags f=0);
41 void dataChange(); 43 virtual ~FretBoard();
42private: 44 private slots:
43 void paintEvent(QPaintEvent* pe); 45 void dataChange();
44 void resizeEvent(QResizeEvent* re); 46 private:
45 //void mousePressEvent(QMouseEvent* mpe); 47 void paintEvent(QPaintEvent* pe);
46 //void mouseMoveEvent(QMouseEvent* mme); 48 void resizeEvent(QResizeEvent* re);
47 //void mouseReleaseEvent(QMouseEvent* mre); 49 void paintBoard(QPainter* p);
48 void paintBoard(QPainter* p); 50 void paintFrets(QPainter* p);
49 void paintFrets(QPainter* p); 51 void paintStrings(QPainter* p);
50 void paintStrings(QPainter* p); 52 void paintScale(QPainter* p);
51 void paintScale(QPainter* p); 53 };
52}; 54};
53 55
54#endif //TONLEITER_FRET_BOARD_H 56#endif //TONLEITER_FRET_BOARD_H
diff --git a/noncore/multimedia/tonleiter/mainwidget.cpp b/noncore/multimedia/tonleiter/mainwidget.cpp
index 0a20b9e..f09207b 100644
--- a/noncore/multimedia/tonleiter/mainwidget.cpp
+++ b/noncore/multimedia/tonleiter/mainwidget.cpp
@@ -1,28 +1,28 @@
1#include "mainwidget.h" 1#include "mainwidget.h"
2 2
3#include <qwidget.h> 3#include <qwidget.h>
4#include <qlayout.h> 4#include <qlayout.h>
5 5
6MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) 6MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f)
7:QMainWindow(parent,name,f) 7:QMainWindow(parent,name,f)
8{ 8{
9 setCaption("Tonleiter"); 9 setCaption("Tonleiter");
10 data=new TonleiterData(this); 10 data=new Data::TonleiterData(this);
11 11
12 QWidget* mainwidget=new QWidget(this,"mainwidget"); 12 QWidget* mainwidget=new QWidget(this,"mainwidget");
13 setCentralWidget(mainwidget); 13 setCentralWidget(mainwidget);
14 QBoxLayout* mainlayout=new QBoxLayout(mainwidget,QBoxLayout::TopToBottom); 14 QBoxLayout* mainlayout=new QBoxLayout(mainwidget,QBoxLayout::TopToBottom);
15 15
16 menuwidget=new MenuWidget(data,mainwidget); 16 menuwidget=new Menu::MenuWidget(data,mainwidget);
17 mainlayout->addWidget(menuwidget); 17 mainlayout->addWidget(menuwidget);
18 18
19 fretboard=new FretBoard(data,mainwidget); 19 fretboard=new Graph::FretBoard(data,mainwidget);
20 mainlayout->addWidget(fretboard); 20 mainlayout->addWidget(fretboard);
21 21
22} 22}
23//**************************************************************************** 23//****************************************************************************
24MainWidget::~MainWidget() 24MainWidget::~MainWidget()
25{ 25{
26} 26}
27//**************************************************************************** 27//****************************************************************************
28//**************************************************************************** 28//****************************************************************************
diff --git a/noncore/multimedia/tonleiter/mainwidget.h b/noncore/multimedia/tonleiter/mainwidget.h
index 71b5ba9..9bb593c 100644
--- a/noncore/multimedia/tonleiter/mainwidget.h
+++ b/noncore/multimedia/tonleiter/mainwidget.h
@@ -1,22 +1,22 @@
1#ifndef TONLEITER_MAINWIDGET_H 1#ifndef TONLEITER_MAINWIDGET_H
2#define TONLEITER_MAINWIDGET_H 2#define TONLEITER_MAINWIDGET_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5 5
6#include "fretboard.h" 6#include "fretboard.h"
7#include "menuwidget.h" 7#include "menuwidget.h"
8#include "tonleiterdata.h" 8#include "tonleiterdata.h"
9 9
10class MainWidget : public QMainWindow 10class MainWidget : public QMainWindow
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13private: 13private:
14 TonleiterData* data; 14 Data::TonleiterData* data;
15 MenuWidget* menuwidget; 15 Menu::MenuWidget* menuwidget;
16 FretBoard* fretboard; 16 Graph::FretBoard* fretboard;
17public: 17public:
18 MainWidget(QWidget* parent=0,const char* name="MainWidget",WFlags f=0); 18 MainWidget(QWidget* parent=0,const char* name="MainWidget",WFlags f=0);
19 virtual ~MainWidget(); 19 virtual ~MainWidget();
20}; 20};
21 21
22#endif //TONLEITER_MAINWIDGET_H 22#endif //TONLEITER_MAINWIDGET_H
diff --git a/noncore/multimedia/tonleiter/menuwidget.cpp b/noncore/multimedia/tonleiter/menuwidget.cpp
index 3dfa09d..1e3742c 100644
--- a/noncore/multimedia/tonleiter/menuwidget.cpp
+++ b/noncore/multimedia/tonleiter/menuwidget.cpp
@@ -1,72 +1,89 @@
1#include "menuwidget.h" 1#include "menuwidget.h"
2 2
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qlayout.h> 4#include <qlayout.h>
5 5
6MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) 6#include "editinst.h"
7#include "editscale.h"
8
9Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f)
7:QWidget(parent,name,f),data(data) 10:QWidget(parent,name,f),data(data)
8{ 11{
9 QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout"); 12 QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout");
10 13
11 QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel"); 14 QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel");
12 layout->addWidget(instLabel,0,0); 15 layout->addWidget(instLabel,0,0);
13 boxInst=new QComboBox(this,"boxInst"); 16 boxInst=new QComboBox(this,"boxInst");
14 connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int))); 17 connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int)));
15 layout->addWidget(boxInst,0,1); 18 layout->addWidget(boxInst,0,1);
16 editInst=new QPushButton(tr("Edit"),this,"editInst"); 19 editInst=new QPushButton(tr("Edit"),this,"editInst");
20 connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed()));
17 layout->addWidget(editInst,0,2); 21 layout->addWidget(editInst,0,2);
18 22
19 QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel"); 23 QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel");
20 layout->addWidget(noteLabel,1,0); 24 layout->addWidget(noteLabel,1,0);
21 boxNote=new QComboBox(this,"boxNote"); 25 boxNote=new QComboBox(this,"boxNote");
22 connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); 26 connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int)));
23 layout->addWidget(boxNote,1,1); 27 layout->addWidget(boxNote,1,1);
24 for(int a=0;a<12;a++) 28 for(int a=0;a<12;a++)
25 boxNote->insertItem(Note::notenames[a],a); 29 boxNote->insertItem(Note::notenames[a],a);
26 boxNote->setCurrentItem(data->getCurrentBaseNote()); 30 boxNote->setCurrentItem(data->getCurrentBaseNote());
27 noteCheck=new QCheckBox(tr("show"),this,"noteCheck"); 31 noteCheck=new QCheckBox(tr("show"),this,"noteCheck");
28 noteCheck->setChecked(data->isDrawNames()); 32 noteCheck->setChecked(data->isDrawNames());
29 connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool))); 33 connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool)));
30 layout->addWidget(noteCheck,1,2); 34 layout->addWidget(noteCheck,1,2);
31 35
32 QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel"); 36 QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel");
33 layout->addWidget(scaleLabel,2,0); 37 layout->addWidget(scaleLabel,2,0);
34 boxScale=new QComboBox(this,"boxScale"); 38 boxScale=new QComboBox(this,"boxScale");
35 connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); 39 connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int)));
36 layout->addWidget(boxScale,2,1); 40 layout->addWidget(boxScale,2,1);
37 editScale=new QPushButton(tr("Edit"),this,"editScale"); 41 editScale=new QPushButton(tr("Edit"),this,"editScale");
42 connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed()));
38 layout->addWidget(editScale,2,2); 43 layout->addWidget(editScale,2,2);
39 44
40 updateBoxes(); 45 updateBoxes();
41 46
42} 47}
43//**************************************************************************** 48//****************************************************************************
44MenuWidget::~MenuWidget() 49Menu::MenuWidget::~MenuWidget()
50{
51}
52//****************************************************************************
53void Menu::MenuWidget::editInstPressed()
54{
55 InstEditDialog* instdialog=new InstEditDialog(data,this);
56 instdialog->exec();
57}
58//****************************************************************************
59void Menu::MenuWidget::editScalePressed()
45{ 60{
61 ScaleEditDialog* scaledialog=new ScaleEditDialog(data,this);
62 scaledialog->exec();
46} 63}
47//**************************************************************************** 64//****************************************************************************
48void MenuWidget::updateBoxes() 65void Menu::MenuWidget::updateBoxes()
49{ 66{
50 boxInst->clear(); 67 boxInst->clear();
51 68
52 for(int i=0;i<data->noOfInstruments();i++) 69 for(int i=0;i<data->noOfInstruments();i++)
53 { 70 {
54 Instrument inst=data->getInstrument(i); 71 Instrument inst=data->getInstrument(i);
55 QString name=inst.instName(); 72 QString name=inst.instName();
56 if(name.isNull()) continue; 73 if(name.isNull()) continue;
57 boxInst->insertItem(name,i); 74 boxInst->insertItem(name,i);
58 } 75 }
59 boxInst->setCurrentItem(data->getCurrentInstrumentID()); 76 boxInst->setCurrentItem(data->getCurrentInstrumentID());
60 77
61 boxScale->clear(); 78 boxScale->clear();
62 for(int s=0;s<data->noOfScales();s++) 79 for(int s=0;s<data->noOfScales();s++)
63 { 80 {
64 Scale scale=data->getScale(s); 81 Scale scale=data->getScale(s);
65 QString name=scale.scaleName(); 82 QString name=scale.scaleName();
66 if(name.isNull()) continue; 83 if(name.isNull()) continue;
67 boxScale->insertItem(name,s); 84 boxScale->insertItem(name,s);
68 } 85 }
69 boxScale->setCurrentItem(data->getCurrentScaleID()); 86 boxScale->setCurrentItem(data->getCurrentScaleID());
70} 87}
71//**************************************************************************** 88//****************************************************************************
72//**************************************************************************** 89//****************************************************************************
diff --git a/noncore/multimedia/tonleiter/menuwidget.h b/noncore/multimedia/tonleiter/menuwidget.h
index 2635f8a..044a3e6 100644
--- a/noncore/multimedia/tonleiter/menuwidget.h
+++ b/noncore/multimedia/tonleiter/menuwidget.h
@@ -1,30 +1,37 @@
1#ifndef TONLEITER_MENU_WIDGET_H 1#ifndef TONLEITER_MENU_WIDGET_H
2#define TONLEITER_MENU_WIDGET_H 2#define TONLEITER_MENU_WIDGET_H
3 3
4#include <qcheckbox.h> 4#include <qcheckbox.h>
5#include <qcombobox.h> 5#include <qcombobox.h>
6#include <qpushbutton.h> 6#include <qpushbutton.h>
7#include <qwidget.h> 7#include <qwidget.h>
8#include <qlabel.h> 8#include <qlabel.h>
9 9
10#include "tonleiterdata.h" 10#include "tonleiterdata.h"
11 11
12class MenuWidget : public QWidget 12using namespace Data;
13namespace Menu
13{ 14{
14 Q_OBJECT 15 class MenuWidget : public QWidget
15private: 16 {
16 TonleiterData* data; 17 Q_OBJECT
17 QComboBox* boxInst; 18 private:
18 QPushButton* editInst; 19 TonleiterData* data;
19 QComboBox* boxNote; 20 QComboBox* boxInst;
20 QCheckBox* noteCheck; 21 QPushButton* editInst;
21 QComboBox* boxScale; 22 QComboBox* boxNote;
22 QPushButton* editScale; 23 QCheckBox* noteCheck;
23public: 24 QComboBox* boxScale;
24 MenuWidget(TonleiterData* data,QWidget* parent,const char* name="MenuWidget",WFlags f=0); 25 QPushButton* editScale;
25 ~MenuWidget(); 26 public:
26public slots: 27 MenuWidget(TonleiterData* data,QWidget* parent,const char* name="MenuWidget",WFlags f=0);
27 void updateBoxes(); 28 ~MenuWidget();
29 private slots:
30 void editInstPressed();
31 void editScalePressed();
32 public slots:
33 void updateBoxes();
34 };
28}; 35};
29 36
30#endif //TONLEITER_MENU_WIDGET_H 37#endif //TONLEITER_MENU_WIDGET_H
diff --git a/noncore/multimedia/tonleiter/tonleiter.pro b/noncore/multimedia/tonleiter/tonleiter.pro
index bf19c3a..2b0a798 100644
--- a/noncore/multimedia/tonleiter/tonleiter.pro
+++ b/noncore/multimedia/tonleiter/tonleiter.pro
@@ -1,13 +1,13 @@
1TEMPLATE = app 1TEMPLATE = app
2#CONFIG = qt warn_on debug 2#CONFIG = qt warn_on debug
3CONFIG = qt warn_on release 3CONFIG = qt warn_on release
4HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h 4HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editscale.h
5SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp 5SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editscale.cpp
6INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
7DEPENDPATH += $(OPIEDIR)/include 7DEPENDPATH += $(OPIEDIR)/include
8LIBS += -lqpe 8LIBS += -lqpe
9INTERFACES = 9INTERFACES =
10TARGET = tonleiter 10TARGET = tonleiter
11DESTDIR = $(OPIEDIR)/bin 11DESTDIR = $(OPIEDIR)/bin
12#TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti 12#TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti
13include ( $(OPIEDIR)/include.pro ) 13include ( $(OPIEDIR)/include.pro )
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,215 +1,198 @@
1#include "tonleiterdata.h" 1#include "tonleiterdata.h"
2 2
3#include <qpe/config.h> 3#include <qpe/config.h>
4 4
5using namespace Data;
6
7
5TonleiterData::TonleiterData(QObject* parent) 8TonleiterData::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//****************************************************************************
12TonleiterData::~TonleiterData() 15TonleiterData::~TonleiterData()
13{ 16{
14 saveData(); 17 saveData();
15} 18}
16//**************************************************************************** 19//****************************************************************************
17void TonleiterData::setCurrentInstrumetID(int id) 20void 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//****************************************************************************
26void TonleiterData::setCurrentScaleID(int id) 29void 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//****************************************************************************
35void TonleiterData::setCurrentNote(int id) 38void 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//****************************************************************************
44void TonleiterData::setDrawNames(bool dn) 47void TonleiterData::setDrawNames(bool dn)
45{ 48{
46 drawnames=dn; 49 drawnames=dn;
47 emit dataChange(); 50 emit dataChange();
48} 51}
49//**************************************************************************** 52//****************************************************************************
50void TonleiterData::loadData() 53void 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++)
120 halftones.append(scalelist[ht].toInt()); 103 halftones.append(scalelist[ht].toInt());
121 scales.append(Scale(scalelist[0],halftones)); 104 scales.append(Scale(scalelist[0],halftones));
122 } 105 }
123 106
124} 107}
125//**************************************************************************** 108//****************************************************************************
126void TonleiterData::saveData() 109void TonleiterData::saveData()
127{ 110{
128 Config save("Tonleiter"); 111 Config save("Tonleiter");
129 save.setGroup("General"); 112 save.setGroup("General");
130 save.writeEntry("currentNote",currentNote); 113 save.writeEntry("currentNote",currentNote);
131 save.writeEntry("drawnames",drawnames); 114 save.writeEntry("drawnames",drawnames);
132 save.writeEntry("currentInstrumentID",currentInstrumentID); 115 save.writeEntry("currentInstrumentID",currentInstrumentID);
133 save.writeEntry("currentScaleID",currentScaleID); 116 save.writeEntry("currentScaleID",currentScaleID);
134 117
135 save.setGroup("Instrument"); 118 save.setGroup("Instrument");
136 save.writeEntry("noOfInstruments",noOfInstruments()); 119 save.writeEntry("noOfInstruments",noOfInstruments());
137 for(int i=0;i<noOfInstruments();i++) 120 for(int i=0;i<noOfInstruments();i++)
138 { 121 {
139 QStringList instlist; 122 QStringList instlist;
140 Instrument inst=getInstrument(i); 123 Instrument inst=getInstrument(i);
141 instlist.append(inst.instName()); 124 instlist.append(inst.instName());
142 instlist.append(QString::number(inst.noOfFrets())); 125 instlist.append(QString::number(inst.noOfFrets()));
143 for(int st=0;st<inst.noOfStrings();st++) 126 for(int st=0;st<inst.noOfStrings();st++)
144 instlist.append(QString::number(inst.string(st))); 127 instlist.append(QString::number(inst.string(st)));
145 save.writeEntry("Inst"+QString::number(i),instlist,';'); 128 save.writeEntry("Inst"+QString::number(i),instlist,';');
146 } 129 }
147 130
148 save.setGroup("Scale"); 131 save.setGroup("Scale");
149 save.writeEntry("noOfScales",noOfScales()); 132 save.writeEntry("noOfScales",noOfScales());
150 for(int s=0;s<noOfScales();s++) 133 for(int s=0;s<noOfScales();s++)
151 { 134 {
152 QStringList scalelist; 135 QStringList scalelist;
153 Scale scale=getScale(s); 136 Scale scale=getScale(s);
154 scalelist.append(scale.scaleName()); 137 scalelist.append(scale.scaleName());
155 for(int ht=0;ht<scale.noOfHaltones();ht++) 138 for(int ht=0;ht<scale.noOfHaltones();ht++)
156 scalelist.append(QString::number(scale.getHalfTone(ht))); 139 scalelist.append(QString::number(scale.getHalfTone(ht)));
157 save.writeEntry("Scale"+QString::number(s),scalelist,';'); 140 save.writeEntry("Scale"+QString::number(s),scalelist,';');
158 } 141 }
159} 142}
160//**************************************************************************** 143//****************************************************************************
161int TonleiterData::noOfInstruments() 144int TonleiterData::noOfInstruments()
162{ 145{
163 return (int)instruments.count(); 146 return (int)instruments.count();
164} 147}
165//**************************************************************************** 148//****************************************************************************
166Instrument TonleiterData::getInstrument(int id) 149Instrument TonleiterData::getInstrument(int id)
167{ 150{
168 if(id>=0 && id<noOfInstruments()) 151 if(id>=0 && id<noOfInstruments())
169 return instruments[id]; 152 return instruments[id];
170 else 153 else
171 { 154 {
172 qDebug("undefined insrtument %d of %d",id,instruments.count()); 155 qDebug("undefined insrtument %d of %d",id,instruments.count());
173 return Instrument(); 156 return Instrument();
174 } 157 }
175 158
176} 159}
177//**************************************************************************** 160//****************************************************************************
178int TonleiterData::getCurrentInstrumentID() 161int TonleiterData::getCurrentInstrumentID()
179{ 162{
180 return currentInstrumentID; 163 return currentInstrumentID;
181} 164}
182//**************************************************************************** 165//****************************************************************************
183int TonleiterData::noOfScales() 166int TonleiterData::noOfScales()
184{ 167{
185 return (int)scales.count(); 168 return (int)scales.count();
186} 169}
187//**************************************************************************** 170//****************************************************************************
188Scale TonleiterData::getScale(int id) 171Scale TonleiterData::getScale(int id)
189{ 172{
190 if(id>=0 && id<noOfScales()) 173 if(id>=0 && id<noOfScales())
191 return scales[id]; 174 return scales[id];
192 else 175 else
193 { 176 {
194 qDebug("Undefined scale"); 177 qDebug("Undefined scale");
195 return Scale(); 178 return Scale();
196 } 179 }
197} 180}
198//**************************************************************************** 181//****************************************************************************
199int TonleiterData::getCurrentScaleID() 182int TonleiterData::getCurrentScaleID()
200{ 183{
201 return currentScaleID; 184 return currentScaleID;
202} 185}
203//**************************************************************************** 186//****************************************************************************
204int TonleiterData::getCurrentBaseNote() 187int TonleiterData::getCurrentBaseNote()
205{ 188{
206 return currentNote; 189 return currentNote;
207} 190}
208//**************************************************************************** 191//****************************************************************************
209bool TonleiterData::isDrawNames() 192bool TonleiterData::isDrawNames()
210{ 193{
211 return drawnames; 194 return drawnames;
212} 195}
213//**************************************************************************** 196//****************************************************************************
214//**************************************************************************** 197//****************************************************************************
215 198
diff --git a/noncore/multimedia/tonleiter/tonleiterdata.h b/noncore/multimedia/tonleiter/tonleiterdata.h
index a5e6884..71d05fd 100644
--- a/noncore/multimedia/tonleiter/tonleiterdata.h
+++ b/noncore/multimedia/tonleiter/tonleiterdata.h
@@ -1,46 +1,49 @@
1#ifndef TONLEITER_DATA_H 1#ifndef TONLEITER_DATA_H
2#define TONLEITER_DATA_H 2#define TONLEITER_DATA_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5 5
6#include "tonleiterdatahelper.h" 6#include "tonleiterdatahelper.h"
7 7
8class TonleiterData : public QObject 8namespace Data
9{ 9{
10 Q_OBJECT 10 class TonleiterData : public QObject
11private: 11 {
12 QValueList<Instrument> instruments; 12 Q_OBJECT
13 int currentInstrumentID; 13 private:
14 14 QValueList<Instrument> instruments;
15 QValueList<Scale> scales; 15 int currentInstrumentID;
16 int currentScaleID; 16
17 17 QValueList<Scale> scales;
18 int currentNote; 18 int currentScaleID;
19 bool drawnames; 19
20public: 20 int currentNote;
21 TonleiterData(QObject* parent); 21 bool drawnames;
22 ~TonleiterData(); 22 public:
23signals: 23 TonleiterData(QObject* parent);
24 void dataChange(); 24 ~TonleiterData();
25public slots: 25 signals:
26 void setCurrentInstrumetID(int id); 26 void dataChange();
27 void setCurrentScaleID(int id); 27 public slots:
28 void setCurrentNote(int id); 28 void setCurrentInstrumetID(int id);
29 void setDrawNames(bool dn); 29 void setCurrentScaleID(int id);
30private: 30 void setCurrentNote(int id);
31 void loadData(); 31 void setDrawNames(bool dn);
32 void saveData(); 32 private:
33public: 33 void loadData();
34 int noOfInstruments(); 34 void saveData();
35 Instrument getInstrument(int id); 35 public:
36 int getCurrentInstrumentID(); 36 int noOfInstruments();
37 37 Instrument getInstrument(int id);
38 int noOfScales(); 38 int getCurrentInstrumentID();
39 Scale getScale(int id); 39
40 int getCurrentScaleID(); 40 int noOfScales();
41 41 Scale getScale(int id);
42 int getCurrentBaseNote(); 42 int getCurrentScaleID();
43 bool isDrawNames(); 43
44 int getCurrentBaseNote();
45 bool isDrawNames();
46 };
44}; 47};
45 48
46#endif //TONLEITER_DATA_H 49#endif //TONLEITER_DATA_H
diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp
index c52e0da..5714cea 100644
--- a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp
+++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp
@@ -1,131 +1,133 @@
1#include "tonleiterdatahelper.h" 1#include "tonleiterdatahelper.h"
2 2
3using namespace Data;
4
3int Note::getOctaveOfNote(int note) 5int Note::getOctaveOfNote(int note)
4{ 6{
5 int remain=note%12; 7 int remain=note%12;
6 return (note-remain)/12; 8 return (note-remain)/12;
7} 9}
8//**************************************************************************** 10//****************************************************************************
9QString Note::getNameOfNote(int note) 11QString Note::getNameOfNote(int note)
10{ 12{
11 int octave=getOctaveOfNote(note); 13 int octave=getOctaveOfNote(note);
12 return notenames[note-12*octave]; 14 return notenames[note-12*octave];
13} 15}
14//**************************************************************************** 16//****************************************************************************
15int Note::getNoteFromName(QString name,int octave) 17int Note::getNoteFromName(QString name,int octave)
16{ 18{
17 int notevalue=0; 19 int notevalue=0;
18 for(int a=0;a<12;a++) 20 for(int a=0;a<12;a++)
19 { 21 {
20 if(name==notenames[a]) 22 if(name==notenames[a])
21 { 23 {
22 notevalue=a; 24 notevalue=a;
23 break; 25 break;
24 } 26 }
25 } 27 }
26 return notevalue+12*octave; 28 return notevalue+12*octave;
27} 29}
28//**************************************************************************** 30//****************************************************************************
29int Note::octaveOfBaseNote(int base,int note) 31int Note::octaveOfBaseNote(int base,int note)
30{ 32{
31 int normnote = (note>=base) ? note-base : (12-base)+note; 33 int normnote = (note>=base) ? note-base : (12-base)+note;
32 int octave=getOctaveOfNote(normnote); 34 int octave=getOctaveOfNote(normnote);
33 //qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave); 35 //qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave);
34 return octave; 36 return octave;
35} 37}
36//**************************************************************************** 38//****************************************************************************
37//**************************************************************************** 39//****************************************************************************
38Instrument::Instrument() 40Instrument::Instrument()
39{ 41{
40 name="UNDEFINED"; 42 name="UNDEFINED";
41 frets=0; 43 frets=0;
42} 44}
43//**************************************************************************** 45//****************************************************************************
44Instrument::Instrument(QString name,int frets,QValueList<int> strings) 46Instrument::Instrument(QString name,int frets,QValueList<int> strings)
45:name(name),frets(frets),strings(strings) 47:name(name),frets(frets),strings(strings)
46{ 48{
47} 49}
48//**************************************************************************** 50//****************************************************************************
49Instrument::~Instrument() 51Instrument::~Instrument()
50{ 52{
51} 53}
52//**************************************************************************** 54//****************************************************************************
53int Instrument::noOfStrings() 55int Instrument::noOfStrings()
54{ 56{
55 return (int)strings.count(); 57 return (int)strings.count();
56} 58}
57//**************************************************************************** 59//****************************************************************************
58int Instrument::noOfFrets() 60int Instrument::noOfFrets()
59{ 61{
60 return frets; 62 return frets;
61} 63}
62//**************************************************************************** 64//****************************************************************************
63QString Instrument::instName() 65QString Instrument::instName()
64{ 66{
65 return name; 67 return name;
66} 68}
67//**************************************************************************** 69//****************************************************************************
68int Instrument::string(int id) 70int Instrument::string(int id)
69{ 71{
70 return strings[id]; 72 return strings[id];
71} 73}
72//**************************************************************************** 74//****************************************************************************
73int Instrument::noOfOctaves() 75int Instrument::noOfOctaves()
74{ 76{
75 int lowest=strings[0]; 77 int lowest=strings[0];
76 int highest=strings[strings.count()-1]+frets; 78 int highest=strings[strings.count()-1]+frets;
77 return (int)((highest-lowest)/12.0); 79 return (int)((highest-lowest)/12.0);
78} 80}
79//**************************************************************************** 81//****************************************************************************
80//**************************************************************************** 82//****************************************************************************
81Scale::Scale() 83Scale::Scale()
82{ 84{
83 name="UNDEFINED"; 85 name="UNDEFINED";
84} 86}
85//**************************************************************************** 87//****************************************************************************
86Scale::Scale(QString name,QValueList<int> halftones) 88Scale::Scale(QString name,QValueList<int> halftones)
87:name(name),halftones(halftones) 89:name(name),halftones(halftones)
88{ 90{
89} 91}
90//**************************************************************************** 92//****************************************************************************
91Scale::~Scale() 93Scale::~Scale()
92{ 94{
93} 95}
94//**************************************************************************** 96//****************************************************************************
95int Scale::noOfHaltones() 97int Scale::noOfHaltones()
96{ 98{
97 return (int)halftones.count(); 99 return (int)halftones.count();
98} 100}
99//**************************************************************************** 101//****************************************************************************
100int Scale::getHalfTone(int id) 102int Scale::getHalfTone(int id)
101{ 103{
102 if(id>=0 && id<noOfHaltones()) 104 if(id>=0 && id<noOfHaltones())
103 return halftones[id]; 105 return halftones[id];
104 else 106 else
105 return 0; 107 return 0;
106} 108}
107//**************************************************************************** 109//****************************************************************************
108QString Scale::scaleName() 110QString Scale::scaleName()
109{ 111{
110 return name; 112 return name;
111} 113}
112//**************************************************************************** 114//****************************************************************************
113bool Scale::noteInScale(int base,int note) 115bool Scale::noteInScale(int base,int note)
114{ 116{
115 int octave=Note::getOctaveOfNote(note); 117 int octave=Note::getOctaveOfNote(note);
116 note-=12*octave; 118 note-=12*octave;
117 int normnote = (note>=base) ? note-base : (12-base)+note; 119 int normnote = (note>=base) ? note-base : (12-base)+note;
118 120
119 if(halftones.contains(normnote)>0) 121 if(halftones.contains(normnote)>0)
120 { 122 {
121 //qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote); 123 //qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote);
122 return true; 124 return true;
123 } 125 }
124 else 126 else
125 { 127 {
126 //qDebug("BAD : base : %d, note %d -> norm %d",base,note,normnote); 128 //qDebug("BAD : base : %d, note %d -> norm %d",base,note,normnote);
127 return false; 129 return false;
128 } 130 }
129} 131}
130//**************************************************************************** 132//****************************************************************************
131//**************************************************************************** 133//****************************************************************************
diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.h b/noncore/multimedia/tonleiter/tonleiterdatahelper.h
index 94895ea..b79162a 100644
--- a/noncore/multimedia/tonleiter/tonleiterdatahelper.h
+++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.h
@@ -1,53 +1,55 @@
1#ifndef TONLEITER_DATA_HELPER_H 1#ifndef TONLEITER_DATA_HELPER_H
2#define TONLEITER_DATA_HELPER_H 2#define TONLEITER_DATA_HELPER_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qvaluelist.h> 5#include <qvaluelist.h>
6 6
7namespace Note 7namespace Data
8{ 8{
9 const QString notenames[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"}; 9 namespace Note
10 10 {
11 int getOctaveOfNote(int note); 11 const QString notenames[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
12 QString getNameOfNote(int note); 12
13 int getNoteFromName(QString name,int octave); 13 int getOctaveOfNote(int note);
14 int octaveOfBaseNote(int base,int note); 14 QString getNameOfNote(int note);
15}; 15 int getNoteFromName(QString name,int octave);
16 16 int octaveOfBaseNote(int base,int note);
17class Instrument 17 };
18{ 18
19private: 19 class Instrument
20 QString name; 20 {
21 int frets; 21 private:
22 QValueList<int> strings; 22 QString name;
23public: 23 int frets;
24 Instrument(); 24 QValueList<int> strings;
25 Instrument(QString name,int frets,QValueList<int> strings); 25 public:
26 ~Instrument(); 26 Instrument();
27public: 27 Instrument(QString name,int frets,QValueList<int> strings);
28 int noOfStrings(); 28 ~Instrument();
29 int noOfFrets(); 29 public:
30 QString instName(); 30 int noOfStrings();
31 int string(int id); 31 int noOfFrets();
32 int noOfOctaves(); 32 QString instName();
33 int string(int id);
34 int noOfOctaves();
35 };
36
37 class Scale
38 {
39 private:
40 QValueList<int> halftones;
41 QString name;
42 public:
43 Scale();
44 Scale(QString name,QValueList<int> halftones);
45 ~Scale();
46 public:
47 int noOfHaltones();
48 int getHalfTone(int id);
49 QString scaleName();
50 bool noteInScale(int base,int note);
51 };
33}; 52};
34 53
35class Scale
36{
37private:
38 QValueList<int> halftones;
39 QString name;
40public:
41 Scale();
42 Scale(QString name,QValueList<int> halftones);
43 ~Scale();
44public:
45 int noOfHaltones();
46 int getHalfTone(int id);
47 QString scaleName();
48 bool noteInScale(int base,int note);
49};
50
51
52#endif //TONLEITER_DATA_HELPER_H 54#endif //TONLEITER_DATA_HELPER_H
53 55