diff options
author | Werner Schweer <ws.seh.de> | 2006-11-15 15:56:11 +0000 |
---|---|---|
committer | Werner Schweer <ws.seh.de> | 2006-11-15 15:56:11 +0000 |
commit | 2c71a89579e38cd9ff527c33b9ada07fc471b7fd (patch) | |
tree | 305f1abef6dc93e6290c79ce1c1c8402e3ebf8de | |
parent | d25787cab1ce403f1fe38337b99f1d06192a9de9 (diff) |
list edit updates
-rw-r--r-- | muse/all.h | 2 | ||||
-rw-r--r-- | muse/muse/ctrl.cpp | 10 | ||||
-rw-r--r-- | muse/muse/ctrl.h | 1 | ||||
-rw-r--r-- | muse/muse/liste/ctrllistedit.cpp | 360 | ||||
-rw-r--r-- | muse/muse/liste/ctrllistedit.h | 55 | ||||
-rw-r--r-- | muse/muse/liste/ctrllistedit.ui | 198 | ||||
-rw-r--r-- | muse/muse/liste/listedit.cpp | 20 | ||||
-rw-r--r-- | muse/muse/liste/listedit.h | 7 | ||||
-rw-r--r-- | muse/muse/song.h | 1 | ||||
-rw-r--r-- | muse/muse/track.cpp | 10 | ||||
-rw-r--r-- | muse/muse/track.h | 1 | ||||
-rw-r--r-- | muse/muse/undo.cpp | 11 | ||||
-rw-r--r-- | muse/muse/undo.h | 6 |
13 files changed, 618 insertions, 64 deletions
@@ -115,7 +115,7 @@ #include <QtGui/QStyleFactory> #include <QtGui/QDockWidget> #include <QtGui/QDesktopServices> +#include <QtGui/QItemDelegate> #include <QtSvg/QSvgRenderer> - #endif diff --git a/muse/muse/ctrl.cpp b/muse/muse/ctrl.cpp index 2e40f297..c2198d77 100644 --- a/muse/muse/ctrl.cpp +++ b/muse/muse/ctrl.cpp @@ -427,3 +427,13 @@ void Ctrl::setRange(int _min, int _max) max.i = _max; } +//--------------------------------------------------------- +// setRange +//--------------------------------------------------------- + +void Ctrl::setRange(CVal mi, CVal ma) + { + min = mi; + max = ma; + } + diff --git a/muse/muse/ctrl.h b/muse/muse/ctrl.h index 3a45bc97..6426f5e8 100644 --- a/muse/muse/ctrl.h +++ b/muse/muse/ctrl.h @@ -197,6 +197,7 @@ class Ctrl : public CTRL { bool touched() const { return _touched; } void setRange(double min, double max); void setRange(int min, int max); + void setRange(CVal, CVal); CVal minVal() const { return min; } CVal maxVal() const { return max; } void read(QDomNode node, bool midi); diff --git a/muse/muse/liste/ctrllistedit.cpp b/muse/muse/liste/ctrllistedit.cpp index 8fcc34fe..472e02f4 100644 --- a/muse/muse/liste/ctrllistedit.cpp +++ b/muse/muse/liste/ctrllistedit.cpp @@ -20,14 +20,20 @@ #include "ctrllistedit.h" #include "ctrl.h" +#include "track.h" +#include "song.h" +#include "al/pos.h" +#include "awl/posedit.h" //--------------------------------------------------------- // CtrlListEditor //--------------------------------------------------------- -CtrlListEditor::CtrlListEditor(QWidget* parent) +CtrlListEditor::CtrlListEditor(ListEdit* e, QWidget* parent) : ListWidget(parent) { + listEdit = e; + updateListDisabled = false; QWidget* cew = new QWidget; le.setupUi(cew); QVBoxLayout* layout = new QVBoxLayout; @@ -39,6 +45,43 @@ CtrlListEditor::CtrlListEditor(QWidget* parent) le.minValue->setSingleStep(1.0); le.maxValue->setSingleStep(1.0); le.defaultValue->setSingleStep(1.0); + + le.ctrlList->setColumnWidth(TICK_COL, 60); + le.ctrlList->setColumnWidth(TIME_COL, 120); + MidiTimeDelegate* midiTimeDelegate = new MidiTimeDelegate(this); + le.ctrlList->setItemDelegate(midiTimeDelegate); + + track = 0; + connect(le.ctrlList, SIGNAL(itemActivated(QTreeWidgetItem*, int)), + SLOT(itemDoubleClicked(QTreeWidgetItem*,int))); + connect(le.ctrlList, SIGNAL(itemChanged(QTreeWidgetItem*, int)), + SLOT(itemChanged(QTreeWidgetItem*, int))); + connect(le.ctrlList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), + SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); + connect(le.insertButton, SIGNAL(clicked()), SLOT(insertClicked())); + connect(le.deleteButton, SIGNAL(clicked()), SLOT(deleteClicked())); + connect(le.controllerName, SIGNAL(textEdited(const QString&)), + SLOT(nameEdited(const QString&))); + connect(le.minValue, SIGNAL(valueChanged(double)), SLOT(minValChanged(double))); + connect(le.maxValue, SIGNAL(valueChanged(double)), SLOT(maxValChanged(double))); + connect(le.defaultValue, SIGNAL(valueChanged(double)), SLOT(defaultValChanged(double))); + EscapeFilter* ef = new EscapeFilter(this); + installEventFilter(ef); + } + +//--------------------------------------------------------- +// eventFilter +//--------------------------------------------------------- + +bool EscapeFilter::eventFilter(QObject* obj, QEvent* event) + { + if (event->type() == QEvent::KeyPress) { + if (((QKeyEvent*)event)->key() == Qt::Key_Escape) { + ((CtrlListEditor*)parent())->sendEscape(); + return true; + } + } + return QObject::eventFilter(obj, event); } //--------------------------------------------------------- @@ -47,11 +90,17 @@ CtrlListEditor::CtrlListEditor(QWidget* parent) void CtrlListEditor::setup(const ListType& lt) { - Ctrl* c = lt.ctrl; + if (track) + disconnect(track, SIGNAL(controllerChanged(int)), this, SLOT(controllerChanged(int))); + track = lt.track; + connect(track, SIGNAL(controllerChanged(int)), SLOT(controllerChanged(int))); + + c = lt.ctrl; le.controllerName->setText(c->name()); le.discreteCheckBox->setChecked(c->type() & Ctrl::DISCRETE); le.logarithmicCheckBox->setChecked(c->type() & Ctrl::LOG); le.floatCheckBox->setChecked(!(c->type() & Ctrl::INT)); + le.ctrlId->setValue(c->id()); if (c->type() & Ctrl::INT) { le.minValue->setDecimals(0); le.minValue->setValue(c->minVal().i); @@ -68,18 +117,317 @@ void CtrlListEditor::setup(const ListType& lt) le.defaultValue->setDecimals(1); le.defaultValue->setValue(c->getDefault().f); } + updateList(); + } + +//--------------------------------------------------------- +// updateList +//--------------------------------------------------------- + +void CtrlListEditor::updateList() + { + if (updateListDisabled) + return; le.ctrlList->clear(); int idx = 0; + bool curItemSet = false; for (iCtrlVal i = c->begin(); i != c->end(); ++i, ++idx) { CVal v = i.value(); QTreeWidgetItem* item = new QTreeWidgetItem; - item->setText(0, QString("%1").arg(i.key())); - item->setText(1, QString("%1").arg(i.key())); + item->setData(TICK_COL, Qt::TextAlignmentRole, int(Qt::AlignRight | Qt::AlignVCenter)); + item->setData(TIME_COL, Qt::TextAlignmentRole, int(Qt::AlignRight | Qt::AlignVCenter)); + item->setData(VAL_COL, Qt::TextAlignmentRole, int(Qt::AlignRight | Qt::AlignVCenter)); +// item->setItemDelegate(TIME_COL, midiTimeDelegate); + + item->setData(TICK_COL, Qt::DisplayRole, i.key()); + item->setData(TIME_COL, Qt::DisplayRole, i.key()); if (c->type() & Ctrl::INT) - item->setText(2, QString("%1").arg(v.i)); + item->setData(VAL_COL, Qt::DisplayRole, v.i); else - item->setText(2, QString("%1").arg(v.f)); + item->setData(VAL_COL, Qt::DisplayRole, v.f); le.ctrlList->insertTopLevelItem(idx, item); + if (!curItemSet && (i.key() >= listEdit->pos().tick())) { + le.ctrlList->setCurrentItem(item); + curItemSet = true; + } + } + } + +//--------------------------------------------------------- +// controllerChanged +//--------------------------------------------------------- + +void CtrlListEditor::controllerChanged(int id) + { + if (id != c->id()) + return; + updateList(); + } + +//--------------------------------------------------------- +// itemDoubleClicked +//--------------------------------------------------------- + +void CtrlListEditor::itemDoubleClicked(QTreeWidgetItem* item, int column) + { + le.ctrlList->openPersistentEditor(item, column); + } + +//--------------------------------------------------------- +// itemChanged +//--------------------------------------------------------- + +void CtrlListEditor::itemChanged(QTreeWidgetItem* item, int column) + { + if (column != VAL_COL) { + printf("time change not implemented\n"); + return; + } + + CVal val; + if (c->type() & Ctrl::INT) { + val.i = item->data(VAL_COL, Qt::DisplayRole).toInt(); + bool updateData = false; + if (val.i < c->minVal().i) { + val.i = c->minVal().i; + updateData = true; + } + else if (val.i > c->maxVal().i) { + val.i = c->maxVal().i; + updateData = true; + } + if (updateData) + item->setData(VAL_COL, Qt::DisplayRole, val.i); + } + else { + val.f = item->data(VAL_COL, Qt::DisplayRole).toDouble(); + bool updateData = false; + if (val.f < c->minVal().f) { + val.f = c->minVal().f; + updateData = true; + } + else if (val.f > c->maxVal().f) { + val.f = c->maxVal().f; + updateData = true; + } + if (updateData) + item->setData(VAL_COL, Qt::DisplayRole, val.f); + } + le.ctrlList->closePersistentEditor(item, TICK_COL); + le.ctrlList->closePersistentEditor(item, TIME_COL); + le.ctrlList->closePersistentEditor(item, VAL_COL); + updateListDisabled = true; + song->addControllerVal(track, c, listEdit->pos(), val); + updateListDisabled = false; + } + +//--------------------------------------------------------- +// sendEscape +//--------------------------------------------------------- + +void CtrlListEditor::sendEscape() + { + QTreeWidgetItem* cur = le.ctrlList->currentItem(); + if (cur == 0) + return; + le.ctrlList->closePersistentEditor(cur, TICK_COL); + le.ctrlList->closePersistentEditor(cur, TIME_COL); + le.ctrlList->closePersistentEditor(cur, VAL_COL); + } + +//--------------------------------------------------------- +// currentItemChanged +//--------------------------------------------------------- + +void CtrlListEditor::currentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev) + { + if (prev) { + le.ctrlList->closePersistentEditor(prev, TICK_COL); + le.ctrlList->closePersistentEditor(prev, TIME_COL); + le.ctrlList->closePersistentEditor(prev, VAL_COL); + } + if (cur) + listEdit->pos().setTick(cur->data(TICK_COL, Qt::DisplayRole).toInt()); + le.deleteButton->setEnabled(cur); + } + +//--------------------------------------------------------- +// insertClicked +// insert one tick before current value +//--------------------------------------------------------- + +void CtrlListEditor::insertClicked() + { + CVal val = c->minVal(); + QTreeWidgetItem* cur = le.ctrlList->currentItem(); + if (cur) { + int tick = cur->data(TICK_COL, Qt::DisplayRole).toInt(); + if (tick == 0) // cannot insert value at position < 0 + return; + listEdit->pos().setTick(tick - 1); + if (c->type() & Ctrl::INT) + val.i = cur->data(VAL_COL, Qt::DisplayRole).toInt(); + else + val.f = cur->data(VAL_COL, Qt::DisplayRole).toDouble(); + } + song->addControllerVal(track, c, listEdit->pos(), val); + } + +//--------------------------------------------------------- +// deleteClicked +//--------------------------------------------------------- + +void CtrlListEditor::deleteClicked() + { + QTreeWidgetItem* cur = le.ctrlList->currentItem(); + if (cur == 0) + return; + int tick = cur->data(TICK_COL, Qt::DisplayRole).toInt(); + song->removeControllerVal(track, c->id(), tick); + } + +//--------------------------------------------------------- +// nameEdited +//--------------------------------------------------------- + +void CtrlListEditor::nameEdited(const QString& s) + { + track->changeCtrlName(c, s); + } + +//--------------------------------------------------------- +// minValChanged +//--------------------------------------------------------- + +void CtrlListEditor::minValChanged(double v) + { + CVal val; + if (c->type() & Ctrl::INT) + val.i = int(v); + else + val.f = v; + c->setRange(val, c->maxVal()); + } + +//--------------------------------------------------------- +// maxValChanged +//--------------------------------------------------------- + +void CtrlListEditor::maxValChanged(double v) + { + CVal val; + if (c->type() & Ctrl::INT) + val.i = int(v); + else + val.f = v; + c->setRange(c->minVal(), val); + } + +//--------------------------------------------------------- +// defaultValChanged +//--------------------------------------------------------- + +void CtrlListEditor::defaultValChanged(double v) + { + CVal val; + if (c->type() & Ctrl::INT) + val.i = int(v); + else + val.f = v; + c->setDefault(val); + } + +//--------------------------------------------------------- +// MidiTimeDelegate +//--------------------------------------------------------- + +MidiTimeDelegate::MidiTimeDelegate(QObject* parent) + : QItemDelegate(parent) + { + } + +//--------------------------------------------------------- +// createEditor +//--------------------------------------------------------- + +QWidget* MidiTimeDelegate::createEditor(QWidget* parent, + const QStyleOptionViewItem& option, const QModelIndex& index) const + { + if (index.column() != CtrlListEditor::TIME_COL) + return QItemDelegate::createEditor(parent, option, index); + + Awl::PosEdit* pe = new Awl::PosEdit(parent); + return pe; + } + +//--------------------------------------------------------- +// setEditorData +//--------------------------------------------------------- + +void MidiTimeDelegate::setEditorData(QWidget* editor, + const QModelIndex& index) const + { + if (index.column() != CtrlListEditor::TIME_COL) { + QItemDelegate::setEditorData(editor, index); + return; + } + Awl::PosEdit* pe = (Awl::PosEdit*)editor; + pe->setValue(AL::Pos(index.data().toInt())); + } + +//--------------------------------------------------------- +// setModelData +//--------------------------------------------------------- + +void MidiTimeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, + const QModelIndex& index) const + { + if (index.column() != CtrlListEditor::TIME_COL) { + QItemDelegate::setModelData(editor, model, index); + return; + } + Awl::PosEdit* pe = (Awl::PosEdit*)editor; + model->setData(index, pe->pos().tick(), Qt::DisplayRole); + } + +//--------------------------------------------------------- +// paint +//--------------------------------------------------------- + +void MidiTimeDelegate::paint(QPainter* painter, + const QStyleOptionViewItem& option, const QModelIndex& index) const + { + if (index.column() != CtrlListEditor::TIME_COL) { + QItemDelegate::paint(painter, option, index); + return; + } + AL::Pos pos(index.data().toInt()); + int measure, beat, tick; + pos.mbt(&measure, &beat, &tick); + QString text; + text.sprintf("%04d.%02d.%03u", measure+1, beat+1, tick); + + QStyleOptionViewItemV2 opt = setOptions(index, option); + const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(&option); + opt.features = v2 ? v2->features : QStyleOptionViewItemV2::ViewItemFeatures(QStyleOptionViewItemV2::None); + + painter->save(); + QVariant value; + QRect displayRect; + displayRect = option.rect; // textRectangle(painter, d->textLayoutBounds(opt), opt.font, text); + + QRect checkRect; + Qt::CheckState checkState = Qt::Unchecked; + value = index.data(Qt::CheckStateRole); + if (value.isValid()) { + checkState = static_cast<Qt::CheckState>(value.toInt()); + checkRect = check(opt, opt.rect, value); } + + drawBackground(painter, opt, index); + drawCheck(painter, opt, checkRect, checkState); + drawDisplay(painter, opt, displayRect, text); + drawFocus(painter, opt, text.isEmpty() ? QRect() : displayRect); + painter->restore(); } diff --git a/muse/muse/liste/ctrllistedit.h b/muse/muse/liste/ctrllistedit.h index 57fd5eac..842ba7eb 100644 --- a/muse/muse/liste/ctrllistedit.h +++ b/muse/muse/liste/ctrllistedit.h @@ -21,10 +21,41 @@ #ifndef __CTRLLISTEDIT_H__ #define __CTRLLISTEDIT_H__ +#include "al/pos.h" #include "listedit.h" #include "ui_ctrllistedit.h" //--------------------------------------------------------- +// MidiTimeDelegate +//--------------------------------------------------------- + +class MidiTimeDelegate : public QItemDelegate { + + virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem&, + const QModelIndex& index) const; + virtual void setEditorData(QWidget* editor, const QModelIndex&) const; + virtual void setModelData(QWidget* editor, QAbstractItemModel*, + const QModelIndex&) const; + void paint(QPainter*, const QStyleOptionViewItem&, + const QModelIndex&) const; + + public: + MidiTimeDelegate(QObject* parent = 0); + }; + +//--------------------------------------------------------- +// EscapeFilter +//--------------------------------------------------------- + +class EscapeFilter : public QObject { + Q_OBJECT + protected: + bool eventFilter(QObject*, QEvent*); + public: + EscapeFilter(QObject* parent = 0): QObject(parent) {} + }; + +//--------------------------------------------------------- // CtrlListEditor //--------------------------------------------------------- @@ -32,12 +63,32 @@ class CtrlListEditor : public ListWidget { Q_OBJECT Ui::CtrlListEdit le; + Track* track; + Ctrl* c; + bool updateListDisabled; + ListEdit* listEdit; + MidiTimeDelegate* midiTimeDelegate; + + void updateList(); + + private slots: + void controllerChanged(int id); + void itemDoubleClicked(QTreeWidgetItem*,int); + void itemChanged(QTreeWidgetItem*,int); + void currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*); + void insertClicked(); + void deleteClicked(); + void nameEdited(const QString&); + void minValChanged(double); + void maxValChanged(double); + void defaultValChanged(double); public: - CtrlListEditor(QWidget* parent = 0); + CtrlListEditor(ListEdit*, QWidget* parent = 0); virtual void setup(const ListType&); + void sendEscape(); + enum { TICK_COL, TIME_COL, VAL_COL }; }; - #endif diff --git a/muse/muse/liste/ctrllistedit.ui b/muse/muse/liste/ctrllistedit.ui index 4f0c3b9d..88f850d9 100644 --- a/muse/muse/liste/ctrllistedit.ui +++ b/muse/muse/liste/ctrllistedit.ui @@ -6,7 +6,7 @@ <x>0</x> <y>0</y> <width>400</width> - <height>300</height> + <height>341</height> </rect> </property> <property name="windowTitle" > @@ -14,10 +14,10 @@ </property> <layout class="QVBoxLayout" > <property name="margin" > - <number>9</number> + <number>0</number> </property> <property name="spacing" > - <number>6</number> + <number>3</number> </property> <item> <layout class="QHBoxLayout" > @@ -29,6 +29,14 @@ </property> <item> <widget class="QLabel" name="label" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="font" > <font> <weight>75</weight> @@ -41,29 +49,29 @@ </widget> </item> <item> - <widget class="QLabel" name="controllerName" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Sunken</enum> - </property> - <property name="lineWidth" > - <number>2</number> - </property> + <widget class="QLineEdit" name="controllerName" /> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label_3" > <property name="text" > - <string>Volume</string> + <string>Id:</string> </property> - <property name="textFormat" > - <enum>Qt::PlainText</enum> + </widget> + </item> + <item> + <widget class="QSpinBox" name="ctrlId" > + <property name="readOnly" > + <bool>true</bool> </property> </widget> </item> @@ -79,6 +87,17 @@ </property> <item> <widget class="QCheckBox" name="discreteCheckBox" > + <property name="enabled" > + <bool>false</bool> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text" > <string>discrete</string> </property> @@ -86,6 +105,17 @@ </item> <item> <widget class="QCheckBox" name="logarithmicCheckBox" > + <property name="enabled" > + <bool>false</bool> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text" > <string>logarithmic</string> </property> @@ -93,6 +123,17 @@ </item> <item> <widget class="QCheckBox" name="floatCheckBox" > + <property name="enabled" > + <bool>false</bool> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text" > <string>float</string> </property> @@ -110,6 +151,14 @@ </property> <item> <widget class="QLabel" name="label_2" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text" > <string>min:</string> </property> @@ -119,10 +168,27 @@ </widget> </item> <item> - <widget class="QDoubleSpinBox" name="minValue" /> + <widget class="QDoubleSpinBox" name="minValue" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> </item> <item> <widget class="QLabel" name="l2" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text" > <string>max:</string> </property> @@ -132,10 +198,27 @@ </widget> </item> <item> - <widget class="QDoubleSpinBox" name="maxValue" /> + <widget class="QDoubleSpinBox" name="maxValue" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> </item> <item> <widget class="QLabel" name="l3" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text" > <string>default:</string> </property> @@ -145,12 +228,36 @@ </widget> </item> <item> - <widget class="QDoubleSpinBox" name="defaultValue" /> + <widget class="QDoubleSpinBox" name="defaultValue" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> </item> </layout> </item> <item> <widget class="QTreeWidget" name="ctrlList" > + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + <property name="indentation" > + <number>0</number> + </property> + <property name="rootIsDecorated" > + <bool>false</bool> + </property> + <property name="uniformRowHeights" > + <bool>true</bool> + </property> + <property name="itemsExpandable" > + <bool>false</bool> + </property> <column> <property name="text" > <string>Tick</string> @@ -168,6 +275,43 @@ </column> </widget> </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QToolButton" name="deleteButton" > + <property name="text" > + <string>Delete</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="insertButton" > + <property name="text" > + <string>Insert</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>231</width> + <height>29</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> </layout> </widget> <resources/> diff --git a/muse/muse/liste/listedit.cpp b/muse/muse/liste/listedit.cpp index 52d8a757..09e2ed86 100644 --- a/muse/muse/liste/listedit.cpp +++ b/muse/muse/liste/listedit.cpp @@ -19,12 +19,15 @@ //============================================================================= #include "listedit.h" -#include "al/pos.h" #include "ctrllistedit.h" #include "song.h" #include "part.h" #include "ctrl.h" +//--------------------------------------------------------- +// operator== +//--------------------------------------------------------- + bool ListType::operator==(const ListType& t) const { return id == t.id && track == t.track @@ -57,7 +60,7 @@ ListEdit::ListEdit(QWidget*) stack = new QStackedWidget; split->addWidget(stack); - ctrlPanel = new CtrlListEditor; + ctrlPanel = new CtrlListEditor(this); stack->addWidget(ctrlPanel); connect(list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), @@ -89,9 +92,9 @@ void ListEdit::itemChanged(QTreeWidgetItem* i, QTreeWidgetItem*) lt = i->data(0, Qt::UserRole).value<ListType>(); switch(lt.id) { case LIST_TRACK: - break; + return; case LIST_PART: - break; + return; case LIST_CTRL: ew = ctrlPanel; break; @@ -171,8 +174,9 @@ QTreeWidgetItem* ListEdit::findItem(const ListType& lt, QTreeWidgetItem* item) // selectItem //--------------------------------------------------------- -void ListEdit::selectItem(const AL::Pos&, Track* track, Part* part, Ctrl* ctrl) +void ListEdit::selectItem(const AL::Pos& p, Track* track, Part* part, Ctrl* ctrl) { + _pos = p; stack->setCurrentWidget(ctrlPanel); if (ctrl) lt.id = LIST_CTRL; @@ -190,6 +194,7 @@ void ListEdit::selectItem(const AL::Pos&, Track* track, Part* part, Ctrl* ctrl) void ListEdit::selectItem(const ListType& l) { + lt = l; stack->setCurrentWidget(ctrlPanel); buildList(); for (int i = 0;; ++i) { @@ -228,6 +233,8 @@ void ListEdit::read(QDomNode node) printf("MusE::ListEdit::read: track not found\n"); } } + else if (tag == "Pos") + _pos.read(node); else if (tag == "Ctrl") { int ctrlId = e.text().toInt(); ctrl = track->getController(ctrlId); @@ -240,7 +247,7 @@ void ListEdit::read(QDomNode node) else AL::readProperties(this, node); } - selectItem(AL::Pos(), track, part, ctrl); + selectItem(_pos, track, part, ctrl); } //--------------------------------------------------------- @@ -255,6 +262,7 @@ void ListEdit::write(Xml& xml) const xml.strTag("Track", lt.track->name()); if (lt.ctrl) { xml.intTag("Ctrl", lt.ctrl->id()); + _pos.write(xml, "Pos"); } xml.etag(metaObject()->className()); } diff --git a/muse/muse/liste/listedit.h b/muse/muse/liste/listedit.h index e386f49b..2c33cdab 100644 --- a/muse/muse/liste/listedit.h +++ b/muse/muse/liste/listedit.h @@ -21,12 +21,9 @@ #ifndef __LISTEDIT_H__ #define __LISTEDIT_H__ +#include "al/pos.h" #include "cobject.h" -namespace AL { - class Pos; - }; - class Track; class Part; class Ctrl; @@ -70,6 +67,7 @@ class ListEdit : public TopWin { Q_OBJECT; ListType lt; + AL::Pos _pos; QStackedWidget* stack; QTreeWidget* list; @@ -88,6 +86,7 @@ class ListEdit : public TopWin { void selectItem(const AL::Pos&, Track*, Part*, Ctrl*); virtual void read(QDomNode); virtual void write(Xml& xml) const; + AL::Pos& pos() { return _pos; } }; #endif diff --git a/muse/muse/song.h b/muse/muse/song.h index 29a5a433..610b0eec 100644 --- a/muse/muse/song.h +++ b/muse/muse/song.h @@ -344,7 +344,6 @@ class Song : public QObject { void undoOp(UndoOp::UndoType, Part*); void undoOp(UndoOp::UndoType, Event& oevent, Event& nevent, Part*); void undoOp(UndoOp::UndoType, SigEvent* oevent, SigEvent* nevent); - void undoOp(UndoOp::UndoType, int channel, int ctrl, int oval, int nval); void undoOp(UndoOp::UndoType, Part* oPart, Part* nPart); void undoOp(UndoOp::UndoType, Track*, int, unsigned, CVal, CVal); void undoOp(UndoOp::UndoType, Track*, const QString&, const QString&); diff --git a/muse/muse/track.cpp b/muse/muse/track.cpp index 6e0e4a99..14189c61 100644 --- a/muse/muse/track.cpp +++ b/muse/muse/track.cpp @@ -397,6 +397,16 @@ void Track::removeController(int id) } //--------------------------------------------------------- +// changeCtrlName +//--------------------------------------------------------- + +void Track::changeCtrlName(Ctrl* c, const QString& s) + { + c->setName(s); + emit clChanged(); + } + +//--------------------------------------------------------- // addControllerVal // return true if new controller value added //--------------------------------------------------------- diff --git a/muse/muse/track.h b/muse/muse/track.h index 84afe3df..7ffb76a6 100644 --- a/muse/muse/track.h +++ b/muse/muse/track.h @@ -210,6 +210,7 @@ class Track : public QObject { // signal interface: virtual void emitControllerChanged(int id) { emit controllerChanged(id); } void updateController(); + void changeCtrlName(Ctrl* c, const QString& s); // automation void startAutoRecord(int); diff --git a/muse/muse/undo.cpp b/muse/muse/undo.cpp index b65269f4..1303ed79 100644 --- a/muse/muse/undo.cpp +++ b/muse/muse/undo.cpp @@ -345,17 +345,6 @@ void Song::undoOp(UndoOp::UndoType type, Part* oPart, Part* nPart) addUndo(i); } -void Song::undoOp(UndoOp::UndoType type, int c, int ctrl, int ov, int nv) - { - UndoOp i; - i.type = type; - i.channel = c; - i.ctrl = ctrl; - i.oVal = ov; - i.nVal = nv; - addUndo(i); - } - void Song::undoOp(UndoOp::UndoType type, SigEvent* oevent, SigEvent* nevent) { UndoOp i; diff --git a/muse/muse/undo.h b/muse/muse/undo.h index 5e9976c8..ac9222c2 100644 --- a/muse/muse/undo.h +++ b/muse/muse/undo.h @@ -65,12 +65,6 @@ struct UndoOp { SigEvent* oSignature; }; struct { - int channel; - int ctrl; - int oVal; - int nVal; - }; - struct { int startframe; //!< Start frame of changed data int endframe; //!< End frame of changed data const char* filename; //!< The file that is changed |