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

Diff of /qsampler/trunk/src/qsamplerInstrumentListForm.cpp

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

revision 2066 by capela, Sat Mar 13 19:15:24 2010 UTC revision 2071 by capela, Mon Mar 15 18:21:28 2010 UTC
# Line 73  InstrumentListForm::InstrumentListForm ( Line 73  InstrumentListForm::InstrumentListForm (
73                  SLOT(stabilizeForm()));                  SLOT(stabilizeForm()));
74          QObject::connect(          QObject::connect(
75                  m_pInstrumentListView,                  m_pInstrumentListView,
76                  SIGNAL(doubleClicked(const QModelIndex&)),                  SIGNAL(activated(const QModelIndex&)),
77                  SLOT(editInstrument(const QModelIndex&)));                  SLOT(editInstrument(const QModelIndex&)));
78          QObject::connect(          QObject::connect(
79                  m_ui.newInstrumentAction,                  m_ui.newInstrumentAction,
# Line 190  void InstrumentListForm::activateMap ( i Line 190  void InstrumentListForm::activateMap ( i
190  }  }
191    
192    
193    void InstrumentListForm::newInstrument (void)
194    {
195            Instrument instrument;
196    
197            InstrumentForm form(this);
198            form.setup(&instrument);
199            if (!form.exec())
200                    return;
201    
202            // Commit...
203            instrument.mapInstrument();
204    
205            // add new item to the table model
206            m_pInstrumentListView->addInstrument(
207                    instrument.map(),
208                    instrument.bank(),
209                    instrument.prog());
210    
211            stabilizeForm();
212    }
213    
214    
215  void InstrumentListForm::editInstrument (void)  void InstrumentListForm::editInstrument (void)
216  {  {
217          editInstrument(m_pInstrumentListView->currentIndex());          editInstrument(m_pInstrumentListView->currentIndex());
# Line 215  void InstrumentListForm::editInstrument Line 237  void InstrumentListForm::editInstrument
237    
238          // Do the edit dance...          // Do the edit dance...
239          InstrumentForm form(this);          InstrumentForm form(this);
240          form.setup(&instrument);          form.setup(pInstrument);
         if (form.exec()) {  
                 // Commit...  
                 instrument.mapInstrument();  
                 // Check whether we changed instrument key...  
                 if (instrument.map()  == iMap  &&  
                         instrument.bank() == iBank &&  
                         instrument.prog() == iProg) {  
                         // Just update tree item...  
                         //pItem->update();  
                 } else {  
                         // Unmap old instance...  
                         Instrument(iMap, iBank, iProg).unmapInstrument();  
                         // correct the position of the instrument in the model  
                         m_pInstrumentListView->updateInstrument(pInstrument);  
                 }  
         }  
   
         stabilizeForm();  
 }  
   
   
 void InstrumentListForm::newInstrument (void)  
 {  
         Instrument instrument;  
   
         InstrumentForm form(this);  
         form.setup(&instrument);  
241          if (!form.exec())          if (!form.exec())
242                  return;                  return;
243            
244          // Commit...          // Commit...
245          instrument.mapInstrument();          pInstrument->mapInstrument();
246    
247          // add new item to the table model          // Check whether we changed instrument key...
248          m_pInstrumentListView->addInstrument(          if (pInstrument->map()  == iMap  &&
249                  instrument.map(),                  pInstrument->bank() == iBank &&
250                  instrument.bank(),                  pInstrument->prog() == iProg) {
251                  instrument.prog());                  // Just update tree item...
252                    m_pInstrumentListView->updateInstrument(pInstrument);
253            } else {
254                    // Unmap old instance...
255                    instrument.unmapInstrument();
256                    // Correct the position of the instrument in the model
257                    m_pInstrumentListView->resortInstrument(pInstrument);
258            }
259    
260          stabilizeForm();          stabilizeForm();
261  }  }
# Line 290  void InstrumentListForm::deleteInstrumen Line 292  void InstrumentListForm::deleteInstrumen
292    
293          pInstrument->unmapInstrument();          pInstrument->unmapInstrument();
294    
295          // let the instrument vanish from the table model          // Let the instrument vanish from the table model...
296          m_pInstrumentListView->removeInstrument(pInstrument);          m_pInstrumentListView->removeInstrument(pInstrument);
297    
298          stabilizeForm();          stabilizeForm();
# Line 315  void InstrumentListForm::stabilizeForm ( Line 317  void InstrumentListForm::stabilizeForm (
317  void InstrumentListForm::contextMenuEvent (  void InstrumentListForm::contextMenuEvent (
318          QContextMenuEvent *pContextMenuEvent )          QContextMenuEvent *pContextMenuEvent )
319  {  {
320          if (m_ui.newInstrumentAction->isEnabled())          QMenu menu(this);
321                  m_ui.contextMenu->exec(pContextMenuEvent->globalPos());  
322            menu.addAction(m_ui.newInstrumentAction);
323            menu.addSeparator();
324            menu.addAction(m_ui.editInstrumentAction);
325            menu.addAction(m_ui.deleteInstrumentAction);
326            menu.addSeparator();
327            menu.addAction(m_ui.refreshInstrumentsAction);
328    
329            menu.exec(pContextMenuEvent->globalPos());
330  }  }
331    
332    

Legend:
Removed from v.2066  
changed lines
  Added in v.2071

  ViewVC Help
Powered by ViewVC