/[svn]/qsampler/trunk/src/qsamplerDeviceForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerDeviceForm.ui.h

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

revision 436 by capela, Wed Mar 9 20:55:04 2005 UTC revision 488 by capela, Thu Mar 31 16:26:40 2005 UTC
# Line 24  Line 24 
24  #include <qfiledialog.h>  #include <qfiledialog.h>
25  #include <qfileinfo.h>  #include <qfileinfo.h>
26  #include <qlistbox.h>  #include <qlistbox.h>
27    #include <qptrlist.h>
28    #include <qpopupmenu.h>
29    
30  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
31    
# Line 34  Line 36 
36  void qsamplerDeviceForm::init (void)  void qsamplerDeviceForm::init (void)
37  {  {
38          // Initialize locals.          // Initialize locals.
39          m_pMainForm   = (qsamplerMainForm *) QWidget::parentWidget();          m_pMainForm   = NULL;
40          m_pClient     = NULL;          m_pClient     = NULL;
41          m_iDirtySetup = 0;          m_iDirtySetup = 0;
42          m_iDirtyCount = 0;          m_iDirtyCount = 0;
43          m_bNewDevice  = false;          m_bNewDevice  = false;
44          m_deviceType  = qsamplerDevice::None;          m_deviceType  = qsamplerDevice::None;
45            m_pAudioItems = NULL;
46            m_pMidiItems  = NULL;
47            
48          // This an outsider (from designer), but rather important.          // This an outsider (from designer), but rather important.
49          QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)),          QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)),
50                  this, SLOT(changeValue(int,int)));                  this, SLOT(changeDeviceParam(int,int)));
51                    QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)),
52                    this, SLOT(changeDevicePortParam(int,int)));
53    
54            // Initial contents.
55            refreshDevices();
56          // Try to restore normal window positioning.          // Try to restore normal window positioning.
57          adjustSize();          adjustSize();
58  }  }
# Line 75  void qsamplerDeviceForm::hideEvent ( QHi Line 83  void qsamplerDeviceForm::hideEvent ( QHi
83    
84          if (m_pMainForm)          if (m_pMainForm)
85                  m_pMainForm->stabilizeForm();                  m_pMainForm->stabilizeForm();
86                    
87            // Signal special whether we changed the device set.
88            if (m_iDirtyCount > 0) {
89                    m_iDirtyCount = 0;
90                    emit devicesChanged();
91            }
92    }
93    
94    
95    // Application main form settler (life depends on it).
96    void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm )
97    {
98       m_pMainForm = pMainForm;
99  }  }
100    
101    
# Line 93  void qsamplerDeviceForm::setClient ( lsc Line 114  void qsamplerDeviceForm::setClient ( lsc
114  }  }
115    
116    
117  // Create a new device from current table view.  // Set current selected device by type and id.
118  void qsamplerDeviceForm::createDevice (void)  void qsamplerDeviceForm::setDevice (
119  {          qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID )
120          //  {
121          // TODO: Create a new device from current table view...          // Get the device view root item...
122          //          qsamplerDeviceItem *pRootItem = NULL;
123          m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()");          switch (deviceType) {
   
         QListViewItem *pItem = DeviceListView->selectedItem();  
         if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)  
                 return;  
   
         qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();  
   
         // Build the parameter list...  
         qsamplerDeviceParamMap& params = device.params();  
         lscp_param_t *pParams = new lscp_param_t [params.count() + 1];  
         int iParam = 0;  
         qsamplerDeviceParamMap::ConstIterator iter;  
         for (iter = params.begin(); iter != params.end(); ++iter) {  
                 pParams[iParam].key   = (char *) iter.key().latin1();  
                 pParams[iParam].value = (char *) iter.data().value.latin1();  
                 ++iParam;  
         }  
         // Null terminated.  
         pParams[iParam].key   = NULL;  
         pParams[iParam].value = NULL;  
   
         // Now it depends on the device type...  
         int iDeviceID = -1;  
         switch (device.deviceType()) {  
124          case qsamplerDevice::Audio:          case qsamplerDevice::Audio:
125                  if ((iDeviceID = ::lscp_create_audio_device(m_pClient,                  pRootItem = m_pAudioItems;
                                 device.driverName().latin1(), pParams)) < 0)  
                         m_pMainForm->appendMessagesClient("lscp_create_audio_device");  
126                  break;                  break;
127          case qsamplerDevice::Midi:          case qsamplerDevice::Midi:
128                  if ((iDeviceID = ::lscp_create_midi_device(m_pClient,                  pRootItem = m_pMidiItems;
                                 device.driverName().latin1(), pParams)) < 0)  
                         m_pMainForm->appendMessagesClient("lscp_create_midi_device");  
129                  break;                  break;
130          case qsamplerDevice::None:          case qsamplerDevice::None:
131                  break;                  break;
132          }          }
133            
134            // Is the root present?
135            if (pRootItem == NULL)
136                return;
137    
138            // For each child, test for identity...
139            qsamplerDeviceItem *pDeviceItem =
140                    (qsamplerDeviceItem *) pRootItem->firstChild();
141            while (pDeviceItem) {
142                    // If identities match, select as current device item.
143                    if (pDeviceItem->device().deviceID() == iDeviceID) {
144                            DeviceListView->setSelected(pDeviceItem, true);
145                            break;
146                    }
147                    pDeviceItem = (qsamplerDeviceItem *) pDeviceItem->nextSibling();
148            }
149    }
150    
         // Free used parameter array.  
         delete pParams;  
151    
152          // Show result.  
153          if (iDeviceID >= 0) {  // Create a new device from current table view.
154                  m_pMainForm->appendMessages(device.deviceName() + ' ' + tr("created."));  void qsamplerDeviceForm::createDevice (void)
155                  // Done.  {
156                  refreshDevices();          if (m_pMainForm == NULL)
157                return;
158    
159            QListViewItem *pItem = DeviceListView->selectedItem();
160            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
161                    return;
162    
163            // About a brand new device instance...
164            qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device());
165            if (device.createDevice()) {
166                    // Now it depends on the device type...
167                    qsamplerDeviceItem *pRootItem = NULL;
168                    switch (device.deviceType()) {
169                    case qsamplerDevice::Audio:
170                            pRootItem = m_pAudioItems;
171                            break;
172                    case qsamplerDevice::Midi:
173                            pRootItem = m_pMidiItems;
174                            break;
175                    case qsamplerDevice::None:
176                            break;
177                    }
178                    // Append the new device item.
179                    qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem,
180                            m_pMainForm, device.deviceType(), device.deviceID());
181                    // Just make it the new selection...
182                    DeviceListView->setSelected(pDeviceItem, true);
183                  // Main session should be marked dirty.                  // Main session should be marked dirty.
184                  m_pMainForm->sessionDirty();                  m_pMainForm->sessionDirty();
185                    m_iDirtyCount++;
186          }          }
187  }  }
188    
# Line 155  void qsamplerDeviceForm::createDevice (v Line 190  void qsamplerDeviceForm::createDevice (v
190  // Delete current device in table view.  // Delete current device in table view.
191  void qsamplerDeviceForm::deleteDevice (void)  void qsamplerDeviceForm::deleteDevice (void)
192  {  {
193          //          if (m_pMainForm == NULL)
194          // TODO: Delete current device in table view...              return;
         //  
         m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()");  
195    
196          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
197          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
# Line 166  void qsamplerDeviceForm::deleteDevice (v Line 199  void qsamplerDeviceForm::deleteDevice (v
199    
200          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
201    
202          // Now it depends on the device type...          // Prompt user if this is for real...
203          lscp_status_t ret = LSCP_FAILED;          qsamplerOptions *pOptions = m_pMainForm->options();
204          switch (device.deviceType()) {          if (pOptions && pOptions->bConfirmRemove) {
205          case qsamplerDevice::Audio:                  if (QMessageBox::warning(this, tr("Warning"),
206                  if ((ret = ::lscp_destroy_audio_device(m_pClient,                          tr("Delete device:\n\n"
207                                  device.deviceID())) != LSCP_OK)                          "%1\n\n"
208                          m_pMainForm->appendMessagesClient("lscp_destroy_audio_device");                          "Are you sure?")
209                  break;                          .arg(device.deviceName()),
210          case qsamplerDevice::Midi:                          tr("OK"), tr("Cancel")) > 0)
211                  if ((ret = ::lscp_destroy_midi_device(m_pClient,                          return;
                                 device.deviceID())) != LSCP_OK)  
                         m_pMainForm->appendMessagesClient("lscp_destroy_midi_device");  
                 break;  
         case qsamplerDevice::None:  
                 break;  
212          }          }
213    
214          // Show result.          // Go and destroy...
215          if (ret == LSCP_OK) {          if (device.deleteDevice()) {
216                  m_pMainForm->appendMessages(device.deviceName() + ' ' + tr("deleted."));                  // Remove it from the device view...
217                  // Done.                  delete pItem;
                 refreshDevices();  
218                  // Main session should be marked dirty.                  // Main session should be marked dirty.
219                  m_pMainForm->sessionDirty();                  m_pMainForm->sessionDirty();
220                    m_iDirtyCount++;
221          }          }
222  }  }
223    
# Line 197  void qsamplerDeviceForm::deleteDevice (v Line 225  void qsamplerDeviceForm::deleteDevice (v
225  // Refresh all device list and views.  // Refresh all device list and views.
226  void qsamplerDeviceForm::refreshDevices (void)  void qsamplerDeviceForm::refreshDevices (void)
227  {  {
228            if (m_pMainForm == NULL)
229                return;
230    
231          // Avoid nested changes.          // Avoid nested changes.
232          m_iDirtySetup++;          m_iDirtySetup++;
233    
234          //          //
235          // TODO: Load device configuration data ...          // (Re)Load complete device configuration data ...
236          //          //
237          m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()");          m_pAudioItems = NULL;
238            m_pMidiItems = NULL;
239          DeviceListView->clear();          DeviceListView->clear();
240          if (m_pClient) {          if (m_pClient) {
                 qsamplerDeviceItem *pItem;  
241                  int *piDeviceIDs;                  int *piDeviceIDs;
242                  // Grab and pop Audio devices...                  // Grab and pop Audio devices...
243                  pItem = new qsamplerDeviceItem(DeviceListView, m_pClient,                  m_pAudioItems = new qsamplerDeviceItem(DeviceListView,
244                          qsamplerDevice::Audio);                          m_pMainForm, qsamplerDevice::Audio);
245                  if (pItem) {                  if (m_pAudioItems) {
                         pItem->setText(0, tr("Audio"));  
246                          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);                          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
247                          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {                          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
248                                  new qsamplerDeviceItem(pItem, m_pClient,                                  new qsamplerDeviceItem(m_pAudioItems, m_pMainForm,
249                                          qsamplerDevice::Audio, piDeviceIDs[i]);                                          qsamplerDevice::Audio, piDeviceIDs[i]);
250                          }                          }
251                          pItem->setOpen(true);                          m_pAudioItems->setOpen(true);
252                  }                  }
253                  // Grab and pop MIDI devices...                  // Grab and pop MIDI devices...
254                  pItem = new qsamplerDeviceItem(DeviceListView, m_pClient,                  m_pMidiItems = new qsamplerDeviceItem(DeviceListView,
255                          qsamplerDevice::Midi);                          m_pMainForm, qsamplerDevice::Midi);
256                  if (pItem) {                  if (m_pMidiItems) {
                         pItem->setText(0, tr("MIDI"));  
257                          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);                          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
258                          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {                          for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
259                                  new qsamplerDeviceItem(pItem, m_pClient,                                  new qsamplerDeviceItem(m_pMidiItems, m_pMainForm,
260                                          qsamplerDevice::Midi, piDeviceIDs[i]);                                          qsamplerDevice::Midi, piDeviceIDs[i]);
261                          }                          }
262                          pItem->setOpen(true);                          m_pMidiItems->setOpen(true);
263                  }                  }
264          }          }
265    
266          // Done.          // Done.
         m_iDirtyCount = 0;  
267          m_iDirtySetup--;          m_iDirtySetup--;
268    
269          // Show something.          // Show something.
# Line 251  void qsamplerDeviceForm::selectDriver ( Line 278  void qsamplerDeviceForm::selectDriver (
278                  return;                  return;
279    
280          //          //
281          //  TODO: Driver name has changed for a new device...          //  Driver name has changed for a new device...
282          //          //
         m_pMainForm->appendMessages("qsamplerDeviceForm::selectDriver()");  
283    
284          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
285          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
# Line 263  void qsamplerDeviceForm::selectDriver ( Line 289  void qsamplerDeviceForm::selectDriver (
289    
290          // Driver change is only valid for scratch devices...          // Driver change is only valid for scratch devices...
291          if (m_bNewDevice) {          if (m_bNewDevice) {
292                  device.setDriver(m_pClient, sDriverName);                  m_iDirtySetup++;
293                  DeviceParamTable->refresh(device);                  device.setDriver(sDriverName);
294                  m_iDirtyCount++;                  DeviceParamTable->refresh(device.params(), m_bNewDevice);
295                    m_iDirtySetup--;
296                  // Done.                  // Done.
297                  stabilizeForm();                  stabilizeForm();
298          }          }
# Line 279  void qsamplerDeviceForm::selectDevice (v Line 306  void qsamplerDeviceForm::selectDevice (v
306                  return;                  return;
307    
308          //          //
309          //  TODO: Device selection has changed...          //  Device selection has changed...
310          //          //
         m_pMainForm->appendMessages("qsamplerDeviceForm::selectDevice()");  
311    
312          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
313          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) {          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) {
314                  m_deviceType = qsamplerDevice::None;                  m_deviceType = qsamplerDevice::None;
315                  DeviceNameTextLabel->setText(QString::null);                  DeviceNameTextLabel->setText(QString::null);
316                  DeviceParamTable->setNumRows(0);                  DeviceParamTable->setNumRows(0);
317                    DevicePortComboBox->clear();
318                    DevicePortParamTable->setNumRows(0);
319                    DevicePortComboBox->setEnabled(false);
320                    DevicePortParamTable->setEnabled(false);
321                  stabilizeForm();                  stabilizeForm();
322                  return;                  return;
323          }          }
324    
325          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
326    
327            m_iDirtySetup++;
328          // Flag whether this is a new device.          // Flag whether this is a new device.
329          m_bNewDevice = (device.deviceID() < 0);          m_bNewDevice = (device.deviceID() < 0);
330    
331          // Fill the device/driver heading...          // Fill the device/driver heading...
332          DeviceNameTextLabel->setText(device.deviceTypeName() + ' ' + device.deviceName());          DeviceNameTextLabel->setText(device.deviceName());
333          // The driver combobox is only rebuilt if device type has changed...          // The driver combobox is only rebuilt if device type has changed...
334          if (device.deviceType() != m_deviceType) {          if (device.deviceType() != m_deviceType) {
335                  DriverNameComboBox->clear();                  DriverNameComboBox->clear();
# Line 308  void qsamplerDeviceForm::selectDevice (v Line 339  void qsamplerDeviceForm::selectDevice (v
339          }          }
340          // Do we need a driver name?          // Do we need a driver name?
341          if (m_bNewDevice || device.driverName().isEmpty())          if (m_bNewDevice || device.driverName().isEmpty())
342                  device.setDriver(m_pClient, DriverNameComboBox->currentText());                  device.setDriver(DriverNameComboBox->currentText());
343          const QString& sDriverName = device.driverName();          const QString& sDriverName = device.driverName();
344          if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL)          if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL)
345                  DriverNameComboBox->insertItem(sDriverName);                  DriverNameComboBox->insertItem(sDriverName);
# Line 316  void qsamplerDeviceForm::selectDevice (v Line 347  void qsamplerDeviceForm::selectDevice (v
347          DriverNameTextLabel->setEnabled(m_bNewDevice);          DriverNameTextLabel->setEnabled(m_bNewDevice);
348          DriverNameComboBox->setEnabled(m_bNewDevice);          DriverNameComboBox->setEnabled(m_bNewDevice);
349          // Fill the device parameter table...          // Fill the device parameter table...
350          DeviceParamTable->refresh(device);          DeviceParamTable->refresh(device.params(), m_bNewDevice);
351            // And now the device port/channel parameter table...
352            DevicePortComboBox->clear();
353            DevicePortParamTable->setNumRows(0);
354            if (m_bNewDevice) {
355                    DevicePortComboBox->setEnabled(false);
356                    DevicePortParamTable->setEnabled(false);
357            } else {
358                    QPixmap pixmap;
359                    switch (device.deviceType()) {
360                    case qsamplerDevice::Audio:
361                        pixmap = QPixmap::fromMimeSource("audio2.png");
362                        break;
363                    case qsamplerDevice::Midi:
364                        pixmap = QPixmap::fromMimeSource("midi2.png");
365                        break;
366                    case qsamplerDevice::None:
367                        break;
368                    }
369                    qsamplerDevicePortList& ports = device.ports();
370                    qsamplerDevicePort *pPort;
371                    for (pPort = ports.first(); pPort; pPort = ports.next()) {
372                DevicePortComboBox->insertItem(pixmap, device.deviceTypeName()
373                                    + ' ' + device.driverName()
374                                    + ' ' + pPort->portName());
375                    }
376                    bool bEnabled = (ports.count() > 0);
377                    DevicePortComboBox->setEnabled(bEnabled);
378                    DevicePortParamTable->setEnabled(bEnabled);
379            }
380            // Done.
381            m_iDirtySetup--;
382            
383            // Make the device port/channel selection effective.
384            selectDevicePort(DevicePortComboBox->currentItem());
385    }
386    
387    
388    // Device port/channel selection slot.
389    void qsamplerDeviceForm::selectDevicePort ( int iPort )
390    {
391            if (m_iDirtySetup > 0)
392                    return;
393    
394            //
395            //  Device port/channel selection has changed...
396            //
397    
398            QListViewItem *pItem = DeviceListView->selectedItem();
399            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
400                    return;
401    
402            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
403            qsamplerDevicePort *pPort = device.ports().at(iPort);
404            if (pPort) {
405                    m_iDirtySetup++;
406                    DevicePortParamTable->refresh(pPort->params(), false);
407                    m_iDirtySetup--;
408            }
409          // Done.          // Done.
410          stabilizeForm();          stabilizeForm();
411  }  }
412    
413    
414  // parameter value change slot.  // Device parameter value change slot.
415  void qsamplerDeviceForm::changeValue ( int iRow, int iCol )  void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol )
416  {  {
417            if (m_pMainForm == NULL)
418                return;
419            if (m_iDirtySetup > 0)
420                    return;
421            if (iRow < 0 || iCol < 0)
422                    return;
423                    
424          //          //
425          //  TODO: Device parameter change...          //  Device parameter change...
426          //          //
427          m_pMainForm->appendMessages("qsamplerDeviceForm::changeValue()");  
           
428          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
429          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
430                  return;                  return;
# Line 337  void qsamplerDeviceForm::changeValue ( i Line 432  void qsamplerDeviceForm::changeValue ( i
432          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
433    
434          // Table 1st column has the parameter name;          // Table 1st column has the parameter name;
         qsamplerDeviceParamMap& params = device.params();  
435          const QString sParam = DeviceParamTable->text(iRow, 0);          const QString sParam = DeviceParamTable->text(iRow, 0);
436          const QString sValue = DeviceParamTable->text(iRow, iCol);          const QString sValue = DeviceParamTable->text(iRow, iCol);
437          params[sParam].value = sValue;          // Set the local device parameter value.
438            if (device.setParam(sParam, sValue)) {
439          // Set proper device parameter, on existing device ...                  selectDevice();
440          if (device.deviceID() >= 0) {          } else {
441                  // Prepare parameter struct.                  stabilizeForm();
                 lscp_param_t param;  
                 param.key   = (char *) sParam.latin1();  
                 param.value = (char *) sValue.latin1();  
                 // Now it depends on the device type...  
                 lscp_status_t ret = LSCP_FAILED;  
                 switch (device.deviceType()) {  
                 case qsamplerDevice::Audio:  
                         if ((ret = ::lscp_set_audio_device_param(m_pClient,  
                                         device.deviceID(), &param)) != LSCP_OK)  
                                 m_pMainForm->appendMessagesClient("lscp_set_audio_device_param");  
                         break;  
                 case qsamplerDevice::Midi:  
                         if ((ret = ::lscp_set_midi_device_param(m_pClient,  
                                         device.deviceID(), &param)) != LSCP_OK)  
                                 m_pMainForm->appendMessagesClient("lscp_set_midi_device_param");  
                         break;  
                 case qsamplerDevice::None:  
                         break;  
                 }  
                 // Show result.  
                 if (ret == LSCP_OK) {  
                         m_pMainForm->appendMessages(device.deviceName() + ' ' +  
                                 QString("%1: %2.").arg(sParam).arg(sValue));  
                 }  
442          }          }
443            // Main session should be dirtier...
444            m_pMainForm->sessionDirty();
445    }
446    
447    
448    // Device port/channel parameter value change slot.
449    void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol )
450    {
451            if (m_pMainForm == NULL)
452                return;
453            if (m_iDirtySetup > 0)
454                    return;
455            if (iRow < 0 || iCol < 0)
456                    return;
457    
458            //
459            //  Device port/channel parameter change...
460            //
461    
462            QListViewItem *pItem = DeviceListView->selectedItem();
463            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
464                    return;
465    
466            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
467    
468            int iPort = DevicePortComboBox->currentItem();
469            qsamplerDevicePort *pPort = device.ports().at(iPort);
470            if (pPort == NULL)
471                return;
472    
473            // Table 1st column has the parameter name;
474            const QString sParam = DevicePortParamTable->text(iRow, 0);
475            const QString sValue = DevicePortParamTable->text(iRow, iCol);
476            // Set the local device port/channel parameter value.
477            pPort->setParam(sParam, sValue);
478          // Done.          // Done.
         m_iDirtyCount++;  
479          stabilizeForm();          stabilizeForm();
480          // Main session should be dirtier...          // Main session should be dirtier...
481          m_pMainForm->sessionDirty();          m_pMainForm->sessionDirty();
482  }  }
483    
484    
485    // Device list view context menu handler.
486    void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int )
487    {
488            int iItemID;
489            
490            // Build the device context menu...
491            QPopupMenu* pContextMenu = new QPopupMenu(this);
492            
493            bool bClient = (m_pClient != NULL);
494            bool bEnabled = (pItem != NULL);
495            iItemID = pContextMenu->insertItem(
496                    QIconSet(QPixmap::fromMimeSource("deviceCreate.png")),
497                    tr("&Create device"), this, SLOT(createDevice()));
498            pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice));
499            iItemID = pContextMenu->insertItem(
500                    QIconSet(QPixmap::fromMimeSource("deviceDelete.png")),
501                    tr("&Delete device"), this, SLOT(deleteDevice()));
502            pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice);
503            pContextMenu->insertSeparator();
504            iItemID = pContextMenu->insertItem(
505                    QIconSet(QPixmap::fromMimeSource("formRefresh.png")),
506                    tr("&Refresh"), this, SLOT(refreshDevices()));
507            pContextMenu->setItemEnabled(iItemID, bClient);
508            
509            pContextMenu->exec(pos);
510            
511            delete pContextMenu;
512    }
513    
514    
515  // Stabilize current form state.  // Stabilize current form state.
516  void qsamplerDeviceForm::stabilizeForm (void)  void qsamplerDeviceForm::stabilizeForm (void)
517  {  {
518          QListViewItem *pItem = DeviceListView->selectedItem();          QListViewItem *pItem = DeviceListView->selectedItem();
519            bool bClient = (m_pClient != NULL);
520          bool bEnabled = (pItem != NULL);          bool bEnabled = (pItem != NULL);
521          DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);          DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);
522          DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);          DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);
523          DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);          DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);
524          DeviceParamTable->setEnabled(bEnabled);          DeviceParamTable->setEnabled(bEnabled);
525          CreateDevicePushButton->setEnabled(bEnabled ||  m_bNewDevice);          RefreshDevicesPushButton->setEnabled(bClient);
526            CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));
527          DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);          DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);
528  }  }
529    
530    
531  // end of qsamplerDeviceForm.ui.h  // end of qsamplerDeviceForm.ui.h
532    
533    
534    

Legend:
Removed from v.436  
changed lines
  Added in v.488

  ViewVC Help
Powered by ViewVC