34 |
QWidget* pParent, Qt::WindowFlags wflags ) |
QWidget* pParent, Qt::WindowFlags wflags ) |
35 |
: QMainWindow(pParent, wflags) |
: QMainWindow(pParent, wflags) |
36 |
{ |
{ |
37 |
ui.setupUi(this); |
m_ui.setupUi(this); |
38 |
|
|
39 |
// Setup toolbar widgets. |
// Setup toolbar widgets. |
40 |
m_pMapComboBox = new QComboBox(ui.InstrumentToolbar); |
m_pMapComboBox = new QComboBox(m_ui.InstrumentToolbar); |
41 |
m_pMapComboBox->setMinimumWidth(120); |
m_pMapComboBox->setMinimumWidth(120); |
42 |
m_pMapComboBox->setEnabled(false); |
m_pMapComboBox->setEnabled(false); |
43 |
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
44 |
ui.InstrumentToolbar->addWidget(m_pMapComboBox); |
m_ui.InstrumentToolbar->addWidget(m_pMapComboBox); |
45 |
|
|
46 |
ui.InstrumentToolbar->addSeparator(); |
m_ui.InstrumentToolbar->addSeparator(); |
47 |
ui.InstrumentToolbar->addAction(ui.newInstrumentAction); |
m_ui.InstrumentToolbar->addAction(m_ui.newInstrumentAction); |
48 |
ui.InstrumentToolbar->addAction(ui.editInstrumentAction); |
m_ui.InstrumentToolbar->addAction(m_ui.editInstrumentAction); |
49 |
ui.InstrumentToolbar->addAction(ui.deleteInstrumentAction); |
m_ui.InstrumentToolbar->addAction(m_ui.deleteInstrumentAction); |
50 |
ui.InstrumentToolbar->addSeparator(); |
m_ui.InstrumentToolbar->addSeparator(); |
51 |
ui.InstrumentToolbar->addAction(ui.refreshInstrumentsAction); |
m_ui.InstrumentToolbar->addAction(m_ui.refreshInstrumentsAction); |
52 |
|
|
53 |
ui.InstrumentTable->setModel(&model); |
m_ui.InstrumentTable->setModel(&m_model); |
54 |
ui.InstrumentTable->setItemDelegate(&delegate); |
m_ui.InstrumentTable->setItemDelegate(&m_delegate); |
55 |
|
|
56 |
QObject::connect(m_pMapComboBox, |
QObject::connect(m_pMapComboBox, |
57 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
58 |
SLOT(activateMap(int))); |
SLOT(activateMap(int))); |
|
|
|
59 |
QObject::connect( |
QObject::connect( |
60 |
ui.refreshInstrumentsAction, |
m_ui.refreshInstrumentsAction, |
61 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
62 |
SLOT(refreshInstruments(void)) |
SLOT(refreshInstruments(void))); |
|
); |
|
|
|
|
63 |
QObject::connect( |
QObject::connect( |
64 |
ui.InstrumentTable, |
m_ui.InstrumentTable, |
65 |
SIGNAL(activated(const QModelIndex&)), |
SIGNAL(activated(const QModelIndex&)), |
66 |
SLOT(editInstrument(const QModelIndex&)) |
SLOT(editInstrument(const QModelIndex&))); |
|
); |
|
67 |
QObject::connect( |
QObject::connect( |
68 |
ui.newInstrumentAction, |
m_ui.newInstrumentAction, |
69 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
70 |
SLOT(newInstrument()) |
SLOT(newInstrument())); |
|
); |
|
71 |
QObject::connect( |
QObject::connect( |
72 |
ui.deleteInstrumentAction, |
m_ui.deleteInstrumentAction, |
73 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
74 |
SLOT(deleteInstrument()) |
SLOT(deleteInstrument())); |
|
); |
|
75 |
QObject::connect( |
QObject::connect( |
76 |
ui.editInstrumentAction, |
m_ui.editInstrumentAction, |
77 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
78 |
SLOT(editInstrument()) |
SLOT(editInstrument())); |
79 |
); |
|
80 |
|
MainForm *pMainForm = MainForm::getInstance(); |
81 |
|
if (pMainForm) { |
82 |
|
QObject::connect(&m_model, |
83 |
|
SIGNAL(instrumentsChanged()), |
84 |
|
pMainForm, SLOT(sessionDirty())); |
85 |
|
} |
86 |
} |
} |
87 |
|
|
88 |
|
|
171 |
if (iMidiMap >= 0) |
if (iMidiMap >= 0) |
172 |
pOptions->iMidiMap = iMidiMap; |
pOptions->iMidiMap = iMidiMap; |
173 |
|
|
174 |
model.setMidiMap(iMidiMap); |
m_model.setMidiMap(iMidiMap); |
175 |
model.refresh(); |
m_model.refresh(); |
176 |
} |
} |
177 |
|
|
178 |
|
|
179 |
void InstrumentListForm::editInstrument (void) |
void InstrumentListForm::editInstrument (void) |
180 |
{ |
{ |
181 |
editInstrument(ui.InstrumentTable->currentIndex()); |
editInstrument(m_ui.InstrumentTable->currentIndex()); |
182 |
} |
} |
183 |
|
|
184 |
|
|
212 |
// Unmap old instance... |
// Unmap old instance... |
213 |
oldInstrument.unmapInstrument(); |
oldInstrument.unmapInstrument(); |
214 |
// correct the position of the instrument in the model |
// correct the position of the instrument in the model |
215 |
model.resort(*pInstrument); |
m_model.resort(*pInstrument); |
216 |
} |
} |
217 |
// Notify we've changes... |
// Notify we've changes... |
218 |
emit model.reset(); |
emit m_model.reset(); |
219 |
} |
} |
220 |
} |
} |
221 |
|
|
232 |
// Commit... |
// Commit... |
233 |
instrument.mapInstrument(); |
instrument.mapInstrument(); |
234 |
// add new item to the table model |
// add new item to the table model |
235 |
model.resort(instrument); |
m_model.resort(instrument); |
236 |
// Notify we've changes... |
// Notify we've changes... |
237 |
//emit model.reset(); |
//emit model.reset(); |
238 |
//FIXME: call above didnt really refresh, so we use this for now ... |
//FIXME: call above didnt really refresh, so we use this for now ... |
242 |
|
|
243 |
void InstrumentListForm::deleteInstrument (void) |
void InstrumentListForm::deleteInstrument (void) |
244 |
{ |
{ |
245 |
const QModelIndex& index = ui.InstrumentTable->currentIndex(); |
const QModelIndex& index = m_ui.InstrumentTable->currentIndex(); |
246 |
if (!index.isValid() || !index.data(Qt::UserRole).isValid()) |
if (!index.isValid() || !index.data(Qt::UserRole).isValid()) |
247 |
return; |
return; |
248 |
|
|
255 |
|
|
256 |
pInstrument->unmapInstrument(); |
pInstrument->unmapInstrument(); |
257 |
// let the instrument vanish from the table model |
// let the instrument vanish from the table model |
258 |
model.removeInstrument(*pInstrument); |
m_model.removeInstrument(*pInstrument); |
259 |
// Notify we've changes... |
// Notify we've changes... |
260 |
emit model.reset(); |
emit m_model.reset(); |
261 |
} |
} |
262 |
|
|
263 |
} // namespace QSampler |
} // namespace QSampler |