/[svn]/qsampler/trunk/src/qsamplerDeviceForm.ui.h
ViewVC logotype

Contents of /qsampler/trunk/src/qsamplerDeviceForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 428 - (show annotations) (download) (as text)
Mon Mar 7 17:05:55 2005 UTC (19 years ago) by capela
File MIME type: text/x-c++hdr
File size: 7979 byte(s)
More device configuration interface preparations.

1 // qsamplerDeviceForm.ui.h
2 //
3 // 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.
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
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 *****************************************************************************/
22
23 #include <qmessagebox.h>
24 #include <qfiledialog.h>
25 #include <qfileinfo.h>
26
27 #include "qsamplerMainForm.h"
28
29 #include "config.h"
30
31
32 // Kind of constructor.
33 void qsamplerDeviceForm::init (void)
34 {
35 // Initialize locals.
36 m_pMainForm = (qsamplerMainForm *) QWidget::parentWidget();
37 m_pClient = NULL;
38 m_iDirtySetup = 0;
39 m_iDirtyCount = 0;
40 m_iUntitled = 1;
41
42 // Try to restore normal window positioning.
43 adjustSize();
44 }
45
46
47 // Kind of destructor.
48 void qsamplerDeviceForm::destroy (void)
49 {
50 }
51
52
53 // Notify our parent that we're emerging.
54 void qsamplerDeviceForm::showEvent ( QShowEvent *pShowEvent )
55 {
56 if (m_pMainForm)
57 m_pMainForm->stabilizeForm();
58
59 stabilizeForm();
60
61 QWidget::showEvent(pShowEvent);
62 }
63
64
65 // Notify our parent that we're closing.
66 void qsamplerDeviceForm::hideEvent ( QHideEvent *pHideEvent )
67 {
68 QWidget::hideEvent(pHideEvent);
69
70 if (m_pMainForm)
71 m_pMainForm->stabilizeForm();
72 }
73
74
75 // Device configuration dialog setup formal initializer.
76 void qsamplerDeviceForm::setClient ( lscp_client_t *pClient )
77 {
78 // If it has not changed, do nothing.
79 if (m_pClient && m_pClient == pClient)
80 return;
81
82 // Set new reference.
83 m_pClient = pClient;
84
85 // Set our main client reference.
86 DeviceParameterTable->setClient(m_pClient);
87
88 // OK. Do a whole refresh around.
89 refreshDevices();
90 }
91
92
93 // Format the displayable device configuration filename.
94 QString qsamplerDeviceForm::devicesName ( const QString& sFilename )
95 {
96 QString sDevicesName = sFilename;
97 qsamplerOptions *pOptions = m_pMainForm->options();
98 if (pOptions) {
99 bool bCompletePath = (pOptions && pOptions->bCompletePath);
100 if (sDevicesName.isEmpty())
101 sDevicesName = tr("Untitled") + QString::number(m_iUntitled);
102 else if (!bCompletePath)
103 sDevicesName = QFileInfo(sDevicesName).fileName();
104 }
105 return sDevicesName;
106 }
107
108
109 // Window close event handlers.
110 bool qsamplerDeviceForm::queryClose (void)
111 {
112 bool bQueryClose = true;
113
114 if (m_iDirtyCount > 0) {
115 switch (QMessageBox::warning(this, tr("Warning"),
116 tr("The device configuration has been changed.\n\n"
117 "\"%1\"\n\n"
118 "Do you want to save the changes?")
119 .arg(devicesName(m_sFilename)),
120 tr("Save"), tr("Discard"), tr("Cancel"))) {
121 case 0: // Save...
122 saveDevices();
123 // Fall thru....
124 case 1: // Discard
125 break;
126 default: // Cancel.
127 bQueryClose = false;
128 }
129 }
130
131 return bQueryClose;
132 }
133
134
135
136 // Dirty up settings.
137 void qsamplerDeviceForm::contentsChanged (void)
138 {
139 if (m_iDirtySetup > 0)
140 return;
141
142 m_iDirtyCount++;
143 stabilizeForm();
144 }
145
146
147 // Load device configuration slot.
148 void qsamplerDeviceForm::loadDevices (void)
149 {
150 QString sFilename = QFileDialog::getOpenFileName(
151 m_sFilename, // Start here.
152 tr("Device Configuration files") + " (*.lscp)", // Filter (XML files)
153 this, 0, // Parent and name (none)
154 tr("Load Device Configuration") // Caption.
155 );
156
157 if (sFilename.isEmpty())
158 return;
159
160 // Check if we're going to discard safely the current one...
161 if (!queryClose())
162 return;
163
164 // Load it right away...
165 loadDevicesFile(sFilename);
166 }
167
168
169 // Save device configuration slot.
170 void qsamplerDeviceForm::saveDevices (void)
171 {
172 QString sFilename = QFileDialog::getSaveFileName(
173 m_sFilename, // Start here.
174 tr("Device Configuration files") + " (*.lscp)", // Filter (XML files)
175 this, 0, // Parent and name (none)
176 tr("Save Device Configuration") // Caption.
177 );
178
179 if (sFilename.isEmpty())
180 return;
181
182 // Enforce .xml extension...
183 if (QFileInfo(sFilename).extension().isEmpty())
184 sFilename += ".lscp";
185
186 // Save it right away...
187 saveDevicesFile(sFilename);
188 }
189
190
191 // Load device configuration from file.
192 void qsamplerDeviceForm::loadDevicesFile ( const QString& sFilename )
193 {
194 //
195 // TODO: Load device configuration from file...
196 //
197 m_pMainForm->appendMessages("qsamplerDeviceForm::loadDevicesFile(\"" + sFilename + "\")...");
198
199 m_sFilename = sFilename;
200 m_iDirtyCount = 0;
201
202 refreshDevices();
203 }
204
205
206 // Save device configuration into file.
207 void qsamplerDeviceForm::saveDevicesFile ( const QString& sFilename )
208 {
209 //
210 // TODO: Save device configuration into file...
211 //
212 m_pMainForm->appendMessages("qsamplerDeviceForm::saveDevicesFile(\"" + sFilename + "\")...");
213
214 m_sFilename = sFilename;
215 m_iDirtyCount = 0;
216 stabilizeForm();
217 }
218
219
220 // Create a new device from current table view.
221 void qsamplerDeviceForm::createDevice (void)
222 {
223 //
224 // TODO: Create a new device from current table view...
225 //
226 m_pMainForm->appendMessages("qsamplerDeviceForm::createDevice()...");
227 }
228
229
230 // Update current device in table view.
231 void qsamplerDeviceForm::updateDevice (void)
232 {
233 //
234 // TODO: Update current device in table view...
235 //
236 m_pMainForm->appendMessages("qsamplerDeviceForm::updateDevice()...");
237 }
238
239
240 // Delete current device in table view.
241 void qsamplerDeviceForm::deleteDevice (void)
242 {
243 //
244 // TODO: Delete current device in table view...
245 //
246 m_pMainForm->appendMessages("qsamplerDeviceForm::deleteDevice()...");
247 }
248
249
250 // Refresh all device list and views.
251 void qsamplerDeviceForm::refreshDevices (void)
252 {
253 // Avoid nested changes.
254 m_iDirtySetup++;
255
256 DeviceListView->clear();
257 if (m_pClient)
258 new QListViewItem(DeviceListView, tr("<New device>"));
259
260 //
261 // TODO: Load device configuration data ...
262 //
263 m_pMainForm->appendMessages("qsamplerDeviceForm::refreshDevices()");
264
265 DeviceParameterTable->setNumRows(0);
266 if (m_pClient) {
267 DeviceParameterTable->insertRows(0, 3);
268 for (int c = 0; c < DeviceParameterTable->numCols(); c++) {
269 for (int r = 0; r < DeviceParameterTable->numRows(); r++)
270 DeviceParameterTable->setText(r, c, QString("R%1C%1").arg(r).arg(c));
271 DeviceParameterTable->adjustColumn(c);
272 }
273 }
274
275 // Done.
276 m_iDirtySetup--;
277 // stabilizeForm();
278 }
279
280
281 // Stabilize current form state.
282 void qsamplerDeviceForm::stabilizeForm (void)
283 {
284 // Update the main caption...
285 QString sDevicesName = devicesName(m_sFilename);
286 if (m_iDirtyCount > 0)
287 sDevicesName += '*';
288 setCaption(tr("Devices - [%1]").arg(sDevicesName));
289
290 //
291 // TODO: Enable/disable available command buttons.
292 //
293 m_pMainForm->appendMessages("qsamplerDeviceForm::stabilizeForm()");
294
295 SaveDevicesPushButton->setEnabled(m_iDirtyCount > 0);
296
297 CreateDevicePushButton->setEnabled(m_iDirtyCount > 0);
298 UpdateDevicePushButton->setEnabled(m_iDirtyCount > 0);
299 DeleteDevicePushButton->setEnabled(m_iDirtyCount > 0);
300 }
301
302
303 // end of qsamplerDeviceForm.ui.h
304

  ViewVC Help
Powered by ViewVC