diff options
-rw-r--r-- | muse2/ChangeLog | 1 | ||||
-rw-r--r-- | muse2/muse/master/lmaster.cpp | 145 | ||||
-rw-r--r-- | muse2/muse/master/lmaster.h | 37 | ||||
-rw-r--r-- | muse2/muse/master/master.cpp | 8 | ||||
-rw-r--r-- | muse2/muse/master/master.h | 10 | ||||
-rw-r--r-- | muse2/muse/master/masteredit.cpp | 22 | ||||
-rw-r--r-- | muse2/muse/master/masteredit.h | 7 |
7 files changed, 106 insertions, 124 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 26ccf925..a56d1a92 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -6,6 +6,7 @@ TODO: Plugin controllers disabled - we need the Ctrl class. Restoring of state (that's a MusE problem I think). Fix deicsonze.cpp:3612: warning: deprecated conversion from string constant to ‘char*’ + - Ported Mastertrack list view. (Orcan) 27.11.2010 - Completed porting pianoroll module including menus, shortcuts. Should be done. (Tim) - Ported the following .ui widgets to Qt4: organguibase, gatetime, midisync, diff --git a/muse2/muse/master/lmaster.cpp b/muse2/muse/master/lmaster.cpp index 3193bbb3..18d2e718 100644 --- a/muse2/muse/master/lmaster.cpp +++ b/muse2/muse/master/lmaster.cpp @@ -15,21 +15,13 @@ #include "shortcuts.h" #include "debug.h" -//#include <q3toolbar.h> -#include <QToolBar> -#include <QToolButton> -#include <QToolTip> -#include <QLayout> -#include <QSizeGrip> -#include <Q3PopupMenu> -#include <QMenuBar> -#include <Q3ListView> +#include <QCloseEvent> +#include <QMenu> #include <QMessageBox> #include <QStyle> -//#include <Q3Accel> -#include <QAction> -//Added by qt3to4: -#include <QCloseEvent> +#include <QToolBar> +#include <QToolButton> +#include <QTreeWidget> #define LMASTER_BEAT_COL 0 #define LMASTER_TIME_COL 1 @@ -74,19 +66,31 @@ LMaster::LMaster() setFixedWidth(400); //---------Pulldown Menu---------------------------- - menuEdit = new Q3PopupMenu(this); - menuBar()->insertItem(tr("&Edit"), menuEdit); - undoRedo->addTo(menuEdit); + menuEdit = new QMenu(tr("&Edit")); + QSignalMapper *signalMapper = new QSignalMapper(this); + menuBar()->addMenu(menuEdit); + menuEdit->addActions(undoRedo->actions()); menuEdit->insertSeparator(); - menuEdit->insertItem(tr("Insert Tempo"), CMD_INSERT_TEMPO); - menuEdit->insertItem(tr("Insert Signature"), CMD_INSERT_SIG); - menuEdit->insertItem(tr("Edit Positon"), CMD_EDIT_BEAT); - menuEdit->insertItem(tr("Edit Value"), CMD_EDIT_VALUE); - - menuEdit->insertItem(tr("Delete Event"), CMD_DELETE); - menuEdit->setAccel(Qt::Key_Delete, CMD_DELETE); - - connect(menuEdit, SIGNAL(activated(int)), SLOT(cmd(int))); + QAction *tempoAction = menuEdit->addAction(tr("Insert Tempo")); + QAction *signAction = menuEdit->addAction(tr("Insert Signature")); + QAction *posAction = menuEdit->addAction(tr("Edit Positon")); + QAction *valAction = menuEdit->addAction(tr("Edit Value")); + QAction *delAction = menuEdit->addAction(tr("Delete Event")); + delAction->setShortcut(Qt::Key_Delete); + + connect(tempoAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + connect(signAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + connect(posAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + connect(valAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + connect(delAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + + signalMapper->setMapping(tempoAction, CMD_INSERT_TEMPO); + signalMapper->setMapping(signAction, CMD_INSERT_SIG); + signalMapper->setMapping(posAction, CMD_EDIT_BEAT); + signalMapper->setMapping(valAction, CMD_EDIT_VALUE); + signalMapper->setMapping(delAction, CMD_DELETE); + + connect(signalMapper, SIGNAL(mapped(int)), SLOT(cmd(int))); //---------ToolBar---------------------------------- tools = addToolBar(tr("Master tools")); @@ -113,14 +117,15 @@ LMaster::LMaster() // master //--------------------------------------------------- - view = new Q3ListView(mainw); + view = new QTreeWidget; view->setAllColumnsShowFocus(true); - view->setSelectionMode(Q3ListView::Single); - view->addColumn(tr("Meter"), 100); - view->addColumn(tr("Time"), 100); - view->addColumn(tr("Type"), 100); - view->addColumn(tr("Value"), 100); - view->setSorting(-1); + view->setSelectionMode(QAbstractItemView::SingleSelection); + QStringList columnnames; + columnnames << tr("Meter") + << tr("Time") + << tr("Type") + << tr("Value"); + view->setHeaderLabels(columnnames); //--------------------------------------------------- // Rest @@ -135,9 +140,9 @@ LMaster::LMaster() // mainGrid->addWidget(corner, 1, 1, AlignBottom | AlignRight); updateList(); - connect(view, SIGNAL(selectionChanged(Q3ListViewItem*)), SLOT(select(Q3ListViewItem*))); - connect(view, SIGNAL(pressed(Q3ListViewItem*, const QPoint&, int)), SLOT(itemPressed(Q3ListViewItem*, const QPoint&, int))); - connect(view, SIGNAL(doubleClicked(Q3ListViewItem* )), SLOT(itemDoubleClicked(Q3ListViewItem*))); + connect(view, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(select(QTreeWidgetItem*, QTreeWidgetItem*))); + connect(view, SIGNAL(itemPressed(QTreeWidgetItem*, int)), SLOT(itemPressed(QTreeWidgetItem*, int))); + connect(view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(itemDoubleClicked(QTreeWidgetItem*))); connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); connect(tempoButton, SIGNAL(clicked()), SLOT(tempoButtonClicked())); connect(timeSigButton, SIGNAL(clicked()), SLOT(timeSigButtonClicked())); @@ -178,7 +183,7 @@ void LMaster::insertTempo(const TEvent* ev) void LMaster::updateList() { - LMasterLViewItem* selected = (LMasterLViewItem*) view->selectedItem(); + LMasterLViewItem* selected = (LMasterLViewItem*) view->currentItem(); LMASTER_LVTYPE type = LMASTER_TEMPO; unsigned tick = 0; @@ -224,7 +229,7 @@ void LMaster::updateList() LMasterLViewItem* tmp = getItemAtPos(tick, type); if (tmp) { view->clearSelection(); - view->setSelected(tmp, true); + view->setCurrentItem(tmp); } } } @@ -271,7 +276,7 @@ void LMaster::writeStatus(int level, Xml& xml) const // select //--------------------------------------------------------- -void LMaster::select(Q3ListViewItem* /*item*/) +void LMaster::select(QTreeWidgetItem* /*item*/, QTreeWidgetItem* /*previous_item*/) { // printf("select %x\n", unsigned(item)); } @@ -284,15 +289,15 @@ void LMaster::cmd(int cmd) { switch(cmd) { case CMD_DELETE: { - LMasterLViewItem* l = (LMasterLViewItem*) view->selectedItem(); + LMasterLViewItem* l = (LMasterLViewItem*) view->currentItem(); if (!l) return; // Delete item: if (l->tick() != 0) { - if (l == view->lastItem()) - view->setSelected(l->itemAbove(), true); + if (l == view->topLevelItem(view->topLevelItemCount() - 1)) + view->setCurrentItem(view->itemAbove(l)); else - view->setSelected(l->itemBelow(), true); + view->setCurrentItem(view->itemBelow(l)); switch (l->getType()) { case LMASTER_TEMPO: @@ -323,8 +328,8 @@ void LMaster::cmd(int cmd) case CMD_EDIT_BEAT: case CMD_EDIT_VALUE: cmd == CMD_EDIT_VALUE ? editorColumn = LMASTER_VAL_COL : editorColumn = LMASTER_BEAT_COL; - if (view->selectedItem() && !editedItem) { - itemDoubleClicked(view->selectedItem()); + if (view->currentItem() && !editedItem) { + itemDoubleClicked(view->currentItem()); } break; } @@ -333,7 +338,7 @@ void LMaster::cmd(int cmd) /*! \fn LMaster::itemPressed(QListViewItem* i, const QPoint& p, int column) */ -void LMaster::itemPressed(Q3ListViewItem* i, const QPoint& /*p*/, int column) +void LMaster::itemPressed(QTreeWidgetItem* i, int column) { //printf("itemPressed, column: %d\n", column); if (editedItem) { @@ -348,13 +353,13 @@ void LMaster::itemPressed(Q3ListViewItem* i, const QPoint& /*p*/, int column) // itemDoubleClicked(QListViewItem* item) //! Sets lmaster in edit mode, and opens editor for selected value //--------------------------------------------------------- -void LMaster::itemDoubleClicked(Q3ListViewItem* i) +void LMaster::itemDoubleClicked(QTreeWidgetItem* i) { //printf("itemDoubleClicked\n"); if (!editedItem && editorColumn == LMASTER_VAL_COL) { editedItem = (LMasterLViewItem*) i; - QRect itemRect = view->itemRect(editedItem); + QRect itemRect = view->visualItemRect(editedItem); int x1 = view->columnWidth(LMASTER_BEAT_COL) + view->columnWidth(LMASTER_TIME_COL) + view->columnWidth(LMASTER_TYPE_COL); itemRect.setX(x1); @@ -372,7 +377,7 @@ void LMaster::itemDoubleClicked(Q3ListViewItem* i) // Edit tempo value: if (editedItem->getType() == LMASTER_TEMPO) { if (!editor) - editor = new QLineEdit(view->viewport(), "lineedit"); + editor = new QLineEdit(view->viewport()); editor->setText(editedItem->text(LMASTER_VAL_COL)); editor->setGeometry(itemRect); editor->show(); @@ -382,7 +387,7 @@ void LMaster::itemDoubleClicked(Q3ListViewItem* i) } else { // Edit signatur value: if (!sig_editor) - sig_editor = new SigEdit(view->viewport(), "sigedit"); + sig_editor = new SigEdit(view->viewport()); sig_editor->setValue(editedItem->text(LMASTER_VAL_COL)); sig_editor->setGeometry(itemRect); sig_editor->show(); @@ -402,9 +407,9 @@ void LMaster::itemDoubleClicked(Q3ListViewItem* i) // Everything OK else { if (!pos_editor) - pos_editor = new PosEdit(view->viewport(), "tmpposedit"); + pos_editor = new PosEdit(view->viewport()); pos_editor->setValue(editedItem->tick()); - QRect itemRect = view->itemRect(editedItem); + QRect itemRect = view->visualItemRect(editedItem); itemRect.setX(0); itemRect.setWidth(view->columnWidth(LMASTER_BEAT_COL)); pos_editor->setGeometry(itemRect); @@ -479,10 +484,10 @@ void LMaster::returnPressed() audio->msgAddTempo(newtick, tempo, false); song->endUndo(SC_TEMPO); // Select the item: - Q3ListViewItem* newSelected = (Q3ListViewItem*) getItemAtPos(newtick, LMASTER_TEMPO); + QTreeWidgetItem* newSelected = (QTreeWidgetItem*) getItemAtPos(newtick, LMASTER_TEMPO); if (newSelected) { view->clearSelection(); - view->setSelected(newSelected, true); + view->setCurrentItem(newSelected); } } else if (editedItem->getType() == LMASTER_SIGEVENT) { @@ -501,10 +506,10 @@ void LMaster::returnPressed() //audio->msgAddSig(newtick, z, n, true); // Select the item: - Q3ListViewItem* newSelected = (Q3ListViewItem*) getItemAtPos(newtick, LMASTER_SIGEVENT); + QTreeWidgetItem* newSelected = (QTreeWidgetItem*) getItemAtPos(newtick, LMASTER_SIGEVENT); if (newSelected) { view->clearSelection(); - view->setSelected(newSelected, true); + view->setCurrentItem(newSelected); } } @@ -578,7 +583,7 @@ QString LMasterLViewItem::text(int column) const // LMasterTempoItem //! Initializes a LMasterTempoItem with a TEvent //--------------------------------------------------------- -LMasterTempoItem::LMasterTempoItem(Q3ListView* parent, const TEvent* ev) +LMasterTempoItem::LMasterTempoItem(QTreeWidget* parent, const TEvent* ev) : LMasterLViewItem(parent) { tempoEvent = ev; @@ -597,13 +602,17 @@ LMasterTempoItem::LMasterTempoItem(Q3ListView* parent, const TEvent* ev) c3 = "Tempo"; double dt = (1000000.0 * 60.0)/ev->tempo; c4.setNum(dt, 'f', 3); + setText(0, c1); + setText(1, c2); + setText(2, c3); + setText(3, c4); } //--------------------------------------------------------- // LMasterSigEventItem //! Initializes a ListView item with a SigEvent //--------------------------------------------------------- -LMasterSigEventItem::LMasterSigEventItem(Q3ListView* parent, const SigEvent* ev) +LMasterSigEventItem::LMasterSigEventItem(QTreeWidget* parent, const SigEvent* ev) : LMasterLViewItem(parent) { sigEvent = ev; @@ -620,6 +629,10 @@ LMasterSigEventItem::LMasterSigEventItem(Q3ListView* parent, const SigEvent* ev) c2.sprintf("%03d:%02d:%03d", min, sec, msec); c3 = "Timesig"; c4.sprintf("%d/%d", ev->z, ev->n); + setText(0, c1); + setText(1, c2); + setText(2, c3); + setText(3, c4); } //--------------------------------------------------------- @@ -637,12 +650,13 @@ void LMaster::tempoButtonClicked() int newTick = sigmap.bar2tick(m, b, t); TEvent* ev = new TEvent(lastTempo->tempo(), newTick); new LMasterTempoItem(view, ev); - Q3ListViewItem* newTempoItem = view->firstChild(); + QTreeWidgetItem* newTempoItem = view->topLevelItem(0); + //LMasterTempoItem* newTempoItem = new LMasterTempoItem(view, ev); editingNewItem = true; // State editorColumn = LMASTER_VAL_COL; // Set that we edit editorColumn view->clearSelection(); - view->setSelected(newTempoItem, true); + view->setCurrentItem(newTempoItem); itemDoubleClicked(newTempoItem); } @@ -662,12 +676,13 @@ void LMaster::timeSigButtonClicked() int newTick = sigmap.bar2tick(m, b, t); SigEvent* ev = new SigEvent(lastSig->z(), lastSig->n(), newTick); new LMasterSigEventItem(view, ev); - Q3ListViewItem* newSigItem = view->firstChild(); + QTreeWidgetItem* newSigItem = view->topLevelItem(0); + //LMasterSigEventItem* newSigItem = new LMasterSigEventItem(view, ev); editingNewItem = true; // State editorColumn = LMASTER_VAL_COL; // Set that we edit editorColumn view->clearSelection(); - view->setSelected(newSigItem, true); + view->setCurrentItem(newSigItem); itemDoubleClicked(newSigItem); } @@ -677,9 +692,9 @@ void LMaster::timeSigButtonClicked() */ LMasterLViewItem* LMaster::getLastOfType(LMASTER_LVTYPE t) { - LMasterLViewItem* tmp = (LMasterLViewItem*) view->lastItem(); + LMasterLViewItem* tmp = (LMasterLViewItem*) view->topLevelItem(view->topLevelItemCount() - 1); while (tmp->getType() != t) { - tmp = (LMasterLViewItem*) tmp->itemAbove(); + tmp = (LMasterLViewItem*) view->itemAbove(tmp); } return tmp; } @@ -690,11 +705,11 @@ LMasterLViewItem* LMaster::getLastOfType(LMASTER_LVTYPE t) */ LMasterLViewItem* LMaster::getItemAtPos(unsigned tick, LMASTER_LVTYPE t) { - LMasterLViewItem* tmp = (LMasterLViewItem*) view->firstChild(); + LMasterLViewItem* tmp = (LMasterLViewItem*) view->topLevelItem(0); while (tmp) { if (tmp->getType() == t && tmp->tick() == tick) return tmp; - tmp = (LMasterLViewItem*) tmp->itemBelow(); + tmp = (LMasterLViewItem*) view->itemBelow(tmp); } return 0; diff --git a/muse2/muse/master/lmaster.h b/muse2/muse/master/lmaster.h index bb74a903..92c213b0 100644 --- a/muse2/muse/master/lmaster.h +++ b/muse2/muse/master/lmaster.h @@ -8,25 +8,16 @@ #ifndef __LMASTER_EDIT_H__ #define __LMASTER_EDIT_H__ -#include <QWidget> -#include <QLineEdit> -//Added by qt3to4: -#include <QMouseEvent> -#include <Q3PopupMenu> -#include <QCloseEvent> #include "midieditor.h" #include "noteinfo.h" #include "cobject.h" -//#include <q3mainwindow.h> -#include <Q3ListView> #include "tempo.h" #include "sig.h" -class QToolButton; -class Q3ListView; -class SigEvent; +#include <QTreeWidgetItem> + class QLineEdit; -class QMouseEvent; +class SigEvent; class PosEdit; class SigEdit; @@ -40,15 +31,13 @@ enum LMASTER_LVTYPE // LMasterLViewItem //! QListViewItem base class for LMasterTempoItem and LMasterSigEventItem //--------------------------------------------------------- -class LMasterLViewItem : public Q3ListViewItem { +class LMasterLViewItem : public QTreeWidgetItem { protected: QString c1, c2, c3, c4; public: - LMasterLViewItem(Q3ListView* parent) - : Q3ListViewItem(parent) { } - LMasterLViewItem(Q3ListView* parent, Q3ListViewItem* after) - : Q3ListViewItem(parent, after) { } + LMasterLViewItem(QTreeWidget* parent) + : QTreeWidgetItem(QTreeWidgetItem::UserType) {parent->insertTopLevelItem(0, this);} virtual QString text(int column) const; virtual LMASTER_LVTYPE getType() = 0; virtual unsigned tick() = 0; @@ -64,7 +53,7 @@ class LMasterTempoItem : public LMasterLViewItem { const TEvent* tempoEvent; public: - LMasterTempoItem(Q3ListView* parent, const TEvent* t); + LMasterTempoItem(QTreeWidget* parent, const TEvent* t); virtual LMASTER_LVTYPE getType() { return LMASTER_TEMPO; } const TEvent* getEvent() { return tempoEvent; } virtual unsigned tick() { return tempoEvent->tick; } @@ -81,7 +70,7 @@ class LMasterSigEventItem : public LMasterLViewItem { const SigEvent* sigEvent; public: - LMasterSigEventItem(Q3ListView* parent, const SigEvent* s); + LMasterSigEventItem(QTreeWidget* parent, const SigEvent* s); virtual LMASTER_LVTYPE getType() { return LMASTER_SIGEVENT; } const SigEvent* getEvent() { return sigEvent; } virtual unsigned tick() { return sigEvent->tick; } @@ -95,9 +84,9 @@ class LMasterSigEventItem : public LMasterLViewItem { //--------------------------------------------------------- class LMaster : public MidiEditor { - Q3ListView* view; + QTreeWidget* view; QToolBar* tools; - Q3PopupMenu* menuEdit; + QMenu* menuEdit; enum { CMD_DELETE, CMD_INSERT_SIG, CMD_INSERT_TEMPO, CMD_EDIT_BEAT, CMD_EDIT_VALUE }; @@ -117,10 +106,10 @@ class LMaster : public MidiEditor { bool editingNewItem; private slots: - void select(Q3ListViewItem*); - void itemDoubleClicked(Q3ListViewItem* item); + void select(QTreeWidgetItem*, QTreeWidgetItem*); + void itemDoubleClicked(QTreeWidgetItem* item); void returnPressed(); - void itemPressed(Q3ListViewItem* i, const QPoint& p, int column); + void itemPressed(QTreeWidgetItem* i, int column); void tempoButtonClicked(); void timeSigButtonClicked(); void cmd(int cmd); diff --git a/muse2/muse/master/master.cpp b/muse2/muse/master/master.cpp index 2c6b5bf7..3b593fee 100644 --- a/muse2/muse/master/master.cpp +++ b/muse2/muse/master/master.cpp @@ -8,14 +8,10 @@ #include <stdio.h> #include <values.h> -#include <QLineEdit> -#include <Q3PopupMenu> -#include <QPainter> -#include <Q3Header> #include <QCursor> -//Added by qt3to4: -#include <QMouseEvent> #include <QEvent> +#include <QMouseEvent> +#include <QPainter> #include "globals.h" #include "master.h" diff --git a/muse2/muse/master/master.h b/muse2/muse/master/master.h index a5b2dc71..4c38bc16 100644 --- a/muse2/muse/master/master.h +++ b/muse2/muse/master/master.h @@ -8,19 +8,17 @@ #ifndef __MASTER_H__ #define __MASTER_H__ -#include <QPoint> -//Added by qt3to4: -#include <QMouseEvent> -#include <QEvent> - #include "view.h" #include "song.h" #include "tools.h" -class ScrollScale; +class QMouseEvent; class QPainter; +class QPoint; class QRect; + class MidiEditor; +class ScrollScale; //--------------------------------------------------------- // Master diff --git a/muse2/muse/master/masteredit.cpp b/muse2/muse/master/masteredit.cpp index 7f9a2f7e..2736808e 100644 --- a/muse2/muse/master/masteredit.cpp +++ b/muse2/muse/master/masteredit.cpp @@ -22,27 +22,11 @@ #include "globals.h" #include <values.h> -//#include <q3toolbar.h> + +#include <QCloseEvent> +#include <QLabel> #include <QToolBar> #include <QToolButton> -#include <QToolTip> -#include <q3accel.h> -#include <QLayout> -#include <q3hbox.h> -#include <QSizeGrip> -#include <QScrollBar> -#include <QLabel> -#include <QPushButton> -#include <QRadioButton> -#include <q3buttongroup.h> -#include <q3listbox.h> -#include <QComboBox> -#include <q3header.h> -#include <q3popupmenu.h> -#include <QMenuBar> -#include <QAction> -//Added by qt3to4: -#include <QCloseEvent> int MasterEdit::_rasterInit = 0; diff --git a/muse2/muse/master/masteredit.h b/muse2/muse/master/masteredit.h index 62de4d58..9fa3bd6d 100644 --- a/muse2/muse/master/masteredit.h +++ b/muse2/muse/master/masteredit.h @@ -8,15 +8,14 @@ #ifndef __MASTER_EDIT_H__ #define __MASTER_EDIT_H__ -#include <QWidget> -//Added by qt3to4: -#include <QCloseEvent> #include "midieditor.h" #include "noteinfo.h" #include "cobject.h" -//#include <q3mainwindow.h> +class QCloseEvent; +class QToolBar; class QToolButton; + class Master; class ScrollScale; class MTScale; |