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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1519 - (show annotations) (download)
Sat Nov 24 13:06:19 2007 UTC (16 years, 4 months ago) by capela
File size: 19907 byte(s)
* Narrower QTableView row heights and header section left-alignment.
* Smoothed the old shinny display effect bitmap.

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

  ViewVC Help
Powered by ViewVC