/[svn]/qsampler/trunk/src/qsamplerDeviceForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerDeviceForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1499 by capela, Tue Nov 20 16:48:04 2007 UTC revision 1528 by capela, Mon Nov 26 18:24:38 2007 UTC
# Line 31  Line 31 
31    
32  namespace QSampler {  namespace QSampler {
33    
34  DeviceForm::DeviceForm(QWidget* parent, Qt::WFlags f) : QDialog(parent, f) {  DeviceForm::DeviceForm ( QWidget *pParent, Qt::WindowFlags wflags )
35      ui.setupUi(this);          : QDialog(pParent, wflags)
36    {
37            m_ui.setupUi(this);
38    
39          // Initialize locals.          // Initialize locals.
40          m_iDirtySetup = 0;          m_iDirtySetup = 0;
# Line 44  DeviceForm::DeviceForm(QWidget* parent, Line 46  DeviceForm::DeviceForm(QWidget* parent,
46          // No exclusive mode as default.          // No exclusive mode as default.
47          m_deviceTypeMode = qsamplerDevice::None;          m_deviceTypeMode = qsamplerDevice::None;
48    
49          ui.DeviceListView->header()->hide();          m_ui.DeviceListView->header()->hide();
50    
51          ui.DeviceParamTable->setModel(&deviceParamModel);          int iRowHeight = m_ui.DeviceParamTable->fontMetrics().height() + 4;
52          ui.DeviceParamTable->setItemDelegate(&deviceParamDelegate);          m_ui.DeviceParamTable->verticalHeader()->setDefaultSectionSize(iRowHeight);
53          ui.DeviceParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);          m_ui.DevicePortParamTable->verticalHeader()->setDefaultSectionSize(iRowHeight);
54            m_ui.DeviceParamTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
55          ui.DevicePortParamTable->setModel(&devicePortParamModel);          m_ui.DevicePortParamTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
56          ui.DevicePortParamTable->setItemDelegate(&devicePortParamDelegate);  
57          ui.DevicePortParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);          m_ui.DeviceParamTable->setModel(&m_deviceParamModel);
58            m_ui.DeviceParamTable->setItemDelegate(&m_deviceParamDelegate);
59            m_ui.DeviceParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
60            m_ui.DeviceParamTable->verticalHeader()->hide();
61    
62            m_ui.DevicePortParamTable->setModel(&m_devicePortParamModel);
63            m_ui.DevicePortParamTable->setItemDelegate(&m_devicePortParamDelegate);
64            m_ui.DevicePortParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
65            m_ui.DevicePortParamTable->verticalHeader()->hide();
66    
67          // Initial contents.          // Initial contents.
68          refreshDevices();          refreshDevices();
69          // Try to restore normal window positioning.          // Try to restore normal window positioning.
70          adjustSize();          adjustSize();
71    
72          QObject::connect(ui.DeviceListView,          QObject::connect(m_ui.DeviceListView,
73                  SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),                  SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
74                  SLOT(selectDevice()));                  SLOT(selectDevice()));
75          QObject::connect(ui.DeviceListView,          QObject::connect(m_ui.DeviceListView,
76                  SIGNAL(customContextMenuRequested(const QPoint&)),                  SIGNAL(customContextMenuRequested(const QPoint&)),
77                  SLOT(deviceListViewContextMenu(const QPoint&)));                  SLOT(deviceListViewContextMenu(const QPoint&)));
78          QObject::connect(ui.RefreshDevicesPushButton,          QObject::connect(m_ui.RefreshDevicesPushButton,
79                  SIGNAL(clicked()),                  SIGNAL(clicked()),
80                  SLOT(refreshDevices()));                  SLOT(refreshDevices()));
81          QObject::connect(ui.DriverNameComboBox,          QObject::connect(m_ui.DriverNameComboBox,
82                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
83                  SLOT(selectDriver(const QString&)));                  SLOT(selectDriver(const QString&)));
84          QObject::connect(ui.DevicePortComboBox,          QObject::connect(m_ui.DevicePortComboBox,
85                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
86                  SLOT(selectDevicePort(int)));                  SLOT(selectDevicePort(int)));
87          QObject::connect(ui.CreateDevicePushButton,          QObject::connect(m_ui.CreateDevicePushButton,
88                  SIGNAL(clicked()),                  SIGNAL(clicked()),
89                  SLOT(createDevice()));                  SLOT(createDevice()));
90          QObject::connect(ui.DeleteDevicePushButton,          QObject::connect(m_ui.DeleteDevicePushButton,
91                  SIGNAL(clicked()),                  SIGNAL(clicked()),
92                  SLOT(deleteDevice()));                  SLOT(deleteDevice()));
93          QObject::connect(ui.ClosePushButton,          QObject::connect(m_ui.ClosePushButton,
94                  SIGNAL(clicked()),                  SIGNAL(clicked()),
95                  SLOT(close()));                  SLOT(close()));
96          QObject::connect(&deviceParamModel,          QObject::connect(&m_deviceParamModel,
97                  SIGNAL(modelReset()),                  SIGNAL(modelReset()),
98                  SLOT(updateCellRenderers()));                  SLOT(updateCellRenderers()));
99          QObject::connect(&deviceParamModel,          QObject::connect(&m_deviceParamModel,
100                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
101                  SLOT(updateCellRenderers(const QModelIndex&, const QModelIndex&)));                  SLOT(updateCellRenderers(const QModelIndex&, const QModelIndex&)));
102          QObject::connect(&devicePortParamModel,          QObject::connect(&m_devicePortParamModel,
103                  SIGNAL(modelReset()),                  SIGNAL(modelReset()),
104                  SLOT(updatePortCellRenderers()));                  SLOT(updatePortCellRenderers()));
105          QObject::connect(&devicePortParamModel,          QObject::connect(&m_devicePortParamModel,
106                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
107                  SLOT(updatePortCellRenderers(const QModelIndex&, const QModelIndex&)));                  SLOT(updatePortCellRenderers(const QModelIndex&, const QModelIndex&)));
108  }  }
109    
110  DeviceForm::~DeviceForm() {  
111    DeviceForm::~DeviceForm (void)
112    {
113  }  }
114    
115    
# Line 108  void DeviceForm::showEvent ( QShowEvent Line 120  void DeviceForm::showEvent ( QShowEvent
120          if (pMainForm)          if (pMainForm)
121                  pMainForm->stabilizeForm();                  pMainForm->stabilizeForm();
122    
         stabilizeForm();  
   
123          QWidget::showEvent(pShowEvent);          QWidget::showEvent(pShowEvent);
124    
125            refreshDevices();
126  }  }
127    
128    
# Line 133  void DeviceForm::hideEvent ( QHideEvent Line 145  void DeviceForm::hideEvent ( QHideEvent
145    
146  // Set device type spacial exclusive mode.  // Set device type spacial exclusive mode.
147  void DeviceForm::setDeviceTypeMode (  void DeviceForm::setDeviceTypeMode (
148          qsamplerDevice::qsamplerDeviceType deviceTypeMode )          qsamplerDevice::DeviceType deviceTypeMode )
149  {  {
150          // If it has not changed, do nothing.          // If it has not changed, do nothing.
151          if (m_deviceTypeMode == deviceTypeMode)          if (m_deviceTypeMode == deviceTypeMode)
# Line 149  void DeviceForm::setDeviceTypeMode ( Line 161  void DeviceForm::setDeviceTypeMode (
161  // Device driver name setup formal initializer.  // Device driver name setup formal initializer.
162  void DeviceForm::setDriverName ( const QString& sDriverName )  void DeviceForm::setDriverName ( const QString& sDriverName )
163  {  {
164          if (ui.DriverNameComboBox->findText(sDriverName) < 0)          if (m_ui.DriverNameComboBox->findText(sDriverName) < 0)
165                  ui.DriverNameComboBox->insertItem(0, sDriverName);                  m_ui.DriverNameComboBox->insertItem(0, sDriverName);
166          ui.DriverNameComboBox->setItemText(          m_ui.DriverNameComboBox->setItemText(
167                  ui.DriverNameComboBox->currentIndex(),                  m_ui.DriverNameComboBox->currentIndex(),
168                  sDriverName);                  sDriverName);
169  }  }
170    
# Line 161  void DeviceForm::setDriverName ( const Q Line 173  void DeviceForm::setDriverName ( const Q
173  void DeviceForm::setDevice ( qsamplerDevice *pDevice )  void DeviceForm::setDevice ( qsamplerDevice *pDevice )
174  {  {
175          // In case no device is given...          // In case no device is given...
176          qsamplerDevice::qsamplerDeviceType deviceType = m_deviceTypeMode;          qsamplerDevice::DeviceType deviceType = m_deviceTypeMode;
177          if (pDevice)          if (pDevice)
178                  deviceType = pDevice->deviceType();                  deviceType = pDevice->deviceType();
179    
# Line 184  void DeviceForm::setDevice ( qsamplerDev Line 196  void DeviceForm::setDevice ( qsamplerDev
196    
197          // So there's no device huh?          // So there's no device huh?
198          if (pDevice == NULL) {          if (pDevice == NULL) {
199                  ui.DeviceListView->setCurrentItem(pRootItem);                  m_ui.DeviceListView->setCurrentItem(pRootItem);
200                  return;                  return;
201          }          }
202    
# Line 210  void DeviceForm::createDevice (void) Line 222  void DeviceForm::createDevice (void)
222          if (pMainForm == NULL)          if (pMainForm == NULL)
223                  return;                  return;
224    
225          QTreeWidgetItem *pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem *pItem = m_ui.DeviceListView->currentItem();
226          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
227                  return;                  return;
228    
# Line 248  void DeviceForm::deleteDevice (void) Line 260  void DeviceForm::deleteDevice (void)
260          if (pMainForm == NULL)          if (pMainForm == NULL)
261                  return;                  return;
262    
263          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
264          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
265                  return;                  return;
266    
# Line 259  void DeviceForm::deleteDevice (void) Line 271  void DeviceForm::deleteDevice (void)
271          if (pOptions && pOptions->bConfirmRemove) {          if (pOptions && pOptions->bConfirmRemove) {
272                  if (QMessageBox::warning(this,                  if (QMessageBox::warning(this,
273                          QSAMPLER_TITLE ": " + tr("Warning"),                          QSAMPLER_TITLE ": " + tr("Warning"),
274                          tr("Delete device:\n\n"                          tr("About to delete device:\n\n"
275                          "%1\n\n"                          "%1\n\n"
276                          "Are you sure?")                          "Are you sure?")
277                          .arg(device.deviceName()),                          .arg(device.deviceName()),
# Line 293  void DeviceForm::refreshDevices (void) Line 305  void DeviceForm::refreshDevices (void)
305          //          //
306          m_pAudioItems = NULL;          m_pAudioItems = NULL;
307          m_pMidiItems = NULL;          m_pMidiItems = NULL;
308          ui.DeviceListView->clear();          m_ui.DeviceListView->clear();
309          if (pMainForm->client()) {          if (pMainForm->client()) {
310                  int *piDeviceIDs;                  int *piDeviceIDs;
311                  // Grab and pop Audio devices...                  // Grab and pop Audio devices...
312                  if (m_deviceTypeMode == qsamplerDevice::None ||                  if (m_deviceTypeMode == qsamplerDevice::None ||
313                          m_deviceTypeMode == qsamplerDevice::Audio) {                          m_deviceTypeMode == qsamplerDevice::Audio) {
314                          m_pAudioItems = new qsamplerDeviceItem(ui.DeviceListView,                          m_pAudioItems = new qsamplerDeviceItem(m_ui.DeviceListView,
315                                  qsamplerDevice::Audio);                                  qsamplerDevice::Audio);
316                  }                  }
317                  if (m_pAudioItems) {                  if (m_pAudioItems) {
# Line 314  void DeviceForm::refreshDevices (void) Line 326  void DeviceForm::refreshDevices (void)
326                  // Grab and pop MIDI devices...                  // Grab and pop MIDI devices...
327                  if (m_deviceTypeMode == qsamplerDevice::None ||                  if (m_deviceTypeMode == qsamplerDevice::None ||
328                          m_deviceTypeMode == qsamplerDevice::Midi) {                          m_deviceTypeMode == qsamplerDevice::Midi) {
329                          m_pMidiItems = new qsamplerDeviceItem(ui.DeviceListView,                          m_pMidiItems = new qsamplerDeviceItem(m_ui.DeviceListView,
330                                  qsamplerDevice::Midi);                                  qsamplerDevice::Midi);
331                  }                  }
332                  if (m_pMidiItems) {                  if (m_pMidiItems) {
# Line 346  void DeviceForm::selectDriver ( const QS Line 358  void DeviceForm::selectDriver ( const QS
358          //  Driver name has changed for a new device...          //  Driver name has changed for a new device...
359          //          //
360    
361          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
362          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
363                  return;                  return;
364    
# Line 356  void DeviceForm::selectDriver ( const QS Line 368  void DeviceForm::selectDriver ( const QS
368          if (m_bNewDevice) {          if (m_bNewDevice) {
369                  m_iDirtySetup++;                  m_iDirtySetup++;
370                  device.setDriver(sDriverName);                  device.setDriver(sDriverName);
371                  deviceParamModel.refresh(&device, m_bNewDevice);                  m_deviceParamModel.refresh(&device, m_bNewDevice);
372                  m_iDirtySetup--;                  m_iDirtySetup--;
373                  // Done.                  // Done.
374                  stabilizeForm();                  stabilizeForm();
# Line 378  void DeviceForm::selectDevice () Line 390  void DeviceForm::selectDevice ()
390          //  Device selection has changed...          //  Device selection has changed...
391          //          //
392    
393          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
394          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) {          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) {
395                  m_deviceType = qsamplerDevice::None;                  m_deviceType = qsamplerDevice::None;
396                  ui.DeviceNameTextLabel->setText(QString::null);                  m_ui.DeviceNameTextLabel->setText(QString::null);
397                  deviceParamModel.clear();                  m_deviceParamModel.clear();
398                  ui.DevicePortComboBox->clear();                  m_ui.DevicePortComboBox->clear();
399                  devicePortParamModel.clear();                  m_devicePortParamModel.clear();
400                  ui.DevicePortTextLabel->setEnabled(false);                  m_ui.DevicePortTextLabel->setEnabled(false);
401                  ui.DevicePortComboBox->setEnabled(false);                  m_ui.DevicePortComboBox->setEnabled(false);
402                  ui.DevicePortParamTable->setEnabled(false);                  m_ui.DevicePortParamTable->setEnabled(false);
403                  stabilizeForm();                  stabilizeForm();
404                  return;                  return;
405          }          }
# Line 399  void DeviceForm::selectDevice () Line 411  void DeviceForm::selectDevice ()
411          m_bNewDevice = (device.deviceID() < 0);          m_bNewDevice = (device.deviceID() < 0);
412    
413          // Fill the device/driver heading...          // Fill the device/driver heading...
414          ui.DeviceNameTextLabel->setText(device.deviceName());          m_ui.DeviceNameTextLabel->setText(device.deviceName());
415          // The driver combobox is only rebuilt if device type has changed...          // The driver combobox is only rebuilt if device type has changed...
416          if (device.deviceType() != m_deviceType) {          if (device.deviceType() != m_deviceType) {
417                  ui.DriverNameComboBox->clear();                  m_ui.DriverNameComboBox->clear();
418                  ui.DriverNameComboBox->insertItems(0,                  m_ui.DriverNameComboBox->insertItems(0,
419                          qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType()));                          qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType()));
420                  m_deviceType = device.deviceType();                  m_deviceType = device.deviceType();
421          }          }
422          // Do we need a driver name?          // Do we need a driver name?
423          if (m_bNewDevice || device.driverName().isEmpty())          if (m_bNewDevice || device.driverName().isEmpty())
424                  device.setDriver(ui.DriverNameComboBox->currentText());                  device.setDriver(m_ui.DriverNameComboBox->currentText());
425          setDriverName(device.driverName());          setDriverName(device.driverName());
426          ui.DriverNameTextLabel->setEnabled(m_bNewDevice);          m_ui.DriverNameTextLabel->setEnabled(m_bNewDevice);
427          ui.DriverNameComboBox->setEnabled(m_bNewDevice);          m_ui.DriverNameComboBox->setEnabled(m_bNewDevice);
428          // Fill the device parameter table...          // Fill the device parameter table...
429          deviceParamModel.refresh(&device, m_bNewDevice);          m_deviceParamModel.refresh(&device, m_bNewDevice);
430          // And now the device port/channel parameter table...          // And now the device port/channel parameter table...
431          switch (device.deviceType()) {          switch (device.deviceType()) {
432          case qsamplerDevice::Audio:          case qsamplerDevice::Audio:
433                  ui.DevicePortTextLabel->setText(tr("Ch&annel:"));                  m_ui.DevicePortTextLabel->setText(tr("Ch&annel:"));
434                  break;                  break;
435          case qsamplerDevice::Midi:          case qsamplerDevice::Midi:
436                  ui.DevicePortTextLabel->setText(tr("P&ort:"));                  m_ui.DevicePortTextLabel->setText(tr("P&ort:"));
437                  break;                  break;
438          case qsamplerDevice::None:          case qsamplerDevice::None:
439                  break;                  break;
440          }          }
441          ui.DevicePortComboBox->clear();          m_ui.DevicePortComboBox->clear();
442          devicePortParamModel.clear();          m_devicePortParamModel.clear();
443          if (m_bNewDevice) {          if (m_bNewDevice) {
444                  ui.DevicePortTextLabel->setEnabled(false);                  m_ui.DevicePortTextLabel->setEnabled(false);
445                  ui.DevicePortComboBox->setEnabled(false);                  m_ui.DevicePortComboBox->setEnabled(false);
446                  ui.DevicePortParamTable->setEnabled(false);                  m_ui.DevicePortParamTable->setEnabled(false);
447          } else {          } else {
448                  QPixmap pixmap;                  QPixmap pixmap;
449                  switch (device.deviceType()) {                  switch (device.deviceType()) {
# Line 448  void DeviceForm::selectDevice () Line 460  void DeviceForm::selectDevice ()
460                  QListIterator<qsamplerDevicePort *> iter(ports);                  QListIterator<qsamplerDevicePort *> iter(ports);
461                  while (iter.hasNext()) {                  while (iter.hasNext()) {
462                          qsamplerDevicePort *pPort = iter.next();                          qsamplerDevicePort *pPort = iter.next();
463                          ui.DevicePortComboBox->addItem(pixmap,                          m_ui.DevicePortComboBox->addItem(pixmap,
464                                  device.deviceTypeName()                                  device.deviceTypeName()
465                                  + ' ' + device.driverName()                                  + ' ' + device.driverName()
466                                  + ' ' + pPort->portName());                                  + ' ' + pPort->portName());
467                  }                  }
468                  bool bEnabled = (ports.count() > 0);                  bool bEnabled = (ports.count() > 0);
469                  ui.DevicePortTextLabel->setEnabled(bEnabled);                  m_ui.DevicePortTextLabel->setEnabled(bEnabled);
470                  ui.DevicePortComboBox->setEnabled(bEnabled);                  m_ui.DevicePortComboBox->setEnabled(bEnabled);
471                  ui.DevicePortParamTable->setEnabled(bEnabled);                  m_ui.DevicePortParamTable->setEnabled(bEnabled);
472          }          }
473          // Done.          // Done.
474          m_iDirtySetup--;          m_iDirtySetup--;
475    
476          // Make the device port/channel selection effective.          // Make the device port/channel selection effective.
477          selectDevicePort(ui.DevicePortComboBox->currentIndex());          selectDevicePort(m_ui.DevicePortComboBox->currentIndex());
478  }  }
479    
480    
# Line 476  void DeviceForm::selectDevicePort ( int Line 488  void DeviceForm::selectDevicePort ( int
488          //  Device port/channel selection has changed...          //  Device port/channel selection has changed...
489          //          //
490    
491          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
492          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
493                  return;                  return;
494    
495          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
496          qsamplerDevicePort *pPort = device.ports().at(iPort);          qsamplerDevicePort *pPort = NULL;
497            if (iPort >= 0 && iPort < device.ports().count())
498                    pPort = device.ports().at(iPort);
499          if (pPort) {          if (pPort) {
500                  m_iDirtySetup++;                  m_iDirtySetup++;
501                  devicePortParamModel.refresh(pPort, false);                  m_devicePortParamModel.refresh(pPort, false);
502                  m_iDirtySetup--;                  m_iDirtySetup--;
503          }          }
504          // Done.          // Done.
# Line 505  void DeviceForm::changeDeviceParam ( int Line 519  void DeviceForm::changeDeviceParam ( int
519          //          //
520    
521  /* we do that in the model class now ...  /* we do that in the model class now ...
522          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
523          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
524                  return;                  return;
525    
526          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
527    
528          // Table 1st column has the parameter name;          // Table 1st column has the parameter name;
529          //const QString sParam = ui.DeviceParamTable->text(iRow, 0);          //const QString sParam = m_ui.DeviceParamTable->text(iRow, 0);
530          //const QString sValue = ui.DeviceParamTable->text(iRow, iCol);          //const QString sValue = m_ui.DeviceParamTable->text(iRow, iCol);
531          const QString sParam = deviceParamModel.data(deviceParamModel.index(iRow, 0), Qt::DisplayRole).value<DeviceParameterRow>().name;          const QString sParam = m_deviceParamModel.data(m_deviceParamModel.index(iRow, 0), Qt::DisplayRole).value<DeviceParameterRow>().name;
532          const QString sValue = deviceParamModel.data(deviceParamModel.index(iRow, iCol), Qt::DisplayRole).value<DeviceParameterRow>().param.value;          const QString sValue = m_deviceParamModel.data(m_deviceParamModel.index(iRow, iCol), Qt::DisplayRole).value<DeviceParameterRow>().param.value;
533          // Set the local device parameter value.          // Set the local device parameter value.
534          if (device.setParam(sParam, sValue)) {          if (device.setParam(sParam, sValue)) {
535                  selectDevice();                  selectDevice();
# Line 544  void DeviceForm::changeDevicePortParam ( Line 558  void DeviceForm::changeDevicePortParam (
558          //          //
559    
560  /* we do that in the model class now ...  /* we do that in the model class now ...
561          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
562          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
563                  return;                  return;
564    
565          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
566    
567          int iPort = ui.DevicePortComboBox->currentIndex();          int iPort = m_ui.DevicePortComboBox->currentIndex();
568          qsamplerDevicePort *pPort = device.ports().at(iPort);          qsamplerDevicePort *pPort = NULL;
569            if (iPort >= 0 && iPort < device.ports().count())
570                    pPort = device.ports().at(iPort);
571          if (pPort == NULL)          if (pPort == NULL)
572                  return;                  return;
573    
574          // Table 1st column has the parameter name;          // Table 1st column has the parameter name;
575          //const QString sParam = ui.DevicePortParamTable->text(iRow, 0);          //const QString sParam = m_ui.DevicePortParamTable->text(iRow, 0);
576          //const QString sValue = ui.DevicePortParamTable->text(iRow, iCol);          //const QString sValue = m_ui.DevicePortParamTable->text(iRow, iCol);
577          const QString sParam = devicePortParamModel.data(devicePortParamModel.index(iRow, 0), Qt::DisplayRole).value<DeviceParameterRow>().name;          const QString sParam = m_devicePortParamModel.data(m_devicePortParamModel.index(iRow, 0), Qt::DisplayRole).value<DeviceParameterRow>().name;
578          const QString sValue = devicePortParamModel.data(devicePortParamModel.index(iRow, iCol), Qt::DisplayRole).value<DeviceParameterRow>().param.value;          const QString sValue = m_devicePortParamModel.data(m_devicePortParamModel.index(iRow, iCol), Qt::DisplayRole).value<DeviceParameterRow>().param.value;
579    
580          // Set the local device port/channel parameter value.          // Set the local device port/channel parameter value.
581          pPort->setParam(sParam, sValue);          pPort->setParam(sParam, sValue);
# Line 582  void DeviceForm::deviceListViewContextMe Line 598  void DeviceForm::deviceListViewContextMe
598          if (pMainForm == NULL)          if (pMainForm == NULL)
599                  return;                  return;
600    
601          QTreeWidgetItem* pItem = ui.DeviceListView->itemAt(pos);          QTreeWidgetItem* pItem = m_ui.DeviceListView->itemAt(pos);
602          if (pItem == NULL)          if (pItem == NULL)
603                  return;                  return;
604    
# Line 614  void DeviceForm::deviceListViewContextMe Line 630  void DeviceForm::deviceListViewContextMe
630  void DeviceForm::stabilizeForm (void)  void DeviceForm::stabilizeForm (void)
631  {  {
632          MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
633          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
634          bool bClient = (pMainForm && pMainForm->client() != NULL);          bool bClient = (pMainForm && pMainForm->client() != NULL);
635          bool bEnabled = (pItem != NULL);          bool bEnabled = (pItem != NULL);
636          ui.DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);          m_ui.DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);
637          ui.DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);          m_ui.DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);
638          ui.DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);          m_ui.DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);
639          ui.DeviceParamTable->setEnabled(bEnabled);          m_ui.DeviceParamTable->setEnabled(bEnabled);
640          ui.RefreshDevicesPushButton->setEnabled(bClient);          m_ui.RefreshDevicesPushButton->setEnabled(bClient);
641          ui.CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));          m_ui.CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));
642          ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);          m_ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);
643  }  }
644    
645  void DeviceForm::updateCellRenderers() {  
646      const int rows = deviceParamModel.rowCount();  void DeviceForm::updateCellRenderers (void)
647      const int cols = deviceParamModel.columnCount();  {
648      updateCellRenderers(deviceParamModel.index(0,0),deviceParamModel.index(rows-1,cols-1));          const int rows = m_deviceParamModel.rowCount();
649  }          const int cols = m_deviceParamModel.columnCount();
650            updateCellRenderers(
651  void DeviceForm::updateCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {                  m_deviceParamModel.index(0, 0),
652      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {                  m_deviceParamModel.index(rows - 1, cols - 1));
653          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {  }
654              const QModelIndex index = deviceParamModel.index(r,c);  
655              ui.DeviceParamTable->openPersistentEditor(index);  
656          }  void DeviceForm::updateCellRenderers (
657      }          const QModelIndex& topLeft, const QModelIndex& bottomRight )
658  }  {
659            for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
660  void DeviceForm::updatePortCellRenderers() {                  for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
661      const int rows = devicePortParamModel.rowCount();                          const QModelIndex index = m_deviceParamModel.index(r, c);
662      const int cols = devicePortParamModel.columnCount();                          m_ui.DeviceParamTable->openPersistentEditor(index);
663      updatePortCellRenderers(devicePortParamModel.index(0,0),devicePortParamModel.index(rows-1,cols-1));                  }
664  }          }
665    }
666  void DeviceForm::updatePortCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {  
667      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {  
668          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {  void DeviceForm::updatePortCellRenderers (void)
669              const QModelIndex index = devicePortParamModel.index(r,c);  {
670              ui.DevicePortParamTable->openPersistentEditor(index);          const int rows = m_devicePortParamModel.rowCount();
671          }          const int cols = m_devicePortParamModel.columnCount();
672      }          updatePortCellRenderers(
673                    m_devicePortParamModel.index(0, 0),
674                    m_devicePortParamModel.index(rows - 1, cols - 1));
675    }
676    
677    
678    void DeviceForm::updatePortCellRenderers (
679            const QModelIndex& topLeft, const QModelIndex& bottomRight )
680    {
681            for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
682                    for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
683                            const QModelIndex index = m_devicePortParamModel.index(r, c);
684                            m_ui.DevicePortParamTable->openPersistentEditor(index);
685                    }
686            }
687  }  }
688    
689  } // namespace QSampler  } // namespace QSampler

Legend:
Removed from v.1499  
changed lines
  Added in v.1528

  ViewVC Help
Powered by ViewVC