/[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 3554 by capela, Mon Jul 1 10:53:41 2019 UTC revision 3555 by capela, Tue Aug 13 10:19:32 2019 UTC
# Line 47  DeviceForm::DeviceForm ( QWidget *pParen Line 47  DeviceForm::DeviceForm ( QWidget *pParen
47          m_iDirtyCount = 0;          m_iDirtyCount = 0;
48          m_bNewDevice  = false;          m_bNewDevice  = false;
49          m_deviceType  = Device::None;          m_deviceType  = Device::None;
50          m_pAudioItems = NULL;          m_pAudioItems = nullptr;
51          m_pMidiItems  = NULL;          m_pMidiItems  = nullptr;
52          // No exclusive mode as default.          // No exclusive mode as default.
53          m_deviceTypeMode = Device::None;          m_deviceTypeMode = Device::None;
54    
# Line 192  void DeviceForm::setDevice ( Device *pDe Line 192  void DeviceForm::setDevice ( Device *pDe
192                  deviceType = pDevice->deviceType();                  deviceType = pDevice->deviceType();
193    
194          // Get the device view root item...          // Get the device view root item...
195          DeviceItem *pRootItem = NULL;          DeviceItem *pRootItem = nullptr;
196          switch (deviceType) {          switch (deviceType) {
197          case Device::Audio:          case Device::Audio:
198                  pRootItem = m_pAudioItems;                  pRootItem = m_pAudioItems;
# Line 205  void DeviceForm::setDevice ( Device *pDe Line 205  void DeviceForm::setDevice ( Device *pDe
205          }          }
206    
207          // Is the root present?          // Is the root present?
208          if (pRootItem == NULL)          if (pRootItem == nullptr)
209                  return;                  return;
210    
211          // So there's no device huh?          // So there's no device huh?
212          if (pDevice == NULL) {          if (pDevice == nullptr) {
213                  m_ui.DeviceListView->setCurrentItem(pRootItem);                  m_ui.DeviceListView->setCurrentItem(pRootItem);
214                  return;                  return;
215          }          }
# Line 233  void DeviceForm::setDevice ( Device *pDe Line 233  void DeviceForm::setDevice ( Device *pDe
233  void DeviceForm::createDevice (void)  void DeviceForm::createDevice (void)
234  {  {
235          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
236          if (pMainForm == NULL)          if (pMainForm == nullptr)
237                  return;                  return;
238    
239          QTreeWidgetItem *pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem *pItem = m_ui.DeviceListView->currentItem();
240          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == nullptr || pItem->type() != QSAMPLER_DEVICE_ITEM)
241                  return;                  return;
242    
243          // About a brand new device instance...          // About a brand new device instance...
244          Device device(((DeviceItem *) pItem)->device());          Device device(((DeviceItem *) pItem)->device());
245          if (device.createDevice()) {          if (device.createDevice()) {
246                  // Now it depends on the device type...                  // Now it depends on the device type...
247                  DeviceItem *pRootItem = NULL;                  DeviceItem *pRootItem = nullptr;
248                  switch (device.deviceType()) {                  switch (device.deviceType()) {
249                  case Device::Audio:                  case Device::Audio:
250                          pRootItem = m_pAudioItems;                          pRootItem = m_pAudioItems;
# Line 271  void DeviceForm::createDevice (void) Line 271  void DeviceForm::createDevice (void)
271  void DeviceForm::deleteDevice (void)  void DeviceForm::deleteDevice (void)
272  {  {
273          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
274          if (pMainForm == NULL)          if (pMainForm == nullptr)
275                  return;                  return;
276    
277          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
278          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == nullptr || pItem->type() != QSAMPLER_DEVICE_ITEM)
279                  return;                  return;
280    
281          Device& device = ((DeviceItem *) pItem)->device();          Device& device = ((DeviceItem *) pItem)->device();
# Line 325  void DeviceForm::deleteDevice (void) Line 325  void DeviceForm::deleteDevice (void)
325  void DeviceForm::refreshDevices (void)  void DeviceForm::refreshDevices (void)
326  {  {
327          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
328          if (pMainForm == NULL)          if (pMainForm == nullptr)
329                  return;                  return;
330    
331          // Avoid nested changes.          // Avoid nested changes.
# Line 334  void DeviceForm::refreshDevices (void) Line 334  void DeviceForm::refreshDevices (void)
334          //          //
335          // (Re)Load complete device configuration data ...          // (Re)Load complete device configuration data ...
336          //          //
337          m_pAudioItems = NULL;          m_pAudioItems = nullptr;
338          m_pMidiItems = NULL;          m_pMidiItems = nullptr;
339          m_ui.DeviceListView->clear();          m_ui.DeviceListView->clear();
340          if (pMainForm->client()) {          if (pMainForm->client()) {
341                  int *piDeviceIDs;                  int *piDeviceIDs;
# Line 390  void DeviceForm::selectDriver ( const QS Line 390  void DeviceForm::selectDriver ( const QS
390          //          //
391    
392          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
393          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == nullptr || pItem->type() != QSAMPLER_DEVICE_ITEM)
394                  return;                  return;
395    
396          Device& device = ((DeviceItem *) pItem)->device();          Device& device = ((DeviceItem *) pItem)->device();
# Line 411  void DeviceForm::selectDriver ( const QS Line 411  void DeviceForm::selectDriver ( const QS
411  void DeviceForm::selectDevice ()  void DeviceForm::selectDevice ()
412  {  {
413          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
414          if (pMainForm == NULL)          if (pMainForm == nullptr)
415                  return;                  return;
416    
417          if (m_iDirtySetup > 0)          if (m_iDirtySetup > 0)
# Line 422  void DeviceForm::selectDevice () Line 422  void DeviceForm::selectDevice ()
422          //          //
423    
424          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
425          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) {          if (pItem == nullptr || pItem->type() != QSAMPLER_DEVICE_ITEM) {
426                  m_deviceType = Device::None;                  m_deviceType = Device::None;
427                  m_ui.DeviceNameTextLabel->setText(QString());                  m_ui.DeviceNameTextLabel->setText(QString());
428                  m_deviceParamModel.clear();                  m_deviceParamModel.clear();
# Line 520  void DeviceForm::selectDevicePort ( int Line 520  void DeviceForm::selectDevicePort ( int
520          //          //
521    
522          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
523          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == nullptr || pItem->type() != QSAMPLER_DEVICE_ITEM)
524                  return;                  return;
525    
526          Device& device = ((DeviceItem *) pItem)->device();          Device& device = ((DeviceItem *) pItem)->device();
527          DevicePort *pPort = NULL;          DevicePort *pPort = nullptr;
528          if (iPort >= 0 && iPort < device.ports().count())          if (iPort >= 0 && iPort < device.ports().count())
529                  pPort = device.ports().at(iPort);                  pPort = device.ports().at(iPort);
530          if (pPort) {          if (pPort) {
# Line 551  void DeviceForm::changeDeviceParam ( int Line 551  void DeviceForm::changeDeviceParam ( int
551    
552  /* we do that in the model class now ...  /* we do that in the model class now ...
553          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
554          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == nullptr || pItem->type() != QSAMPLER_DEVICE_ITEM)
555                  return;                  return;
556    
557          Device& device = ((DeviceItem *) pItem)->device();          Device& device = ((DeviceItem *) pItem)->device();
# Line 590  void DeviceForm::changeDevicePortParam ( Line 590  void DeviceForm::changeDevicePortParam (
590    
591  /* we do that in the model class now ...  /* we do that in the model class now ...
592          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
593          if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)          if (pItem == nullptr || pItem->type() != QSAMPLER_DEVICE_ITEM)
594                  return;                  return;
595    
596          Device& device = ((DeviceItem *) pItem)->device();          Device& device = ((DeviceItem *) pItem)->device();
597    
598          int iPort = m_ui.DevicePortComboBox->currentIndex();          int iPort = m_ui.DevicePortComboBox->currentIndex();
599          DevicePort *pPort = NULL;          DevicePort *pPort = nullptr;
600          if (iPort >= 0 && iPort < device.ports().count())          if (iPort >= 0 && iPort < device.ports().count())
601                  pPort = device.ports().at(iPort);                  pPort = device.ports().at(iPort);
602          if (pPort == NULL)          if (pPort == nullptr)
603                  return;                  return;
604    
605          // Table 1st column has the parameter name;          // Table 1st column has the parameter name;
# Line 626  void DeviceForm::changeDevicePortParam ( Line 626  void DeviceForm::changeDevicePortParam (
626  void DeviceForm::deviceListViewContextMenu ( const QPoint& pos )  void DeviceForm::deviceListViewContextMenu ( const QPoint& pos )
627  {  {
628          MainForm *pMainForm = MainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
629          if (pMainForm == NULL)          if (pMainForm == nullptr)
630                  return;                  return;
631    
632          QTreeWidgetItem* pItem = m_ui.DeviceListView->itemAt(pos);          QTreeWidgetItem* pItem = m_ui.DeviceListView->itemAt(pos);
633          if (pItem == NULL)          if (pItem == nullptr)
634                  return;                  return;
635    
636          // Build the device context menu...          // Build the device context menu...
637          QMenu menu(this);          QMenu menu(this);
638          QAction *pAction;          QAction *pAction;
639    
640          bool bClient = (pMainForm->client() != NULL);          bool bClient = (pMainForm->client() != nullptr);
641          bool bEnabled = (pItem != NULL);          bool bEnabled = (pItem != nullptr);
642          pAction = menu.addAction(          pAction = menu.addAction(
643                  QIcon(":/images/deviceCreate.png"),                  QIcon(":/images/deviceCreate.png"),
644                  tr("&Create device"), this, SLOT(createDevice()));                  tr("&Create device"), this, SLOT(createDevice()));
# Line 662  void DeviceForm::stabilizeForm (void) Line 662  void DeviceForm::stabilizeForm (void)
662  {  {
663          MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
664          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();          QTreeWidgetItem* pItem = m_ui.DeviceListView->currentItem();
665          bool bClient = (pMainForm && pMainForm->client() != NULL);          bool bClient = (pMainForm && pMainForm->client() != nullptr);
666          bool bEnabled = (pItem != NULL);          bool bEnabled = (pItem != nullptr);
667          m_ui.DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);          m_ui.DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);
668          m_ui.DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);          m_ui.DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);
669          m_ui.DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);          m_ui.DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);

Legend:
Removed from v.3554  
changed lines
  Added in v.3555

  ViewVC Help
Powered by ViewVC