/[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 2065 by capela, Sat Mar 13 12:44:15 2010 UTC revision 2066 by capela, Sat Mar 13 19:15:24 2010 UTC
# Line 33  Line 33 
33    
34  #include <QHeaderView>  #include <QHeaderView>
35  #include <QMessageBox>  #include <QMessageBox>
36    #include <QContextMenuEvent>
37    
38    
39  namespace QSampler {  namespace QSampler {
# Line 47  InstrumentListForm::InstrumentListForm ( Line 48  InstrumentListForm::InstrumentListForm (
48  {  {
49          m_ui.setupUi(this);          m_ui.setupUi(this);
50    
51            m_pInstrumentListView = new InstrumentListView(this);
52            QMainWindow::setCentralWidget(m_pInstrumentListView);
53    
54          // Setup toolbar widgets.          // Setup toolbar widgets.
55          m_pMapComboBox = new QComboBox(m_ui.instrumentToolbar);          m_pMapComboBox = new QComboBox(m_ui.instrumentToolbar);
56          m_pMapComboBox->setMinimumWidth(120);          m_pMapComboBox->setMinimumWidth(120);
57          m_pMapComboBox->setEnabled(false);          m_pMapComboBox->setEnabled(false);
58          m_pMapComboBox->setToolTip(tr("Instrument Map"));          m_pMapComboBox->setToolTip(tr("Instrument Map"));
59            
60          m_ui.instrumentToolbar->addWidget(m_pMapComboBox);          m_ui.instrumentToolbar->addWidget(m_pMapComboBox);
   
61          m_ui.instrumentToolbar->addSeparator();          m_ui.instrumentToolbar->addSeparator();
62          m_ui.instrumentToolbar->addAction(m_ui.newInstrumentAction);          m_ui.instrumentToolbar->addAction(m_ui.newInstrumentAction);
63          m_ui.instrumentToolbar->addAction(m_ui.editInstrumentAction);          m_ui.instrumentToolbar->addAction(m_ui.editInstrumentAction);
# Line 61  InstrumentListForm::InstrumentListForm ( Line 65  InstrumentListForm::InstrumentListForm (
65          m_ui.instrumentToolbar->addSeparator();          m_ui.instrumentToolbar->addSeparator();
66          m_ui.instrumentToolbar->addAction(m_ui.refreshInstrumentsAction);          m_ui.instrumentToolbar->addAction(m_ui.refreshInstrumentsAction);
67    
         m_pInstrumentListView = new InstrumentListView(this);  
         m_pInstrumentListView->setContextMenuPolicy(Qt::CustomContextMenu);  
         QMainWindow::setCentralWidget(m_pInstrumentListView);  
   
68          QObject::connect(m_pMapComboBox,          QObject::connect(m_pMapComboBox,
69                  SIGNAL(activated(int)),                  SIGNAL(activated(int)),
70                  SLOT(activateMap(int)));                  SLOT(activateMap(int)));
71          QObject::connect(          QObject::connect(m_pInstrumentListView->selectionModel(),
72                  m_pInstrumentListView,                  SIGNAL(currentRowChanged(const QModelIndex&,const QModelIndex&)),
                 SIGNAL(customContextMenuRequested(const QPoint&)),  
                 SLOT(contextMenu(const QPoint&)));  
         QObject::connect(  
                 m_pInstrumentListView,  
                 SIGNAL(activated(const QModelIndex&)),  
73                  SLOT(stabilizeForm()));                  SLOT(stabilizeForm()));
74          QObject::connect(          QObject::connect(
75                  m_pInstrumentListView,                  m_pInstrumentListView,
# Line 104  InstrumentListForm::InstrumentListForm ( Line 99  InstrumentListForm::InstrumentListForm (
99    
100  InstrumentListForm::~InstrumentListForm (void)  InstrumentListForm::~InstrumentListForm (void)
101  {  {
         delete m_pInstrumentListView;  
102          delete m_pMapComboBox;          delete m_pMapComboBox;
103            delete m_pInstrumentListView;
104  }  }
105    
106    
# Line 316  void InstrumentListForm::stabilizeForm ( Line 311  void InstrumentListForm::stabilizeForm (
311  }  }
312    
313    
314  // Handle custom context menu here...  // Context menu request.
315  void InstrumentListForm::contextMenu ( const QPoint& pos )  void InstrumentListForm::contextMenuEvent (
316            QContextMenuEvent *pContextMenuEvent )
317  {  {
318          if (!m_ui.newInstrumentAction->isEnabled())          if (m_ui.newInstrumentAction->isEnabled())
319                  return;                  m_ui.contextMenu->exec(pContextMenuEvent->globalPos());
   
         m_ui.contextMenu->exec(  
                 (m_pInstrumentListView->viewport())->mapToGlobal(pos));  
320  }  }
321    
322    

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

  ViewVC Help
Powered by ViewVC