author | waspe <waspe> | 2003-11-20 19:34:08 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-11-20 19:34:08 (UTC) |
commit | e6a5ed6de7e821a070d571045ff063f8c41b0b79 (patch) (side-by-side diff) | |
tree | 8455d7bf537cf804337b6c03b28f891ee3f286ce | |
parent | f43e28fe8f226039d96ebda4e6c4d26e4f3320ba (diff) | |
download | opie-e6a5ed6de7e821a070d571045ff063f8c41b0b79.zip opie-e6a5ed6de7e821a070d571045ff063f8c41b0b79.tar.gz opie-e6a5ed6de7e821a070d571045ff063f8c41b0b79.tar.bz2 |
added preliminary edit dialogs
default config added
-rw-r--r-- | noncore/multimedia/tonleiter/editinst.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editinst.h | 23 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editscale.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editscale.h | 23 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/fretboard.cpp | 18 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/fretboard.h | 8 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/mainwidget.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/mainwidget.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/menuwidget.cpp | 23 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/menuwidget.h | 7 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiter.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdata.cpp | 67 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdata.h | 3 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdatahelper.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdatahelper.h | 4 |
15 files changed, 156 insertions, 66 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 @@ +#include "editinst.h" + +Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) +:QDialog(parent,name,true,0),data(data) +{ + setCaption("Tonleiter::"+tr("Instrument")); + showMaximized(); +} +//**************************************************************************** +Menu::InstEditDialog::~InstEditDialog() +{ +} +//**************************************************************************** +//**************************************************************************** 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 @@ +#ifndef TONLEITER_EDIT_INSTRUMENT_DIALOG_H +#define TONLEITER_EDIT_INSTRUMENT_DIALOG_H + +#include <qdialog.h> + +#include "tonleiterdata.h" + +using namespace Data; + +namespace Menu +{ + class InstEditDialog : public QDialog + { + Q_OBJECT + private: + TonleiterData* data; + public: + InstEditDialog(TonleiterData* data,QWidget* parent,const char* name="InstEditDialog"); + ~InstEditDialog(); + }; +}; + +#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 @@ +#include "editscale.h" + +Menu::ScaleEditDialog::ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name) +:QDialog(parent,name,true,0),data(data) +{ + setCaption("Tonleiter::"+tr("Scale")); + showMaximized(); +} +//**************************************************************************** +Menu::ScaleEditDialog::~ScaleEditDialog() +{ +} +//**************************************************************************** +//**************************************************************************** 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 @@ +#ifndef TONLEITER_EDIT_SCALE_DIALOG_H +#define TONLEITER_EDIT_SCALE_DIALOG_H + +#include <qdialog.h> + +#include "tonleiterdata.h" + +using namespace Data; + +namespace Menu +{ + class ScaleEditDialog : public QDialog + { + Q_OBJECT + private: + TonleiterData* data; + public: + ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name="ScaleEditDialog"); + ~ScaleEditDialog(); + }; +}; + +#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,36 +1,36 @@ #include "fretboard.h" #include <qpainter.h> -FretBoard::FretBoard(TonleiterData* data,QWidget* parent,const char* name,WFlags f) +Graph::FretBoard::FretBoard(TonleiterData* data,QWidget* parent,const char* name,WFlags f) :QWidget(parent,name,f),data(data) { setBackgroundColor(QColor(0,0,0)); fretpen=QPen(QColor(155,155,155),0); markerbrush=QBrush(QColor(155,155,155)); stringpen=QPen(QColor(255,255,255),3); connect(data,SIGNAL(dataChange()),this,SLOT(dataChange())); } //**************************************************************************** -FretBoard::~FretBoard() +Graph::FretBoard::~FretBoard() { } //**************************************************************************** -void FretBoard::dataChange() +void Graph::FretBoard::dataChange() { repaint(true); } //**************************************************************************** -void FretBoard::paintEvent(QPaintEvent* pe) +void Graph::FretBoard::paintEvent(QPaintEvent* pe) { Q_UNUSED(pe); int instid=data->getCurrentInstrumentID(); inst=data->getInstrument(instid); //qDebug("inst %d is %s",instid,inst.instName().data()); QRect mysize=rect(); xmargin=(int)(mysize.width()*0.05); xmin=2*xmargin; xmax=mysize.width()-xmargin; @@ -39,40 +39,40 @@ void FretBoard::paintEvent(QPaintEvent* pe) ymargin=(int)(mysize.height()*0.1); ymin=ymargin; ymax=mysize.height()-2*ymargin; yheight=ymax-ymin; QPainter p(this); paintBoard(&p); paintFrets(&p); paintStrings(&p); paintScale(&p); } //**************************************************************************** -void FretBoard::resizeEvent(QResizeEvent* re) +void Graph::FretBoard::resizeEvent(QResizeEvent* re) { Q_UNUSED(re); } //**************************************************************************** -void FretBoard::paintBoard(QPainter* p) +void Graph::FretBoard::paintBoard(QPainter* p) { //debug QColor bgc=QColor(142,138,120); p->setPen(QPen(bgc,5)); p->setBrush(QBrush(bgc)); p->drawRect(xmin,ymin,xwidth,yheight); } //**************************************************************************** -void FretBoard::paintFrets(QPainter* p) +void Graph::FretBoard::paintFrets(QPainter* p) { //draw frets p->setPen(fretpen); p->setBrush(markerbrush); fretdist=(double)(xwidth)/(double)(inst.noOfFrets()); int markerwidth = (int)(fretdist/4.0); if(markerwidth>5) markerwidth=5; else if(markerwidth<2) markerwidth=2; @@ -90,42 +90,42 @@ void FretBoard::paintFrets(QPainter* p) { p->drawEllipse(fretpos+xmin,ymax+ymargin,markerwidth,markerwidth); } else if(marker==0 && f!=0) { p->drawEllipse(fretpos+xmin,ymax+ymargin+2*markerwidth,markerwidth,markerwidth); p->drawEllipse(fretpos+xmin,ymax+ymargin-2*markerwidth,markerwidth,markerwidth); } } } //**************************************************************************** -void FretBoard::paintStrings(QPainter* p) +void Graph::FretBoard::paintStrings(QPainter* p) { //draw strings p->setPen(stringpen); stringdist=(double)(yheight)/(double)(inst.noOfStrings()-1); for(int s=0;s<inst.noOfStrings();s++) { int stringpos=(int)(stringdist*s); p->drawLine(xmin,stringpos+ymin,xmax,stringpos+ymin); int stinglabelid=inst.noOfStrings()-(s+1); QString label=Note::getNameOfNote(inst.string(stinglabelid)); p->drawText(xmargin/2,stringpos+ymin,label); } } //**************************************************************************** -void FretBoard::paintScale(QPainter* p) +void Graph::FretBoard::paintScale(QPainter* p) { int dotsize=10; int scaleid=data->getCurrentScaleID(); Scale scale=data->getScale(scaleid); int colorstart=255%inst.noOfOctaves(); int colorintervall=(255-colorstart)/inst.noOfOctaves(); for(int s=0;s<inst.noOfStrings();s++) { int y=(int)(stringdist*s)+ymin; int stingid=inst.noOfStrings()-(s+1); 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,23 +1,27 @@ #ifndef TONLEITER_FRET_BOARD_H #define TONLEITER_FRET_BOARD_H #include <qbrush.h> #include <qpen.h> #include <qvaluelist.h> #include <qwidget.h> #include "tonleiterdata.h" +using namespace Data; + +namespace Graph +{ class FretBoard : public QWidget { Q_OBJECT private: TonleiterData* data; QPen fretpen; QBrush markerbrush; QPen stringpen; Instrument inst; @@ -33,22 +37,20 @@ private: double fretdist; double stringdist; public: FretBoard(TonleiterData* data,QWidget* parent,const char* name="FretBoard",WFlags f=0); virtual ~FretBoard(); private slots: void dataChange(); private: void paintEvent(QPaintEvent* pe); void resizeEvent(QResizeEvent* re); - //void mousePressEvent(QMouseEvent* mpe); - //void mouseMoveEvent(QMouseEvent* mme); - //void mouseReleaseEvent(QMouseEvent* mre); void paintBoard(QPainter* p); void paintFrets(QPainter* p); void paintStrings(QPainter* p); void paintScale(QPainter* p); }; +}; #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 @@ #include "mainwidget.h" #include <qwidget.h> #include <qlayout.h> MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) :QMainWindow(parent,name,f) { setCaption("Tonleiter"); - data=new TonleiterData(this); + data=new Data::TonleiterData(this); QWidget* mainwidget=new QWidget(this,"mainwidget"); setCentralWidget(mainwidget); QBoxLayout* mainlayout=new QBoxLayout(mainwidget,QBoxLayout::TopToBottom); - menuwidget=new MenuWidget(data,mainwidget); + menuwidget=new Menu::MenuWidget(data,mainwidget); mainlayout->addWidget(menuwidget); - fretboard=new FretBoard(data,mainwidget); + fretboard=new Graph::FretBoard(data,mainwidget); mainlayout->addWidget(fretboard); } //**************************************************************************** MainWidget::~MainWidget() { } //**************************************************************************** //**************************************************************************** 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 @@ -2,21 +2,21 @@ #define TONLEITER_MAINWIDGET_H #include <qmainwindow.h> #include "fretboard.h" #include "menuwidget.h" #include "tonleiterdata.h" class MainWidget : public QMainWindow { Q_OBJECT private: - TonleiterData* data; - MenuWidget* menuwidget; - FretBoard* fretboard; + Data::TonleiterData* data; + Menu::MenuWidget* menuwidget; + Graph::FretBoard* fretboard; public: MainWidget(QWidget* parent=0,const char* name="MainWidget",WFlags f=0); virtual ~MainWidget(); }; #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,60 +1,77 @@ #include "menuwidget.h" #include <qlabel.h> #include <qlayout.h> -MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) +#include "editinst.h" +#include "editscale.h" + +Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) :QWidget(parent,name,f),data(data) { QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout"); QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel"); layout->addWidget(instLabel,0,0); boxInst=new QComboBox(this,"boxInst"); connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int))); layout->addWidget(boxInst,0,1); editInst=new QPushButton(tr("Edit"),this,"editInst"); + connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed())); layout->addWidget(editInst,0,2); QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel"); layout->addWidget(noteLabel,1,0); boxNote=new QComboBox(this,"boxNote"); connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); layout->addWidget(boxNote,1,1); for(int a=0;a<12;a++) boxNote->insertItem(Note::notenames[a],a); boxNote->setCurrentItem(data->getCurrentBaseNote()); noteCheck=new QCheckBox(tr("show"),this,"noteCheck"); noteCheck->setChecked(data->isDrawNames()); connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool))); layout->addWidget(noteCheck,1,2); QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel"); layout->addWidget(scaleLabel,2,0); boxScale=new QComboBox(this,"boxScale"); connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); layout->addWidget(boxScale,2,1); editScale=new QPushButton(tr("Edit"),this,"editScale"); + connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed())); layout->addWidget(editScale,2,2); updateBoxes(); } //**************************************************************************** -MenuWidget::~MenuWidget() +Menu::MenuWidget::~MenuWidget() +{ +} +//**************************************************************************** +void Menu::MenuWidget::editInstPressed() +{ + InstEditDialog* instdialog=new InstEditDialog(data,this); + instdialog->exec(); +} +//**************************************************************************** +void Menu::MenuWidget::editScalePressed() { + ScaleEditDialog* scaledialog=new ScaleEditDialog(data,this); + scaledialog->exec(); } //**************************************************************************** -void MenuWidget::updateBoxes() +void Menu::MenuWidget::updateBoxes() { boxInst->clear(); for(int i=0;i<data->noOfInstruments();i++) { Instrument inst=data->getInstrument(i); QString name=inst.instName(); if(name.isNull()) continue; boxInst->insertItem(name,i); } boxInst->setCurrentItem(data->getCurrentInstrumentID()); 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 @@ #ifndef TONLEITER_MENU_WIDGET_H #define TONLEITER_MENU_WIDGET_H #include <qcheckbox.h> #include <qcombobox.h> #include <qpushbutton.h> #include <qwidget.h> #include <qlabel.h> #include "tonleiterdata.h" +using namespace Data; +namespace Menu +{ class MenuWidget : public QWidget { Q_OBJECT private: TonleiterData* data; QComboBox* boxInst; QPushButton* editInst; QComboBox* boxNote; QCheckBox* noteCheck; QComboBox* boxScale; QPushButton* editScale; public: MenuWidget(TonleiterData* data,QWidget* parent,const char* name="MenuWidget",WFlags f=0); ~MenuWidget(); + private slots: + void editInstPressed(); + void editScalePressed(); public slots: void updateBoxes(); }; +}; #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 @@ TEMPLATE = app #CONFIG = qt warn_on debug CONFIG = qt warn_on release -HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h -SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp +HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editscale.h +SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editscale.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe INTERFACES = TARGET = tonleiter DESTDIR = $(OPIEDIR)/bin #TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti include ( $(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,16 +1,19 @@ #include "tonleiterdata.h" #include <qpe/config.h> +using namespace Data; + + TonleiterData::TonleiterData(QObject* parent) :QObject(parent) { drawnames=true; loadData(); } //**************************************************************************** TonleiterData::~TonleiterData() { saveData(); } //**************************************************************************** @@ -40,68 +43,48 @@ 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)); - strings2.append(Note::getNoteFromName("D",2)); - strings2.append(Note::getNoteFromName("G",2)); - instruments.append(Instrument("Bass 4",12,strings2)); - - currentInstrumentID=1; - - QValueList<int> scale1; - scale1.append(0); - scale1.append(2); - scale1.append(3); - scale1.append(5); - scale1.append(7); - scale1.append(8); - scale1.append(10); - scales.append(Scale("Minor",scale1)); - - QValueList<int> scale2; - 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)); + Config load("Tonleiter"); + if(!load.isValid()) + { + //write some default values + load.setGroup("General"); + load.writeEntry("currentInstrumentID",1); + load.writeEntry("currentNote",0); + load.writeEntry("currentScaleID",1); + load.writeEntry("drawnames",1); + load.setGroup("Instrument"); + load.writeEntry("Inst0","Thumb6;26;11;16;21;26;31;36;"); + load.writeEntry("Inst1","Bass 4;12;16;21;26;31;"); + load.writeEntry("noOfInstruments",2); + load.setGroup("Scale"); + load.writeEntry("Scale0","ionian;0;2;4;5;7;9;11;"); + load.writeEntry("Scale1","aeolian;0;2;3;5;7;8;10;"); + load.writeEntry("Scale2","dorian;0;2;3;5;7;9;10;"); + load.writeEntry("Scale3","phrygian;0;1;3;5;7;8;10;"); + load.writeEntry("Scale4","lydian;0;2;4;6;7;9;11;"); + load.writeEntry("Scale5","mixolyd.;0;2;4;5;7;9;10;"); + load.writeEntry("noOfScales",6); - 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; 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,19 +1,21 @@ #ifndef TONLEITER_DATA_H #define TONLEITER_DATA_H #include <qobject.h> #include "tonleiterdatahelper.h" +namespace Data +{ class TonleiterData : public QObject { Q_OBJECT private: QValueList<Instrument> instruments; int currentInstrumentID; QValueList<Scale> scales; int currentScaleID; int currentNote; bool drawnames; @@ -33,14 +35,15 @@ private: public: int noOfInstruments(); Instrument getInstrument(int id); int getCurrentInstrumentID(); int noOfScales(); Scale getScale(int id); int getCurrentScaleID(); int getCurrentBaseNote(); bool isDrawNames(); }; +}; #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,14 +1,16 @@ #include "tonleiterdatahelper.h" +using namespace Data; + int Note::getOctaveOfNote(int note) { int remain=note%12; return (note-remain)/12; } //**************************************************************************** QString Note::getNameOfNote(int note) { int octave=getOctaveOfNote(note); return notenames[note-12*octave]; } //**************************************************************************** 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,18 +1,20 @@ #ifndef TONLEITER_DATA_HELPER_H #define TONLEITER_DATA_HELPER_H #include <qstring.h> #include <qvaluelist.h> +namespace Data +{ namespace Note { const QString notenames[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"}; int getOctaveOfNote(int note); QString getNameOfNote(int note); int getNoteFromName(QString name,int octave); int octaveOfBaseNote(int base,int note); }; class Instrument { @@ -38,16 +40,16 @@ private: QValueList<int> halftones; QString name; public: Scale(); Scale(QString name,QValueList<int> halftones); ~Scale(); public: int noOfHaltones(); int getHalfTone(int id); QString scaleName(); bool noteInScale(int base,int note); }; - +}; #endif //TONLEITER_DATA_HELPER_H |