73 |
SLOT(stabilizeForm())); |
SLOT(stabilizeForm())); |
74 |
QObject::connect( |
QObject::connect( |
75 |
m_pInstrumentListView, |
m_pInstrumentListView, |
76 |
SIGNAL(doubleClicked(const QModelIndex&)), |
SIGNAL(activated(const QModelIndex&)), |
77 |
SLOT(editInstrument(const QModelIndex&))); |
SLOT(editInstrument(const QModelIndex&))); |
78 |
QObject::connect( |
QObject::connect( |
79 |
m_ui.newInstrumentAction, |
m_ui.newInstrumentAction, |
190 |
} |
} |
191 |
|
|
192 |
|
|
193 |
|
void InstrumentListForm::newInstrument (void) |
194 |
|
{ |
195 |
|
Instrument instrument; |
196 |
|
|
197 |
|
InstrumentForm form(this); |
198 |
|
form.setup(&instrument); |
199 |
|
if (!form.exec()) |
200 |
|
return; |
201 |
|
|
202 |
|
// Commit... |
203 |
|
instrument.mapInstrument(); |
204 |
|
|
205 |
|
// add new item to the table model |
206 |
|
m_pInstrumentListView->addInstrument( |
207 |
|
instrument.map(), |
208 |
|
instrument.bank(), |
209 |
|
instrument.prog()); |
210 |
|
|
211 |
|
stabilizeForm(); |
212 |
|
} |
213 |
|
|
214 |
|
|
215 |
void InstrumentListForm::editInstrument (void) |
void InstrumentListForm::editInstrument (void) |
216 |
{ |
{ |
217 |
editInstrument(m_pInstrumentListView->currentIndex()); |
editInstrument(m_pInstrumentListView->currentIndex()); |
238 |
// Do the edit dance... |
// Do the edit dance... |
239 |
InstrumentForm form(this); |
InstrumentForm form(this); |
240 |
form.setup(&instrument); |
form.setup(&instrument); |
|
if (form.exec()) { |
|
|
// Commit... |
|
|
instrument.mapInstrument(); |
|
|
// Check whether we changed instrument key... |
|
|
if (instrument.map() == iMap && |
|
|
instrument.bank() == iBank && |
|
|
instrument.prog() == iProg) { |
|
|
// Just update tree item... |
|
|
//pItem->update(); |
|
|
} else { |
|
|
// Unmap old instance... |
|
|
Instrument(iMap, iBank, iProg).unmapInstrument(); |
|
|
// correct the position of the instrument in the model |
|
|
m_pInstrumentListView->updateInstrument(pInstrument); |
|
|
} |
|
|
} |
|
|
|
|
|
stabilizeForm(); |
|
|
} |
|
|
|
|
|
|
|
|
void InstrumentListForm::newInstrument (void) |
|
|
{ |
|
|
Instrument instrument; |
|
|
|
|
|
InstrumentForm form(this); |
|
|
form.setup(&instrument); |
|
241 |
if (!form.exec()) |
if (!form.exec()) |
242 |
return; |
return; |
243 |
|
|
244 |
// Commit... |
// Commit... |
245 |
instrument.mapInstrument(); |
instrument.mapInstrument(); |
246 |
|
|
247 |
// add new item to the table model |
// Check whether we changed instrument key... |
248 |
m_pInstrumentListView->addInstrument( |
if (instrument.map() == iMap && |
249 |
instrument.map(), |
instrument.bank() == iBank && |
250 |
instrument.bank(), |
instrument.prog() == iProg) { |
251 |
instrument.prog()); |
// Just update tree item... |
252 |
|
//pItem->update(); |
253 |
|
} else { |
254 |
|
// Unmap old instance... |
255 |
|
Instrument(iMap, iBank, iProg).unmapInstrument(); |
256 |
|
// correct the position of the instrument in the model |
257 |
|
m_pInstrumentListView->updateInstrument(pInstrument); |
258 |
|
} |
259 |
|
|
260 |
stabilizeForm(); |
stabilizeForm(); |
261 |
} |
} |
317 |
void InstrumentListForm::contextMenuEvent ( |
void InstrumentListForm::contextMenuEvent ( |
318 |
QContextMenuEvent *pContextMenuEvent ) |
QContextMenuEvent *pContextMenuEvent ) |
319 |
{ |
{ |
320 |
if (m_ui.newInstrumentAction->isEnabled()) |
QMenu menu(this); |
321 |
m_ui.contextMenu->exec(pContextMenuEvent->globalPos()); |
|
322 |
|
menu.addAction(m_ui.newInstrumentAction); |
323 |
|
menu.addSeparator(); |
324 |
|
menu.addAction(m_ui.editInstrumentAction); |
325 |
|
menu.addAction(m_ui.deleteInstrumentAction); |
326 |
|
menu.addSeparator(); |
327 |
|
menu.addAction(m_ui.refreshInstrumentsAction); |
328 |
|
|
329 |
|
menu.exec(pContextMenuEvent->globalPos()); |
330 |
} |
} |
331 |
|
|
332 |
|
|