--- qsampler/trunk/src/qsamplerDeviceForm.cpp 2007/11/05 20:47:38 1474 +++ qsampler/trunk/src/qsamplerDeviceForm.cpp 2007/11/17 02:02:28 1486 @@ -40,17 +40,15 @@ // No exclusive mode as default. m_deviceTypeMode = qsamplerDevice::None; + ui.DeviceListView->header()->hide(); + ui.DeviceParamTable->setModel(&deviceParamModel); ui.DeviceParamTable->setItemDelegate(&deviceParamDelegate); + ui.DeviceParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); ui.DevicePortParamTable->setModel(&devicePortParamModel); ui.DevicePortParamTable->setItemDelegate(&devicePortParamDelegate); - - // This an outsider (from designer), but rather important. - //QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)), - // this, SLOT(changeDeviceParam(int,int))); - //QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)), - // this, SLOT(changeDevicePortParam(int,int))); + ui.DevicePortParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); // Initial contents. refreshDevices(); @@ -58,7 +56,7 @@ adjustSize(); QObject::connect(ui.DeviceListView, - SIGNAL(itemSelectionChanged()), + SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(selectDevice())); QObject::connect(ui.DeviceListView, SIGNAL(customContextMenuRequested(const QPoint&)), @@ -81,6 +79,18 @@ QObject::connect(ui.ClosePushButton, SIGNAL(clicked()), SLOT(close())); + QObject::connect(&deviceParamModel, + SIGNAL(modelReset()), + SLOT(updateCellRenderers())); + QObject::connect(&deviceParamModel, + SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), + SLOT(updateCellRenderers(const QModelIndex&, const QModelIndex&))); + QObject::connect(&devicePortParamModel, + SIGNAL(modelReset()), + SLOT(updatePortCellRenderers())); + QObject::connect(&devicePortParamModel, + SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), + SLOT(updatePortCellRenderers(const QModelIndex&, const QModelIndex&))); } DeviceForm::~DeviceForm() { @@ -341,7 +351,7 @@ if (m_bNewDevice) { m_iDirtySetup++; device.setDriver(sDriverName); - deviceParamModel.refresh(device.params(), m_bNewDevice); + deviceParamModel.refresh(&device, m_bNewDevice); m_iDirtySetup--; // Done. stabilizeForm(); @@ -350,7 +360,7 @@ // Device selection slot. -void DeviceForm::selectDevice (void) +void DeviceForm::selectDevice () { MainForm *pMainForm = MainForm::getInstance(); if (pMainForm == NULL) @@ -399,7 +409,7 @@ ui.DriverNameTextLabel->setEnabled(m_bNewDevice); ui.DriverNameComboBox->setEnabled(m_bNewDevice); // Fill the device parameter table... - deviceParamModel.refresh(device.params(), m_bNewDevice); + deviceParamModel.refresh(&device, m_bNewDevice); // And now the device port/channel parameter table... switch (device.deviceType()) { case qsamplerDevice::Audio: @@ -421,10 +431,10 @@ QPixmap pixmap; switch (device.deviceType()) { case qsamplerDevice::Audio: - pixmap = QPixmap(":/qsampler/pixmaps/audio2.png"); + pixmap = QPixmap(":/icons/audio2.png"); break; case qsamplerDevice::Midi: - pixmap = QPixmap(":/qsampler/pixmaps/midi2.png"); + pixmap = QPixmap(":/icons/midi2.png"); break; case qsamplerDevice::None: break; @@ -467,7 +477,7 @@ qsamplerDevicePort *pPort = device.ports().at(iPort); if (pPort) { m_iDirtySetup++; - devicePortParamModel.refresh(pPort->params(), false); + devicePortParamModel.refresh(pPort, false); m_iDirtySetup--; } // Done. @@ -487,6 +497,7 @@ // Device parameter change... // +/* we do that in the model class now ... QTreeWidgetItem* pItem = ui.DeviceListView->currentItem(); if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) return; @@ -504,6 +515,7 @@ } else { stabilizeForm(); } +*/ // Main session should be dirtier... MainForm *pMainForm = MainForm::getInstance(); @@ -524,6 +536,7 @@ // Device port/channel parameter change... // +/* we do that in the model class now ... QTreeWidgetItem* pItem = ui.DeviceListView->currentItem(); if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) return; @@ -543,6 +556,8 @@ // Set the local device port/channel parameter value. pPort->setParam(sParam, sValue); +*/ + // Done. stabilizeForm(); @@ -607,6 +622,36 @@ ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice); } +void DeviceForm::updateCellRenderers() { + const int rows = deviceParamModel.rowCount(); + const int cols = deviceParamModel.columnCount(); + updateCellRenderers(deviceParamModel.index(0,0),deviceParamModel.index(rows-1,cols-1)); +} + +void DeviceForm::updateCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) { + for (int r = topLeft.row(); r <= bottomRight.row(); r++) { + for (int c = topLeft.column(); c <= bottomRight.column(); c++) { + const QModelIndex index = deviceParamModel.index(r,c); + ui.DeviceParamTable->openPersistentEditor(index); + } + } +} + +void DeviceForm::updatePortCellRenderers() { + const int rows = devicePortParamModel.rowCount(); + const int cols = devicePortParamModel.columnCount(); + updatePortCellRenderers(devicePortParamModel.index(0,0),devicePortParamModel.index(rows-1,cols-1)); +} + +void DeviceForm::updatePortCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) { + for (int r = topLeft.row(); r <= bottomRight.row(); r++) { + for (int c = topLeft.column(); c <= bottomRight.column(); c++) { + const QModelIndex index = devicePortParamModel.index(r,c); + ui.DevicePortParamTable->openPersistentEditor(index); + } + } +} + } // namespace QSampler