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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1464 - (show annotations) (download)
Thu Nov 1 17:14:21 2007 UTC (16 years, 5 months ago) by capela
File size: 4505 byte(s)
- Qt4 migration: missing copyright headers update.

1 // qsamplerInstrumentListForm.cpp
2 //
3 /****************************************************************************
4 Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5 Copyright (C) 2007, Christian Schoenebeck
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
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 *****************************************************************************/
22
23 #include "qsamplerInstrumentListForm.h"
24
25 #include "qsamplerMainForm.h"
26 #include "qsamplerOptions.h"
27 #include "qsamplerInstrument.h"
28
29 #include <QToolTip>
30
31 namespace QSampler {
32
33 InstrumentListForm::InstrumentListForm(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) {
34 ui.setupUi(this);
35
36 ui.newInstrumentAction->setText(tr("New &Instrument..."));
37 ui.newInstrumentAction->setShortcut(Qt::Key_Insert);
38 ui.editInstrumentAction->setText(tr("&Edit..."));
39 ui.editInstrumentAction->setShortcut(Qt::Key_Enter);
40 ui.deleteInstrumentAction->setText(tr("&Delete"));
41 ui.deleteInstrumentAction->setShortcut(Qt::Key_Delete);
42 ui.refreshInstrumentsAction->setText(tr("&Refresh"));
43 ui.refreshInstrumentsAction->setShortcut(Qt::Key_F5);
44
45 // Setup toolbar widgets.
46 InstrumentToolbar = addToolBar(tr("MIDI Instruments"));
47 m_pMapComboBox = new QComboBox(InstrumentToolbar);
48 m_pMapComboBox->setMinimumWidth(120);
49 m_pMapComboBox->setEnabled(false);
50 QToolTip::add(m_pMapComboBox, tr("Instrument Map"));
51
52 InstrumentToolbar->addSeparator();
53 ui.newInstrumentAction->addTo(InstrumentToolbar);
54 ui.editInstrumentAction->addTo(InstrumentToolbar);
55 ui.deleteInstrumentAction->addTo(InstrumentToolbar);
56 InstrumentToolbar->addSeparator();
57 ui.refreshInstrumentsAction->addTo(InstrumentToolbar);
58
59 ui.InstrumentTable->setModel(&model);
60 //ui.InstrumentTable->setDelegate(delegate);
61
62 QObject::connect(m_pMapComboBox,
63 SIGNAL(activated(int)),
64 SLOT(activateMap(int)));
65
66 connect(
67 ui.refreshInstrumentsAction,
68 SIGNAL(triggered()), SLOT(refreshInstruments(void))
69 );
70 }
71
72 InstrumentListForm::~InstrumentListForm() {
73 delete m_pMapComboBox;
74 }
75
76
77 // Notify our parent that we're emerging.
78 void InstrumentListForm::showEvent ( QShowEvent *pShowEvent )
79 {
80 //MainForm* pMainForm = MainForm::getInstance();
81 //if (pMainForm)
82 // pMainForm->stabilizeForm();
83
84 QWidget::showEvent(pShowEvent);
85 }
86
87
88 // Notify our parent that we're closing.
89 void InstrumentListForm::hideEvent ( QHideEvent *pHideEvent )
90 {
91 QWidget::hideEvent(pHideEvent);
92
93 //MainForm* pMainForm = MainForm::getInstance();
94 //if (pMainForm)
95 // pMainForm->stabilizeForm();
96 }
97
98
99 // Refresh all instrument list and views.
100 void InstrumentListForm::refreshInstruments (void)
101 {
102 MainForm* pMainForm = MainForm::getInstance();
103 if (pMainForm == NULL)
104 return;
105
106 qsamplerOptions *pOptions = pMainForm->options();
107 if (pOptions == NULL)
108 return;
109
110 // Get/save current map selection...
111 int iMap = m_pMapComboBox->currentItem();
112 if (iMap < 0 || m_pMapComboBox->count() < 2)
113 iMap = pOptions->iMidiMap + 1;
114
115 // Populate maps list.
116 m_pMapComboBox->clear();
117 m_pMapComboBox->insertItem(tr("(All)"));
118 m_pMapComboBox->insertStringList(qsamplerInstrument::getMapNames());
119
120 // Adjust to saved selection...
121 if (iMap < 0 || iMap >= m_pMapComboBox->count())
122 iMap = 0;
123 m_pMapComboBox->setCurrentItem(iMap);
124 m_pMapComboBox->setEnabled(m_pMapComboBox->count() > 1);
125
126 activateMap(iMap);
127 }
128
129
130 // Refresh instrument maps selector.
131 void InstrumentListForm::activateMap ( int iMap )
132 {
133 MainForm* pMainForm = MainForm::getInstance();
134 if (pMainForm == NULL)
135 return;
136
137 qsamplerOptions *pOptions = pMainForm->options();
138 if (pOptions == NULL)
139 return;
140
141 int iMidiMap = iMap - 1;
142 if (iMidiMap >= 0)
143 pOptions->iMidiMap = iMidiMap;
144
145 model.setMidiMap(iMidiMap);
146 model.refresh();
147 }
148
149 } // namespace QSampler
150
151
152 // end of qsamplerInstrumentListForm.cpp

  ViewVC Help
Powered by ViewVC