20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
|
#include "qsamplerAbout.h" |
24 |
#include "qsamplerInstrumentListForm.h" |
#include "qsamplerInstrumentListForm.h" |
25 |
|
|
26 |
#include "qsamplerInstrumentForm.h" |
#include "qsamplerInstrumentForm.h" |
27 |
#include "qsamplerMainForm.h" |
|
28 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
29 |
#include "qsamplerInstrument.h" |
#include "qsamplerInstrument.h" |
30 |
|
#include "qsamplerMainForm.h" |
31 |
|
|
32 |
|
#include <QHeaderView> |
33 |
|
|
34 |
|
|
35 |
namespace QSampler { |
namespace QSampler { |
38 |
QWidget* pParent, Qt::WindowFlags wflags ) |
QWidget* pParent, Qt::WindowFlags wflags ) |
39 |
: QMainWindow(pParent, wflags) |
: QMainWindow(pParent, wflags) |
40 |
{ |
{ |
41 |
ui.setupUi(this); |
m_ui.setupUi(this); |
|
|
|
|
// Setup toolbar widgets. |
|
|
m_pMapComboBox = new QComboBox(ui.InstrumentToolbar); |
|
|
m_pMapComboBox->setMinimumWidth(120); |
|
|
m_pMapComboBox->setEnabled(false); |
|
|
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
|
|
ui.InstrumentToolbar->addWidget(m_pMapComboBox); |
|
|
|
|
|
ui.InstrumentToolbar->addSeparator(); |
|
|
ui.InstrumentToolbar->addAction(ui.newInstrumentAction); |
|
|
ui.InstrumentToolbar->addAction(ui.editInstrumentAction); |
|
|
ui.InstrumentToolbar->addAction(ui.deleteInstrumentAction); |
|
|
ui.InstrumentToolbar->addSeparator(); |
|
|
ui.InstrumentToolbar->addAction(ui.refreshInstrumentsAction); |
|
42 |
|
|
43 |
ui.InstrumentTable->setModel(&model); |
// Setup toolbar widgets. |
44 |
ui.InstrumentTable->setItemDelegate(&delegate); |
m_pMapComboBox = new QComboBox(m_ui.InstrumentToolbar); |
45 |
|
m_pMapComboBox->setMinimumWidth(120); |
46 |
|
m_pMapComboBox->setEnabled(false); |
47 |
|
m_pMapComboBox->setToolTip(tr("Instrument Map")); |
48 |
|
m_ui.InstrumentToolbar->addWidget(m_pMapComboBox); |
49 |
|
|
50 |
|
m_ui.InstrumentToolbar->addSeparator(); |
51 |
|
m_ui.InstrumentToolbar->addAction(m_ui.newInstrumentAction); |
52 |
|
m_ui.InstrumentToolbar->addAction(m_ui.editInstrumentAction); |
53 |
|
m_ui.InstrumentToolbar->addAction(m_ui.deleteInstrumentAction); |
54 |
|
m_ui.InstrumentToolbar->addSeparator(); |
55 |
|
m_ui.InstrumentToolbar->addAction(m_ui.refreshInstrumentsAction); |
56 |
|
|
57 |
|
int iRowHeight = m_ui.InstrumentTable->fontMetrics().height() + 4; |
58 |
|
m_ui.InstrumentTable->verticalHeader()->setDefaultSectionSize(iRowHeight); |
59 |
|
m_ui.InstrumentTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); |
60 |
|
|
61 |
|
m_ui.InstrumentTable->setModel(&m_model); |
62 |
|
m_ui.InstrumentTable->setItemDelegate(&m_delegate); |
63 |
|
m_ui.InstrumentTable->verticalHeader()->hide(); |
64 |
|
|
65 |
QObject::connect(m_pMapComboBox, |
QObject::connect(m_pMapComboBox, |
66 |
SIGNAL(activated(int)), |
SIGNAL(activated(int)), |
67 |
SLOT(activateMap(int))); |
SLOT(activateMap(int))); |
|
|
|
68 |
QObject::connect( |
QObject::connect( |
69 |
ui.refreshInstrumentsAction, |
m_ui.refreshInstrumentsAction, |
70 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
71 |
SLOT(refreshInstruments(void)) |
SLOT(refreshInstruments(void))); |
|
); |
|
|
|
|
72 |
QObject::connect( |
QObject::connect( |
73 |
ui.InstrumentTable, |
m_ui.InstrumentTable, |
74 |
SIGNAL(activated(const QModelIndex&)), |
SIGNAL(activated(const QModelIndex&)), |
75 |
SLOT(editInstrument(const QModelIndex&)) |
SLOT(editInstrument(const QModelIndex&))); |
|
); |
|
76 |
QObject::connect( |
QObject::connect( |
77 |
ui.newInstrumentAction, |
m_ui.newInstrumentAction, |
78 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
79 |
SLOT(newInstrument()) |
SLOT(newInstrument())); |
|
); |
|
80 |
QObject::connect( |
QObject::connect( |
81 |
ui.deleteInstrumentAction, |
m_ui.deleteInstrumentAction, |
82 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
83 |
SLOT(deleteInstrument()) |
SLOT(deleteInstrument())); |
|
); |
|
84 |
QObject::connect( |
QObject::connect( |
85 |
ui.editInstrumentAction, |
m_ui.editInstrumentAction, |
86 |
SIGNAL(triggered()), |
SIGNAL(triggered()), |
87 |
SLOT(editInstrument()) |
SLOT(editInstrument())); |
88 |
); |
|
89 |
|
MainForm *pMainForm = MainForm::getInstance(); |
90 |
|
if (pMainForm) { |
91 |
|
QObject::connect(&m_model, |
92 |
|
SIGNAL(instrumentsChanged()), |
93 |
|
pMainForm, SLOT(sessionDirty())); |
94 |
|
} |
95 |
} |
} |
96 |
|
|
97 |
|
|
180 |
if (iMidiMap >= 0) |
if (iMidiMap >= 0) |
181 |
pOptions->iMidiMap = iMidiMap; |
pOptions->iMidiMap = iMidiMap; |
182 |
|
|
183 |
model.setMidiMap(iMidiMap); |
m_model.setMidiMap(iMidiMap); |
184 |
model.refresh(); |
m_model.refresh(); |
185 |
} |
} |
186 |
|
|
187 |
|
|
188 |
void InstrumentListForm::editInstrument (void) |
void InstrumentListForm::editInstrument (void) |
189 |
{ |
{ |
190 |
editInstrument(ui.InstrumentTable->currentIndex()); |
editInstrument(m_ui.InstrumentTable->currentIndex()); |
191 |
} |
} |
192 |
|
|
193 |
|
|
221 |
// Unmap old instance... |
// Unmap old instance... |
222 |
oldInstrument.unmapInstrument(); |
oldInstrument.unmapInstrument(); |
223 |
// correct the position of the instrument in the model |
// correct the position of the instrument in the model |
224 |
model.resort(*pInstrument); |
m_model.resort(*pInstrument); |
225 |
} |
} |
226 |
// Notify we've changes... |
// Notify we've changes... |
227 |
emit model.reset(); |
emit m_model.reset(); |
228 |
} |
} |
229 |
} |
} |
230 |
|
|
241 |
// Commit... |
// Commit... |
242 |
instrument.mapInstrument(); |
instrument.mapInstrument(); |
243 |
// add new item to the table model |
// add new item to the table model |
244 |
model.resort(instrument); |
m_model.resort(instrument); |
245 |
// Notify we've changes... |
// Notify we've changes... |
246 |
//emit model.reset(); |
//emit model.reset(); |
247 |
//FIXME: call above didnt really refresh, so we use this for now ... |
//FIXME: call above didnt really refresh, so we use this for now ... |
251 |
|
|
252 |
void InstrumentListForm::deleteInstrument (void) |
void InstrumentListForm::deleteInstrument (void) |
253 |
{ |
{ |
254 |
const QModelIndex& index = ui.InstrumentTable->currentIndex(); |
const QModelIndex& index = m_ui.InstrumentTable->currentIndex(); |
255 |
if (!index.isValid() || !index.data(Qt::UserRole).isValid()) |
if (!index.isValid() || !index.data(Qt::UserRole).isValid()) |
256 |
return; |
return; |
257 |
|
|
264 |
|
|
265 |
pInstrument->unmapInstrument(); |
pInstrument->unmapInstrument(); |
266 |
// let the instrument vanish from the table model |
// let the instrument vanish from the table model |
267 |
model.removeInstrument(*pInstrument); |
m_model.removeInstrument(*pInstrument); |
268 |
// Notify we've changes... |
// Notify we've changes... |
269 |
emit model.reset(); |
emit m_model.reset(); |
270 |
} |
} |
271 |
|
|
272 |
} // namespace QSampler |
} // namespace QSampler |