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

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

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

revision 1558 by capela, Thu Dec 6 09:35:33 2007 UTC revision 3402 by schoenebeck, Wed Jan 3 13:01:00 2018 UTC
# Line 1  Line 1 
1  // qsamplerDevice.cpp  // qsamplerDevice.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2012, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 702  int *Device::getDevices ( lscp_client_t Line 702  int *Device::getDevices ( lscp_client_t
702          return piDeviceIDs;          return piDeviceIDs;
703  }  }
704    
705    std::set<int> Device::getDeviceIDs(lscp_client_t *pClient,
706            DeviceType deviceType)
707    {
708            std::set<int> result;
709            int* piDeviceIDs = getDevices(pClient, deviceType);
710            if (!piDeviceIDs) return result;
711            for (int i = 0; piDeviceIDs[i] != -1; ++i)
712                    result.insert(piDeviceIDs[i]);
713            return result;
714    }
715    
716    
717  // Driver names enumerator.  // Driver names enumerator.
718  QStringList Device::getDrivers ( lscp_client_t *pClient,  QStringList Device::getDrivers ( lscp_client_t *pClient,
# Line 901  bool DevicePort::setParam ( const QStrin Line 912  bool DevicePort::setParam ( const QStrin
912  DeviceItem::DeviceItem ( QTreeWidget* pTreeWidget,  DeviceItem::DeviceItem ( QTreeWidget* pTreeWidget,
913          Device::DeviceType deviceType )          Device::DeviceType deviceType )
914          : QTreeWidgetItem(pTreeWidget, QSAMPLER_DEVICE_ITEM),          : QTreeWidgetItem(pTreeWidget, QSAMPLER_DEVICE_ITEM),
915          m_device(deviceType)                  m_device(deviceType)
916  {  {
917          switch(m_device.deviceType()) {          switch(m_device.deviceType()) {
918          case Device::Audio:          case Device::Audio:
919                  setIcon(0, QPixmap(":/icons/audio1.png"));                  setIcon(0, QPixmap(":/images/audio1.png"));
920                  setText(0, QObject::tr("Audio Devices"));                  setText(0, QObject::tr("Audio Devices"));
921                  break;                  break;
922          case Device::Midi:          case Device::Midi:
923                  setIcon(0, QPixmap(":/icons/midi1.png"));                  setIcon(0, QPixmap(":/images/midi1.png"));
924                  setText(0, QObject::tr("MIDI Devices"));                  setText(0, QObject::tr("MIDI Devices"));
925                  break;                  break;
926          case Device::None:          case Device::None:
# Line 924  DeviceItem::DeviceItem ( QTreeWidgetItem Line 935  DeviceItem::DeviceItem ( QTreeWidgetItem
935          Device::DeviceType deviceType,          Device::DeviceType deviceType,
936          int iDeviceID )          int iDeviceID )
937          : QTreeWidgetItem(pItem, QSAMPLER_DEVICE_ITEM),          : QTreeWidgetItem(pItem, QSAMPLER_DEVICE_ITEM),
938          m_device(deviceType, iDeviceID)                  m_device(deviceType, iDeviceID)
939  {  {
940          switch(m_device.deviceType()) {          switch(m_device.deviceType()) {
941          case Device::Audio:          case Device::Audio:
942                  setIcon(0, QPixmap(":/icons/audio2.png"));                  setIcon(0, QPixmap(":/images/audio2.png"));
943                  break;                  break;
944          case Device::Midi:          case Device::Midi:
945                  setIcon(0, QPixmap(":/icons/midi2.png"));                  setIcon(0, QPixmap(":/images/midi2.png"));
946                  break;                  break;
947          case Device::None:          case Device::None:
948                  break;                  break;
# Line 1007  void AbstractDeviceParamModel::refresh ( Line 1018  void AbstractDeviceParamModel::refresh (
1018          m_pParams   = pParams;          m_pParams   = pParams;
1019          m_bEditable = bEditable;          m_bEditable = bEditable;
1020          // inform the outer world (QTableView) that our data changed          // inform the outer world (QTableView) that our data changed
1021    #if QT_VERSION < 0x050000
1022          QAbstractTableModel::reset();          QAbstractTableModel::reset();
1023    #else
1024            QAbstractTableModel::beginResetModel();
1025            QAbstractTableModel::endResetModel();
1026    #endif
1027  }  }
1028    
1029    
# Line 1015  void AbstractDeviceParamModel::clear (vo Line 1031  void AbstractDeviceParamModel::clear (vo
1031  {  {
1032          m_pParams = NULL;          m_pParams = NULL;
1033          // inform the outer world (QTableView) that our data changed          // inform the outer world (QTableView) that our data changed
1034    #if QT_VERSION < 0x050000
1035          QAbstractTableModel::reset();          QAbstractTableModel::reset();
1036    #else
1037            QAbstractTableModel::beginResetModel();
1038            QAbstractTableModel::endResetModel();
1039    #endif
1040  }  }
1041    
1042    
# Line 1150  QWidget* DeviceParamDelegate::createEdit Line 1171  QWidget* DeviceParamDelegate::createEdit
1171                  Qt::DisplayRole).value<DeviceParameterRow>();                  Qt::DisplayRole).value<DeviceParameterRow>();
1172    
1173          const bool bEnabled = (r.alive) ? !r.param.fix : true;          const bool bEnabled = (r.alive) ? !r.param.fix : true;
1174            const bool bFix = r.param.fix;
1175    
1176          QString val = (r.alive) ? r.param.value : r.param.defaultv;          QString val = (r.alive) ? r.param.value : r.param.defaultv;
1177    
# Line 1162  QWidget* DeviceParamDelegate::createEdit Line 1184  QWidget* DeviceParamDelegate::createEdit
1184                                  if (val != QString::null)                                  if (val != QString::null)
1185                                          pCheckBox->setChecked(val.toLower() == "true");                                          pCheckBox->setChecked(val.toLower() == "true");
1186                                  pCheckBox->setEnabled(bEnabled);                                  pCheckBox->setEnabled(bEnabled);
1187                                    pCheckBox->setCheckable(!bFix);
1188                                  return pCheckBox;                                  return pCheckBox;
1189                          } else if (r.param.possibilities.count() > 0) {                          } else if (r.param.possibilities.count() > 0) {
1190                                  QStringList opts = r.param.possibilities;                                  QStringList opts = r.param.possibilities;
# Line 1174  QWidget* DeviceParamDelegate::createEdit Line 1197  QWidget* DeviceParamDelegate::createEdit
1197                                  else                                  else
1198                                          pComboBox->setCurrentIndex(pComboBox->findText(val));                                          pComboBox->setCurrentIndex(pComboBox->findText(val));
1199                                  pComboBox->setEnabled(bEnabled);                                  pComboBox->setEnabled(bEnabled);
1200                                    pComboBox->setEditable(!bFix);
1201                                  return pComboBox;                                  return pComboBox;
1202                          } else if (r.param.type == LSCP_TYPE_INT && bEnabled) {                          } else if (r.param.type == LSCP_TYPE_INT && bEnabled) {
1203                                  QSpinBox *pSpinBox = new QSpinBox(pParent);                                  QSpinBox *pSpinBox = new QSpinBox(pParent);
# Line 1183  QWidget* DeviceParamDelegate::createEdit Line 1207  QWidget* DeviceParamDelegate::createEdit
1207                                  );                                  );
1208                                  pSpinBox->setMaximum(                                  pSpinBox->setMaximum(
1209                                          (!r.param.range_max.isEmpty()) ?                                          (!r.param.range_max.isEmpty()) ?
1210                                                  r.param.range_max.toInt() : (1 << 16) // or better a nigher default max value ?                                                  r.param.range_max.toInt() : (1 << 24) // or better a higher default max value ?
1211                                  );                                  );
1212                                  pSpinBox->setValue(val.toInt());                                  pSpinBox->setValue(val.toInt());
1213                                    pSpinBox->setReadOnly(bFix);
1214                                  return pSpinBox;                                  return pSpinBox;
1215                          } else if (bEnabled) {                          } else if (bEnabled) {
1216                                  QLineEdit *pLineEdit = new QLineEdit(val, pParent);                                  QLineEdit *pLineEdit = new QLineEdit(val, pParent);
1217                                    pLineEdit->setReadOnly(bFix);
1218                                  return pLineEdit;                                  return pLineEdit;
1219                          } else {                          } else {
1220                                  QLabel *pLabel = new QLabel(val, pParent);                                  QLabel *pLabel = new QLabel(val, pParent);
# Line 1217  void DeviceParamDelegate::setModelData ( Line 1243  void DeviceParamDelegate::setModelData (
1243                  DeviceParameterRow r = index.model()->data(index,                  DeviceParameterRow r = index.model()->data(index,
1244                          Qt::DisplayRole).value<DeviceParameterRow> ();                          Qt::DisplayRole).value<DeviceParameterRow> ();
1245                  if (pEditor->metaObject()->className() == QString("QCheckBox")) {                  if (pEditor->metaObject()->className() == QString("QCheckBox")) {
1246                          QCheckBox* pCheckBox = static_cast<QCheckBox*> (pEditor);                          QCheckBox *pCheckBox = static_cast<QCheckBox *> (pEditor);
1247                          pModel->setData(index, QVariant(pCheckBox->checkState() == Qt::Checked));                          pModel->setData(index, QVariant(pCheckBox->checkState() == Qt::Checked));
1248                  } else if (pEditor->metaObject()->className() == QString("QComboBox")) {                  } else if (pEditor->metaObject()->className() == QString("QComboBox")) {
1249                          QComboBox* pComboBox = static_cast<QComboBox*> (pEditor);                          QComboBox *pComboBox = static_cast<QComboBox *> (pEditor);
1250                          pModel->setData(index, pComboBox->currentText());                          pModel->setData(index, pComboBox->currentText());
1251                  } else if (pEditor->metaObject()->className() == QString("QSpinBox")) {                  } else if (pEditor->metaObject()->className() == QString("QSpinBox")) {
1252                          QSpinBox* pSpinBox = static_cast<QSpinBox*> (pEditor);                          QSpinBox *pSpinBox = static_cast<QSpinBox *> (pEditor);
1253                          pModel->setData(index, pSpinBox->value());                          pModel->setData(index, pSpinBox->value());
1254                  } else if (pEditor->metaObject()->className() == QString("QLineEdit")) {                  } else if (pEditor->metaObject()->className() == QString("QLineEdit")) {
1255                          QLineEdit* pLineEdit = static_cast<QLineEdit*> (pEditor);                          QLineEdit *pLineEdit = static_cast<QLineEdit *> (pEditor);
1256                          pModel->setData(index, pLineEdit->text());                          pModel->setData(index, pLineEdit->text());
1257                  } else if (pEditor->metaObject()->className() == QString("QLabel")) {                  } else if (pEditor->metaObject()->className() == QString("QLabel")) {
1258                          QLabel* pLabel = static_cast<QLabel*> (pEditor);                          QLabel *pLabel = static_cast<QLabel *> (pEditor);
1259                          pModel->setData(index, pLabel->text());                          pModel->setData(index, pLabel->text());
1260                  }                  }
1261          }          }

Legend:
Removed from v.1558  
changed lines
  Added in v.3402

  ViewVC Help
Powered by ViewVC