/[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 1504 by capela, Wed Nov 21 11:46:40 2007 UTC revision 1526 by capela, Mon Nov 26 10:58:23 2007 UTC
# Line 20  Line 20 
20    
21  *****************************************************************************/  *****************************************************************************/
22    
23    #include "qsamplerAbout.h"
24  #include "qsamplerInstrumentListForm.h"  #include "qsamplerInstrumentListForm.h"
25    
26  #include "qsamplerInstrumentForm.h"  #include "qsamplerInstrumentForm.h"
27  #include "qsamplerMainForm.h"  
28  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
29  #include "qsamplerInstrument.h"  #include "qsamplerInstrument.h"
30    #include "qsamplerMainForm.h"
31    
32    #include <QHeaderView>
33    
34    
35  namespace QSampler {  namespace QSampler {
# Line 34  InstrumentListForm::InstrumentListForm ( Line 38  InstrumentListForm::InstrumentListForm (
38          QWidget* pParent, Qt::WindowFlags wflags )          QWidget* pParent, Qt::WindowFlags wflags )
39          : QMainWindow(pParent, wflags)          : QMainWindow(pParent, wflags)
40  {  {
41      ui.setupUi(this);          m_ui.setupUi(this);
   
     // Setup toolbar widgets.  
     m_pMapComboBox = new QComboBox(ui.InstrumentToolbar);  
     m_pMapComboBox->setMinimumWidth(120);  
     m_pMapComboBox->setEnabled(false);  
     m_pMapComboBox->setToolTip(tr("Instrument Map"));  
     ui.InstrumentToolbar->addWidget(m_pMapComboBox);  
   
     ui.InstrumentToolbar->addSeparator();  
     ui.InstrumentToolbar->addAction(ui.newInstrumentAction);  
     ui.InstrumentToolbar->addAction(ui.editInstrumentAction);  
     ui.InstrumentToolbar->addAction(ui.deleteInstrumentAction);  
     ui.InstrumentToolbar->addSeparator();  
     ui.InstrumentToolbar->addAction(ui.refreshInstrumentsAction);  
42    
43      ui.InstrumentTable->setModel(&model);          // Setup toolbar widgets.
44      ui.InstrumentTable->setItemDelegate(&delegate);          m_pMapComboBox = new QComboBox(m_ui.InstrumentToolbar);
45            m_pMapComboBox->setMinimumWidth(120);
46            m_pMapComboBox->setEnabled(false);
47            m_pMapComboBox->setToolTip(tr("Instrument Map"));
48            m_ui.InstrumentToolbar->addWidget(m_pMapComboBox);
49    
50            m_ui.InstrumentToolbar->addSeparator();
51            m_ui.InstrumentToolbar->addAction(m_ui.newInstrumentAction);
52            m_ui.InstrumentToolbar->addAction(m_ui.editInstrumentAction);
53            m_ui.InstrumentToolbar->addAction(m_ui.deleteInstrumentAction);
54            m_ui.InstrumentToolbar->addSeparator();
55            m_ui.InstrumentToolbar->addAction(m_ui.refreshInstrumentsAction);
56    
57            int iRowHeight = m_ui.InstrumentTable->fontMetrics().height() + 4;
58            m_ui.InstrumentTable->verticalHeader()->setDefaultSectionSize(iRowHeight);
59    
60            m_ui.InstrumentTable->setModel(&m_model);
61            m_ui.InstrumentTable->setItemDelegate(&m_delegate);
62            m_ui.InstrumentTable->verticalHeader()->hide();
63    
64            QHeaderView *pHeader = m_ui.InstrumentTable->horizontalHeader();
65            pHeader->setDefaultAlignment(Qt::AlignLeft);
66            pHeader->setMovable(false);
67            pHeader->setStretchLastSection(true);
68            pHeader->resizeSection(0, 120);                                         // Name
69            m_ui.InstrumentTable->resizeColumnToContents(1);        // Map
70            m_ui.InstrumentTable->resizeColumnToContents(2);        // Bank
71            m_ui.InstrumentTable->resizeColumnToContents(3);        // Prog
72            m_ui.InstrumentTable->resizeColumnToContents(4);        // Engine
73            pHeader->resizeSection(5, 240);                                         // File
74            m_ui.InstrumentTable->resizeColumnToContents(6);        // Nr
75            pHeader->resizeSection(7, 60);                                          // vol
76    
77          QObject::connect(m_pMapComboBox,          QObject::connect(m_pMapComboBox,
78                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
79                  SLOT(activateMap(int)));                  SLOT(activateMap(int)));
   
80          QObject::connect(          QObject::connect(
81                  ui.refreshInstrumentsAction,                  m_ui.refreshInstrumentsAction,
82                  SIGNAL(triggered()),                  SIGNAL(triggered()),
83                  SLOT(refreshInstruments(void))                  SLOT(refreshInstruments(void)));
     );  
   
84          QObject::connect(          QObject::connect(
85                  ui.InstrumentTable,                  m_ui.InstrumentTable,
86                  SIGNAL(activated(const QModelIndex&)),                  SIGNAL(activated(const QModelIndex&)),
87                  SLOT(editInstrument(const QModelIndex&))                  SLOT(editInstrument(const QModelIndex&)));
         );  
88          QObject::connect(          QObject::connect(
89                  ui.newInstrumentAction,                  m_ui.newInstrumentAction,
90                  SIGNAL(triggered()),                  SIGNAL(triggered()),
91                  SLOT(newInstrument())                  SLOT(newInstrument()));
         );  
92          QObject::connect(          QObject::connect(
93                  ui.deleteInstrumentAction,                  m_ui.deleteInstrumentAction,
94                  SIGNAL(triggered()),                  SIGNAL(triggered()),
95                  SLOT(deleteInstrument())                  SLOT(deleteInstrument()));
         );  
96          QObject::connect(          QObject::connect(
97                  ui.editInstrumentAction,                  m_ui.editInstrumentAction,
98                  SIGNAL(triggered()),                  SIGNAL(triggered()),
99                  SLOT(editInstrument())                  SLOT(editInstrument()));
100          );  
101            MainForm *pMainForm = MainForm::getInstance();
102            if (pMainForm) {
103                    QObject::connect(&m_model,
104                            SIGNAL(instrumentsChanged()),
105                            pMainForm, SLOT(sessionDirty()));
106            }
107  }  }
108    
109    
# Line 171  void InstrumentListForm::activateMap ( i Line 192  void InstrumentListForm::activateMap ( i
192          if (iMidiMap >= 0)          if (iMidiMap >= 0)
193                  pOptions->iMidiMap = iMidiMap;                  pOptions->iMidiMap = iMidiMap;
194    
195          model.setMidiMap(iMidiMap);          m_model.setMidiMap(iMidiMap);
196          model.refresh();          m_model.refresh();
197  }  }
198    
199    
200  void InstrumentListForm::editInstrument (void)  void InstrumentListForm::editInstrument (void)
201  {  {
202          editInstrument(ui.InstrumentTable->currentIndex());          editInstrument(m_ui.InstrumentTable->currentIndex());
203  }  }
204    
205    
# Line 206  void InstrumentListForm::editInstrument Line 227  void InstrumentListForm::editInstrument
227                  if (oldInstrument.map()  == pInstrument->map()  &&                  if (oldInstrument.map()  == pInstrument->map()  &&
228                          oldInstrument.bank() == pInstrument->bank() &&                          oldInstrument.bank() == pInstrument->bank() &&
229                          oldInstrument.prog() == pInstrument->prog()) {                          oldInstrument.prog() == pInstrument->prog()) {
230                          // just update tree item...                          // Just update tree item...
231                          //pItem->update();                          //pItem->update();
232                  } else {                  } else {
233                          // Unmap old instance...                          // Unmap old instance...
234                          oldInstrument.unmapInstrument();                          oldInstrument.unmapInstrument();
235                          // correct the position of the instrument in the model                          // correct the position of the instrument in the model
236                          model.resort(*pInstrument);                          m_model.resort(*pInstrument);
237                  }                  }
238                  // Notify we've changes...                  // Notify we've changes...
239                  emit model.reset();                  emit m_model.reset();
240          }          }
241  }  }
242    
# Line 232  void InstrumentListForm::newInstrument ( Line 253  void InstrumentListForm::newInstrument (
253          // Commit...          // Commit...
254          instrument.mapInstrument();          instrument.mapInstrument();
255          // add new item to the table model          // add new item to the table model
256          model.resort(instrument);          m_model.resort(instrument);
257          // Notify we've changes...          // Notify we've changes...
258          //emit model.reset();          //emit model.reset();
259          //FIXME: call above didnt really refresh, so we use this for now ...          //FIXME: call above didnt really refresh, so we use this for now ...
# Line 242  void InstrumentListForm::newInstrument ( Line 263  void InstrumentListForm::newInstrument (
263    
264  void InstrumentListForm::deleteInstrument (void)  void InstrumentListForm::deleteInstrument (void)
265  {  {
266          const QModelIndex& index = ui.InstrumentTable->currentIndex();          const QModelIndex& index = m_ui.InstrumentTable->currentIndex();
267          if (!index.isValid() || !index.data(Qt::UserRole).isValid())          if (!index.isValid() || !index.data(Qt::UserRole).isValid())
268                  return;                  return;
269    
# Line 255  void InstrumentListForm::deleteInstrumen Line 276  void InstrumentListForm::deleteInstrumen
276    
277          pInstrument->unmapInstrument();          pInstrument->unmapInstrument();
278          // let the instrument vanish from the table model          // let the instrument vanish from the table model
279          model.removeInstrument(*pInstrument);          m_model.removeInstrument(*pInstrument);
280          // Notify we've changes...          // Notify we've changes...
281          emit model.reset();          emit m_model.reset();
282  }  }
283    
284  } // namespace QSampler  } // namespace QSampler

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

  ViewVC Help
Powered by ViewVC