summaryrefslogtreecommitdiff
Side-by-side diff
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 @@
+#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
@@ -4,3 +4,3 @@
-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)
@@ -14,3 +14,3 @@ FretBoard::FretBoard(TonleiterData* data,QWidget* parent,const char* name,WFlags
//****************************************************************************
-FretBoard::~FretBoard()
+Graph::FretBoard::~FretBoard()
{
@@ -18,3 +18,3 @@ FretBoard::~FretBoard()
//****************************************************************************
-void FretBoard::dataChange()
+void Graph::FretBoard::dataChange()
{
@@ -23,3 +23,3 @@ void FretBoard::dataChange()
//****************************************************************************
-void FretBoard::paintEvent(QPaintEvent* pe)
+void Graph::FretBoard::paintEvent(QPaintEvent* pe)
{
@@ -50,3 +50,3 @@ void FretBoard::paintEvent(QPaintEvent* pe)
//****************************************************************************
-void FretBoard::resizeEvent(QResizeEvent* re)
+void Graph::FretBoard::resizeEvent(QResizeEvent* re)
{
@@ -55,3 +55,3 @@ void FretBoard::resizeEvent(QResizeEvent* re)
//****************************************************************************
-void FretBoard::paintBoard(QPainter* p)
+void Graph::FretBoard::paintBoard(QPainter* p)
{
@@ -65,5 +65,5 @@ void FretBoard::paintBoard(QPainter* p)
//****************************************************************************
-void FretBoard::paintFrets(QPainter* p)
+void Graph::FretBoard::paintFrets(QPainter* p)
{
- //draw frets
+ //draw frets
p->setPen(fretpen);
@@ -101,3 +101,3 @@ void FretBoard::paintFrets(QPainter* p)
//****************************************************************************
-void FretBoard::paintStrings(QPainter* p)
+void Graph::FretBoard::paintStrings(QPainter* p)
{
@@ -118,3 +118,3 @@ void FretBoard::paintStrings(QPainter* p)
//****************************************************************************
-void FretBoard::paintScale(QPainter* p)
+void Graph::FretBoard::paintScale(QPainter* p)
{
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
@@ -11,42 +11,44 @@
-class FretBoard : public QWidget
+using namespace Data;
+
+namespace Graph
{
- Q_OBJECT
-private:
- TonleiterData* data;
-
- QPen fretpen;
- QBrush markerbrush;
- QPen stringpen;
-
- Instrument inst;
-
- int xmargin;
- int xmin;
- int xmax;
- int xwidth;
-
- int ymargin;
- int ymin;
- int ymax;
- int yheight;
-
- 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);
+ class FretBoard : public QWidget
+ {
+ Q_OBJECT
+ private:
+ TonleiterData* data;
+
+ QPen fretpen;
+ QBrush markerbrush;
+ QPen stringpen;
+
+ Instrument inst;
+
+ int xmargin;
+ int xmin;
+ int xmax;
+ int xwidth;
+
+ int ymargin;
+ int ymin;
+ int ymax;
+ int yheight;
+
+ 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 paintBoard(QPainter* p);
+ void paintFrets(QPainter* p);
+ void paintStrings(QPainter* p);
+ void paintScale(QPainter* p);
+ };
};
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
@@ -9,3 +9,3 @@ MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f)
setCaption("Tonleiter");
- data=new TonleiterData(this);
+ data=new Data::TonleiterData(this);
@@ -15,6 +15,6 @@ MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f)
- 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);
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
@@ -13,5 +13,5 @@ class MainWidget : public QMainWindow
private:
- TonleiterData* data;
- MenuWidget* menuwidget;
- FretBoard* fretboard;
+ Data::TonleiterData* data;
+ Menu::MenuWidget* menuwidget;
+ Graph::FretBoard* fretboard;
public:
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
@@ -5,3 +5,6 @@
-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)
@@ -16,2 +19,3 @@ MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFla
editInst=new QPushButton(tr("Edit"),this,"editInst");
+ connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed()));
layout->addWidget(editInst,0,2);
@@ -37,2 +41,3 @@ MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFla
editScale=new QPushButton(tr("Edit"),this,"editScale");
+ connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed()));
layout->addWidget(editScale,2,2);
@@ -43,7 +48,19 @@ MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFla
//****************************************************************************
-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()
{
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
@@ -11,18 +11,25 @@
-class MenuWidget : public QWidget
+using namespace Data;
+namespace Menu
{
- 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();
-public slots:
- void updateBoxes();
+ 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();
+ };
};
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
@@ -3,4 +3,4 @@ TEMPLATE = app
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
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
@@ -4,2 +4,5 @@
+using namespace Data;
+
+
TonleiterData::TonleiterData(QObject* parent)
@@ -51,46 +54,26 @@ 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");
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
@@ -7,38 +7,41 @@
-class TonleiterData : public QObject
+namespace Data
{
- Q_OBJECT
-private:
- QValueList<Instrument> instruments;
- int currentInstrumentID;
-
- QValueList<Scale> scales;
- int currentScaleID;
-
- int currentNote;
- bool drawnames;
-public:
- TonleiterData(QObject* parent);
- ~TonleiterData();
-signals:
- void dataChange();
-public slots:
- void setCurrentInstrumetID(int id);
- void setCurrentScaleID(int id);
- void setCurrentNote(int id);
- void setDrawNames(bool dn);
-private:
- void loadData();
- void saveData();
-public:
- int noOfInstruments();
- Instrument getInstrument(int id);
- int getCurrentInstrumentID();
-
- int noOfScales();
- Scale getScale(int id);
- int getCurrentScaleID();
-
- int getCurrentBaseNote();
- bool isDrawNames();
+ class TonleiterData : public QObject
+ {
+ Q_OBJECT
+ private:
+ QValueList<Instrument> instruments;
+ int currentInstrumentID;
+
+ QValueList<Scale> scales;
+ int currentScaleID;
+
+ int currentNote;
+ bool drawnames;
+ public:
+ TonleiterData(QObject* parent);
+ ~TonleiterData();
+ signals:
+ void dataChange();
+ public slots:
+ void setCurrentInstrumetID(int id);
+ void setCurrentScaleID(int id);
+ void setCurrentNote(int id);
+ void setDrawNames(bool dn);
+ private:
+ void loadData();
+ void saveData();
+ public:
+ int noOfInstruments();
+ Instrument getInstrument(int id);
+ int getCurrentInstrumentID();
+
+ int noOfScales();
+ Scale getScale(int id);
+ int getCurrentScaleID();
+
+ int getCurrentBaseNote();
+ bool isDrawNames();
+ };
};
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
@@ -2,2 +2,4 @@
+using namespace Data;
+
int Note::getOctaveOfNote(int note)
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
@@ -6,47 +6,49 @@
-namespace Note
+namespace Data
{
- 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
-{
-private:
- QString name;
- int frets;
- QValueList<int> strings;
-public:
- Instrument();
- Instrument(QString name,int frets,QValueList<int> strings);
- ~Instrument();
-public:
- int noOfStrings();
- int noOfFrets();
- QString instName();
- int string(int id);
- int noOfOctaves();
+ 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
+ {
+ private:
+ QString name;
+ int frets;
+ QValueList<int> strings;
+ public:
+ Instrument();
+ Instrument(QString name,int frets,QValueList<int> strings);
+ ~Instrument();
+ public:
+ int noOfStrings();
+ int noOfFrets();
+ QString instName();
+ int string(int id);
+ int noOfOctaves();
+ };
+
+ class Scale
+ {
+ 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);
+ };
};
-class Scale
-{
-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