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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1461 - (hide annotations) (download)
Sun Oct 28 23:30:36 2007 UTC (16 years, 5 months ago) by schoenebeck
File size: 3434 byte(s)
* started to port QSampler to Qt4 (NOTE: this version is yet broken, use
  the latest tarball release 0.1.5 until the Qt4 port is completed)

1 schoenebeck 1461 #include "qsamplerInstrumentListForm.h"
2    
3     #include "qsamplerMainForm.h"
4     #include "qsamplerOptions.h"
5     #include "qsamplerInstrument.h"
6    
7     #include <QToolTip>
8    
9     namespace QSampler {
10    
11     InstrumentListForm::InstrumentListForm(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) {
12     ui.setupUi(this);
13    
14     ui.newInstrumentAction->setText(tr("New &Instrument..."));
15     ui.newInstrumentAction->setShortcut(Qt::Key_Insert);
16     ui.editInstrumentAction->setText(tr("&Edit..."));
17     ui.editInstrumentAction->setShortcut(Qt::Key_Enter);
18     ui.deleteInstrumentAction->setText(tr("&Delete"));
19     ui.deleteInstrumentAction->setShortcut(Qt::Key_Delete);
20     ui.refreshInstrumentsAction->setText(tr("&Refresh"));
21     ui.refreshInstrumentsAction->setShortcut(Qt::Key_F5);
22    
23     // Setup toolbar widgets.
24     InstrumentToolbar = addToolBar(tr("MIDI Instruments"));
25     m_pMapComboBox = new QComboBox(InstrumentToolbar);
26     m_pMapComboBox->setMinimumWidth(120);
27     m_pMapComboBox->setEnabled(false);
28     QToolTip::add(m_pMapComboBox, tr("Instrument Map"));
29    
30     InstrumentToolbar->addSeparator();
31     ui.newInstrumentAction->addTo(InstrumentToolbar);
32     ui.editInstrumentAction->addTo(InstrumentToolbar);
33     ui.deleteInstrumentAction->addTo(InstrumentToolbar);
34     InstrumentToolbar->addSeparator();
35     ui.refreshInstrumentsAction->addTo(InstrumentToolbar);
36    
37     ui.InstrumentTable->setModel(&model);
38     //ui.InstrumentTable->setDelegate(delegate);
39    
40     QObject::connect(m_pMapComboBox,
41     SIGNAL(activated(int)),
42     SLOT(activateMap(int)));
43    
44     connect(
45     ui.refreshInstrumentsAction,
46     SIGNAL(triggered()), SLOT(refreshInstruments(void))
47     );
48     }
49    
50     InstrumentListForm::~InstrumentListForm() {
51     delete m_pMapComboBox;
52     }
53    
54    
55     // Notify our parent that we're emerging.
56     void InstrumentListForm::showEvent ( QShowEvent *pShowEvent )
57     {
58     //MainForm* pMainForm = MainForm::getInstance();
59     //if (pMainForm)
60     // pMainForm->stabilizeForm();
61    
62     QWidget::showEvent(pShowEvent);
63     }
64    
65    
66     // Notify our parent that we're closing.
67     void InstrumentListForm::hideEvent ( QHideEvent *pHideEvent )
68     {
69     QWidget::hideEvent(pHideEvent);
70    
71     //MainForm* pMainForm = MainForm::getInstance();
72     //if (pMainForm)
73     // pMainForm->stabilizeForm();
74     }
75    
76    
77     // Refresh all instrument list and views.
78     void InstrumentListForm::refreshInstruments (void)
79     {
80     MainForm* pMainForm = MainForm::getInstance();
81     if (pMainForm == NULL)
82     return;
83    
84     qsamplerOptions *pOptions = pMainForm->options();
85     if (pOptions == NULL)
86     return;
87    
88     // Get/save current map selection...
89     int iMap = m_pMapComboBox->currentItem();
90     if (iMap < 0 || m_pMapComboBox->count() < 2)
91     iMap = pOptions->iMidiMap + 1;
92    
93     // Populate maps list.
94     m_pMapComboBox->clear();
95     m_pMapComboBox->insertItem(tr("(All)"));
96     m_pMapComboBox->insertStringList(qsamplerInstrument::getMapNames());
97    
98     // Adjust to saved selection...
99     if (iMap < 0 || iMap >= m_pMapComboBox->count())
100     iMap = 0;
101     m_pMapComboBox->setCurrentItem(iMap);
102     m_pMapComboBox->setEnabled(m_pMapComboBox->count() > 1);
103    
104     activateMap(iMap);
105     }
106    
107    
108     // Refresh instrument maps selector.
109     void InstrumentListForm::activateMap ( int iMap )
110     {
111     MainForm* pMainForm = MainForm::getInstance();
112     if (pMainForm == NULL)
113     return;
114    
115     qsamplerOptions *pOptions = pMainForm->options();
116     if (pOptions == NULL)
117     return;
118    
119     int iMidiMap = iMap - 1;
120     if (iMidiMap >= 0)
121     pOptions->iMidiMap = iMidiMap;
122    
123     model.setMidiMap(iMidiMap);
124     model.refresh();
125     }
126    
127     } // namespace QSampler

  ViewVC Help
Powered by ViewVC