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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1473 - (show annotations) (download)
Mon Nov 5 19:07:26 2007 UTC (16 years, 5 months ago) by capela
File size: 4519 byte(s)
* Qt4 migration: still far from complete, the .ui files got shaved
  with special regard to some redundant or duplicated signal/slot
  connections and to the options dialog font aesthetics as also
  other minors.

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

  ViewVC Help
Powered by ViewVC