30 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
31 |
|
|
32 |
#include <QHeaderView> |
#include <QHeaderView> |
33 |
|
#include <QMessageBox> |
34 |
|
|
35 |
|
|
36 |
namespace QSampler { |
namespace QSampler { |
73 |
m_ui.InstrumentTable->resizeColumnToContents(4); // Engine |
m_ui.InstrumentTable->resizeColumnToContents(4); // Engine |
74 |
pHeader->resizeSection(5, 240); // File |
pHeader->resizeSection(5, 240); // File |
75 |
m_ui.InstrumentTable->resizeColumnToContents(6); // Nr |
m_ui.InstrumentTable->resizeColumnToContents(6); // Nr |
76 |
pHeader->resizeSection(7, 60); // vol |
pHeader->resizeSection(7, 60); // Vol |
77 |
|
|
78 |
|
// Enable custom context menu... |
79 |
|
m_ui.InstrumentTable->setContextMenuPolicy(Qt::CustomContextMenu); |
80 |
|
|
81 |
QObject::connect(m_pMapComboBox, |
QObject::connect(m_pMapComboBox, |
82 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
83 |
SLOT(activateMap(int))); |
SLOT(activateMap(int))); |
84 |
QObject::connect( |
QObject::connect( |
85 |
m_ui.refreshInstrumentsAction, |
m_ui.InstrumentTable, |
86 |
SIGNAL(triggered()), |
SIGNAL(customContextMenuRequested(const QPoint&)), |
87 |
SLOT(refreshInstruments(void))); |
SLOT(contextMenu(const QPoint&))); |
88 |
|
QObject::connect( |
89 |
|
m_ui.InstrumentTable, |
90 |
|
SIGNAL(pressed(const QModelIndex&)), |
91 |
|
SLOT(stabilizeForm())); |
92 |
QObject::connect( |
QObject::connect( |
93 |
m_ui.InstrumentTable, |
m_ui.InstrumentTable, |
94 |
SIGNAL(activated(const QModelIndex&)), |
SIGNAL(activated(const QModelIndex&)), |
105 |
m_ui.editInstrumentAction, |
m_ui.editInstrumentAction, |
106 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
107 |
SLOT(editInstrument())); |
SLOT(editInstrument())); |
108 |
|
QObject::connect( |
109 |
|
m_ui.refreshInstrumentsAction, |
110 |
|
SIGNAL(triggered()), |
111 |
|
SLOT(refreshInstruments())); |
112 |
|
|
113 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
114 |
if (pMainForm) { |
if (pMainForm) { |
116 |
SIGNAL(instrumentsChanged()), |
SIGNAL(instrumentsChanged()), |
117 |
pMainForm, SLOT(sessionDirty())); |
pMainForm, SLOT(sessionDirty())); |
118 |
} |
} |
119 |
|
|
120 |
|
// Things must be stable from the start. |
121 |
|
stabilizeForm(); |
122 |
} |
} |
123 |
|
|
124 |
|
|
209 |
|
|
210 |
m_model.setMidiMap(iMidiMap); |
m_model.setMidiMap(iMidiMap); |
211 |
m_model.refresh(); |
m_model.refresh(); |
212 |
|
|
213 |
|
stabilizeForm(); |
214 |
} |
} |
215 |
|
|
216 |
|
|
284 |
if (!index.isValid() || !index.data(Qt::UserRole).isValid()) |
if (!index.isValid() || !index.data(Qt::UserRole).isValid()) |
285 |
return; |
return; |
286 |
|
|
287 |
qsamplerInstrument* pInstrument = |
qsamplerInstrument *pInstrument = |
288 |
static_cast<qsamplerInstrument*> ( |
static_cast<qsamplerInstrument*> ( |
289 |
index.data(Qt::UserRole).value<void *> ()); |
index.data(Qt::UserRole).value<void *> ()); |
290 |
|
|
291 |
if (pInstrument == NULL) |
if (pInstrument == NULL) |
292 |
return; |
return; |
293 |
|
|
294 |
|
MainForm *pMainForm = MainForm::getInstance(); |
295 |
|
if (pMainForm == NULL) |
296 |
|
return; |
297 |
|
|
298 |
|
// Prompt user if this is for real... |
299 |
|
qsamplerOptions *pOptions = pMainForm->options(); |
300 |
|
if (pOptions && pOptions->bConfirmRemove) { |
301 |
|
if (QMessageBox::warning(this, |
302 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
303 |
|
tr("About to delete instrument map entry:\n\n" |
304 |
|
"%1\n\n" |
305 |
|
"Are you sure?") |
306 |
|
.arg(pInstrument->name()), |
307 |
|
tr("OK"), tr("Cancel")) > 0) |
308 |
|
return; |
309 |
|
} |
310 |
|
|
311 |
pInstrument->unmapInstrument(); |
pInstrument->unmapInstrument(); |
312 |
// let the instrument vanish from the table model |
// let the instrument vanish from the table model |
313 |
m_model.removeInstrument(*pInstrument); |
m_model.removeInstrument(*pInstrument); |
315 |
emit m_model.reset(); |
emit m_model.reset(); |
316 |
} |
} |
317 |
|
|
318 |
|
|
319 |
|
// Update form actions enablement... |
320 |
|
void InstrumentListForm::stabilizeForm (void) |
321 |
|
{ |
322 |
|
MainForm *pMainForm = MainForm::getInstance(); |
323 |
|
|
324 |
|
bool bEnabled = (pMainForm && pMainForm->client()); |
325 |
|
m_ui.newInstrumentAction->setEnabled(bEnabled); |
326 |
|
const QModelIndex& index = m_ui.InstrumentTable->currentIndex(); |
327 |
|
bEnabled = (bEnabled && index.isValid()); |
328 |
|
m_ui.editInstrumentAction->setEnabled(bEnabled); |
329 |
|
m_ui.deleteInstrumentAction->setEnabled(bEnabled); |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
|
// Handle custom context menu here... |
334 |
|
void InstrumentListForm::contextMenu ( const QPoint& pos ) |
335 |
|
{ |
336 |
|
if (!m_ui.newInstrumentAction->isEnabled()) |
337 |
|
return; |
338 |
|
|
339 |
|
m_ui.contextMenu->exec( |
340 |
|
(m_ui.InstrumentTable->viewport())->mapToGlobal(pos)); |
341 |
|
} |
342 |
|
|
343 |
|
|
344 |
} // namespace QSampler |
} // namespace QSampler |
345 |
|
|
346 |
|
|