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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 426 by capela, Mon Mar 7 11:09:32 2005 UTC revision 428 by capela, Mon Mar 7 17:05:55 2005 UTC
# Line 20  Line 20 
20    
21  *****************************************************************************/  *****************************************************************************/
22    
 #include <qvalidator.h>  
23  #include <qmessagebox.h>  #include <qmessagebox.h>
24    #include <qfiledialog.h>
25    #include <qfileinfo.h>
26    
27  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
28    
# Line 32  Line 33 
33  void qsamplerDeviceForm::init (void)  void qsamplerDeviceForm::init (void)
34  {  {
35      // Initialize locals.      // Initialize locals.
36      m_pMainForm   = NULL;      m_pMainForm   = (qsamplerMainForm *) QWidget::parentWidget();
37        m_pClient     = NULL;
38          m_iDirtySetup = 0;          m_iDirtySetup = 0;
39      m_iDirtyCount = 0;      m_iDirtyCount = 0;
40        m_iUntitled   = 1;
41    
42      // Try to restore normal window positioning.      // Try to restore normal window positioning.
43      adjustSize();      adjustSize();
# Line 47  void qsamplerDeviceForm::destroy (void) Line 50  void qsamplerDeviceForm::destroy (void)
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.  // Device configuration dialog setup formal initializer.
76  void qsamplerDeviceForm::setup ( qsamplerMainForm *pMainForm )  void qsamplerDeviceForm::setClient ( lscp_client_t *pClient )
77  {  {
78      m_pMainForm   = pMainForm;          // If it has not changed, do nothing.
79          m_iDirtySetup = 0;          if (m_pClient && m_pClient == pClient)
80      m_iDirtyCount = 0;              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    
     if (m_pMainForm == NULL)  
         return;  
     if (m_pMainForm->client() == NULL)  
         return;  
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();      qsamplerOptions *pOptions = m_pMainForm->options();
98      if (pOptions == NULL)      if (pOptions) {
99          return;          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    
         // Set our main client reference.  
     DeviceParameterTable->setClient(pMainForm->client());  
108    
109      // Avoid nested changes.  // Window close event handlers.
110      m_iDirtySetup++;  bool qsamplerDeviceForm::queryClose (void)
111    {
112        bool bQueryClose = true;
113    
114          //      if (m_iDirtyCount > 0) {
115      // TODO: Load initial device configuration data ...          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      // Done.      return bQueryClose;
     m_iDirtySetup--;  
     stabilizeForm();  
132  }  }
133    
134    
135    
136  // Dirty up settings.  // Dirty up settings.
137  void qsamplerDeviceForm::contentsChanged (void)  void qsamplerDeviceForm::contentsChanged (void)
138  {  {
# Line 90  void qsamplerDeviceForm::contentsChanged Line 144  void qsamplerDeviceForm::contentsChanged
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.  // Stabilize current form state.
282  void qsamplerDeviceForm::stabilizeForm (void)  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.          // 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    

Legend:
Removed from v.426  
changed lines
  Added in v.428

  ViewVC Help
Powered by ViewVC