/[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 1486 by schoenebeck, Sat Nov 17 02:02:28 2007 UTC revision 1499 by capela, Tue Nov 20 16:48:04 2007 UTC
# Line 25  Line 25 
25  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
26  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
27    
28    #include <QHeaderView>
29    #include <QMessageBox>
30    
31    
32  namespace QSampler {  namespace QSampler {
33    
34  DeviceForm::DeviceForm(QWidget* parent, Qt::WFlags f) : QDialog(parent, f) {  DeviceForm::DeviceForm(QWidget* parent, Qt::WFlags f) : QDialog(parent, f) {
# Line 145  void DeviceForm::setDeviceTypeMode ( Line 149  void DeviceForm::setDeviceTypeMode (
149  // Device driver name setup formal initializer.  // Device driver name setup formal initializer.
150  void DeviceForm::setDriverName ( const QString& sDriverName )  void DeviceForm::setDriverName ( const QString& sDriverName )
151  {  {
152          if (ui.DriverNameComboBox->findText(sDriverName) < 0) {          if (ui.DriverNameComboBox->findText(sDriverName) < 0)
153                  ui.DriverNameComboBox->insertItem(sDriverName);                  ui.DriverNameComboBox->insertItem(0, sDriverName);
154          }          ui.DriverNameComboBox->setItemText(
155          ui.DriverNameComboBox->setCurrentText(sDriverName);                  ui.DriverNameComboBox->currentIndex(),
156                    sDriverName);
157  }  }
158    
159    
# Line 398  void DeviceForm::selectDevice () Line 403  void DeviceForm::selectDevice ()
403          // The driver combobox is only rebuilt if device type has changed...          // The driver combobox is only rebuilt if device type has changed...
404          if (device.deviceType() != m_deviceType) {          if (device.deviceType() != m_deviceType) {
405                  ui.DriverNameComboBox->clear();                  ui.DriverNameComboBox->clear();
406                  ui.DriverNameComboBox->insertStringList(                  ui.DriverNameComboBox->insertItems(0,
407                          qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType()));                          qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType()));
408                  m_deviceType = device.deviceType();                  m_deviceType = device.deviceType();
409          }          }
# Line 440  void DeviceForm::selectDevice () Line 445  void DeviceForm::selectDevice ()
445                          break;                          break;
446                  }                  }
447                  qsamplerDevicePortList& ports = device.ports();                  qsamplerDevicePortList& ports = device.ports();
448                  qsamplerDevicePort *pPort;                  QListIterator<qsamplerDevicePort *> iter(ports);
449                  for (pPort = ports.first(); pPort; pPort = ports.next()) {                  while (iter.hasNext()) {
450                          ui.DevicePortComboBox->insertItem(pixmap, device.deviceTypeName()                          qsamplerDevicePort *pPort = iter.next();
451                            ui.DevicePortComboBox->addItem(pixmap,
452                                    device.deviceTypeName()
453                                  + ' ' + device.driverName()                                  + ' ' + device.driverName()
454                                  + ' ' + pPort->portName());                                  + ' ' + pPort->portName());
455                  }                  }
# Line 455  void DeviceForm::selectDevice () Line 462  void DeviceForm::selectDevice ()
462          m_iDirtySetup--;          m_iDirtySetup--;
463    
464          // Make the device port/channel selection effective.          // Make the device port/channel selection effective.
465          selectDevicePort(ui.DevicePortComboBox->currentItem());          selectDevicePort(ui.DevicePortComboBox->currentIndex());
466  }  }
467    
468    
# Line 543  void DeviceForm::changeDevicePortParam ( Line 550  void DeviceForm::changeDevicePortParam (
550    
551          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
552    
553          int iPort = ui.DevicePortComboBox->currentItem();          int iPort = ui.DevicePortComboBox->currentIndex();
554          qsamplerDevicePort *pPort = device.ports().at(iPort);          qsamplerDevicePort *pPort = device.ports().at(iPort);
555          if (pPort == NULL)          if (pPort == NULL)
556                  return;                  return;
# Line 579  void DeviceForm::deviceListViewContextMe Line 586  void DeviceForm::deviceListViewContextMe
586          if (pItem == NULL)          if (pItem == NULL)
587                  return;                  return;
588    
         int iItemID;  
   
589          // Build the device context menu...          // Build the device context menu...
590          QMenu* pContextMenu = new QMenu(this);          QMenu menu(this);
591            QAction *pAction;
592    
593          bool bClient = (pMainForm->client() != NULL);          bool bClient = (pMainForm->client() != NULL);
594          bool bEnabled = (pItem != NULL);          bool bEnabled = (pItem != NULL);
595          iItemID = pContextMenu->insertItem(          pAction = menu.addAction(
596                  QIconSet(QPixmap(":/qsampler/pixmaps/deviceCreate.png")),                  QIcon(":/qsampler/pixmaps/deviceCreate.png"),
597                  tr("&Create device"), this, SLOT(createDevice()));                  tr("&Create device"), this, SLOT(createDevice()));
598          pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice));          pAction->setEnabled(bEnabled || (bClient && m_bNewDevice));
599          iItemID = pContextMenu->insertItem(          pAction = menu.addAction(
600                  QIconSet(QPixmap(":/qsampler/pixmaps/deviceDelete.png")),                  QIcon(":/qsampler/pixmaps/deviceDelete.png"),
601                  tr("&Delete device"), this, SLOT(deleteDevice()));                  tr("&Delete device"), this, SLOT(deleteDevice()));
602          pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice);          pAction->setEnabled(bEnabled && !m_bNewDevice);
603          pContextMenu->insertSeparator();          menu.addSeparator();
604          iItemID = pContextMenu->insertItem(          pAction = menu.addAction(
605                  QIconSet(QPixmap(":/qsampler/pixmaps/formRefresh.png")),                  QIcon(":/qsampler/pixmaps/formRefresh.png"),
606                  tr("&Refresh"), this, SLOT(refreshDevices()));                  tr("&Refresh"), this, SLOT(refreshDevices()));
607          pContextMenu->setItemEnabled(iItemID, bClient);          pAction->setEnabled(bClient);
   
         pContextMenu->exec(pos);  
608    
609          delete pContextMenu;          menu.exec(pos);
610  }  }
611    
612    

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

  ViewVC Help
Powered by ViewVC