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

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

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

revision 1474 by schoenebeck, Mon Nov 5 20:47:38 2007 UTC revision 1489 by schoenebeck, Mon Nov 19 03:29:57 2007 UTC
# Line 52  ChannelForm::ChannelForm(QWidget* parent Line 52  ChannelForm::ChannelForm(QWidget* parent
52          // Try to restore normal window positioning.          // Try to restore normal window positioning.
53          adjustSize();          adjustSize();
54    
55            ui.AudioRoutingTable->setModel(&routingModel);
56            ui.AudioRoutingTable->setItemDelegate(&routingDelegate);
57            ui.AudioRoutingTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
58    
59          QObject::connect(ui.EngineNameComboBox,          QObject::connect(ui.EngineNameComboBox,
60                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
61                  SLOT(optionsChanged()));                  SLOT(optionsChanged()));
# Line 97  ChannelForm::ChannelForm(QWidget* parent Line 101  ChannelForm::ChannelForm(QWidget* parent
101          QObject::connect(ui.AudioDeviceToolButton,          QObject::connect(ui.AudioDeviceToolButton,
102                  SIGNAL(clicked()),                  SIGNAL(clicked()),
103                  SLOT(setupAudioDevice()));                  SLOT(setupAudioDevice()));
104            QObject::connect(&routingModel,
105                    SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
106                    SLOT(optionsChanged()));
107            QObject::connect(&routingModel,
108                    SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
109                    SLOT(updateTableCellRenderers(const QModelIndex&, const QModelIndex&)));
110            QObject::connect(&routingModel,
111                    SIGNAL(modelReset()),
112                    SLOT(updateTableCellRenderers()));
113  }  }
114    
115  ChannelForm::~ChannelForm() {  ChannelForm::~ChannelForm() {
# Line 138  void ChannelForm::setup ( qsamplerChanne Line 151  void ChannelForm::setup ( qsamplerChanne
151          // Load combo box history...          // Load combo box history...
152          pOptions->loadComboBoxHistory(ui.InstrumentFileComboBox);          pOptions->loadComboBoxHistory(ui.InstrumentFileComboBox);
153    
         // Notify.that we've just changed one audio route.  
         QObject::connect(ui.AudioRoutingTable, SIGNAL(valueChanged(int,int)),  
                 this, SLOT(changeAudioRouting(int,int)));  
   
154          // Populate Engines list.          // Populate Engines list.
155          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());          const char **ppszEngines = ::lscp_list_available_engines(pMainForm->client());
156          if (ppszEngines) {          if (ppszEngines) {
# Line 290  void ChannelForm::accept (void) Line 299  void ChannelForm::accept (void)
299                                  iErrors++;                                  iErrors++;
300                  } else {                  } else {
301                          qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem());                          qsamplerDevice *pDevice = m_audioDevices.at(ui.AudioDeviceComboBox->currentItem());
302                            qsamplerChannelRoutingMap routingMap = routingModel.routingMap();
303                          if (pDevice == NULL)                          if (pDevice == NULL)
304                                  iErrors++;                                  iErrors++;
305                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))                          else if (!m_pChannel->setAudioDevice(pDevice->deviceID()))
306                                  iErrors++;                                  iErrors++;
307                          else if (!m_audioRouting.isEmpty()) {                          else if (!routingMap.isEmpty()) {
308                                  // Set the audio route changes...                                  // Set the audio route changes...
309                                  qsamplerChannelRoutingMap::ConstIterator iter;                                  qsamplerChannelRoutingMap::ConstIterator iter;
310                                  for (iter = m_audioRouting.begin();                                  for (iter = routingMap.begin();
311                                                  iter != m_audioRouting.end(); ++iter) {                                                  iter != routingMap.end(); ++iter) {
312                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.data()))                                          if (!m_pChannel->setAudioChannel(iter.key(), iter.data()))
313                                                  iErrors++;                                                  iErrors++;
314                                  }                                  }
# Line 487  void ChannelForm::selectMidiDriverItem ( Line 497  void ChannelForm::selectMidiDriverItem (
497          m_midiDevices.clear();          m_midiDevices.clear();
498    
499          // Populate with the current ones...          // Populate with the current ones...
500          const QPixmap midiPixmap(":/qsampler/pixmaps/midi2.png");          const QPixmap midiPixmap(":/icons/midi2.png");
501          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),
502                  qsamplerDevice::Midi);                  qsamplerDevice::Midi);
503          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
# Line 591  void ChannelForm::selectAudioDriverItem Line 601  void ChannelForm::selectAudioDriverItem
601          m_audioDevices.clear();          m_audioDevices.clear();
602    
603          // Populate with the current ones...          // Populate with the current ones...
604          const QPixmap audioPixmap(":/qsampler/pixmaps/audio2.png");          const QPixmap audioPixmap(":/icons/audio2.png");
605          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),          int *piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),
606                  qsamplerDevice::Audio);                  qsamplerDevice::Audio);
607          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
# Line 649  void ChannelForm::selectAudioDeviceItem Line 659  void ChannelForm::selectAudioDeviceItem
659                  // Refresh the audio routing table.                  // Refresh the audio routing table.
660                  routingModel.refresh(pDevice, m_pChannel->audioRouting());                  routingModel.refresh(pDevice, m_pChannel->audioRouting());
661                  // Reset routing change map.                  // Reset routing change map.
662                  m_audioRouting.clear();                  routingModel.clear();
663          }          }
664  }  }
665    
# Line 672  void ChannelForm::setupAudioDevice (void Line 682  void ChannelForm::setupAudioDevice (void
682                  qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText());                  qsamplerDevice::Audio, ui.AudioDriverComboBox->currentText());
683  }  }
684    
   
 // Audio routing change slot.  
 void ChannelForm::changeAudioRouting ( int iRow, int iCol )  
 {  
 #if 0  
         if (m_iDirtySetup > 0)  
                 return;  
         if (iRow < 0 || iCol < 0)  
                 return;  
   
         // Verify that this is a QComboTableItem (magic rtti == 1)  
         QTableItem *pItem = ui.AudioRoutingTable->item(iRow, iCol);  
         if (pItem == NULL)  
                 return;  
         qsamplerChannelRoutingComboBox *pComboItem =  
                 static_cast<qsamplerChannelRoutingComboBox*> (pItem);  
         // FIXME: Its not garanteed that we must have  
         // iAudioOut == iRow on all times forth!  
         m_audioRouting[iRow] = pComboItem->currentItem();  
   
         // And let's get dirty...  
         optionsChanged();  
 #endif  
 }  
   
   
685  // UPdate all device lists slot.  // UPdate all device lists slot.
686  void ChannelForm::updateDevices (void)  void ChannelForm::updateDevices (void)
687  {  {
# Line 732  void ChannelForm::stabilizeForm (void) Line 716  void ChannelForm::stabilizeForm (void)
716          ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);          ui.OkPushButton->setEnabled(m_iDirtyCount > 0 && bValid);
717  }  }
718    
719    void ChannelForm::updateTableCellRenderers() {
720        const int rows = routingModel.rowCount();
721        const int cols = routingModel.columnCount();
722        updateTableCellRenderers(routingModel.index(0,0),routingModel.index(rows-1,cols-1));
723    }
724    
725    void ChannelForm::updateTableCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {
726        for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
727            for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
728                const QModelIndex index = routingModel.index(r,c);
729                ui.AudioRoutingTable->openPersistentEditor(index);
730            }
731        }
732    }
733    
734  } // namespace QSampler  } // namespace QSampler
735    

Legend:
Removed from v.1474  
changed lines
  Added in v.1489

  ViewVC Help
Powered by ViewVC