/[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 428 by capela, Mon Mar 7 17:05:55 2005 UTC revision 490 by capela, Fri Apr 1 00:34:58 2005 UTC
# Line 2  Line 2 
2  //  //
3  // ui.h extension file, included from the uic-generated form implementation.  // ui.h extension file, included from the uic-generated form implementation.
4  /****************************************************************************  /****************************************************************************
5     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2005, rncbc aka Rui Nuno Capela. All rights reserved.
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 23  Line 23 
23  #include <qmessagebox.h>  #include <qmessagebox.h>
24  #include <qfiledialog.h>  #include <qfiledialog.h>
25  #include <qfileinfo.h>  #include <qfileinfo.h>
26    #include <qlistbox.h>
27    #include <qptrlist.h>
28    #include <qpopupmenu.h>
29    
30  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
31    
# Line 32  Line 35 
35  // Kind of constructor.  // Kind of constructor.
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_iUntitled   = 1;          m_bNewDevice  = false;
44            m_deviceType  = qsamplerDevice::None;
45            m_pAudioItems = NULL;
46            m_pMidiItems  = NULL;
47            // No exclusive mode as default.
48            m_deviceTypeMode = qsamplerDevice::None;
49    
50            // This an outsider (from designer), but rather important.
51            QObject::connect(DeviceParamTable, SIGNAL(valueChanged(int,int)),
52                    this, SLOT(changeDeviceParam(int,int)));
53            QObject::connect(DevicePortParamTable, SIGNAL(valueChanged(int,int)),
54                    this, SLOT(changeDevicePortParam(int,int)));
55    
56      // Try to restore normal window positioning.          // Initial contents.
57      adjustSize();          refreshDevices();
58            // Try to restore normal window positioning.
59            adjustSize();
60  }  }
61    
62    
# Line 53  void qsamplerDeviceForm::destroy (void) Line 69  void qsamplerDeviceForm::destroy (void)
69  // Notify our parent that we're emerging.  // Notify our parent that we're emerging.
70  void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent )  void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent )
71  {  {
72      if (m_pMainForm)          if (m_pMainForm)
73          m_pMainForm->stabilizeForm();                  m_pMainForm->stabilizeForm();
74    
75      stabilizeForm();          stabilizeForm();
76    
77      QWidget::showEvent(pShowEvent);          QWidget::showEvent(pShowEvent);
78  }  }
79    
80    
81  // Notify our parent that we're closing.  // Notify our parent that we're closing.
82  void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent )  void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent )
83  {  {
84      QWidget::hideEvent(pHideEvent);          QWidget::hideEvent(pHideEvent);
85    
86            if (m_pMainForm)
87                    m_pMainForm->stabilizeForm();
88    
89            // Signal special whether we changed the device set.
90            if (m_iDirtyCount > 0) {
91                    m_iDirtyCount = 0;
92                    emit devicesChanged();
93            }
94    }
95    
96    
97    // Application main form settler (life depends on it).
98    void qsamplerDeviceForm::setMainForm ( qsamplerMainForm *pMainForm )
99    {
100            m_pMainForm = pMainForm;
101    }
102    
103    
104    // Set device type spacial exclusive mode.
105    void qsamplerDeviceForm::setDeviceTypeMode (
106            qsamplerDevice::qsamplerDeviceType deviceTypeMode )
107    {
108            // If it has not changed, do nothing.
109            if (m_deviceTypeMode == deviceTypeMode)
110                    return;
111    
112            m_deviceTypeMode = deviceTypeMode;
113    
114      if (m_pMainForm)          // OK. Do a whole refresh around.
115          m_pMainForm->stabilizeForm();          refreshDevices();
116  }  }
117    
118    
# Line 77  void qsamplerDeviceForm::setClient ( lsc Line 121  void qsamplerDeviceForm::setClient ( lsc
121  {  {
122          // If it has not changed, do nothing.          // If it has not changed, do nothing.
123          if (m_pClient && m_pClient == pClient)          if (m_pClient && m_pClient == pClient)
124              return;                  return;
125    
126          // Set new reference.          // Set new reference.
127          m_pClient = pClient;          m_pClient = pClient;
           
         // Set our main client reference.  
     DeviceParameterTable->setClient(m_pClient);  
128    
129          // OK. Do a whole refresh around.          // OK. Do a whole refresh around.
130          refreshDevices();          refreshDevices();
131  }  }
132    
133    
134  // Format the displayable device configuration filename.  // Device driver name setup formal initializer.
135  QString qsamplerDeviceForm::devicesName ( const QString& sFilename )  void qsamplerDeviceForm::setDriverName ( const QString& sDriverName )
136  {  {
137      QString sDevicesName = sFilename;          if (DriverNameComboBox->listBox()->findItem(sDriverName,
138      qsamplerOptions *pOptions = m_pMainForm->options();                          Qt::ExactMatch | Qt::CaseSensitive) == NULL) {
139      if (pOptions) {                  DriverNameComboBox->insertItem(sDriverName);
         bool bCompletePath = (pOptions && pOptions->bCompletePath);  
         if (sDevicesName.isEmpty())  
                 sDevicesName = tr("Untitled") + QString::number(m_iUntitled);  
         else if (!bCompletePath)  
                 sDevicesName = QFileInfo(sDevicesName).fileName();  
140          }          }
141      return sDevicesName;          DriverNameComboBox->setCurrentText(sDriverName);
142  }  }
143    
144    
145  // Window close event handlers.  // Set current selected device by type and id.
146  bool qsamplerDeviceForm::queryClose (void)  void qsamplerDeviceForm::setDevice ( qsamplerDevice *pDevice )
147  {  {
148      bool bQueryClose = true;          // In case no device is given...
149            qsamplerDevice::qsamplerDeviceType deviceType = m_deviceTypeMode;
150            if (pDevice)
151                    deviceType = pDevice->deviceType();
152    
153            // Get the device view root item...
154            qsamplerDeviceItem *pRootItem = NULL;
155            switch (deviceType) {
156            case qsamplerDevice::Audio:
157                    pRootItem = m_pAudioItems;
158                    break;
159            case qsamplerDevice::Midi:
160                    pRootItem = m_pMidiItems;
161                    break;
162            case qsamplerDevice::None:
163                    break;
164            }
165    
166      if (m_iDirtyCount > 0) {          // Is the root present?
167          switch (QMessageBox::warning(this, tr("Warning"),          if (pRootItem == NULL)
168              tr("The device configuration has been changed.\n\n"                  return;
169                 "\"%1\"\n\n"  
170                 "Do you want to save the changes?")          // So there's no device huh?
171                             .arg(devicesName(m_sFilename)),          if (pDevice == NULL) {
172              tr("Save"), tr("Discard"), tr("Cancel"))) {                  DeviceListView->setSelected(pRootItem, true);
173          case 0:     // Save...                  return;
174              saveDevices();          }
             // Fall thru....  
         case 1:     // Discard  
             break;  
         default:    // Cancel.  
             bQueryClose = false;  
         }  
     }  
175    
176      return bQueryClose;          // For each child, test for identity...
177            qsamplerDeviceItem *pDeviceItem =
178                    (qsamplerDeviceItem *) pRootItem->firstChild();
179            while (pDeviceItem) {
180                    // If identities match, select as current device item.
181                    if (pDeviceItem->device().deviceID() == pDevice->deviceID()) {
182                            DeviceListView->setSelected(pDeviceItem, true);
183                            break;
184                    }
185                    pDeviceItem = (qsamplerDeviceItem *) pDeviceItem->nextSibling();
186            }
187  }  }
188    
189    
190    
191  // Dirty up settings.  // Create a new device from current table view.
192  void qsamplerDeviceForm::contentsChanged (void)  void qsamplerDeviceForm::createDevice (void)
193  {  {
194      if (m_iDirtySetup > 0)          if (m_pMainForm == NULL)
195          return;                  return;
196    
197      m_iDirtyCount++;          QListViewItem *pItem = DeviceListView->selectedItem();
198      stabilizeForm();          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
199                    return;
200    
201            // About a brand new device instance...
202            qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device());
203            if (device.createDevice()) {
204                    // Now it depends on the device type...
205                    qsamplerDeviceItem *pRootItem = NULL;
206                    switch (device.deviceType()) {
207                    case qsamplerDevice::Audio:
208                            pRootItem = m_pAudioItems;
209                            break;
210                    case qsamplerDevice::Midi:
211                            pRootItem = m_pMidiItems;
212                            break;
213                    case qsamplerDevice::None:
214                            break;
215                    }
216                    // Append the new device item.
217                    qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem,
218                            m_pMainForm, device.deviceType(), device.deviceID());
219                    // Just make it the new selection...
220                    DeviceListView->setSelected(pDeviceItem, true);
221                    // Main session should be marked dirty.
222                    m_pMainForm->sessionDirty();
223                    m_iDirtyCount++;
224            }
225  }  }
226    
227    
228  // Load device configuration slot.  // Delete current device in table view.
229  void qsamplerDeviceForm::loadDevices (void)  void qsamplerDeviceForm::deleteDevice (void)
230  {  {
231      QString sFilename = QFileDialog::getOpenFileName(          if (m_pMainForm == NULL)
232              m_sFilename,                                    // Start here.                  return;
             tr("Device Configuration files") + " (*.lscp)", // Filter (XML files)  
             this, 0,                                        // Parent and name (none)  
             tr("Load Device Configuration")                 // Caption.  
     );  
233    
234      if (sFilename.isEmpty())          QListViewItem *pItem = DeviceListView->selectedItem();
235          return;          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
236                    return;
237      // Check if we're going to discard safely the current one...  
238      if (!queryClose())          qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
239          return;  
240            // Prompt user if this is for real...
241            qsamplerOptions *pOptions = m_pMainForm->options();
242            if (pOptions && pOptions->bConfirmRemove) {
243                    if (QMessageBox::warning(this, tr("Warning"),
244                            tr("Delete device:\n\n"
245                            "%1\n\n"
246                            "Are you sure?")
247                            .arg(device.deviceName()),
248                            tr("OK"), tr("Cancel")) > 0)
249                            return;
250            }
251    
252      // Load it right away...          // Go and destroy...
253      loadDevicesFile(sFilename);          if (device.deleteDevice()) {
254                    // Remove it from the device view...
255                    delete pItem;
256                    // Main session should be marked dirty.
257                    m_pMainForm->sessionDirty();
258                    m_iDirtyCount++;
259            }
260  }  }
261    
262    
263  // Save device configuration slot.  // Refresh all device list and views.
264  void qsamplerDeviceForm::saveDevices (void)  void qsamplerDeviceForm::refreshDevices (void)
265  {  {
266      QString sFilename = QFileDialog::getSaveFileName(          if (m_pMainForm == NULL)
267              m_sFilename,                                    // Start here.                  return;
             tr("Device Configuration files") + " (*.lscp)", // Filter (XML files)  
             this, 0,                                        // Parent and name (none)  
             tr("Save Device Configuration")                 // Caption.  
     );  
268    
269      if (sFilename.isEmpty())          // Avoid nested changes.
270          return;          m_iDirtySetup++;
271    
272      // Enforce .xml extension...          //
273      if (QFileInfo(sFilename).extension().isEmpty())          // (Re)Load complete device configuration data ...
274          sFilename += ".lscp";          //
275            m_pAudioItems = NULL;
276            m_pMidiItems = NULL;
277            DeviceListView->clear();
278            if (m_pClient) {
279                    int *piDeviceIDs;
280                    // Grab and pop Audio devices...
281                    if (m_deviceTypeMode == qsamplerDevice::None ||
282                            m_deviceTypeMode == qsamplerDevice::Audio) {
283                            m_pAudioItems = new qsamplerDeviceItem(DeviceListView,
284                                    m_pMainForm, qsamplerDevice::Audio);
285                    }
286                    if (m_pAudioItems) {
287                            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
288                            for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
289                                    new qsamplerDeviceItem(m_pAudioItems, m_pMainForm,
290                                            qsamplerDevice::Audio, piDeviceIDs[i]);
291                            }
292                            m_pAudioItems->setOpen(true);
293                    }
294                    // Grab and pop MIDI devices...
295                    if (m_deviceTypeMode == qsamplerDevice::None ||
296                            m_deviceTypeMode == qsamplerDevice::Midi) {
297                            m_pMidiItems = new qsamplerDeviceItem(DeviceListView,
298                                    m_pMainForm, qsamplerDevice::Midi);
299                    }
300                    if (m_pMidiItems) {
301                            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
302                            for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
303                                    new qsamplerDeviceItem(m_pMidiItems, m_pMainForm,
304                                            qsamplerDevice::Midi, piDeviceIDs[i]);
305                            }
306                            m_pMidiItems->setOpen(true);
307                    }
308            }
309    
310      // Save it right away...          // Done.
311      saveDevicesFile(sFilename);          m_iDirtySetup--;
312    
313            // Show something.
314            selectDevice();
315  }  }
316    
317    
318  // Load device configuration from file.  // Driver selection slot.
319  void qsamplerDeviceForm::loadDevicesFile ( const QString& sFilename )  void qsamplerDeviceForm::selectDriver ( const QString& sDriverName )
320  {  {
321            if (m_iDirtySetup > 0)
322                    return;
323    
324          //          //
325      // TODO: Load device configuration from file...          //  Driver name has changed for a new device...
326          //          //
         m_pMainForm->appendMessages("qsamplerDeviceForm::loadDevicesFile(\"" + sFilename + "\")...");  
327    
328          m_sFilename   = sFilename;          QListViewItem *pItem = DeviceListView->selectedItem();
329          m_iDirtyCount = 0;          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
330                    return;
331          refreshDevices();  
332            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
333    
334            // Driver change is only valid for scratch devices...
335            if (m_bNewDevice) {
336                    m_iDirtySetup++;
337                    device.setDriver(sDriverName);
338                    DeviceParamTable->refresh(device.params(), m_bNewDevice);
339                    m_iDirtySetup--;
340                    // Done.
341                    stabilizeForm();
342            }
343  }  }
344    
345    
346  // Save device configuration into file.  // Device selection slot.
347  void qsamplerDeviceForm::saveDevicesFile ( const QString& sFilename )  void qsamplerDeviceForm::selectDevice (void)
348  {  {
349            if (m_iDirtySetup > 0)
350                    return;
351    
352            //
353            //  Device selection has changed...
354          //          //
     // TODO: Save device configuration into file...  
     //  
         m_pMainForm->appendMessages("qsamplerDeviceForm::saveDevicesFile(\"" + sFilename + "\")...");  
355    
356          m_sFilename   = sFilename;          QListViewItem *pItem = DeviceListView->selectedItem();
357          m_iDirtyCount = 0;          if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) {
358          stabilizeForm();                  m_deviceType = qsamplerDevice::None;
359                    DeviceNameTextLabel->setText(QString::null);
360                    DeviceParamTable->setNumRows(0);
361                    DevicePortComboBox->clear();
362                    DevicePortParamTable->setNumRows(0);
363                    DevicePortComboBox->setEnabled(false);
364                    DevicePortParamTable->setEnabled(false);
365                    stabilizeForm();
366                    return;
367            }
368    
369            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
370    
371            m_iDirtySetup++;
372            // Flag whether this is a new device.
373            m_bNewDevice = (device.deviceID() < 0);
374    
375            // Fill the device/driver heading...
376            DeviceNameTextLabel->setText(device.deviceName());
377            // The driver combobox is only rebuilt if device type has changed...
378            if (device.deviceType() != m_deviceType) {
379                    DriverNameComboBox->clear();
380                    DriverNameComboBox->insertStringList(
381                            qsamplerDevice::getDrivers(m_pClient, device.deviceType()));
382                    m_deviceType = device.deviceType();
383            }
384            // Do we need a driver name?
385            if (m_bNewDevice || device.driverName().isEmpty())
386                    device.setDriver(DriverNameComboBox->currentText());
387            setDriverName(device.driverName());
388            DriverNameTextLabel->setEnabled(m_bNewDevice);
389            DriverNameComboBox->setEnabled(m_bNewDevice);
390            // Fill the device parameter table...
391            DeviceParamTable->refresh(device.params(), m_bNewDevice);
392            // And now the device port/channel parameter table...
393            DevicePortComboBox->clear();
394            DevicePortParamTable->setNumRows(0);
395            if (m_bNewDevice) {
396                    DevicePortComboBox->setEnabled(false);
397                    DevicePortParamTable->setEnabled(false);
398            } else {
399                    QPixmap pixmap;
400                    switch (device.deviceType()) {
401                    case qsamplerDevice::Audio:
402                            pixmap = QPixmap::fromMimeSource("audio2.png");
403                            break;
404                    case qsamplerDevice::Midi:
405                            pixmap = QPixmap::fromMimeSource("midi2.png");
406                            break;
407                    case qsamplerDevice::None:
408                            break;
409                    }
410                    qsamplerDevicePortList& ports = device.ports();
411                    qsamplerDevicePort *pPort;
412                    for (pPort = ports.first(); pPort; pPort = ports.next()) {
413                            DevicePortComboBox->insertItem(pixmap, device.deviceTypeName()
414                                    + ' ' + device.driverName()
415                                    + ' ' + pPort->portName());
416                    }
417                    bool bEnabled = (ports.count() > 0);
418                    DevicePortComboBox->setEnabled(bEnabled);
419                    DevicePortParamTable->setEnabled(bEnabled);
420            }
421            // Done.
422            m_iDirtySetup--;
423    
424            // Make the device port/channel selection effective.
425            selectDevicePort(DevicePortComboBox->currentItem());
426  }  }
427    
428    
429  // Create a new device from current table view.  // Device port/channel selection slot.
430  void qsamplerDeviceForm::createDevice (void)  void qsamplerDeviceForm::selectDevicePort ( int iPort )
431  {  {
432            if (m_iDirtySetup > 0)
433                    return;
434    
435          //          //
436      // TODO: Create a new device from current table view...          //  Device port/channel selection has changed...
437      //          //
438          m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()...");  
439            QListViewItem *pItem = DeviceListView->selectedItem();
440            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
441                    return;
442    
443            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
444            qsamplerDevicePort *pPort = device.ports().at(iPort);
445            if (pPort) {
446                    m_iDirtySetup++;
447                    DevicePortParamTable->refresh(pPort->params(), false);
448                    m_iDirtySetup--;
449            }
450            // Done.
451            stabilizeForm();
452  }  }
453    
454    
455  // Update current device in table view.  // Device parameter value change slot.
456  void qsamplerDeviceForm::updateDevice (void)  void qsamplerDeviceForm::changeDeviceParam ( int iRow, int iCol )
457  {  {
458            if (m_pMainForm == NULL)
459                    return;
460            if (m_iDirtySetup > 0)
461                    return;
462            if (iRow < 0 || iCol < 0)
463                    return;
464    
465          //          //
466      // TODO: Update current device in table view...          //  Device parameter change...
467      //          //
468          m_pMainForm->appendMessages("qsamplerDeviceForm::updateDevice()...");  
469            QListViewItem *pItem = DeviceListView->selectedItem();
470            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
471                    return;
472    
473            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
474    
475            // Table 1st column has the parameter name;
476            const QString sParam = DeviceParamTable->text(iRow, 0);
477            const QString sValue = DeviceParamTable->text(iRow, iCol);
478            // Set the local device parameter value.
479            if (device.setParam(sParam, sValue)) {
480                    selectDevice();
481            } else {
482                    stabilizeForm();
483            }
484            // Main session should be dirtier...
485            m_pMainForm->sessionDirty();
486  }  }
487    
488    
489  // Delete current device in table view.  // Device port/channel parameter value change slot.
490  void qsamplerDeviceForm::deleteDevice (void)  void qsamplerDeviceForm::changeDevicePortParam ( int iRow, int iCol )
491  {  {
492            if (m_pMainForm == NULL)
493                    return;
494            if (m_iDirtySetup > 0)
495                    return;
496            if (iRow < 0 || iCol < 0)
497                    return;
498    
499          //          //
500      // TODO: Delete current device in table view...          //  Device port/channel parameter change...
501      //          //
502          m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()...");  
503            QListViewItem *pItem = DeviceListView->selectedItem();
504            if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM)
505                    return;
506    
507            qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
508    
509            int iPort = DevicePortComboBox->currentItem();
510            qsamplerDevicePort *pPort = device.ports().at(iPort);
511            if (pPort == NULL)
512                    return;
513    
514            // Table 1st column has the parameter name;
515            const QString sParam = DevicePortParamTable->text(iRow, 0);
516            const QString sValue = DevicePortParamTable->text(iRow, iCol);
517            // Set the local device port/channel parameter value.
518            pPort->setParam(sParam, sValue);
519            // Done.
520            stabilizeForm();
521            // Main session should be dirtier...
522            m_pMainForm->sessionDirty();
523  }  }
524    
525    
526  // Refresh all device list and views.  // Device list view context menu handler.
527  void qsamplerDeviceForm::refreshDevices (void)  void qsamplerDeviceForm::contextMenu ( QListViewItem *pItem, const QPoint& pos, int )
528  {  {
529      // Avoid nested changes.          int iItemID;
530      m_iDirtySetup++;  
531            // Build the device context menu...
532      DeviceListView->clear();          QPopupMenu* pContextMenu = new QPopupMenu(this);
533      if (m_pClient)  
534          new QListViewItem(DeviceListView, tr("<New device>"));          bool bClient = (m_pClient != NULL);
535            bool bEnabled = (pItem != NULL);
536          //          iItemID = pContextMenu->insertItem(
537      // TODO: Load device configuration data ...                  QIconSet(QPixmap::fromMimeSource("deviceCreate.png")),
538      //                  tr("&Create device"), this, SLOT(createDevice()));
539          m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()");          pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice));
540            iItemID = pContextMenu->insertItem(
541                    QIconSet(QPixmap::fromMimeSource("deviceDelete.png")),
542                    tr("&Delete device"), this, SLOT(deleteDevice()));
543            pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice);
544            pContextMenu->insertSeparator();
545            iItemID = pContextMenu->insertItem(
546                    QIconSet(QPixmap::fromMimeSource("formRefresh.png")),
547                    tr("&Refresh"), this, SLOT(refreshDevices()));
548            pContextMenu->setItemEnabled(iItemID, bClient);
549    
550          DeviceParameterTable->setNumRows(0);          pContextMenu->exec(pos);
         if (m_pClient) {  
                 DeviceParameterTable->insertRows(0, 3);  
                 for (int c = 0; c < DeviceParameterTable->numCols(); c++) {  
                         for (int r = 0; r < DeviceParameterTable->numRows(); r++)  
                                 DeviceParameterTable->setText(r, c, QString("R%1C%1").arg(r).arg(c));  
                         DeviceParameterTable->adjustColumn(c);  
                 }  
         }  
551    
552      // Done.          delete pContextMenu;
     m_iDirtySetup--;  
 //  stabilizeForm();  
553  }  }
554    
555    
556  // Stabilize current form state.  // Stabilize current form state.
557  void qsamplerDeviceForm::stabilizeForm (void)  void qsamplerDeviceForm::stabilizeForm (void)
558  {  {
559      // Update the main caption...          QListViewItem *pItem = DeviceListView->selectedItem();
560      QString sDevicesName = devicesName(m_sFilename);          bool bClient = (m_pClient != NULL);
561      if (m_iDirtyCount > 0)          bool bEnabled = (pItem != NULL);
562          sDevicesName += '*';          DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);
563      setCaption(tr("Devices - [%1]").arg(sDevicesName));          DriverNameTextLabel->setEnabled(bEnabled &&  m_bNewDevice);
564            DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);
565          //          DeviceParamTable->setEnabled(bEnabled);
566          // TODO: Enable/disable available command buttons.          RefreshDevicesPushButton->setEnabled(bClient);
567          //          CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));
568          m_pMainForm->appendMessages("qsamplerDeviceForm::stabilizeForm()");          DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);
   
     SaveDevicesPushButton->setEnabled(m_iDirtyCount > 0);  
       
     CreateDevicePushButton->setEnabled(m_iDirtyCount > 0);  
     UpdateDevicePushButton->setEnabled(m_iDirtyCount > 0);  
     DeleteDevicePushButton->setEnabled(m_iDirtyCount > 0);  
569  }  }
570    
571    
572  // end of qsamplerDeviceForm.ui.h  // end of qsamplerDeviceForm.ui.h
   

Legend:
Removed from v.428  
changed lines
  Added in v.490

  ViewVC Help
Powered by ViewVC