/[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 1504 by capela, Wed Nov 21 11:46:40 2007 UTC revision 1509 by capela, Thu Nov 22 11:10:44 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);          m_ui.DeviceParamTable->setModel(&m_deviceParamModel);
52          ui.DeviceParamTable->setItemDelegate(&deviceParamDelegate);          m_ui.DeviceParamTable->setItemDelegate(&m_deviceParamDelegate);
53          ui.DeviceParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);          m_ui.DeviceParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
54            m_ui.DeviceParamTable->verticalHeader()->hide();
55          ui.DevicePortParamTable->setModel(&devicePortParamModel);  
56          ui.DevicePortParamTable->setItemDelegate(&devicePortParamDelegate);          m_ui.DevicePortParamTable->setModel(&m_devicePortParamModel);
57          ui.DevicePortParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);          m_ui.DevicePortParamTable->setItemDelegate(&m_devicePortParamDelegate);
58            m_ui.DevicePortParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
59            m_ui.DevicePortParamTable->verticalHeader()->hide();
60    
61          // Initial contents.          // Initial contents.
62          refreshDevices();          refreshDevices();
63          // Try to restore normal window positioning.          // Try to restore normal window positioning.
64          adjustSize();          adjustSize();
65    
66          QObject::connect(ui.DeviceListView,          QObject::connect(m_ui.DeviceListView,
67                  SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),                  SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
68                  SLOT(selectDevice()));                  SLOT(selectDevice()));
69          QObject::connect(ui.DeviceListView,          QObject::connect(m_ui.DeviceListView,
70                  SIGNAL(customContextMenuRequested(const QPoint&)),                  SIGNAL(customContextMenuRequested(const QPoint&)),
71                  SLOT(deviceListViewContextMenu(const QPoint&)));                  SLOT(deviceListViewContextMenu(const QPoint&)));
72          QObject::connect(ui.RefreshDevicesPushButton,          QObject::connect(m_ui.RefreshDevicesPushButton,
73                  SIGNAL(clicked()),                  SIGNAL(clicked()),
74                  SLOT(refreshDevices()));                  SLOT(refreshDevices()));
75          QObject::connect(ui.DriverNameComboBox,          QObject::connect(m_ui.DriverNameComboBox,
76                  SIGNAL(activated(const QString&)),                  SIGNAL(activated(const QString&)),
77                  SLOT(selectDriver(const QString&)));                  SLOT(selectDriver(const QString&)));
78          QObject::connect(ui.DevicePortComboBox,          QObject::connect(m_ui.DevicePortComboBox,
79                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
80                  SLOT(selectDevicePort(int)));                  SLOT(selectDevicePort(int)));
81          QObject::connect(ui.CreateDevicePushButton,          QObject::connect(m_ui.CreateDevicePushButton,
82                  SIGNAL(clicked()),                  SIGNAL(clicked()),
83                  SLOT(createDevice()));                  SLOT(createDevice()));
84          QObject::connect(ui.DeleteDevicePushButton,          QObject::connect(m_ui.DeleteDevicePushButton,
85                  SIGNAL(clicked()),                  SIGNAL(clicked()),
86                  SLOT(deleteDevice()));                  SLOT(deleteDevice()));
87          QObject::connect(ui.ClosePushButton,          QObject::connect(m_ui.ClosePushButton,
88                  SIGNAL(clicked()),                  SIGNAL(clicked()),
89                  SLOT(close()));                  SLOT(close()));
90          QObject::connect(&deviceParamModel,          QObject::connect(&m_deviceParamModel,
91                  SIGNAL(modelReset()),                  SIGNAL(modelReset()),
92                  SLOT(updateCellRenderers()));                  SLOT(updateCellRenderers()));
93          QObject::connect(&deviceParamModel,          QObject::connect(&m_deviceParamModel,
94                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
95                  SLOT(updateCellRenderers(const QModelIndex&, const QModelIndex&)));                  SLOT(updateCellRenderers(const QModelIndex&, const QModelIndex&)));
96          QObject::connect(&devicePortParamModel,          QObject::connect(&m_devicePortParamModel,
97                  SIGNAL(modelReset()),                  SIGNAL(modelReset()),
98                  SLOT(updatePortCellRenderers()));                  SLOT(updatePortCellRenderers()));
99          QObject::connect(&devicePortParamModel,          QObject::connect(&m_devicePortParamModel,
100                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),                  SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
101                  SLOT(updatePortCellRenderers(const QModelIndex&, const QModelIndex&)));                  SLOT(updatePortCellRenderers(const QModelIndex&, const QModelIndex&)));
102  }  }
# Line 133  void DeviceForm::hideEvent ( QHideEvent Line 137  void DeviceForm::hideEvent ( QHideEvent
137    
138  // Set device type spacial exclusive mode.  // Set device type spacial exclusive mode.
139  void DeviceForm::setDeviceTypeMode (  void DeviceForm::setDeviceTypeMode (
140          qsamplerDevice::qsamplerDeviceType deviceTypeMode )          qsamplerDevice::DeviceType deviceTypeMode )
141  {  {
142          // If it has not changed, do nothing.          // If it has not changed, do nothing.
143          if (m_deviceTypeMode == deviceTypeMode)          if (m_deviceTypeMode == deviceTypeMode)
# Line 149  void DeviceForm::setDeviceTypeMode ( Line 153  void DeviceForm::setDeviceTypeMode (
153  // Device driver name setup formal initializer.  // Device driver name setup formal initializer.
154  void DeviceForm::setDriverName ( const QString& sDriverName )  void DeviceForm::setDriverName ( const QString& sDriverName )
155  {  {
156          if (ui.DriverNameComboBox->findText(sDriverName) < 0)          if (m_ui.DriverNameComboBox->findText(sDriverName) < 0)
157                  ui.DriverNameComboBox->insertItem(0, sDriverName);                  m_ui.DriverNameComboBox->insertItem(0, sDriverName);
158          ui.DriverNameComboBox->setItemText(          m_ui.DriverNameComboBox->setItemText(
159                  ui.DriverNameComboBox->currentIndex(),                  m_ui.DriverNameComboBox->currentIndex(),
160                  sDriverName);                  sDriverName);
161  }  }
162    
# Line 161  void DeviceForm::setDriverName ( const Q Line 165  void DeviceForm::setDriverName ( const Q
165  void DeviceForm::setDevice ( qsamplerDevice *pDevice )  void DeviceForm::setDevice ( qsamplerDevice *pDevice )
166  {  {
167          // In case no device is given...          // In case no device is given...
168          qsamplerDevice::qsamplerDeviceType deviceType = m_deviceTypeMode;          qsamplerDevice::DeviceType deviceType = m_deviceTypeMode;
169          if (pDevice)          if (pDevice)
170                  deviceType = pDevice->deviceType();                  deviceType = pDevice->deviceType();
171    
# Line 184  void DeviceForm::setDevice ( qsamplerDev Line 188  void DeviceForm::setDevice ( qsamplerDev
188    
189          // So there's no device huh?          // So there's no device huh?
190          if (pDevice == NULL) {          if (pDevice == NULL) {
191                  ui.DeviceListView->setCurrentItem(pRootItem);                  m_ui.DeviceListView->setCurrentItem(pRootItem);
192                  return;                  return;
193          }          }
194    
# Line 210  void DeviceForm::createDevice (void) Line 214  void DeviceForm::createDevice (void)
214          if (pMainForm == NULL)          if (pMainForm == NULL)
215                  return;                  return;
216    
217          QTreeWidgetItem *pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem *pItem = m_ui.DeviceListView->currentItem();
218          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
219                  return;                  return;
220    
# Line 248  void DeviceForm::deleteDevice (void) Line 252  void DeviceForm::deleteDevice (void)
252          if (pMainForm == NULL)          if (pMainForm == NULL)
253                  return;                  return;
254    
255          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
256          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
257                  return;                  return;
258    
# Line 293  void DeviceForm::refreshDevices (void) Line 297  void DeviceForm::refreshDevices (void)
297          //          //
298          m_pAudioItems = NULL;          m_pAudioItems = NULL;
299          m_pMidiItems = NULL;          m_pMidiItems = NULL;
300          ui.DeviceListView->clear();          m_ui.DeviceListView->clear();
301          if (pMainForm->client()) {          if (pMainForm->client()) {
302                  int *piDeviceIDs;                  int *piDeviceIDs;
303                  // Grab and pop Audio devices...                  // Grab and pop Audio devices...
304                  if (m_deviceTypeMode == qsamplerDevice::None ||                  if (m_deviceTypeMode == qsamplerDevice::None ||
305                          m_deviceTypeMode == qsamplerDevice::Audio) {                          m_deviceTypeMode == qsamplerDevice::Audio) {
306                          m_pAudioItems = new qsamplerDeviceItem(ui.DeviceListView,                          m_pAudioItems = new qsamplerDeviceItem(m_ui.DeviceListView,
307                                  qsamplerDevice::Audio);                                  qsamplerDevice::Audio);
308                  }                  }
309                  if (m_pAudioItems) {                  if (m_pAudioItems) {
# Line 314  void DeviceForm::refreshDevices (void) Line 318  void DeviceForm::refreshDevices (void)
318                  // Grab and pop MIDI devices...                  // Grab and pop MIDI devices...
319                  if (m_deviceTypeMode == qsamplerDevice::None ||                  if (m_deviceTypeMode == qsamplerDevice::None ||
320                          m_deviceTypeMode == qsamplerDevice::Midi) {                          m_deviceTypeMode == qsamplerDevice::Midi) {
321                          m_pMidiItems = new qsamplerDeviceItem(ui.DeviceListView,                          m_pMidiItems = new qsamplerDeviceItem(m_ui.DeviceListView,
322                                  qsamplerDevice::Midi);                                  qsamplerDevice::Midi);
323                  }                  }
324                  if (m_pMidiItems) {                  if (m_pMidiItems) {
# Line 346  void DeviceForm::selectDriver ( const QS Line 350  void DeviceForm::selectDriver ( const QS
350          //  Driver name has changed for a new device...          //  Driver name has changed for a new device...
351          //          //
352    
353          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
354          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
355                  return;                  return;
356    
# Line 356  void DeviceForm::selectDriver ( const QS Line 360  void DeviceForm::selectDriver ( const QS
360          if (m_bNewDevice) {          if (m_bNewDevice) {
361                  m_iDirtySetup++;                  m_iDirtySetup++;
362                  device.setDriver(sDriverName);                  device.setDriver(sDriverName);
363                  deviceParamModel.refresh(&device, m_bNewDevice);                  m_deviceParamModel.refresh(&device, m_bNewDevice);
364                  m_iDirtySetup--;                  m_iDirtySetup--;
365                  // Done.                  // Done.
366                  stabilizeForm();                  stabilizeForm();
# Line 378  void DeviceForm::selectDevice () Line 382  void DeviceForm::selectDevice ()
382          //  Device selection has changed...          //  Device selection has changed...
383          //          //
384    
385          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
386          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) {          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) {
387                  m_deviceType = qsamplerDevice::None;                  m_deviceType = qsamplerDevice::None;
388                  ui.DeviceNameTextLabel->setText(QString::null);                  m_ui.DeviceNameTextLabel->setText(QString::null);
389                  deviceParamModel.clear();                  m_deviceParamModel.clear();
390                  ui.DevicePortComboBox->clear();                  m_ui.DevicePortComboBox->clear();
391                  devicePortParamModel.clear();                  m_devicePortParamModel.clear();
392                  ui.DevicePortTextLabel->setEnabled(false);                  m_ui.DevicePortTextLabel->setEnabled(false);
393                  ui.DevicePortComboBox->setEnabled(false);                  m_ui.DevicePortComboBox->setEnabled(false);
394                  ui.DevicePortParamTable->setEnabled(false);                  m_ui.DevicePortParamTable->setEnabled(false);
395                  stabilizeForm();                  stabilizeForm();
396                  return;                  return;
397          }          }
# Line 399  void DeviceForm::selectDevice () Line 403  void DeviceForm::selectDevice ()
403          m_bNewDevice = (device.deviceID() < 0);          m_bNewDevice = (device.deviceID() < 0);
404    
405          // Fill the device/driver heading...          // Fill the device/driver heading...
406          ui.DeviceNameTextLabel->setText(device.deviceName());          m_ui.DeviceNameTextLabel->setText(device.deviceName());
407          // The driver combobox is only rebuilt if device type has changed...          // The driver combobox is only rebuilt if device type has changed...
408          if (device.deviceType() != m_deviceType) {          if (device.deviceType() != m_deviceType) {
409                  ui.DriverNameComboBox->clear();                  m_ui.DriverNameComboBox->clear();
410                  ui.DriverNameComboBox->insertItems(0,                  m_ui.DriverNameComboBox->insertItems(0,
411                          qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType()));                          qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType()));
412                  m_deviceType = device.deviceType();                  m_deviceType = device.deviceType();
413          }          }
414          // Do we need a driver name?          // Do we need a driver name?
415          if (m_bNewDevice || device.driverName().isEmpty())          if (m_bNewDevice || device.driverName().isEmpty())
416                  device.setDriver(ui.DriverNameComboBox->currentText());                  device.setDriver(m_ui.DriverNameComboBox->currentText());
417          setDriverName(device.driverName());          setDriverName(device.driverName());
418          ui.DriverNameTextLabel->setEnabled(m_bNewDevice);          m_ui.DriverNameTextLabel->setEnabled(m_bNewDevice);
419          ui.DriverNameComboBox->setEnabled(m_bNewDevice);          m_ui.DriverNameComboBox->setEnabled(m_bNewDevice);
420          // Fill the device parameter table...          // Fill the device parameter table...
421          deviceParamModel.refresh(&device, m_bNewDevice);          m_deviceParamModel.refresh(&device, m_bNewDevice);
422          // And now the device port/channel parameter table...          // And now the device port/channel parameter table...
423          switch (device.deviceType()) {          switch (device.deviceType()) {
424          case qsamplerDevice::Audio:          case qsamplerDevice::Audio:
425                  ui.DevicePortTextLabel->setText(tr("Ch&annel:"));                  m_ui.DevicePortTextLabel->setText(tr("Ch&annel:"));
426                  break;                  break;
427          case qsamplerDevice::Midi:          case qsamplerDevice::Midi:
428                  ui.DevicePortTextLabel->setText(tr("P&ort:"));                  m_ui.DevicePortTextLabel->setText(tr("P&ort:"));
429                  break;                  break;
430          case qsamplerDevice::None:          case qsamplerDevice::None:
431                  break;                  break;
432          }          }
433          ui.DevicePortComboBox->clear();          m_ui.DevicePortComboBox->clear();
434          devicePortParamModel.clear();          m_devicePortParamModel.clear();
435          if (m_bNewDevice) {          if (m_bNewDevice) {
436                  ui.DevicePortTextLabel->setEnabled(false);                  m_ui.DevicePortTextLabel->setEnabled(false);
437                  ui.DevicePortComboBox->setEnabled(false);                  m_ui.DevicePortComboBox->setEnabled(false);
438                  ui.DevicePortParamTable->setEnabled(false);                  m_ui.DevicePortParamTable->setEnabled(false);
439          } else {          } else {
440                  QPixmap pixmap;                  QPixmap pixmap;
441                  switch (device.deviceType()) {                  switch (device.deviceType()) {
# Line 448  void DeviceForm::selectDevice () Line 452  void DeviceForm::selectDevice ()
452                  QListIterator<qsamplerDevicePort *> iter(ports);                  QListIterator<qsamplerDevicePort *> iter(ports);
453                  while (iter.hasNext()) {                  while (iter.hasNext()) {
454                          qsamplerDevicePort *pPort = iter.next();                          qsamplerDevicePort *pPort = iter.next();
455                          ui.DevicePortComboBox->addItem(pixmap,                          m_ui.DevicePortComboBox->addItem(pixmap,
456                                  device.deviceTypeName()                                  device.deviceTypeName()
457                                  + ' ' + device.driverName()                                  + ' ' + device.driverName()
458                                  + ' ' + pPort->portName());                                  + ' ' + pPort->portName());
459                  }                  }
460                  bool bEnabled = (ports.count() > 0);                  bool bEnabled = (ports.count() > 0);
461                  ui.DevicePortTextLabel->setEnabled(bEnabled);                  m_ui.DevicePortTextLabel->setEnabled(bEnabled);
462                  ui.DevicePortComboBox->setEnabled(bEnabled);                  m_ui.DevicePortComboBox->setEnabled(bEnabled);
463                  ui.DevicePortParamTable->setEnabled(bEnabled);                  m_ui.DevicePortParamTable->setEnabled(bEnabled);
464          }          }
465          // Done.          // Done.
466          m_iDirtySetup--;          m_iDirtySetup--;
467    
468          // Make the device port/channel selection effective.          // Make the device port/channel selection effective.
469          selectDevicePort(ui.DevicePortComboBox->currentIndex());          selectDevicePort(m_ui.DevicePortComboBox->currentIndex());
470  }  }
471    
472    
# Line 476  void DeviceForm::selectDevicePort ( int Line 480  void DeviceForm::selectDevicePort ( int
480          //  Device port/channel selection has changed...          //  Device port/channel selection has changed...
481          //          //
482    
483          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
484          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
485                  return;                  return;
486    
# Line 486  void DeviceForm::selectDevicePort ( int Line 490  void DeviceForm::selectDevicePort ( int
490                  pPort = device.ports().at(iPort);                  pPort = device.ports().at(iPort);
491          if (pPort) {          if (pPort) {
492                  m_iDirtySetup++;                  m_iDirtySetup++;
493                  devicePortParamModel.refresh(pPort, false);                  m_devicePortParamModel.refresh(pPort, false);
494                  m_iDirtySetup--;                  m_iDirtySetup--;
495          }          }
496          // Done.          // Done.
# Line 507  void DeviceForm::changeDeviceParam ( int Line 511  void DeviceForm::changeDeviceParam ( int
511          //          //
512    
513  /* we do that in the model class now ...  /* we do that in the model class now ...
514          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
515          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
516                  return;                  return;
517    
518          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
519    
520          // Table 1st column has the parameter name;          // Table 1st column has the parameter name;
521          //const QString sParam = ui.DeviceParamTable->text(iRow, 0);          //const QString sParam = m_ui.DeviceParamTable->text(iRow, 0);
522          //const QString sValue = ui.DeviceParamTable->text(iRow, iCol);          //const QString sValue = m_ui.DeviceParamTable->text(iRow, iCol);
523          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;
524          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;
525          // Set the local device parameter value.          // Set the local device parameter value.
526          if (device.setParam(sParam, sValue)) {          if (device.setParam(sParam, sValue)) {
527                  selectDevice();                  selectDevice();
# Line 546  void DeviceForm::changeDevicePortParam ( Line 550  void DeviceForm::changeDevicePortParam (
550          //          //
551    
552  /* we do that in the model class now ...  /* we do that in the model class now ...
553          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
554          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
555                  return;                  return;
556    
557          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
558    
559          int iPort = ui.DevicePortComboBox->currentIndex();          int iPort = m_ui.DevicePortComboBox->currentIndex();
560          qsamplerDevicePort *pPort = NULL;          qsamplerDevicePort *pPort = NULL;
561          if (iPort >= 0 && iPort < device.ports().count())          if (iPort >= 0 && iPort < device.ports().count())
562                  pPort = device.ports().at(iPort);                  pPort = device.ports().at(iPort);
# Line 560  void DeviceForm::changeDevicePortParam ( Line 564  void DeviceForm::changeDevicePortParam (
564                  return;                  return;
565    
566          // Table 1st column has the parameter name;          // Table 1st column has the parameter name;
567          //const QString sParam = ui.DevicePortParamTable->text(iRow, 0);          //const QString sParam = m_ui.DevicePortParamTable->text(iRow, 0);
568          //const QString sValue = ui.DevicePortParamTable->text(iRow, iCol);          //const QString sValue = m_ui.DevicePortParamTable->text(iRow, iCol);
569          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;
570          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;
571    
572          // Set the local device port/channel parameter value.          // Set the local device port/channel parameter value.
573          pPort->setParam(sParam, sValue);          pPort->setParam(sParam, sValue);
# Line 586  void DeviceForm::deviceListViewContextMe Line 590  void DeviceForm::deviceListViewContextMe
590          if (pMainForm == NULL)          if (pMainForm == NULL)
591                  return;                  return;
592    
593          QTreeWidgetItem* pItem = ui.DeviceListView->itemAt(pos);          QTreeWidgetItem* pItem = m_ui.DeviceListView->itemAt(pos);
594          if (pItem == NULL)          if (pItem == NULL)
595                  return;                  return;
596    
# Line 618  void DeviceForm::deviceListViewContextMe Line 622  void DeviceForm::deviceListViewContextMe
622  void DeviceForm::stabilizeForm (void)  void DeviceForm::stabilizeForm (void)
623  {  {
624          MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
625          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
626          bool bClient = (pMainForm && pMainForm->client() != NULL);          bool bClient = (pMainForm && pMainForm->client() != NULL);
627          bool bEnabled = (pItem != NULL);          bool bEnabled = (pItem != NULL);
628          ui.DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);          m_ui.DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);
629          ui.DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);          m_ui.DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);
630          ui.DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);          m_ui.DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);
631          ui.DeviceParamTable->setEnabled(bEnabled);          m_ui.DeviceParamTable->setEnabled(bEnabled);
632          ui.RefreshDevicesPushButton->setEnabled(bClient);          m_ui.RefreshDevicesPushButton->setEnabled(bClient);
633          ui.CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));          m_ui.CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));
634          ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);          m_ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);
635  }  }
636    
637  void DeviceForm::updateCellRenderers() {  
638      const int rows = deviceParamModel.rowCount();  void DeviceForm::updateCellRenderers (void)
639      const int cols = deviceParamModel.columnCount();  {
640      updateCellRenderers(deviceParamModel.index(0,0),deviceParamModel.index(rows-1,cols-1));          const int rows = m_deviceParamModel.rowCount();
641  }          const int cols = m_deviceParamModel.columnCount();
642            updateCellRenderers(
643  void DeviceForm::updateCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {                  m_deviceParamModel.index(0, 0),
644      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {                  m_deviceParamModel.index(rows - 1, cols - 1));
645          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {  }
646              const QModelIndex index = deviceParamModel.index(r,c);  
647              ui.DeviceParamTable->openPersistentEditor(index);  
648          }  void DeviceForm::updateCellRenderers (
649      }          const QModelIndex& topLeft, const QModelIndex& bottomRight )
650  }  {
651            for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
652  void DeviceForm::updatePortCellRenderers() {                  for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
653      const int rows = devicePortParamModel.rowCount();                          const QModelIndex index = m_deviceParamModel.index(r, c);
654      const int cols = devicePortParamModel.columnCount();                          m_ui.DeviceParamTable->openPersistentEditor(index);
655      updatePortCellRenderers(devicePortParamModel.index(0,0),devicePortParamModel.index(rows-1,cols-1));                  }
656  }          }
657    }
658  void DeviceForm::updatePortCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {  
659      for (int r = topLeft.row(); r <= bottomRight.row(); r++) {  
660          for (int c = topLeft.column(); c <= bottomRight.column(); c++) {  void DeviceForm::updatePortCellRenderers (void)
661              const QModelIndex index = devicePortParamModel.index(r,c);  {
662              ui.DevicePortParamTable->openPersistentEditor(index);          const int rows = m_devicePortParamModel.rowCount();
663          }          const int cols = m_devicePortParamModel.columnCount();
664      }          updatePortCellRenderers(
665                    m_devicePortParamModel.index(0, 0),
666                    m_devicePortParamModel.index(rows - 1, cols - 1));
667    }
668    
669    
670    void DeviceForm::updatePortCellRenderers (
671            const QModelIndex& topLeft, const QModelIndex& bottomRight )
672    {
673            for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
674                    for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
675                            const QModelIndex index = m_devicePortParamModel.index(r, c);
676                            m_ui.DevicePortParamTable->openPersistentEditor(index);
677                    }
678            }
679  }  }
680    
681  } // namespace QSampler  } // namespace QSampler

Legend:
Removed from v.1504  
changed lines
  Added in v.1509

  ViewVC Help
Powered by ViewVC