summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-06-22 12:56:49 +0000
committerWerner Schweer <ws.seh.de>2006-06-22 12:56:49 +0000
commitcdf7ab7da6c3bb8b421be189b673fc7feb0b8e5b (patch)
treef5b099ad6abd53f414df50270d615c1aa59ba299
parent3e46c7ac426aab7f66fe253682a6e43afb43b2fd (diff)
rename part, undo split part
-rw-r--r--muse/ChangeLog4
-rw-r--r--muse/muse/arranger/canvas.cpp43
-rw-r--r--muse/muse/miditrack.cpp2
-rw-r--r--muse/muse/part.cpp24
-rw-r--r--muse/muse/part.h2
-rw-r--r--muse/muse/undo.cpp29
-rw-r--r--muse/muse/wavetrack.cpp2
7 files changed, 66 insertions, 40 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 58e5d7d9..b83fe865 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,7 @@
+22.6. (ws)
+ * fix: get reference count right when undo "split part"
+ * implement: rename part
+ * fix loading of cloned midi parts
21.6. (ws)
* show controller name in controller canvas of midi editor
* fix save/restore of controller editors in midi editor
diff --git a/muse/muse/arranger/canvas.cpp b/muse/muse/arranger/canvas.cpp
index ae6c2457..a73872b5 100644
--- a/muse/muse/arranger/canvas.cpp
+++ b/muse/muse/arranger/canvas.cpp
@@ -182,20 +182,21 @@ void PartCanvas::paint(QPainter& p, QRect r)
break;
QRect pr(x1, y, len, h - partBorderWidth);
+ bool clone = part->isCloned();
+ QPen pen(Qt::black, partBorderWidth, clone ? Qt::DashLine : Qt::SolidLine);
if (part->mute()) {
- p.setPen(QPen(Qt::red, partBorderWidth));
+ pen.setColor(Qt::red);
p.setBrush(Qt::gray);
}
else if (part->selected()) {
- p.setPen(QPen(config.partColors[part->colorIndex()], partBorderWidth));
+ pen.setColor(config.partColors[part->colorIndex()]);
p.setBrush(config.selectPartBg);
}
else {
- bool clone = part->events()->arefCount() > 1;
- p.setPen(QPen(Qt::black, partBorderWidth, clone ? Qt::DashLine : Qt::SolidLine));
p.setBrush(config.partColors[part->colorIndex()]);
}
+ p.setPen(pen);
//
// we want to draw the rectangle without transformation
@@ -797,23 +798,10 @@ void PartCanvas::mouseDoubleClick(QMouseEvent* me)
//TD mousePress(pos);
return;
}
- searchPart(pos);
bool shift = keyState & Qt::ShiftModifier;
- if (part) {
+ if (searchPart(pos) == HIT_PART) {
if (button == Qt::LeftButton && shift) {
-#if 0 //TODO1
- editPart = (NPart*)curItem;
- QRect r = map(curItem->bbox());
- if (lineEditor == 0) {
- lineEditor = new QLineEdit(this);
- lineEditor->setFrame(true);
- }
- editMode = true;
- lineEditor->setGeometry(r);
- lineEditor->setText(editPart->name());
- lineEditor->setFocus();
- lineEditor->show();
-#endif
+ renamePart(part);
}
else if (button == Qt::LeftButton) {
emit doubleClickPart(part);
@@ -879,9 +867,22 @@ void PartCanvas::splitPart(Part* part, const QPoint& p)
// renamePart
//---------------------------------------------------------
-void PartCanvas::renamePart(Part*)
+void PartCanvas::renamePart(Part* part)
{
- printf("rename part: not impl.\n");
+ QString s = QInputDialog::getText(this,
+ tr("MusE: Change Part Name"),
+ tr("PartName:"),
+ QLineEdit::Normal,
+ part->name()
+ );
+ if (s != part->name()) {
+ song->startUndo();
+ Part* newPart = new Part(*part);
+ newPart->setName(s);
+ song->cmdChangePart(part, newPart);
+ song->endUndo(SC_PART_MODIFIED);
+ widget()->update();
+ }
}
//---------------------------------------------------------
diff --git a/muse/muse/miditrack.cpp b/muse/muse/miditrack.cpp
index 97f71778..fe4a6768 100644
--- a/muse/muse/miditrack.cpp
+++ b/muse/muse/miditrack.cpp
@@ -119,7 +119,7 @@ void MidiTrack::read(QDomNode node)
compression = i;
else if (tag == "part") {
Part* p = newPart();
- p->read(node.firstChild());
+ p->read(node);
parts()->add(p);
}
else if (tag == "locked")
diff --git a/muse/muse/part.cpp b/muse/muse/part.cpp
index e556e126..b4a6bc86 100644
--- a/muse/muse/part.cpp
+++ b/muse/muse/part.cpp
@@ -402,7 +402,10 @@ void Part::write(Xml& xml) const
int id = -1;
bool dumpEvents = true;
- if (el->arefCount() > 1) {
+ if (isCloned()) {
+ // we have to dump the event list only on first
+ // incarnation of clone
+
for (iClone i = cloneList.begin(); i != cloneList.end(); ++i) {
if (i->el == el) {
id = i->id;
@@ -421,7 +424,8 @@ void Part::write(Xml& xml) const
xml.tag("part cloneId=\"%d\"", id);
else
xml.tag("part");
- xml.strTag("name", _name);
+ if (!_name.isEmpty())
+ xml.strTag("name", _name);
PosLen::write(xml, "poslen");
if (_selected)
@@ -453,11 +457,12 @@ void Part::write(Xml& xml) const
void Part::read(QDomNode node)
{
- int id = -1;
+ QDomElement e = node.toElement();
+ int id = e.attribute("cloneId", "-1").toInt();
bool containsEvents = false;
ctrlCanvasList.clear();
- while (!node.isNull()) {
+ for (node = node.firstChild(); !node.isNull(); node = node.nextSibling()) {
QDomElement e = node.toElement();
QString tag(e.tagName());
QString s(e.text());
@@ -518,11 +523,8 @@ void Part::read(QDomNode node)
_events->add(e);
}
}
- else if (tag == "cloneId")
- id = i;
else
printf("MusE:read: unknown tag %s\n", e.tagName().toLatin1().data());
- node = node.nextSibling();
}
if (id != -1) {
@@ -549,4 +551,12 @@ void Part::read(QDomNode node)
}
}
+//---------------------------------------------------------
+// isCloned
+// return true if this part is cloned
+//---------------------------------------------------------
+bool Part::isCloned() const
+ {
+ return _events->arefCount() > 1;
+ }
diff --git a/muse/muse/part.h b/muse/muse/part.h
index c98a7256..5f898f1a 100644
--- a/muse/muse/part.h
+++ b/muse/muse/part.h
@@ -123,6 +123,8 @@ class Part : public AL::PosLen {
void read(QDomNode);
void write(Xml&) const;
void dump(int n = 0) const;
+
+ bool isCloned() const;
};
//---------------------------------------------------------
diff --git a/muse/muse/undo.cpp b/muse/muse/undo.cpp
index ef402492..61d9c7e9 100644
--- a/muse/muse/undo.cpp
+++ b/muse/muse/undo.cpp
@@ -29,8 +29,8 @@
// iundo points to last Undo() in Undo-list
static bool undoMode = false; // for debugging
-
std::list<QString> temporaryWavFiles;
+
//---------------------------------------------------------
// typeName
//---------------------------------------------------------
@@ -38,12 +38,13 @@ std::list<QString> temporaryWavFiles;
const char* UndoOp::typeName()
{
static const char* name[] = {
- "AddTrack", "DeleteTrack",
+ "AddTrack", "DeleteTrack", "RenameTrack",
"AddPart", "DeletePart", "ModifyPart",
"AddEvent", "DeleteEvent", "ModifyEvent",
"AddTempo", "DeleteTempo",
"AddSig", "DeleteSig",
"SwapTrack",
+ "ModifyClip",
"AddCtrl", "RemoveCtrl", "ModifyCtrl"
};
return name[type];
@@ -121,9 +122,9 @@ void Song::doUndo2()
{
Undo& u = undoList->back();
-//printf("doUndo2\n");
+// printf("doUndo2\n");
for (riUndoOp i = u.rbegin(); i != u.rend(); ++i) {
-//printf(" doUndo2 %s\n", i->typeName());
+// printf(" doUndo2 %s\n", i->typeName());
switch(i->type) {
case UndoOp::AddTrack:
removeTrack2(i->track);
@@ -160,8 +161,6 @@ void Song::doUndo2()
break;
case UndoOp::ModifyPart:
changePart(i->oPart, i->nPart);
- i->oPart->events()->incARef(-1);
- i->nPart->events()->incARef(1);
updateFlags |= SC_PART_MODIFIED;
break;
case UndoOp::AddEvent:
@@ -201,6 +200,8 @@ void Song::doUndo2()
case UndoOp::ModifyCtrl:
i->track->addControllerVal(i->id, i->time, i->cval2);
break;
+ case UndoOp::ModifyClip:
+ break;
}
}
}
@@ -212,9 +213,9 @@ void Song::doUndo2()
void Song::doRedo2()
{
Undo& u = redoList->back();
-//printf("doRedo2\n");
+// printf("doRedo2\n");
for (iUndoOp i = u.begin(); i != u.end(); ++i) {
-//printf(" doUndo2 %s\n", i->typeName());
+// printf(" doRedo2 %s\n", i->typeName());
switch(i->type) {
case UndoOp::AddTrack:
insertTrack2(i->track);
@@ -251,8 +252,6 @@ void Song::doRedo2()
case UndoOp::ModifyPart:
changePart(i->nPart, i->oPart);
updateFlags |= SC_PART_MODIFIED;
- i->oPart->events()->incARef(1);
- i->nPart->events()->incARef(-1);
break;
case UndoOp::AddEvent:
addEvent(i->nEvent, i->part);
@@ -292,6 +291,8 @@ void Song::doRedo2()
case UndoOp::ModifyCtrl:
i->track->addControllerVal(i->id, i->time, i->cval1);
break;
+ case UndoOp::ModifyClip:
+ break;
}
}
}
@@ -424,8 +425,10 @@ bool Song::doUndo1()
{
if (undoList->empty())
return true;
+// printf("doUndo1\n");
Undo& u = undoList->back();
for (riUndoOp i = u.rbegin(); i != u.rend(); ++i) {
+// printf(" doUndo1 %s\n", i->typeName());
switch(i->type) {
case UndoOp::AddTrack:
removeTrack1(i->track);
@@ -450,8 +453,10 @@ bool Song::doUndo1()
void Song::doUndo3()
{
+// printf("doUndo3\n");
Undo& u = undoList->back();
for (riUndoOp i = u.rbegin(); i != u.rend(); ++i) {
+// printf(" doUndo3 %s\n", i->typeName());
switch(i->type) {
case UndoOp::AddTrack:
removeTrack3(i->track);
@@ -490,8 +495,10 @@ bool Song::doRedo1()
{
if (redoList->empty())
return true;
+// printf("doRedo1\n");
Undo& u = redoList->back();
for (iUndoOp i = u.begin(); i != u.end(); ++i) {
+// printf(" doRedo1 %s\n", i->typeName());
switch(i->type) {
case UndoOp::AddTrack:
insertTrack1(i->track, i->id);
@@ -518,8 +525,10 @@ bool Song::doRedo1()
void Song::doRedo3()
{
+// printf("doRedo3\n");
Undo& u = redoList->back();
for (iUndoOp i = u.begin(); i != u.end(); ++i) {
+// printf(" doRedo3 %s\n", i->typeName());
switch(i->type) {
case UndoOp::AddTrack:
emit trackAdded(i->track, i->id);
diff --git a/muse/muse/wavetrack.cpp b/muse/muse/wavetrack.cpp
index c3dce3f3..10753640 100644
--- a/muse/muse/wavetrack.cpp
+++ b/muse/muse/wavetrack.cpp
@@ -150,7 +150,7 @@ void WaveTrack::read(QDomNode node)
QDomElement e = node.toElement();
if (e.tagName() == "part") {
Part* p = newPart();
- p->read(node.firstChild());
+ p->read(node);
parts()->add(p);
}
else if (AudioTrack::readProperties(node))