2 |
// |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
/**************************************************************************** |
5 |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
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 |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
|
#include "qsamplerInstrument.h" |
24 |
|
|
25 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
26 |
|
#include "qsamplerOptions.h" |
27 |
|
|
28 |
|
#include <qapplication.h> |
29 |
|
#include <qcombobox.h> |
30 |
|
#include <qtooltip.h> |
31 |
|
|
32 |
|
|
33 |
// Kind of constructor. |
// Kind of constructor. |
34 |
void qsamplerInstrumentListForm::init (void) |
void qsamplerInstrumentListForm::init (void) |
35 |
{ |
{ |
36 |
|
// Setup toolbar widgets. |
37 |
|
m_pMapComboBox = new QComboBox(InstrumentToolbar); |
38 |
|
m_pMapComboBox->setMinimumWidth(120); |
39 |
|
m_pMapComboBox->setEnabled(false); |
40 |
|
QToolTip::add(m_pMapComboBox, tr("Instrument Map")); |
41 |
|
|
42 |
|
InstrumentToolbar->addSeparator(); |
43 |
|
// InstrumentList->newGroupAction()->addTo(InstrumentToolbar); |
44 |
|
InstrumentList->newItemAction()->addTo(InstrumentToolbar); |
45 |
|
InstrumentList->editItemAction()->addTo(InstrumentToolbar); |
46 |
|
InstrumentList->deleteAction()->addTo(InstrumentToolbar); |
47 |
|
InstrumentToolbar->addSeparator(); |
48 |
|
InstrumentList->refreshAction()->addTo(InstrumentToolbar); |
49 |
|
|
50 |
|
QObject::connect(m_pMapComboBox, |
51 |
|
SIGNAL(activated(int)), |
52 |
|
SLOT(activateMap(int))); |
53 |
} |
} |
54 |
|
|
55 |
|
|
56 |
// Kind of destructor. |
// Kind of destructor. |
57 |
void qsamplerInstrumentListForm::destroy (void) |
void qsamplerInstrumentListForm::destroy (void) |
58 |
{ |
{ |
59 |
|
delete m_pMapComboBox; |
60 |
} |
} |
61 |
|
|
62 |
|
|
85 |
// Refresh all instrument list and views. |
// Refresh all instrument list and views. |
86 |
void qsamplerInstrumentListForm::refreshInstruments (void) |
void qsamplerInstrumentListForm::refreshInstruments (void) |
87 |
{ |
{ |
88 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
89 |
|
if (pMainForm == NULL) |
90 |
|
return; |
91 |
|
|
92 |
|
qsamplerOptions *pOptions = pMainForm->options(); |
93 |
|
if (pOptions == NULL) |
94 |
|
return; |
95 |
|
|
96 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
97 |
|
|
98 |
|
// Get/save current map selection... |
99 |
|
int iMap = m_pMapComboBox->currentItem(); |
100 |
|
if (iMap < 0 || m_pMapComboBox->count() < 2) |
101 |
|
iMap = pOptions->iMidiMap + 1; |
102 |
|
|
103 |
|
// Populate maps list. |
104 |
|
m_pMapComboBox->clear(); |
105 |
|
m_pMapComboBox->insertItem(tr("(All)")); |
106 |
|
m_pMapComboBox->insertStringList(qsamplerInstrument::getMapNames()); |
107 |
|
|
108 |
|
// Adjust to saved selection... |
109 |
|
if (iMap < 0 || iMap >= m_pMapComboBox->count()) |
110 |
|
iMap = 0; |
111 |
|
m_pMapComboBox->setCurrentItem(iMap); |
112 |
|
m_pMapComboBox->setEnabled(m_pMapComboBox->count() > 1); |
113 |
|
|
114 |
|
QApplication::restoreOverrideCursor(); |
115 |
|
|
116 |
|
activateMap(iMap); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
// Refresh instrument maps selector. |
121 |
|
void qsamplerInstrumentListForm::activateMap ( int iMap ) |
122 |
|
{ |
123 |
|
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
124 |
|
if (pMainForm == NULL) |
125 |
|
return; |
126 |
|
|
127 |
|
qsamplerOptions *pOptions = pMainForm->options(); |
128 |
|
if (pOptions == NULL) |
129 |
|
return; |
130 |
|
|
131 |
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
132 |
|
|
133 |
|
int iMidiMap = iMap - 1; |
134 |
|
if (iMidiMap >= 0) |
135 |
|
pOptions->iMidiMap = iMidiMap; |
136 |
|
|
137 |
|
InstrumentList->setMidiMap(iMidiMap); |
138 |
InstrumentList->refresh(); |
InstrumentList->refresh(); |
139 |
|
|
140 |
|
QApplication::restoreOverrideCursor(); |
141 |
} |
} |
142 |
|
|
143 |
|
|