48 |
m_ui.setupUi(this); |
m_ui.setupUi(this); |
49 |
|
|
50 |
// Setup toolbar widgets. |
// Setup toolbar widgets. |
51 |
m_pMapComboBox = new QComboBox(m_ui.InstrumentToolbar); |
m_pMapComboBox = new QComboBox(m_ui.instrumentToolbar); |
52 |
m_pMapComboBox->setMinimumWidth(120); |
m_pMapComboBox->setMinimumWidth(120); |
53 |
m_pMapComboBox->setEnabled(false); |
m_pMapComboBox->setEnabled(false); |
54 |
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
55 |
m_ui.InstrumentToolbar->addWidget(m_pMapComboBox); |
m_ui.instrumentToolbar->addWidget(m_pMapComboBox); |
56 |
|
|
57 |
m_ui.InstrumentToolbar->addSeparator(); |
m_ui.instrumentToolbar->addSeparator(); |
58 |
m_ui.InstrumentToolbar->addAction(m_ui.newInstrumentAction); |
m_ui.instrumentToolbar->addAction(m_ui.newInstrumentAction); |
59 |
m_ui.InstrumentToolbar->addAction(m_ui.editInstrumentAction); |
m_ui.instrumentToolbar->addAction(m_ui.editInstrumentAction); |
60 |
m_ui.InstrumentToolbar->addAction(m_ui.deleteInstrumentAction); |
m_ui.instrumentToolbar->addAction(m_ui.deleteInstrumentAction); |
61 |
m_ui.InstrumentToolbar->addSeparator(); |
m_ui.instrumentToolbar->addSeparator(); |
62 |
m_ui.InstrumentToolbar->addAction(m_ui.refreshInstrumentsAction); |
m_ui.instrumentToolbar->addAction(m_ui.refreshInstrumentsAction); |
63 |
|
|
64 |
m_pInstrumentListView = new InstrumentListView(this); |
m_pInstrumentListView = new InstrumentListView(this); |
|
|
|
|
QHeaderView *pHeader = m_pInstrumentListView->header(); |
|
|
pHeader->setDefaultAlignment(Qt::AlignLeft); |
|
|
pHeader->setMovable(false); |
|
|
pHeader->setStretchLastSection(true); |
|
|
pHeader->resizeSection(0, 120); // Name |
|
|
m_pInstrumentListView->resizeColumnToContents(1); // Map |
|
|
m_pInstrumentListView->resizeColumnToContents(2); // Bank |
|
|
m_pInstrumentListView->resizeColumnToContents(3); // Prog |
|
|
m_pInstrumentListView->resizeColumnToContents(4); // Engine |
|
|
pHeader->resizeSection(5, 240); // File |
|
|
m_pInstrumentListView->resizeColumnToContents(6); // Nr |
|
|
pHeader->resizeSection(7, 60); // Vol |
|
|
|
|
|
// Enable custom context menu... |
|
65 |
m_pInstrumentListView->setContextMenuPolicy(Qt::CustomContextMenu); |
m_pInstrumentListView->setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
66 |
QMainWindow::setCentralWidget(m_pInstrumentListView); |
QMainWindow::setCentralWidget(m_pInstrumentListView); |
67 |
|
|
68 |
QObject::connect(m_pMapComboBox, |
QObject::connect(m_pMapComboBox, |
74 |
SLOT(contextMenu(const QPoint&))); |
SLOT(contextMenu(const QPoint&))); |
75 |
QObject::connect( |
QObject::connect( |
76 |
m_pInstrumentListView, |
m_pInstrumentListView, |
77 |
SIGNAL(pressed(const QModelIndex&)), |
SIGNAL(activated(const QModelIndex&)), |
78 |
SLOT(stabilizeForm())); |
SLOT(stabilizeForm())); |
79 |
QObject::connect( |
QObject::connect( |
80 |
m_pInstrumentListView, |
m_pInstrumentListView, |
81 |
SIGNAL(activated(const QModelIndex&)), |
SIGNAL(doubleClicked(const QModelIndex&)), |
82 |
SLOT(editInstrument(const QModelIndex&))); |
SLOT(editInstrument(const QModelIndex&))); |
83 |
QObject::connect( |
QObject::connect( |
84 |
m_ui.newInstrumentAction, |
m_ui.newInstrumentAction, |
211 |
if (pInstrument == NULL) |
if (pInstrument == NULL) |
212 |
return; |
return; |
213 |
|
|
|
if (pInstrument == NULL) |
|
|
return; |
|
|
|
|
214 |
// Save current key values... |
// Save current key values... |
215 |
Instrument oldInstrument( |
int iMap = pInstrument->map(); |
216 |
pInstrument->map(), |
int iBank = pInstrument->bank(); |
217 |
pInstrument->bank(), |
int iProg = pInstrument->prog(); |
218 |
pInstrument->prog()); |
|
219 |
|
Instrument instrument(iMap, iBank, iProg); |
220 |
|
|
221 |
// Do the edit dance... |
// Do the edit dance... |
222 |
InstrumentForm form(this); |
InstrumentForm form(this); |
223 |
form.setup(pInstrument); |
form.setup(&instrument); |
224 |
if (form.exec()) { |
if (form.exec()) { |
225 |
// Commit... |
// Commit... |
226 |
pInstrument->mapInstrument(); |
instrument.mapInstrument(); |
227 |
// Check whether we changed instrument key... |
// Check whether we changed instrument key... |
228 |
if (oldInstrument.map() == pInstrument->map() && |
if (instrument.map() == iMap && |
229 |
oldInstrument.bank() == pInstrument->bank() && |
instrument.bank() == iBank && |
230 |
oldInstrument.prog() == pInstrument->prog()) { |
instrument.prog() == iProg) { |
231 |
// Just update tree item... |
// Just update tree item... |
232 |
//pItem->update(); |
//pItem->update(); |
233 |
} else { |
} else { |
234 |
// Unmap old instance... |
// Unmap old instance... |
235 |
oldInstrument.unmapInstrument(); |
Instrument(iMap, iBank, iProg).unmapInstrument(); |
236 |
// correct the position of the instrument in the model |
// correct the position of the instrument in the model |
237 |
m_pInstrumentListView->updateInstrument(pInstrument); |
m_pInstrumentListView->updateInstrument(pInstrument); |
238 |
} |
} |
239 |
} |
} |
240 |
|
|
241 |
|
stabilizeForm(); |
242 |
} |
} |
243 |
|
|
244 |
|
|
259 |
instrument.map(), |
instrument.map(), |
260 |
instrument.bank(), |
instrument.bank(), |
261 |
instrument.prog()); |
instrument.prog()); |
262 |
|
|
263 |
|
stabilizeForm(); |
264 |
} |
} |
265 |
|
|
266 |
|
|
297 |
|
|
298 |
// let the instrument vanish from the table model |
// let the instrument vanish from the table model |
299 |
m_pInstrumentListView->removeInstrument(pInstrument); |
m_pInstrumentListView->removeInstrument(pInstrument); |
300 |
|
|
301 |
|
stabilizeForm(); |
302 |
} |
} |
303 |
|
|
304 |
|
|