/[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 1477 by schoenebeck, Mon Nov 12 01:33:13 2007 UTC revision 1486 by schoenebeck, Sat Nov 17 02:02:28 2007 UTC
# Line 44  DeviceForm::DeviceForm(QWidget* parent, Line 44  DeviceForm::DeviceForm(QWidget* parent,
44    
45          ui.DeviceParamTable->setModel(&deviceParamModel);          ui.DeviceParamTable->setModel(&deviceParamModel);
46          ui.DeviceParamTable->setItemDelegate(&deviceParamDelegate);          ui.DeviceParamTable->setItemDelegate(&deviceParamDelegate);
47            ui.DeviceParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
48    
49          ui.DevicePortParamTable->setModel(&devicePortParamModel);          ui.DevicePortParamTable->setModel(&devicePortParamModel);
50          ui.DevicePortParamTable->setItemDelegate(&devicePortParamDelegate);          ui.DevicePortParamTable->setItemDelegate(&devicePortParamDelegate);
51            ui.DevicePortParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
         // 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)));  
52    
53          // Initial contents.          // Initial contents.
54          refreshDevices();          refreshDevices();
# Line 60  DeviceForm::DeviceForm(QWidget* parent, Line 56  DeviceForm::DeviceForm(QWidget* parent,
56          adjustSize();          adjustSize();
57    
58          QObject::connect(ui.DeviceListView,          QObject::connect(ui.DeviceListView,
59                  SIGNAL(itemSelectionChanged()),                  SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
60                  SLOT(selectDevice()));                  SLOT(selectDevice()));
61          QObject::connect(ui.DeviceListView,          QObject::connect(ui.DeviceListView,
62                  SIGNAL(customContextMenuRequested(const QPoint&)),                  SIGNAL(customContextMenuRequested(const QPoint&)),
# Line 83  DeviceForm::DeviceForm(QWidget* parent, Line 79  DeviceForm::DeviceForm(QWidget* parent,
79          QObject::connect(ui.ClosePushButton,          QObject::connect(ui.ClosePushButton,
80                  SIGNAL(clicked()),                  SIGNAL(clicked()),
81                  SLOT(close()));                  SLOT(close()));
82            QObject::connect(&deviceParamModel,
83                    SIGNAL(modelReset()),
84                    SLOT(updateCellRenderers()));
85            QObject::connect(&deviceParamModel,
86                    SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
87                    SLOT(updateCellRenderers(const QModelIndex&, const QModelIndex&)));
88            QObject::connect(&devicePortParamModel,
89                    SIGNAL(modelReset()),
90                    SLOT(updatePortCellRenderers()));
91            QObject::connect(&devicePortParamModel,
92                    SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
93                    SLOT(updatePortCellRenderers(const QModelIndex&, const QModelIndex&)));
94  }  }
95    
96  DeviceForm::~DeviceForm() {  DeviceForm::~DeviceForm() {
# Line 343  void DeviceForm::selectDriver ( const QS Line 351  void DeviceForm::selectDriver ( const QS
351          if (m_bNewDevice) {          if (m_bNewDevice) {
352                  m_iDirtySetup++;                  m_iDirtySetup++;
353                  device.setDriver(sDriverName);                  device.setDriver(sDriverName);
354                  deviceParamModel.refresh(device.params(), m_bNewDevice);                  deviceParamModel.refresh(&device, m_bNewDevice);
355                  m_iDirtySetup--;                  m_iDirtySetup--;
356                  // Done.                  // Done.
357                  stabilizeForm();                  stabilizeForm();
# Line 401  void DeviceForm::selectDevice () Line 409  void DeviceForm::selectDevice ()
409          ui.DriverNameTextLabel->setEnabled(m_bNewDevice);          ui.DriverNameTextLabel->setEnabled(m_bNewDevice);
410          ui.DriverNameComboBox->setEnabled(m_bNewDevice);          ui.DriverNameComboBox->setEnabled(m_bNewDevice);
411          // Fill the device parameter table...          // Fill the device parameter table...
412          deviceParamModel.refresh(device.params(), m_bNewDevice);          deviceParamModel.refresh(&device, m_bNewDevice);
413          // And now the device port/channel parameter table...          // And now the device port/channel parameter table...
414          switch (device.deviceType()) {          switch (device.deviceType()) {
415          case qsamplerDevice::Audio:          case qsamplerDevice::Audio:
# Line 469  void DeviceForm::selectDevicePort ( int Line 477  void DeviceForm::selectDevicePort ( int
477          qsamplerDevicePort *pPort = device.ports().at(iPort);          qsamplerDevicePort *pPort = device.ports().at(iPort);
478          if (pPort) {          if (pPort) {
479                  m_iDirtySetup++;                  m_iDirtySetup++;
480                  devicePortParamModel.refresh(pPort->params(), false);                  devicePortParamModel.refresh(pPort, false);
481                  m_iDirtySetup--;                  m_iDirtySetup--;
482          }          }
483          // Done.          // Done.
# Line 489  void DeviceForm::changeDeviceParam ( int Line 497  void DeviceForm::changeDeviceParam ( int
497          //  Device parameter change...          //  Device parameter change...
498          //          //
499    
500    /* we do that in the model class now ...
501          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
502          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
503                  return;                  return;
# Line 506  void DeviceForm::changeDeviceParam ( int Line 515  void DeviceForm::changeDeviceParam ( int
515          } else {          } else {
516                  stabilizeForm();                  stabilizeForm();
517          }          }
518    */
519    
520          // Main session should be dirtier...          // Main session should be dirtier...
521          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
# Line 526  void DeviceForm::changeDevicePortParam ( Line 536  void DeviceForm::changeDevicePortParam (
536          //  Device port/channel parameter change...          //  Device port/channel parameter change...
537          //          //
538    
539    /* we do that in the model class now ...
540          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
541          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
542                  return;                  return;
# Line 545  void DeviceForm::changeDevicePortParam ( Line 556  void DeviceForm::changeDevicePortParam (
556    
557          // Set the local device port/channel parameter value.          // Set the local device port/channel parameter value.
558          pPort->setParam(sParam, sValue);          pPort->setParam(sParam, sValue);
559    */
560    
561          // Done.          // Done.
562          stabilizeForm();          stabilizeForm();
563    
# Line 609  void DeviceForm::stabilizeForm (void) Line 622  void DeviceForm::stabilizeForm (void)
622          ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);          ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);
623  }  }
624    
625    void DeviceForm::updateCellRenderers() {
626        const int rows = deviceParamModel.rowCount();
627        const int cols = deviceParamModel.columnCount();
628        updateCellRenderers(deviceParamModel.index(0,0),deviceParamModel.index(rows-1,cols-1));
629    }
630    
631    void DeviceForm::updateCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {
632        for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
633            for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
634                const QModelIndex index = deviceParamModel.index(r,c);
635                ui.DeviceParamTable->openPersistentEditor(index);
636            }
637        }
638    }
639    
640    void DeviceForm::updatePortCellRenderers() {
641        const int rows = devicePortParamModel.rowCount();
642        const int cols = devicePortParamModel.columnCount();
643        updatePortCellRenderers(devicePortParamModel.index(0,0),devicePortParamModel.index(rows-1,cols-1));
644    }
645    
646    void DeviceForm::updatePortCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {
647        for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
648            for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
649                const QModelIndex index = devicePortParamModel.index(r,c);
650                ui.DevicePortParamTable->openPersistentEditor(index);
651            }
652        }
653    }
654    
655  } // namespace QSampler  } // namespace QSampler
656    
657    

Legend:
Removed from v.1477  
changed lines
  Added in v.1486

  ViewVC Help
Powered by ViewVC