/[svn]/qsampler/trunk/src/qsamplerInstrumentListForm.ui.h
ViewVC logotype

Contents of /qsampler/trunk/src/qsamplerInstrumentListForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1015 - (show annotations) (download) (as text)
Mon Jan 8 19:10:42 2007 UTC (17 years, 3 months ago) by capela
File MIME type: text/x-c++hdr
File size: 3882 byte(s)
- MIDI instrument selection fixing on the go.

1 // qsamplerInstrumentListForm.ui.h
2 //
3 // ui.h extension file, included from the uic-generated form implementation.
4 /****************************************************************************
5 Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 *****************************************************************************/
22
23 #include "qsamplerInstrument.h"
24
25 #include "qsamplerMainForm.h"
26 #include "qsamplerOptions.h"
27
28 #include <qcombobox.h>
29 #include <qtooltip.h>
30
31
32 // Kind of constructor.
33 void qsamplerInstrumentListForm::init (void)
34 {
35 // Setup toolbar widgets.
36 m_pMapComboBox = new QComboBox(InstrumentToolbar);
37 m_pMapComboBox->setMinimumWidth(120);
38 m_pMapComboBox->setEnabled(false);
39 QToolTip::add(m_pMapComboBox, tr("Instrument Map"));
40
41 InstrumentToolbar->addSeparator();
42 // InstrumentList->newGroupAction()->addTo(InstrumentToolbar);
43 InstrumentList->newItemAction()->addTo(InstrumentToolbar);
44 InstrumentList->editItemAction()->addTo(InstrumentToolbar);
45 InstrumentList->deleteAction()->addTo(InstrumentToolbar);
46 InstrumentToolbar->addSeparator();
47 InstrumentList->refreshAction()->addTo(InstrumentToolbar);
48
49 QObject::connect(m_pMapComboBox,
50 SIGNAL(activated(int)),
51 SLOT(activateMap(int)));
52 }
53
54
55 // Kind of destructor.
56 void qsamplerInstrumentListForm::destroy (void)
57 {
58 delete m_pMapComboBox;
59 }
60
61
62 // Notify our parent that we're emerging.
63 void qsamplerInstrumentListForm::showEvent ( QShowEvent *pShowEvent )
64 {
65 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
66 if (pMainForm)
67 pMainForm->stabilizeForm();
68
69 QWidget::showEvent(pShowEvent);
70 }
71
72
73 // Notify our parent that we're closing.
74 void qsamplerInstrumentListForm::hideEvent ( QHideEvent *pHideEvent )
75 {
76 QWidget::hideEvent(pHideEvent);
77
78 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
79 if (pMainForm)
80 pMainForm->stabilizeForm();
81 }
82
83
84 // Refresh all instrument list and views.
85 void qsamplerInstrumentListForm::refreshInstruments (void)
86 {
87 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
88 if (pMainForm == NULL)
89 return;
90
91 qsamplerOptions *pOptions = pMainForm->options();
92 if (pOptions == NULL)
93 return;
94
95 // Get/save current map selection...
96 int iMap = m_pMapComboBox->currentItem();
97 if (iMap < 0 || m_pMapComboBox->count() < 2)
98 iMap = pOptions->iMidiMap + 1;
99
100 // Populate maps list.
101 m_pMapComboBox->clear();
102 m_pMapComboBox->insertItem(tr("(All)"));
103 m_pMapComboBox->insertStringList(qsamplerInstrument::getMapNames());
104
105 // Adjust to saved selection...
106 if (iMap < 0 || iMap >= m_pMapComboBox->count())
107 iMap = 0;
108 m_pMapComboBox->setCurrentItem(iMap);
109 m_pMapComboBox->setEnabled(m_pMapComboBox->count() > 1);
110
111 activateMap(iMap);
112 }
113
114
115 // Refresh instrument maps selector.
116 void qsamplerInstrumentListForm::activateMap ( int iMap )
117 {
118 qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();
119 if (pMainForm == NULL)
120 return;
121
122 qsamplerOptions *pOptions = pMainForm->options();
123 if (pOptions == NULL)
124 return;
125
126 int iMidiMap = iMap - 1;
127 if (iMidiMap >= 0)
128 pOptions->iMidiMap = iMidiMap;
129
130 InstrumentList->setMidiMap(iMidiMap);
131 InstrumentList->refresh();
132 }
133
134
135 // end of qsamplerInstrumentListForm.ui.h

  ViewVC Help
Powered by ViewVC