/[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 1499 by capela, Tue Nov 20 16:48:04 2007 UTC revision 1504 by capela, Wed Nov 21 11:46:40 2007 UTC
# Line 30  Line 30 
30    
31  namespace QSampler {  namespace QSampler {
32    
33  InstrumentListForm::InstrumentListForm ( QWidget* parent, Qt::WindowFlags flags )  InstrumentListForm::InstrumentListForm (
34          : QMainWindow(parent, flags)          QWidget* pParent, Qt::WindowFlags wflags )
35            : QMainWindow(pParent, wflags)
36  {  {
37      ui.setupUi(this);      ui.setupUi(this);
38    
     ui.newInstrumentAction->setText(tr("New &Instrument..."));  
     ui.newInstrumentAction->setShortcut(Qt::Key_Insert);  
     ui.editInstrumentAction->setText(tr("&Edit..."));  
     ui.editInstrumentAction->setShortcut(Qt::Key_Enter);  
     ui.deleteInstrumentAction->setText(tr("&Delete"));  
     ui.deleteInstrumentAction->setShortcut(Qt::Key_Delete);  
     ui.refreshInstrumentsAction->setText(tr("&Refresh"));  
     ui.refreshInstrumentsAction->setShortcut(Qt::Key_F5);  
   
39      // Setup toolbar widgets.      // Setup toolbar widgets.
40      m_pMapComboBox = new QComboBox(ui.InstrumentToolbar);      m_pMapComboBox = new QComboBox(ui.InstrumentToolbar);
41      m_pMapComboBox->setMinimumWidth(120);      m_pMapComboBox->setMinimumWidth(120);
# Line 71  InstrumentListForm::InstrumentListForm ( Line 63  InstrumentListForm::InstrumentListForm (
63                  SLOT(refreshInstruments(void))                  SLOT(refreshInstruments(void))
64      );      );
65    
66          connect(          QObject::connect(
67                  ui.InstrumentTable,                  ui.InstrumentTable,
68                  SIGNAL(activated(const QModelIndex&)),                  SIGNAL(activated(const QModelIndex&)),
69                  SLOT(editInstrument(const QModelIndex&))                  SLOT(editInstrument(const QModelIndex&))
70          );          );
71          connect(          QObject::connect(
72                  ui.newInstrumentAction,                  ui.newInstrumentAction,
73                  SIGNAL(triggered()),                  SIGNAL(triggered()),
74                  SLOT(newInstrument())                  SLOT(newInstrument())
75          );          );
76          connect(          QObject::connect(
77                  ui.deleteInstrumentAction,                  ui.deleteInstrumentAction,
78                  SIGNAL(triggered()),                  SIGNAL(triggered()),
79                  SLOT(deleteInstrument())                  SLOT(deleteInstrument())
80          );          );
81          connect(          QObject::connect(
82                  ui.editInstrumentAction,                  ui.editInstrumentAction,
83                  SIGNAL(triggered()),                  SIGNAL(triggered()),
84                  SLOT(editInstrument())                  SLOT(editInstrument())
85          );          );
86  }  }
87    
88  InstrumentListForm::~InstrumentListForm() {  
89    InstrumentListForm::~InstrumentListForm (void)
90    {
91          delete m_pMapComboBox;          delete m_pMapComboBox;
92  }  }
93    
# Line 101  InstrumentListForm::~InstrumentListForm( Line 95  InstrumentListForm::~InstrumentListForm(
95  // Notify our parent that we're emerging.  // Notify our parent that we're emerging.
96  void InstrumentListForm::showEvent ( QShowEvent *pShowEvent )  void InstrumentListForm::showEvent ( QShowEvent *pShowEvent )
97  {  {
98          //MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
99          //if (pMainForm)          if (pMainForm)
100          //      pMainForm->stabilizeForm();                  pMainForm->stabilizeForm();
101    
102          QWidget::showEvent(pShowEvent);          QWidget::showEvent(pShowEvent);
103  }  }
# Line 114  void InstrumentListForm::hideEvent ( QHi Line 108  void InstrumentListForm::hideEvent ( QHi
108  {  {
109          QWidget::hideEvent(pHideEvent);          QWidget::hideEvent(pHideEvent);
110    
111          //MainForm* pMainForm = MainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
112          //if (pMainForm)          if (pMainForm)
113          //      pMainForm->stabilizeForm();                  pMainForm->stabilizeForm();
114    }
115    
116    
117    // Just about to notify main-window that we're closing.
118    void InstrumentListForm::closeEvent ( QCloseEvent * /*pCloseEvent*/ )
119    {
120            QWidget::hide();
121    
122            MainForm *pMainForm = MainForm::getInstance();
123            if (pMainForm)
124                    pMainForm->stabilizeForm();
125  }  }
126    
127    
# Line 170  void InstrumentListForm::activateMap ( i Line 175  void InstrumentListForm::activateMap ( i
175          model.refresh();          model.refresh();
176  }  }
177    
178  void InstrumentListForm::editInstrument() {  
179          const QModelIndex index = ui.InstrumentTable->currentIndex();  void InstrumentListForm::editInstrument (void)
180          editInstrument(index);  {
181            editInstrument(ui.InstrumentTable->currentIndex());
182  }  }
183    
184  void InstrumentListForm::editInstrument(const QModelIndex& index) {  
185    void InstrumentListForm::editInstrument ( const QModelIndex& index )
186    {
187          if (!index.isValid() || !index.data(Qt::UserRole).isValid())          if (!index.isValid() || !index.data(Qt::UserRole).isValid())
188                  return;                  return;
189    
190          qsamplerInstrument* pInstrument =          qsamplerInstrument* pInstrument
191                  (qsamplerInstrument*) index.data(Qt::UserRole).value<void*>();                  = static_cast<qsamplerInstrument *> (
192                            index.data(Qt::UserRole).value<void *> ());
193    
194          if (!pInstrument) return;          if (pInstrument == NULL)
195                    return;
196    
197          // Save current key values...          // Save current key values...
198          qsamplerInstrument oldInstrument(*pInstrument);          qsamplerInstrument oldInstrument(*pInstrument);
# Line 209  void InstrumentListForm::editInstrument( Line 219  void InstrumentListForm::editInstrument(
219          }          }
220  }  }
221    
222  void InstrumentListForm::newInstrument() {  
223    void InstrumentListForm::newInstrument (void)
224    {
225          qsamplerInstrument instrument;          qsamplerInstrument instrument;
226    
227          InstrumentForm form(this);          InstrumentForm form(this);
228          form.setup(&instrument);          form.setup(&instrument);
229          if (!form.exec()) return;          if (!form.exec())
230                    return;
231    
232          // Commit...          // Commit...
233          instrument.mapInstrument();          instrument.mapInstrument();
# Line 226  void InstrumentListForm::newInstrument() Line 239  void InstrumentListForm::newInstrument()
239          refreshInstruments();          refreshInstruments();
240  }  }
241    
242  void InstrumentListForm::deleteInstrument() {  
243          const QModelIndex index = ui.InstrumentTable->currentIndex();  void InstrumentListForm::deleteInstrument (void)
244          if (!index.isValid() || !index.data(Qt::UserRole).isValid()) return;  {
245            const QModelIndex& index = ui.InstrumentTable->currentIndex();
246            if (!index.isValid() || !index.data(Qt::UserRole).isValid())
247                    return;
248    
249          qsamplerInstrument* pInstrument =          qsamplerInstrument* pInstrument =
250                  (qsamplerInstrument*) index.data(Qt::UserRole).value<void*>();                  static_cast<qsamplerInstrument*> (
251                            index.data(Qt::UserRole).value<void *> ());
252    
253          if (!pInstrument) return;          if (pInstrument == NULL)
254                    return;
255    
256          pInstrument->unmapInstrument();          pInstrument->unmapInstrument();
257          // let the instrument vanish from the table model          // let the instrument vanish from the table model

Legend:
Removed from v.1499  
changed lines
  Added in v.1504

  ViewVC Help
Powered by ViewVC