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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1520 - (show annotations) (download)
Sat Nov 24 13:22:00 2007 UTC (12 years, 6 months ago) by capela
File size: 19914 byte(s)
* Refresh device list form on initial show up.

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

  ViewVC Help
Powered by ViewVC