summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNil Geisweiller <a-lin@sourceforge.net>2007-02-02 18:52:46 +0000
committerNil Geisweiller <a-lin@sourceforge.net>2007-02-02 18:52:46 +0000
commitd65846e78e59571906d91216382075514bcaf467 (patch)
tree4f27e9194fd96ef622c29c8f6bd93f07e8680517
parent62a4b58e7800629b3b1b59d5817771e9d2d7eac2 (diff)
see ChangeLog
-rw-r--r--muse/ChangeLog2
-rw-r--r--muse/muse/liste/ieventdialog.cpp28
-rw-r--r--muse/muse/liste/ieventdialog.h4
-rw-r--r--muse/muse/liste/partlistedit.cpp216
-rw-r--r--muse/muse/liste/partlistedit.h6
5 files changed, 197 insertions, 59 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index c63ea87d..372d2a53 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,5 @@
+02.02 (ng)
+ - updated partlistedit, direct editing of time & parameters on list edit
01.02 (ng)
- changed PanDelay, time delay is calculated with BPM and beat ratio
27.01
diff --git a/muse/muse/liste/ieventdialog.cpp b/muse/muse/liste/ieventdialog.cpp
index da830cd9..a2914ffc 100644
--- a/muse/muse/liste/ieventdialog.cpp
+++ b/muse/muse/liste/ieventdialog.cpp
@@ -22,7 +22,7 @@
#include <QDialogButtonBox>
#include "ieventdialog.h"
-InsertEventDialog::InsertEventDialog(const Pos& time, Part* part,
+InsertEventDialog::InsertEventDialog(const Pos& time, Part* part, Event* ev,
QWidget* parent, Qt::WindowFlags f)
: QDialog(parent, f) {
setWindowTitle("Insert Event Dialog");
@@ -54,7 +54,7 @@ InsertEventDialog::InsertEventDialog(const Pos& time, Part* part,
_pitchSpinBox = new QSpinBox(_typeWidget[i]);
_pitchSpinBox->setMaximum(127);
_pitchSpinBox->setMinimum(0);
- _pitchSpinBox->setValue(72); //C4
+ _pitchSpinBox->setValue(ev && ev->type()==Note?ev->pitch():72/*C4*/);
tLayout->addWidget(_pitchSpinBox, 0, 1);
//Velocity
QLabel* velocityLabel = new QLabel("Velocity", _typeWidget[i]);
@@ -62,7 +62,7 @@ InsertEventDialog::InsertEventDialog(const Pos& time, Part* part,
_velocitySpinBox = new QSpinBox(_typeWidget[i]);
_velocitySpinBox->setMaximum(127);
_velocitySpinBox->setMinimum(0);
- _velocitySpinBox->setValue(70);
+ _velocitySpinBox->setValue(ev && ev->type()==Note?ev->velo():70);
tLayout->addWidget(_velocitySpinBox, 1, 1);
//Velocity Off
/*QLabel* veloOffLabel = new QLabel("Velocity Off", _typeWidget[i]);
@@ -78,7 +78,7 @@ InsertEventDialog::InsertEventDialog(const Pos& time, Part* part,
_lengthSpinBox = new QSpinBox(_typeWidget[i]);
_lengthSpinBox->setMaximum(32768);
_lengthSpinBox->setMinimum(1);
- _lengthSpinBox->setValue(384);
+ _lengthSpinBox->setValue(ev && ev->type()==Note?ev->lenTick():384);
tLayout->addWidget(_lengthSpinBox, 2, 1);
}
else if(i == IED_ProgramChange) {
@@ -126,15 +126,21 @@ InsertEventDialog::InsertEventDialog(const Pos& time, Part* part,
//length
QLabel* lengthLabel = new QLabel("Length", _typeWidget[i]);
tLayout->addWidget(lengthLabel, 4, 0);
- _lengthIntLabel = new QLabel("0", _typeWidget[i]);
+ _lengthIntLabel = new QLabel(ev && ev->type()==Sysex?
+ QString::number(ev->dataLen()):"0",
+ _typeWidget[i]);
tLayout->addWidget(_lengthIntLabel, 4, 1);
//text edit
_sysexTextEdit = new QTextEdit(_typeWidget[i]);
_sysexCursorPos = 0;
- QByteArray ba;
- _dataSysex.push_back(QByteArray(ba));
+ _dataSysex.push_back(ev && ev->type()==Sysex?
+ QByteArray((const char*)ev->data(), ev->dataLen())
+ :QByteArray());
_lengthIntLabel->setText(QString::number(sysexLength()));
- _dataSysexStr.push_back(QString("F0 F7"));
+ _dataSysexStr.push_back(ev && ev->type()==Sysex?
+ charArray2Str((const char*)ev->data(),
+ ev->dataLen()):
+ "F0 F7");
tLayout->addWidget(_sysexTextEdit, 5, 0, 3, 2);
setSysexTextEdit();
QString HEX = "(?!F7)([A-F]|\\d){1,2}";
@@ -158,6 +164,12 @@ InsertEventDialog::InsertEventDialog(const Pos& time, Part* part,
Qt::Horizontal, parent);
_mainLayout->addWidget(OkCancelBox, 3, 0, 1, 2);
+ if(ev)
+ if(ev->type()==Note) _eventTypeComboBox->setCurrentIndex(IED_Note);
+ else if(ev->type()==Sysex) _eventTypeComboBox->setCurrentIndex(IED_Sysex);
+ else _eventTypeComboBox->setCurrentIndex(IED_Note);
+ else _eventTypeComboBox->setCurrentIndex(IED_Note);
+
updateType(_eventTypeComboBox->currentIndex());
setLayout(_mainLayout);
diff --git a/muse/muse/liste/ieventdialog.h b/muse/muse/liste/ieventdialog.h
index 68ec92cd..7906f6c9 100644
--- a/muse/muse/liste/ieventdialog.h
+++ b/muse/muse/liste/ieventdialog.h
@@ -93,13 +93,13 @@ class InsertEventDialog : public QDialog {
void setSysexTextEdit(); //set the display of sysexTextEdit
public:
- InsertEventDialog(const Pos& time, Part* part,
+ InsertEventDialog(const Pos& time, Part* part, Event* ev = NULL,
QWidget* parent = 0, Qt::WindowFlags f = 0);
~InsertEventDialog();
EventList* elResult();
- static QString charArray2Str(const char* s, int length);
+ static QString charArray2Str(const char* s, int length); //add F0 and F7
static QString ByteArray2Str(const QByteArray& ba); //add F0 and F7
static QByteArray Str2ByteArray(const QString& s); //skip F0 and F7
static char* Str2CharArray(const QString& s);
diff --git a/muse/muse/liste/partlistedit.cpp b/muse/muse/liste/partlistedit.cpp
index 50fbc5f3..d3db4de2 100644
--- a/muse/muse/liste/partlistedit.cpp
+++ b/muse/muse/liste/partlistedit.cpp
@@ -33,6 +33,8 @@ PartListEditor::PartListEditor(ListEdit* e, QWidget* parent)
: ListWidget(parent)
{
listEdit = e;
+ updateListDisabled = false;
+ curEvent = NULL;
QWidget* cew = new QWidget;
le.setupUi(cew);
QVBoxLayout* layout = new QVBoxLayout;
@@ -48,6 +50,13 @@ PartListEditor::PartListEditor(ListEdit* e, QWidget* parent)
part = 0;
+ connect(le.eventList, SIGNAL(itemActivated(QTreeWidgetItem*, int)),
+ SLOT(itemActivated(QTreeWidgetItem*,int)));
+ connect(le.eventList, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
+ SLOT(itemChanged(QTreeWidgetItem*, int)));
+ connect(le.eventList,
+ SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
+ SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
connect(le.insertButton, SIGNAL(clicked()), SLOT(insertClicked()));
connect(le.deleteButton, SIGNAL(clicked()), SLOT(deleteClicked()));
}
@@ -76,32 +85,162 @@ void PartListEditor::setup(const ListType& lt)
// updateList
//---------------------------------------------------------
-void PartListEditor::updateList()
- {
- EventList* el = part->events();
- int idx = 0;
- le.eventList->clear();
- for (iEvent i = el->begin(); i != el->end(); ++i, ++idx) {
- Event e = i->second;
- QTreeWidgetItem* item = new QTreeWidgetItem;
- item->setData(TICK_COL, Qt::TextAlignmentRole, int(Qt::AlignRight | Qt::AlignVCenter));
- item->setData(TIME_COL, Qt::TextAlignmentRole, int(Qt::AlignRight | Qt::AlignVCenter));
- item->setData(TICK_COL, Qt::DisplayRole, e.tick() + part->tick());
- item->setData(TIME_COL, Qt::DisplayRole, e.tick() + part->tick());
- item->setData(TYPE_COL, Qt::TextAlignmentRole, int(Qt::AlignRight | Qt::AlignVCenter));
- item->setData(TYPE_COL, Qt::DisplayRole, e.eventTypeName());
- item->setData(A_COL, Qt::TextAlignmentRole, int(Qt::AlignHCenter | Qt::AlignVCenter));
- item->setData(A_COL, Qt::DisplayRole, e.dataA());
- item->setData(B_COL, Qt::TextAlignmentRole, int(Qt::AlignHCenter | Qt::AlignVCenter));
- item->setData(B_COL, Qt::DisplayRole, e.dataB());
- item->setData(C_COL, Qt::TextAlignmentRole, int(Qt::AlignHCenter | Qt::AlignVCenter));
- item->setData(C_COL, Qt::DisplayRole, e.dataC());
- item->setData(LEN_COL, Qt::TextAlignmentRole, int(Qt::AlignHCenter | Qt::AlignVCenter));
- item->setData(LEN_COL, Qt::DisplayRole, (e.type()==Sysex?e.dataLen():e.lenTick()));
- item->setText(DATA_COL, (e.type()==Sysex?InsertEventDialog::charArray2Str((const char*)e.data(), e.dataLen()):""));
- le.eventList->insertTopLevelItem(idx, item);
- }
+void PartListEditor::updateList() {
+ if(updateListDisabled) {
+ updateListDisabled = false;
+ return;
+ }
+ EventList* el = part->events();
+ int idx = 0;
+ le.eventList->clear();
+ for (iEvent i = el->begin(); i != el->end(); ++i, ++idx) {
+ Event e = i->second;
+ QTreeWidgetItem* item = new QTreeWidgetItem;
+ item->setData(TICK_COL, Qt::TextAlignmentRole,
+ int(Qt::AlignRight | Qt::AlignVCenter));
+ item->setData(TIME_COL, Qt::TextAlignmentRole,
+ int(Qt::AlignRight | Qt::AlignVCenter));
+ item->setData(TICK_COL, Qt::DisplayRole, e.tick() + part->tick());
+ item->setData(TIME_COL, Qt::DisplayRole, e.tick() + part->tick());
+ item->setData(TYPE_COL, Qt::TextAlignmentRole,
+ int(Qt::AlignRight | Qt::AlignVCenter));
+ item->setData(TYPE_COL, Qt::DisplayRole, e.eventTypeName());
+ item->setData(A_COL, Qt::TextAlignmentRole,
+ int(Qt::AlignHCenter | Qt::AlignVCenter));
+ if(e.type()!=Sysex) item->setData(A_COL, Qt::DisplayRole, e.dataA());
+ item->setData(B_COL, Qt::TextAlignmentRole,
+ int(Qt::AlignHCenter | Qt::AlignVCenter));
+ if(e.type()!=Sysex) item->setData(B_COL, Qt::DisplayRole, e.dataB());
+ item->setData(C_COL, Qt::TextAlignmentRole,
+ int(Qt::AlignHCenter | Qt::AlignVCenter));
+ if(e.type()!=Sysex) item->setData(C_COL, Qt::DisplayRole, e.dataC());
+ item->setData(LEN_COL, Qt::TextAlignmentRole,
+ int(Qt::AlignHCenter | Qt::AlignVCenter));
+ item->setData(LEN_COL, Qt::DisplayRole,
+ (e.type()==Sysex?e.dataLen():e.lenTick()));
+ QString dataStr;
+ if(e.type()==Sysex)
+ dataStr = InsertEventDialog::charArray2Str((const char*)e.data(),
+ e.dataLen());
+ else dataStr = QString("");
+ item->setText(DATA_COL, dataStr);
+ le.eventList->insertTopLevelItem(idx, item);
+ }
+}
+
+//---------------------------------------------------------
+// item2Event
+//---------------------------------------------------------
+
+Event* PartListEditor::item2Event(QTreeWidgetItem* item, int time_col) {
+ if(item) {
+ int tick;
+ if(time_col == TICK_COL)
+ tick = item->data(TICK_COL, Qt::DisplayRole).toInt();
+ else tick = item->data(TIME_COL, Qt::DisplayRole).toInt();
+ int evTick = (unsigned)IED_MAX(0, (int)tick - (int)part->tick());
+ QString type = item->text(TYPE_COL);
+ if(type == "Note") {
+ Event* ev = new Event(Note);
+ int pitch = item->data(A_COL, Qt::DisplayRole).toInt();
+ int velo = item->data(B_COL, Qt::DisplayRole).toInt();
+ int len = item->data(LEN_COL, Qt::DisplayRole).toInt();
+ ev->setTick(evTick);
+ ev->setPitch(pitch);
+ ev->setVelo(velo);
+ ev->setLenTick(len);
+ return ev;
+ }
+ else if(type == "Sysex") {
+ Event* ev = new Event(Sysex);
+ QString dataStr = item->text(DATA_COL);
+ char* data = InsertEventDialog::Str2CharArray(dataStr);
+ int len = item->data(LEN_COL, Qt::DisplayRole).toInt();
+ ev->setTick(evTick);
+ ev->setData((const unsigned char*)data, len);
+ return ev;
+ }
+ else return NULL;
+ }
+ else return NULL;
+}
+
+//---------------------------------------------------------
+// itemActivated
+//---------------------------------------------------------
+
+void PartListEditor::itemActivated(QTreeWidgetItem* item, int column) {
+ AL::Pos time;
+ int tick = item->data(TIME_COL, Qt::DisplayRole).toInt();
+ time.setTick(tick);
+ Event* ev = item2Event(item);
+ EventList* el;
+
+ if(column == TYPE_COL) {
+ InsertEventDialog dialog(time, part, ev, this);
+ if(dialog.exec() == QDialog::Accepted) {
+ el = dialog.elResult();
+ if(el) {
+ if(ev) song->deleteEvent(*ev, part);
+ for(iEvent ie = el->begin(); ie != el->end(); ie++) {
+ Event e = ie->second;
+ song->addEvent(e, part);
+ }
}
+ }
+ }
+ else if((column==A_COL || column==B_COL || column==C_COL || column==LEN_COL)
+ && ev && ev->type()==Sysex) {
+ //DO NOTHING
+ }
+ else if(column == DATA_COL) {
+ if(ev && ev->type()==Sysex) {
+ InsertEventDialog dialog(time, part, ev, this);
+ if(dialog.exec() == QDialog::Accepted) {
+ el = dialog.elResult();
+ if(el) {
+ if(ev) song->deleteEvent(*ev, part);
+ for(iEvent ie = el->begin(); ie != el->end(); ie++) {
+ Event e = ie->second;
+ song->addEvent(e, part);
+ }
+ }
+ }
+ }
+ }
+ else le.eventList->openPersistentEditor(item, column);
+}
+
+//---------------------------------------------------------
+// itemChanged
+//---------------------------------------------------------
+
+void PartListEditor::itemChanged(QTreeWidgetItem* item, int column) {
+ updateListDisabled = (column != TICK_COL && column != TIME_COL);
+ if(item) {
+ Event* newEvent = item2Event(item, column);
+ song->changeEvent(*curEvent, *newEvent, part);
+ }
+}
+
+//---------------------------------------------------------
+// currentItemChanged
+//---------------------------------------------------------
+
+void PartListEditor::currentItemChanged(QTreeWidgetItem* cur,
+ QTreeWidgetItem* pre) {
+ if(pre) {
+ le.eventList->closePersistentEditor(pre, TICK_COL);
+ le.eventList->closePersistentEditor(pre, TIME_COL);
+ le.eventList->closePersistentEditor(pre, A_COL);
+ le.eventList->closePersistentEditor(pre, B_COL);
+ le.eventList->closePersistentEditor(pre, C_COL);
+ le.eventList->closePersistentEditor(pre, LEN_COL);
+ }
+ if(cur) {
+ curEvent = item2Event(cur);
+ }
+}
//---------------------------------------------------------
// insertClicked
@@ -119,7 +258,7 @@ void PartListEditor::insertClicked()
EventList* el;
- InsertEventDialog dialog(time, part, this);
+ InsertEventDialog dialog(time, part, NULL, this);
if(dialog.exec() == QDialog::Accepted) {
el = dialog.elResult();
if(el) {
@@ -140,29 +279,8 @@ void PartListEditor::deleteClicked()
QTreeWidgetItem* cur = le.eventList->currentItem();
if (cur == 0)
return;
- int tick = cur->data(TICK_COL, Qt::DisplayRole).toInt();
- int evTick = (unsigned)IED_MAX(0, (int)tick - (int)part->tick());
- QString type = cur->text(TYPE_COL);
- if(type == "Note") {
- Event ev(Note);
- int pitch = cur->data(A_COL, Qt::DisplayRole).toInt();
- int velo = cur->data(B_COL, Qt::DisplayRole).toInt();
- int len = cur->data(LEN_COL, Qt::DisplayRole).toInt();
- ev.setTick(evTick);
- ev.setPitch(pitch);
- ev.setVelo(velo);
- ev.setLenTick(len);
- song->deleteEvent(ev, part);
- }
- else if(type == "Sysex") {
- Event ev(Sysex);
- QString dataStr = cur->text(DATA_COL);
- char* data = InsertEventDialog::Str2CharArray(dataStr);
- int len = cur->data(LEN_COL, Qt::DisplayRole).toInt();
- ev.setTick(evTick);
- ev.setData((const unsigned char*)data, len);
- song->deleteEvent(ev, part);
- }
+ Event* ev = item2Event(cur);
+ song->deleteEvent(*ev, part);
}
//---------------------------------------------------------
diff --git a/muse/muse/liste/partlistedit.h b/muse/muse/liste/partlistedit.h
index 6a39457c..10eda46a 100644
--- a/muse/muse/liste/partlistedit.h
+++ b/muse/muse/liste/partlistedit.h
@@ -55,10 +55,16 @@ class PartListEditor : public ListWidget {
ListEdit* listEdit;
Ui::PartListEdit le;
Part* part;
+ Event* curEvent;
+ bool updateListDisabled;
void updateList();
+ Event* item2Event(QTreeWidgetItem* item, int time_col = TICK_COL);
private slots:
+ void itemActivated(QTreeWidgetItem* item, int column);
+ void itemChanged(QTreeWidgetItem* item, int column);
+ void currentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* pre);
void insertClicked();
void deleteClicked();