41 |
ChannelForm::ChannelForm ( QWidget* pParent ) |
ChannelForm::ChannelForm ( QWidget* pParent ) |
42 |
: QDialog(pParent) |
: QDialog(pParent) |
43 |
{ |
{ |
44 |
m_ui.setupUi(this); |
m_ui.setupUi(this); |
45 |
|
|
46 |
// Initialize locals. |
// Initialize locals. |
47 |
m_pChannel = NULL; |
m_pChannel = NULL; |
54 |
|
|
55 |
m_pDeviceForm = NULL; |
m_pDeviceForm = NULL; |
56 |
|
|
57 |
|
int iRowHeight = m_ui.AudioRoutingTable->fontMetrics().height() + 4; |
58 |
|
m_ui.AudioRoutingTable->verticalHeader()->setDefaultSectionSize(iRowHeight); |
59 |
|
m_ui.AudioRoutingTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); |
60 |
|
|
61 |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
m_ui.AudioRoutingTable->setModel(&m_routingModel); |
62 |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
m_ui.AudioRoutingTable->setItemDelegate(&m_routingDelegate); |
63 |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
m_ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
64 |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
// m_ui.AudioRoutingTable->verticalHeader()->hide(); |
65 |
|
|
66 |
// This goes initially hidden, and will be shown |
// This goes initially hidden, and will be shown |
67 |
// on setup() for currently existing channels... |
// on setup() for currently existing channels... |
68 |
m_ui.AudioRoutingTable->hide(); |
m_ui.AudioRoutingTable->hide(); |
69 |
|
|
70 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
222 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
223 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
224 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
225 |
m_ui.InstrumentNrComboBox->setCurrentIndex(pChannel->instrumentNr()); |
int iInstrumentNr = pChannel->instrumentNr(); |
226 |
|
if (iInstrumentNr < 0) |
227 |
|
iInstrumentNr = 0; |
228 |
|
m_ui.InstrumentNrComboBox->setCurrentIndex(iInstrumentNr); |
229 |
|
|
230 |
// MIDI input device... |
// MIDI input device... |
231 |
qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice()); |
qsamplerDevice midiDevice(qsamplerDevice::Midi, m_pChannel->midiDevice()); |
300 |
// if we're editing an existing sampler channel... |
// if we're editing an existing sampler channel... |
301 |
m_ui.AudioRoutingTable->setVisible(!bNew); |
m_ui.AudioRoutingTable->setVisible(!bNew); |
302 |
|
|
303 |
|
const QString sInstrumentNrToolTip = |
304 |
|
(pOptions->bInstrumentNames) ? |
305 |
|
"Select an instrument of the file" : |
306 |
|
"You might want to enable instrument name retrieval in the " |
307 |
|
"settings dialog"; |
308 |
|
m_ui.InstrumentNrComboBox->setToolTip( |
309 |
|
QObject::tr(sInstrumentNrToolTip.toUtf8().data()) |
310 |
|
); |
311 |
|
|
312 |
// As convenient, make it ready on stabilizeForm() for |
// As convenient, make it ready on stabilizeForm() for |
313 |
// prompt acceptance, if we got the minimum required... |
// prompt acceptance, if we got the minimum required... |
314 |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
/* if (sEngineName != qsamplerChannel::noEngineName() && |
402 |
if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex())) |
if (!m_pChannel->setMidiMap(m_ui.MidiMapComboBox->currentIndex())) |
403 |
iErrors++; |
iErrors++; |
404 |
// Show error messages? |
// Show error messages? |
405 |
if (iErrors > 0) |
if (iErrors > 0) { |
406 |
m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry.")); |
m_pChannel->appendMessagesError( |
407 |
|
tr("Some channel settings could not be set.\n\nSorry.")); |
408 |
|
} |
409 |
} |
} |
410 |
|
|
411 |
// Save default engine name, instrument directory and history... |
// Save default engine name, instrument directory and history... |
510 |
qsamplerDevice::DeviceType deviceTypeMode, |
qsamplerDevice::DeviceType deviceTypeMode, |
511 |
const QString& sDriverName ) |
const QString& sDriverName ) |
512 |
{ |
{ |
|
if (pDevice == NULL) |
|
|
return; |
|
|
|
|
513 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
514 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
515 |
return; |
return; |
519 |
// Create the device form if not already... |
// Create the device form if not already... |
520 |
if (m_pDeviceForm == NULL) { |
if (m_pDeviceForm == NULL) { |
521 |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
m_pDeviceForm = new DeviceForm(this, Qt::Dialog); |
522 |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
m_pDeviceForm->setAttribute(Qt::WA_ShowModal); |
523 |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
QObject::connect(m_pDeviceForm, SIGNAL(devicesChanged()), |
524 |
this, SLOT(updateDevices())); |
this, SLOT(updateDevices())); |
525 |
} |
} |
568 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
569 |
pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]); |
pDevice = new qsamplerDevice(qsamplerDevice::Midi, piDeviceIDs[i]); |
570 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
571 |
m_ui.MidiDeviceComboBox->insertItem(0, midiPixmap, pDevice->deviceName()); |
m_ui.MidiDeviceComboBox->insertItem(0, |
572 |
|
midiPixmap, pDevice->deviceName()); |
573 |
m_midiDevices.append(pDevice); |
m_midiDevices.append(pDevice); |
574 |
} else { |
} else { |
575 |
delete pDevice; |
delete pDevice; |
683 |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
684 |
pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]); |
pDevice = new qsamplerDevice(qsamplerDevice::Audio, piDeviceIDs[i]); |
685 |
if (pDevice->driverName().toUpper() == sDriverName) { |
if (pDevice->driverName().toUpper() == sDriverName) { |
686 |
m_ui.AudioDeviceComboBox->insertItem(0, audioPixmap, pDevice->deviceName()); |
m_ui.AudioDeviceComboBox->insertItem(0, |
687 |
|
audioPixmap, pDevice->deviceName()); |
688 |
m_audioDevices.append(pDevice); |
m_audioDevices.append(pDevice); |
689 |
} else { |
} else { |
690 |
delete pDevice; |
delete pDevice; |
793 |
{ |
{ |
794 |
const bool bValid = |
const bool bValid = |
795 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
796 |
m_ui.EngineNameComboBox->currentText() != |
m_ui.EngineNameComboBox->currentText() |
797 |
qsamplerChannel::noEngineName(); |
!= qsamplerChannel::noEngineName(); |
798 |
#if 0 |
#if 0 |
799 |
const QString& sPath = InstrumentFileComboBox->currentText(); |
const QString& sPath = InstrumentFileComboBox->currentText(); |
800 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
805 |
|
|
806 |
void ChannelForm::updateTableCellRenderers (void) |
void ChannelForm::updateTableCellRenderers (void) |
807 |
{ |
{ |
808 |
const int rows = m_routingModel.rowCount(); |
const int rows = m_routingModel.rowCount(); |
809 |
const int cols = m_routingModel.columnCount(); |
const int cols = m_routingModel.columnCount(); |
810 |
updateTableCellRenderers( |
updateTableCellRenderers( |
811 |
m_routingModel.index(0, 0), |
m_routingModel.index(0, 0), |
812 |
m_routingModel.index(rows - 1, cols - 1)); |
m_routingModel.index(rows - 1, cols - 1)); |
813 |
} |
} |
816 |
void ChannelForm::updateTableCellRenderers ( |
void ChannelForm::updateTableCellRenderers ( |
817 |
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
const QModelIndex& topLeft, const QModelIndex& bottomRight ) |
818 |
{ |
{ |
819 |
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
for (int r = topLeft.row(); r <= bottomRight.row(); r++) { |
820 |
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
for (int c = topLeft.column(); c <= bottomRight.column(); c++) { |
821 |
const QModelIndex index = m_routingModel.index(r, c); |
const QModelIndex index = m_routingModel.index(r, c); |
822 |
m_ui.AudioRoutingTable->openPersistentEditor(index); |
m_ui.AudioRoutingTable->openPersistentEditor(index); |
823 |
} |
} |
824 |
} |
} |
825 |
} |
} |
826 |
|
|
827 |
} // namespace QSampler |
} // namespace QSampler |