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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1466 - (hide annotations) (download)
Thu Nov 1 19:25:10 2007 UTC (16 years, 4 months ago) by capela
File size: 4462 byte(s)
* Qt4 migration: added missing signal/slot connections for most forms.

1 capela 1464 // 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 schoenebeck 1461 #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 capela 1466 m_pMapComboBox = new QComboBox(ui.InstrumentToolbar);
47 schoenebeck 1461 m_pMapComboBox->setMinimumWidth(120);
48     m_pMapComboBox->setEnabled(false);
49     QToolTip::add(m_pMapComboBox, tr("Instrument Map"));
50    
51 capela 1466 ui.InstrumentToolbar->addSeparator();
52     ui.newInstrumentAction->addTo(ui.InstrumentToolbar);
53     ui.editInstrumentAction->addTo(ui.InstrumentToolbar);
54     ui.deleteInstrumentAction->addTo(ui.InstrumentToolbar);
55     ui.InstrumentToolbar->addSeparator();
56     ui.refreshInstrumentsAction->addTo(ui.InstrumentToolbar);
57 schoenebeck 1461
58     ui.InstrumentTable->setModel(&model);
59     //ui.InstrumentTable->setDelegate(delegate);
60    
61     QObject::connect(m_pMapComboBox,
62     SIGNAL(activated(int)),
63     SLOT(activateMap(int)));
64    
65 capela 1466 QObject::connect(
66     ui.refreshInstrumentsAction,
67     SIGNAL(triggered()),
68     SLOT(refreshInstruments(void))
69 schoenebeck 1461 );
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 capela 1464
151    
152     // end of qsamplerInstrumentListForm.cpp

  ViewVC Help
Powered by ViewVC