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 |
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 |
|
|
28 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
29 |
|
|
39 |
m_iDirtySetup = 0; |
m_iDirtySetup = 0; |
40 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
41 |
m_iUntitled = 1; |
m_iUntitled = 1; |
42 |
|
m_bNewDevice = false; |
43 |
|
|
44 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
45 |
adjustSize(); |
adjustSize(); |
84 |
// Set new reference. |
// Set new reference. |
85 |
m_pClient = pClient; |
m_pClient = pClient; |
86 |
|
|
|
// Set our main client reference. |
|
|
DeviceParameterTable->setClient(m_pClient); |
|
|
|
|
87 |
// OK. Do a whole refresh around. |
// OK. Do a whole refresh around. |
88 |
refreshDevices(); |
refreshDevices(); |
89 |
} |
} |
223 |
// TODO: Create a new device from current table view... |
// TODO: Create a new device from current table view... |
224 |
// |
// |
225 |
m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()..."); |
m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()..."); |
226 |
|
|
227 |
|
m_iDirtyCount++; |
228 |
|
stabilizeForm(); |
229 |
} |
} |
230 |
|
|
231 |
|
|
236 |
// TODO: Update current device in table view... |
// TODO: Update current device in table view... |
237 |
// |
// |
238 |
m_pMainForm->appendMessages("qsamplerDeviceForm::updateDevice()..."); |
m_pMainForm->appendMessages("qsamplerDeviceForm::updateDevice()..."); |
239 |
|
|
240 |
|
m_iDirtyCount++; |
241 |
|
stabilizeForm(); |
242 |
} |
} |
243 |
|
|
244 |
|
|
249 |
// TODO: Delete current device in table view... |
// TODO: Delete current device in table view... |
250 |
// |
// |
251 |
m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()..."); |
m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()..."); |
252 |
|
|
253 |
|
m_iDirtyCount++; |
254 |
|
stabilizeForm(); |
255 |
} |
} |
256 |
|
|
257 |
|
|
261 |
// Avoid nested changes. |
// Avoid nested changes. |
262 |
m_iDirtySetup++; |
m_iDirtySetup++; |
263 |
|
|
|
DeviceListView->clear(); |
|
|
if (m_pClient) |
|
|
new QListViewItem(DeviceListView, tr("<New device>")); |
|
|
|
|
264 |
// |
// |
265 |
// TODO: Load device configuration data ... |
// TODO: Load device configuration data ... |
266 |
// |
// |
267 |
m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()"); |
m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()"); |
268 |
|
|
269 |
DeviceParameterTable->setNumRows(0); |
DeviceListView->clear(); |
270 |
if (m_pClient) { |
if (m_pClient) { |
271 |
DeviceParameterTable->insertRows(0, 3); |
qsamplerDeviceItem *pItem; |
272 |
for (int c = 0; c < DeviceParameterTable->numCols(); c++) { |
int *piDeviceIDs; |
273 |
for (int r = 0; r < DeviceParameterTable->numRows(); r++) |
// Grab and pop Audio devices... |
274 |
DeviceParameterTable->setText(r, c, QString("R%1C%1").arg(r).arg(c)); |
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
275 |
DeviceParameterTable->adjustColumn(c); |
qsamplerDevice::Audio); |
276 |
|
if (pItem) { |
277 |
|
pItem->setText(0, tr("Audio")); |
278 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
279 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
280 |
|
new qsamplerDeviceItem(pItem, m_pClient, |
281 |
|
qsamplerDevice::Audio, piDeviceIDs[i]); |
282 |
|
} |
283 |
|
pItem->setOpen(true); |
284 |
|
} |
285 |
|
// Grab and pop MIDI devices... |
286 |
|
pItem = new qsamplerDeviceItem(DeviceListView, m_pClient, |
287 |
|
qsamplerDevice::Midi); |
288 |
|
if (pItem) { |
289 |
|
pItem->setText(0, tr("MIDI")); |
290 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
291 |
|
for (int i = 0; piDeviceIDs && piDeviceIDs[i] >= 0; i++) { |
292 |
|
new qsamplerDeviceItem(pItem, m_pClient, |
293 |
|
qsamplerDevice::Midi, piDeviceIDs[i]); |
294 |
|
} |
295 |
|
pItem->setOpen(true); |
296 |
} |
} |
297 |
} |
} |
298 |
|
|
299 |
// Done. |
// Done. |
300 |
|
selectDevice(); |
301 |
m_iDirtySetup--; |
m_iDirtySetup--; |
302 |
// stabilizeForm(); |
} |
303 |
|
|
304 |
|
|
305 |
|
// Driver selection slot. |
306 |
|
void qsamplerDeviceForm::selectDriver ( const QString& sDriverName ) |
307 |
|
{ |
308 |
|
// |
309 |
|
// TODO: Driver name has changed for a new device... |
310 |
|
// |
311 |
|
m_pMainForm->appendMessages("qsamplerDeviceForm::selectDriver(\"" + sDriverName + "\")"); |
312 |
|
|
313 |
|
m_iDirtyCount++; |
314 |
|
stabilizeForm(); |
315 |
|
} |
316 |
|
|
317 |
|
|
318 |
|
// Device selection slot. |
319 |
|
void qsamplerDeviceForm::selectDevice (void) |
320 |
|
{ |
321 |
|
// |
322 |
|
// TODO: Device selection has changed... |
323 |
|
// |
324 |
|
m_pMainForm->appendMessages("qsamplerDeviceForm::selectDevice()"); |
325 |
|
|
326 |
|
QListViewItem *pItem = DeviceListView->selectedItem(); |
327 |
|
if (pItem == NULL || pItem->rtti() != QSAMPLER_DEVICE_ITEM) { |
328 |
|
stabilizeForm(); |
329 |
|
return; |
330 |
|
} |
331 |
|
|
332 |
|
const qsamplerDevice& device = ((qsamplerDeviceItem *) pItem)->device(); |
333 |
|
m_bNewDevice = (device.deviceID() < 0); |
334 |
|
|
335 |
|
// Fill the device heading... |
336 |
|
DeviceNameTextLabel->setText(' ' + device.deviceName()); |
337 |
|
DriverNameComboBox->clear(); |
338 |
|
DriverNameComboBox->insertStringList( |
339 |
|
qsamplerDevice::getDrivers(m_pClient, device.deviceType())); |
340 |
|
const QString& sDriverName = device.driverName(); |
341 |
|
if (!sDriverName.isEmpty()) { |
342 |
|
if (DriverNameComboBox->listBox()->findItem(sDriverName, Qt::ExactMatch) == NULL) |
343 |
|
DriverNameComboBox->insertItem(sDriverName); |
344 |
|
DriverNameComboBox->setCurrentText(sDriverName); |
345 |
|
} |
346 |
|
DriverNameTextLabel->setEnabled(m_bNewDevice); |
347 |
|
DriverNameComboBox->setEnabled(m_bNewDevice); |
348 |
|
|
349 |
|
// Fill the device parameter table... |
350 |
|
DeviceParamTable->setEnabled(true); |
351 |
|
DeviceParamTable->setDevice(m_pClient, |
352 |
|
device.deviceType(), device.deviceID()); |
353 |
|
|
354 |
|
// Done. |
355 |
|
stabilizeForm(); |
356 |
} |
} |
357 |
|
|
358 |
|
|
371 |
m_pMainForm->appendMessages("qsamplerDeviceForm::stabilizeForm()"); |
m_pMainForm->appendMessages("qsamplerDeviceForm::stabilizeForm()"); |
372 |
|
|
373 |
SaveDevicesPushButton->setEnabled(m_iDirtyCount > 0); |
SaveDevicesPushButton->setEnabled(m_iDirtyCount > 0); |
374 |
|
|
375 |
CreateDevicePushButton->setEnabled(m_iDirtyCount > 0); |
QListViewItem *pItem = DeviceListView->selectedItem(); |
376 |
UpdateDevicePushButton->setEnabled(m_iDirtyCount > 0); |
bool bEnabled = (pItem != NULL); |
377 |
DeleteDevicePushButton->setEnabled(m_iDirtyCount > 0); |
DeviceNameTextLabel->setEnabled(bEnabled); |
378 |
|
DriverNameTextLabel->setEnabled(bEnabled && m_bNewDevice); |
379 |
|
DriverNameComboBox->setEnabled(bEnabled && m_bNewDevice); |
380 |
|
DeviceParamTable->setEnabled(bEnabled); |
381 |
|
CreateDevicePushButton->setEnabled(bEnabled && (m_iDirtyCount > 0 || m_bNewDevice)); |
382 |
|
UpdateDevicePushButton->setEnabled(bEnabled && (m_iDirtyCount > 0 && !m_bNewDevice)); |
383 |
|
DeleteDevicePushButton->setEnabled(bEnabled && (m_iDirtyCount > 0 && !m_bNewDevice)); |
384 |
} |
} |
385 |
|
|
386 |
|
|