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

Annotation of /qsampler/trunk/src/qsamplerDeviceForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1486 - (hide annotations) (download)
Sat Nov 17 02:02:28 2007 UTC (16 years, 5 months ago) by schoenebeck
File size: 19176 byte(s)
* Qt4 migration: finished / fixed device management dialog.
* Fixed creation of devices (don't try to set device parameters which the
  user did not touch in the device creation dialog, this bug already
  existed in the Qt3 version of QSampler).

1 capela 1464 // qsamplerDeviceForm.cpp
2     //
3     /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11    
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License along
18     with this program; if not, write to the Free Software Foundation, Inc.,
19     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20    
21     *****************************************************************************/
22    
23 schoenebeck 1461 #include "qsamplerDeviceForm.h"
24    
25     #include "qsamplerAbout.h"
26 capela 1473 #include "qsamplerMainForm.h"
27 schoenebeck 1461
28     namespace QSampler {
29    
30     DeviceForm::DeviceForm(QWidget* parent, Qt::WFlags f) : QDialog(parent, f) {
31     ui.setupUi(this);
32    
33     // Initialize locals.
34     m_iDirtySetup = 0;
35     m_iDirtyCount = 0;
36     m_bNewDevice = false;
37     m_deviceType = qsamplerDevice::None;
38     m_pAudioItems = NULL;
39     m_pMidiItems = NULL;
40     // No exclusive mode as default.
41     m_deviceTypeMode = qsamplerDevice::None;
42    
43 schoenebeck 1477 ui.DeviceListView->header()->hide();
44    
45 schoenebeck 1461 ui.DeviceParamTable->setModel(&deviceParamModel);
46     ui.DeviceParamTable->setItemDelegate(&deviceParamDelegate);
47 schoenebeck 1486 ui.DeviceParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
48 schoenebeck 1461
49     ui.DevicePortParamTable->setModel(&devicePortParamModel);
50     ui.DevicePortParamTable->setItemDelegate(&devicePortParamDelegate);
51 schoenebeck 1486 ui.DevicePortParamTable->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
52 schoenebeck 1461
53     // Initial contents.
54     refreshDevices();
55     // Try to restore normal window positioning.
56     adjustSize();
57 capela 1466
58     QObject::connect(ui.DeviceListView,
59 schoenebeck 1486 SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
60 capela 1466 SLOT(selectDevice()));
61     QObject::connect(ui.DeviceListView,
62 schoenebeck 1470 SIGNAL(customContextMenuRequested(const QPoint&)),
63     SLOT(deviceListViewContextMenu(const QPoint&)));
64 capela 1466 QObject::connect(ui.RefreshDevicesPushButton,
65     SIGNAL(clicked()),
66     SLOT(refreshDevices()));
67     QObject::connect(ui.DriverNameComboBox,
68 schoenebeck 1470 SIGNAL(activated(const QString&)),
69     SLOT(selectDriver(const QString&)));
70 capela 1466 QObject::connect(ui.DevicePortComboBox,
71     SIGNAL(activated(int)),
72     SLOT(selectDevicePort(int)));
73     QObject::connect(ui.CreateDevicePushButton,
74     SIGNAL(clicked()),
75     SLOT(createDevice()));
76     QObject::connect(ui.DeleteDevicePushButton,
77     SIGNAL(clicked()),
78     SLOT(deleteDevice()));
79     QObject::connect(ui.ClosePushButton,
80     SIGNAL(clicked()),
81     SLOT(close()));
82 schoenebeck 1486 QObject::connect(&deviceParamModel,
83     SIGNAL(modelReset()),
84     SLOT(updateCellRenderers()));
85     QObject::connect(&deviceParamModel,
86     SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
87     SLOT(updateCellRenderers(const QModelIndex&, const QModelIndex&)));
88     QObject::connect(&devicePortParamModel,
89     SIGNAL(modelReset()),
90     SLOT(updatePortCellRenderers()));
91     QObject::connect(&devicePortParamModel,
92     SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
93     SLOT(updatePortCellRenderers(const QModelIndex&, const QModelIndex&)));
94 schoenebeck 1461 }
95    
96     DeviceForm::~DeviceForm() {
97     }
98    
99    
100     // Notify our parent that we're emerging.
101     void DeviceForm::showEvent ( QShowEvent *pShowEvent )
102     {
103     MainForm* pMainForm = MainForm::getInstance();
104     if (pMainForm)
105     pMainForm->stabilizeForm();
106    
107     stabilizeForm();
108    
109     QWidget::showEvent(pShowEvent);
110     }
111    
112    
113     // Notify our parent that we're closing.
114     void DeviceForm::hideEvent ( QHideEvent *pHideEvent )
115     {
116     QWidget::hideEvent(pHideEvent);
117    
118     MainForm *pMainForm = MainForm::getInstance();
119     if (pMainForm)
120     pMainForm->stabilizeForm();
121    
122     // Signal special whether we changed the device set.
123     if (m_iDirtyCount > 0) {
124     m_iDirtyCount = 0;
125     emit devicesChanged();
126     }
127     }
128    
129    
130     // Set device type spacial exclusive mode.
131     void DeviceForm::setDeviceTypeMode (
132     qsamplerDevice::qsamplerDeviceType deviceTypeMode )
133     {
134     // If it has not changed, do nothing.
135     if (m_deviceTypeMode == deviceTypeMode)
136     return;
137    
138     m_deviceTypeMode = deviceTypeMode;
139    
140     // OK. Do a whole refresh around.
141     refreshDevices();
142     }
143    
144    
145     // Device driver name setup formal initializer.
146     void DeviceForm::setDriverName ( const QString& sDriverName )
147     {
148 schoenebeck 1474 if (ui.DriverNameComboBox->findText(sDriverName) < 0) {
149 schoenebeck 1461 ui.DriverNameComboBox->insertItem(sDriverName);
150     }
151     ui.DriverNameComboBox->setCurrentText(sDriverName);
152     }
153    
154    
155     // Set current selected device by type and id.
156     void DeviceForm::setDevice ( qsamplerDevice *pDevice )
157     {
158     // In case no device is given...
159     qsamplerDevice::qsamplerDeviceType deviceType = m_deviceTypeMode;
160     if (pDevice)
161     deviceType = pDevice->deviceType();
162    
163     // Get the device view root item...
164     qsamplerDeviceItem *pRootItem = NULL;
165     switch (deviceType) {
166     case qsamplerDevice::Audio:
167     pRootItem = m_pAudioItems;
168     break;
169     case qsamplerDevice::Midi:
170     pRootItem = m_pMidiItems;
171     break;
172     case qsamplerDevice::None:
173     break;
174     }
175    
176     // Is the root present?
177     if (pRootItem == NULL)
178     return;
179    
180     // So there's no device huh?
181     if (pDevice == NULL) {
182     ui.DeviceListView->setCurrentItem(pRootItem);
183     return;
184     }
185    
186     // For each child, test for identity...
187     for (int i = 0; i < pRootItem->childCount(); i++) {
188     qsamplerDeviceItem* pDeviceItem =
189     (qsamplerDeviceItem*) pRootItem->child(i);
190    
191     // If identities match, select as current device item.
192     if (pDeviceItem->device().deviceID() == pDevice->deviceID()) {
193     pDeviceItem->setSelected(true);
194     break;
195     }
196     }
197     }
198    
199    
200    
201     // Create a new device from current table view.
202     void DeviceForm::createDevice (void)
203     {
204     MainForm *pMainForm = MainForm::getInstance();
205     if (pMainForm == NULL)
206     return;
207    
208     QTreeWidgetItem *pItem = ui.DeviceListView->currentItem();
209     if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
210     return;
211    
212     // About a brand new device instance...
213     qsamplerDevice device(((qsamplerDeviceItem *) pItem)->device());
214     if (device.createDevice()) {
215     // Now it depends on the device type...
216     qsamplerDeviceItem *pRootItem = NULL;
217     switch (device.deviceType()) {
218     case qsamplerDevice::Audio:
219     pRootItem = m_pAudioItems;
220     break;
221     case qsamplerDevice::Midi:
222     pRootItem = m_pMidiItems;
223     break;
224     case qsamplerDevice::None:
225     break;
226     }
227     // Append the new device item.
228     qsamplerDeviceItem *pDeviceItem = new qsamplerDeviceItem(pRootItem,
229     device.deviceType(), device.deviceID());
230     // Just make it the new selection...
231     pDeviceItem->setSelected(true);
232     // Main session should be marked dirty.
233     pMainForm->sessionDirty();
234     m_iDirtyCount++;
235     }
236     }
237    
238    
239     // Delete current device in table view.
240     void DeviceForm::deleteDevice (void)
241     {
242     MainForm *pMainForm = MainForm::getInstance();
243     if (pMainForm == NULL)
244     return;
245    
246     QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
247     if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
248     return;
249    
250     qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
251    
252     // Prompt user if this is for real...
253     qsamplerOptions *pOptions = pMainForm->options();
254     if (pOptions && pOptions->bConfirmRemove) {
255     if (QMessageBox::warning(this,
256     QSAMPLER_TITLE ": " + tr("Warning"),
257     tr("Delete device:\n\n"
258     "%1\n\n"
259     "Are you sure?")
260     .arg(device.deviceName()),
261     tr("OK"), tr("Cancel")) > 0)
262     return;
263     }
264    
265     // Go and destroy...
266     if (device.deleteDevice()) {
267     // Remove it from the device view...
268     delete pItem;
269     // Main session should be marked dirty.
270     pMainForm->sessionDirty();
271     m_iDirtyCount++;
272     }
273     }
274    
275    
276     // Refresh all device list and views.
277     void DeviceForm::refreshDevices (void)
278     {
279     MainForm *pMainForm = MainForm::getInstance();
280     if (pMainForm == NULL)
281     return;
282    
283     // Avoid nested changes.
284     m_iDirtySetup++;
285    
286     //
287     // (Re)Load complete device configuration data ...
288     //
289     m_pAudioItems = NULL;
290     m_pMidiItems = NULL;
291     ui.DeviceListView->clear();
292     if (pMainForm->client()) {
293     int *piDeviceIDs;
294     // Grab and pop Audio devices...
295     if (m_deviceTypeMode == qsamplerDevice::None ||
296     m_deviceTypeMode == qsamplerDevice::Audio) {
297     m_pAudioItems = new qsamplerDeviceItem(ui.DeviceListView,
298     qsamplerDevice::Audio);
299     }
300     if (m_pAudioItems) {
301     piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),
302     qsamplerDevice::Audio);
303     for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
304     new qsamplerDeviceItem(m_pAudioItems,
305     qsamplerDevice::Audio, piDeviceIDs[i]);
306     }
307     m_pAudioItems->setExpanded(true);
308     }
309     // Grab and pop MIDI devices...
310     if (m_deviceTypeMode == qsamplerDevice::None ||
311     m_deviceTypeMode == qsamplerDevice::Midi) {
312     m_pMidiItems = new qsamplerDeviceItem(ui.DeviceListView,
313     qsamplerDevice::Midi);
314     }
315     if (m_pMidiItems) {
316     piDeviceIDs = qsamplerDevice::getDevices(pMainForm->client(),
317     qsamplerDevice::Midi);
318     for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) {
319     new qsamplerDeviceItem(m_pMidiItems,
320     qsamplerDevice::Midi, piDeviceIDs[i]);
321     }
322     m_pMidiItems->setExpanded(true);
323     }
324     }
325    
326     // Done.
327     m_iDirtySetup--;
328    
329     // Show something.
330     selectDevice();
331     }
332    
333    
334     // Driver selection slot.
335     void DeviceForm::selectDriver ( const QString& sDriverName )
336     {
337     if (m_iDirtySetup > 0)
338     return;
339    
340     //
341     // Driver name has changed for a new device...
342     //
343    
344     QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
345     if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
346     return;
347    
348     qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
349    
350     // Driver change is only valid for scratch devices...
351     if (m_bNewDevice) {
352     m_iDirtySetup++;
353     device.setDriver(sDriverName);
354 schoenebeck 1486 deviceParamModel.refresh(&device, m_bNewDevice);
355 schoenebeck 1461 m_iDirtySetup--;
356     // Done.
357     stabilizeForm();
358     }
359     }
360    
361    
362     // Device selection slot.
363 schoenebeck 1477 void DeviceForm::selectDevice ()
364 schoenebeck 1461 {
365     MainForm *pMainForm = MainForm::getInstance();
366     if (pMainForm == NULL)
367     return;
368    
369     if (m_iDirtySetup > 0)
370     return;
371    
372     //
373     // Device selection has changed...
374     //
375    
376     QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
377     if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM) {
378     m_deviceType = qsamplerDevice::None;
379     ui.DeviceNameTextLabel->setText(QString::null);
380     deviceParamModel.clear();
381     ui.DevicePortComboBox->clear();
382     devicePortParamModel.clear();
383     ui.DevicePortTextLabel->setEnabled(false);
384     ui.DevicePortComboBox->setEnabled(false);
385     ui.DevicePortParamTable->setEnabled(false);
386     stabilizeForm();
387     return;
388     }
389    
390     qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
391    
392     m_iDirtySetup++;
393     // Flag whether this is a new device.
394     m_bNewDevice = (device.deviceID() < 0);
395    
396     // Fill the device/driver heading...
397     ui.DeviceNameTextLabel->setText(device.deviceName());
398     // The driver combobox is only rebuilt if device type has changed...
399     if (device.deviceType() != m_deviceType) {
400     ui.DriverNameComboBox->clear();
401     ui.DriverNameComboBox->insertStringList(
402     qsamplerDevice::getDrivers(pMainForm->client(), device.deviceType()));
403     m_deviceType = device.deviceType();
404     }
405     // Do we need a driver name?
406     if (m_bNewDevice || device.driverName().isEmpty())
407     device.setDriver(ui.DriverNameComboBox->currentText());
408     setDriverName(device.driverName());
409     ui.DriverNameTextLabel->setEnabled(m_bNewDevice);
410     ui.DriverNameComboBox->setEnabled(m_bNewDevice);
411     // Fill the device parameter table...
412 schoenebeck 1486 deviceParamModel.refresh(&device, m_bNewDevice);
413 schoenebeck 1461 // And now the device port/channel parameter table...
414     switch (device.deviceType()) {
415     case qsamplerDevice::Audio:
416     ui.DevicePortTextLabel->setText(tr("Ch&annel:"));
417     break;
418     case qsamplerDevice::Midi:
419     ui.DevicePortTextLabel->setText(tr("P&ort:"));
420     break;
421     case qsamplerDevice::None:
422     break;
423     }
424     ui.DevicePortComboBox->clear();
425     devicePortParamModel.clear();
426     if (m_bNewDevice) {
427     ui.DevicePortTextLabel->setEnabled(false);
428     ui.DevicePortComboBox->setEnabled(false);
429     ui.DevicePortParamTable->setEnabled(false);
430     } else {
431     QPixmap pixmap;
432     switch (device.deviceType()) {
433     case qsamplerDevice::Audio:
434 schoenebeck 1477 pixmap = QPixmap(":/icons/audio2.png");
435 schoenebeck 1461 break;
436     case qsamplerDevice::Midi:
437 schoenebeck 1477 pixmap = QPixmap(":/icons/midi2.png");
438 schoenebeck 1461 break;
439     case qsamplerDevice::None:
440     break;
441     }
442     qsamplerDevicePortList& ports = device.ports();
443     qsamplerDevicePort *pPort;
444     for (pPort = ports.first(); pPort; pPort = ports.next()) {
445     ui.DevicePortComboBox->insertItem(pixmap, device.deviceTypeName()
446     + ' ' + device.driverName()
447     + ' ' + pPort->portName());
448     }
449     bool bEnabled = (ports.count() > 0);
450     ui.DevicePortTextLabel->setEnabled(bEnabled);
451     ui.DevicePortComboBox->setEnabled(bEnabled);
452     ui.DevicePortParamTable->setEnabled(bEnabled);
453     }
454     // Done.
455     m_iDirtySetup--;
456    
457     // Make the device port/channel selection effective.
458     selectDevicePort(ui.DevicePortComboBox->currentItem());
459     }
460    
461    
462     // Device port/channel selection slot.
463     void DeviceForm::selectDevicePort ( int iPort )
464     {
465     if (m_iDirtySetup > 0)
466     return;
467    
468     //
469     // Device port/channel selection has changed...
470     //
471    
472     QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
473     if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
474     return;
475    
476     qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
477     qsamplerDevicePort *pPort = device.ports().at(iPort);
478     if (pPort) {
479     m_iDirtySetup++;
480 schoenebeck 1486 devicePortParamModel.refresh(pPort, false);
481 schoenebeck 1461 m_iDirtySetup--;
482     }
483     // Done.
484     stabilizeForm();
485     }
486    
487    
488     // Device parameter value change slot.
489     void DeviceForm::changeDeviceParam ( int iRow, int iCol )
490     {
491     if (m_iDirtySetup > 0)
492     return;
493     if (iRow < 0 || iCol < 0)
494     return;
495    
496     //
497     // Device parameter change...
498     //
499    
500 schoenebeck 1486 /* we do that in the model class now ...
501 schoenebeck 1461 QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
502     if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
503     return;
504    
505     qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
506    
507     // Table 1st column has the parameter name;
508     //const QString sParam = ui.DeviceParamTable->text(iRow, 0);
509     //const QString sValue = ui.DeviceParamTable->text(iRow, iCol);
510     const QString sParam = deviceParamModel.data(deviceParamModel.index(iRow, 0), Qt::DisplayRole).value<DeviceParameterRow>().name;
511     const QString sValue = deviceParamModel.data(deviceParamModel.index(iRow, iCol), Qt::DisplayRole).value<DeviceParameterRow>().param.value;
512     // Set the local device parameter value.
513     if (device.setParam(sParam, sValue)) {
514     selectDevice();
515     } else {
516     stabilizeForm();
517     }
518 schoenebeck 1486 */
519 schoenebeck 1461
520     // Main session should be dirtier...
521     MainForm *pMainForm = MainForm::getInstance();
522     if (pMainForm)
523     pMainForm->sessionDirty();
524     }
525    
526    
527     // Device port/channel parameter value change slot.
528     void DeviceForm::changeDevicePortParam ( int iRow, int iCol )
529     {
530     if (m_iDirtySetup > 0)
531     return;
532     if (iRow < 0 || iCol < 0)
533     return;
534    
535     //
536     // Device port/channel parameter change...
537     //
538    
539 schoenebeck 1486 /* we do that in the model class now ...
540 schoenebeck 1461 QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
541     if (pItem == NULL || pItem->type() != QSAMPLER_DEVICE_ITEM)
542     return;
543    
544     qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device();
545    
546     int iPort = ui.DevicePortComboBox->currentItem();
547     qsamplerDevicePort *pPort = device.ports().at(iPort);
548     if (pPort == NULL)
549     return;
550    
551     // Table 1st column has the parameter name;
552     //const QString sParam = ui.DevicePortParamTable->text(iRow, 0);
553     //const QString sValue = ui.DevicePortParamTable->text(iRow, iCol);
554     const QString sParam = devicePortParamModel.data(devicePortParamModel.index(iRow, 0), Qt::DisplayRole).value<DeviceParameterRow>().name;
555     const QString sValue = devicePortParamModel.data(devicePortParamModel.index(iRow, iCol), Qt::DisplayRole).value<DeviceParameterRow>().param.value;
556    
557     // Set the local device port/channel parameter value.
558     pPort->setParam(sParam, sValue);
559 schoenebeck 1486 */
560    
561 schoenebeck 1461 // Done.
562     stabilizeForm();
563    
564     // Main session should be dirtier...
565     MainForm* pMainForm = MainForm::getInstance();
566     if (pMainForm)
567     pMainForm->sessionDirty();
568     }
569    
570    
571     // Device list view context menu handler.
572 schoenebeck 1470 void DeviceForm::deviceListViewContextMenu ( const QPoint& pos )
573 schoenebeck 1461 {
574     MainForm *pMainForm = MainForm::getInstance();
575     if (pMainForm == NULL)
576     return;
577    
578 schoenebeck 1470 QTreeWidgetItem* pItem = ui.DeviceListView->itemAt(pos);
579     if (pItem == NULL)
580     return;
581    
582 schoenebeck 1461 int iItemID;
583    
584     // Build the device context menu...
585     QMenu* pContextMenu = new QMenu(this);
586    
587     bool bClient = (pMainForm->client() != NULL);
588     bool bEnabled = (pItem != NULL);
589     iItemID = pContextMenu->insertItem(
590     QIconSet(QPixmap(":/qsampler/pixmaps/deviceCreate.png")),
591     tr("&Create device"), this, SLOT(createDevice()));
592     pContextMenu->setItemEnabled(iItemID, bEnabled || (bClient && m_bNewDevice));
593     iItemID = pContextMenu->insertItem(
594     QIconSet(QPixmap(":/qsampler/pixmaps/deviceDelete.png")),
595     tr("&Delete device"), this, SLOT(deleteDevice()));
596     pContextMenu->setItemEnabled(iItemID, bEnabled && !m_bNewDevice);
597     pContextMenu->insertSeparator();
598     iItemID = pContextMenu->insertItem(
599     QIconSet(QPixmap(":/qsampler/pixmaps/formRefresh.png")),
600     tr("&Refresh"), this, SLOT(refreshDevices()));
601     pContextMenu->setItemEnabled(iItemID, bClient);
602    
603     pContextMenu->exec(pos);
604    
605     delete pContextMenu;
606     }
607    
608    
609     // Stabilize current form state.
610     void DeviceForm::stabilizeForm (void)
611     {
612     MainForm* pMainForm = MainForm::getInstance();
613     QTreeWidgetItem* pItem = ui.DeviceListView->currentItem();
614     bool bClient = (pMainForm && pMainForm->client() != NULL);
615     bool bEnabled = (pItem != NULL);
616     ui.DeviceNameTextLabel->setEnabled(bEnabled && !m_bNewDevice);
617     ui.DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice);
618     ui.DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice);
619     ui.DeviceParamTable->setEnabled(bEnabled);
620     ui.RefreshDevicesPushButton->setEnabled(bClient);
621     ui.CreateDevicePushButton->setEnabled(bEnabled || (bClient && m_bNewDevice));
622     ui.DeleteDevicePushButton->setEnabled(bEnabled && !m_bNewDevice);
623     }
624    
625 schoenebeck 1486 void DeviceForm::updateCellRenderers() {
626     const int rows = deviceParamModel.rowCount();
627     const int cols = deviceParamModel.columnCount();
628     updateCellRenderers(deviceParamModel.index(0,0),deviceParamModel.index(rows-1,cols-1));
629     }
630    
631     void DeviceForm::updateCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {
632     for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
633     for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
634     const QModelIndex index = deviceParamModel.index(r,c);
635     ui.DeviceParamTable->openPersistentEditor(index);
636     }
637     }
638     }
639    
640     void DeviceForm::updatePortCellRenderers() {
641     const int rows = devicePortParamModel.rowCount();
642     const int cols = devicePortParamModel.columnCount();
643     updatePortCellRenderers(devicePortParamModel.index(0,0),devicePortParamModel.index(rows-1,cols-1));
644     }
645    
646     void DeviceForm::updatePortCellRenderers(const QModelIndex& topLeft, const QModelIndex& bottomRight) {
647     for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
648     for (int c = topLeft.column(); c <= bottomRight.column(); c++) {
649     const QModelIndex index = devicePortParamModel.index(r,c);
650     ui.DevicePortParamTable->openPersistentEditor(index);
651     }
652     }
653     }
654    
655 schoenebeck 1461 } // namespace QSampler
656 capela 1464
657    
658     // end of qsamplerDeviceForm.cpp

  ViewVC Help
Powered by ViewVC