virtual bool operator<(const QTreeWidgetItem & other) const { int col = other.treeWidget()->sortColumn(); EventListItem* eli = (EventListItem*) & other; switch (col) { case 0: return event.tick() < eli->event.tick(); break; case 1: return part->tick() + event.tick() < (eli->part->tick() + eli->event.tick()); break; case 2: return text(col).localeAwareCompare(other.text(col)) < 0; break; case 3: return part->track()->outChannel() < eli->part->track()->outChannel(); break; case 4: return event.dataA() < eli->event.dataA(); break; case 5: return event.dataB() < eli->event.dataB(); break; case 6: return event.dataC() < eli->event.dataC(); break; case 7: return event.lenTick() < eli->event.lenTick(); break; case 8: return text(col).localeAwareCompare(other.text(col)) < 0; break; default: break; } return 0; }
QString EventListItem::text(int col) const { QString s; QString commentLabel; switch (col) { case 0: s.setNum(event.tick()); break; case 1: { int t = event.tick() + part->tick(); int bar, beat; unsigned tick; sigmap.tickValues(t, &bar, &beat, &tick); s.sprintf("%04d.%02d.%03d", bar + 1, beat + 1, tick); } break; case 2: switch (event.type()) { case Note: s = QString("Note"); break; case Controller: { const char* cs; switch (midiControllerType(event.dataA())) { case MidiController::Controller7: cs = "Ctrl7"; break; case MidiController::Controller14: cs = "Ctrl14"; break; case MidiController::RPN: cs = "RPN"; break; case MidiController::NRPN: cs = "NRPN"; break; case MidiController::Pitch: cs = "Pitch"; break; case MidiController::Program: cs = "Program"; break; case MidiController::RPN14: cs = "RPN14"; break; case MidiController::NRPN14: cs = "NRPN14"; break; default: cs = "Ctrl?"; break; } s = QString(cs); } break; case Sysex: { commentLabel = QString("len "); QString k; k.setNum(event.dataLen()); commentLabel += k; commentLabel += QString(" "); commentLabel += nameSysex(event.dataLen(), event.data()); int i; for (i = 0; i < 10; ++i) { if (i >= event.dataLen()) break; commentLabel += QString(" 0x"); QString k; k.setNum(event.data()[i] & 0xff, 16); commentLabel += k; } if (i == 10) commentLabel += QString("..."); } s = QString("SysEx"); break; case PAfter: s = QString("PoAT"); break; case CAfter: s = QString("ChAT"); break; case Meta: commentLabel = midiMetaComment(event); s = QString("Meta"); break; default: printf("unknown event type %d\n", event.type()); } break; case 3: s.setNum(part->track()->outChannel() + 1); break; case 4: if (event.isNote() || event.type() == PAfter) s = pitch2string(event.dataA()); else if (event.type() == Controller) s.setNum(event.dataA() & 0xffff); // mask off type bits else s.setNum(event.dataA()); break; case 5: if (event.type() == Controller && midiControllerType(event.dataA()) == MidiController::Program) { int val = event.dataB(); int hb = ((val >> 16) & 0xff) + 1; if (hb == 0x100) hb = 0; int lb = ((val >> 8) & 0xff) + 1; if (lb == 0x100) lb = 0; int pr = (val & 0xff) + 1; if (pr == 0x100) pr = 0; s.sprintf("%d-%d-%d", hb, lb, pr); } else