1 |
// qsamplerChannel.cpp |
// qsamplerChannel.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
GNU General Public License for more details. |
GNU General Public License for more details. |
15 |
|
|
16 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License along |
17 |
along with this program; if not, write to the Free Software |
with this program; if not, write to the Free Software Foundation, Inc., |
18 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
|
20 |
*****************************************************************************/ |
*****************************************************************************/ |
21 |
|
|
26 |
#include "qsamplerChannelForm.h" |
#include "qsamplerChannelForm.h" |
27 |
|
|
28 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
29 |
|
#include <qcombobox.h> |
30 |
|
|
31 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
32 |
#include "gig.h" |
#include "gig.h" |
33 |
#endif |
#endif |
34 |
|
|
35 |
#define QSAMPLER_INSTRUMENT_MAX 8 |
#define QSAMPLER_INSTRUMENT_MAX 100 |
36 |
|
|
37 |
|
|
38 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
789 |
QTable::setShowGrid(false); |
QTable::setShowGrid(false); |
790 |
QTable::setSorting(false); |
QTable::setSorting(false); |
791 |
QTable::setFocusStyle(QTable::FollowStyle); |
QTable::setFocusStyle(QTable::FollowStyle); |
792 |
QTable::setSelectionMode(QTable::SingleRow); |
QTable::setSelectionMode(QTable::NoSelection); |
793 |
// No vertical header. |
// No vertical header. |
794 |
QTable::verticalHeader()->hide(); |
QTable::verticalHeader()->hide(); |
795 |
QTable::setLeftMargin(0); |
QTable::setLeftMargin(0); |
831 |
} |
} |
832 |
|
|
833 |
// Those items shall have a proper pixmap... |
// Those items shall have a proper pixmap... |
834 |
|
QPixmap pmChannel = QPixmap::fromMimeSource("qsamplerChannel.png"); |
835 |
QPixmap pmDevice; |
QPixmap pmDevice; |
836 |
switch (pDevice->deviceType()) { |
switch (pDevice->deviceType()) { |
837 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
849 |
int iRow = 0; |
int iRow = 0; |
850 |
qsamplerChannelRoutingMap::ConstIterator iter; |
qsamplerChannelRoutingMap::ConstIterator iter; |
851 |
for (iter = routing.begin(); iter != routing.end(); ++iter) { |
for (iter = routing.begin(); iter != routing.end(); ++iter) { |
852 |
QTable::setPixmap(iRow, 0, pmDevice); |
QTable::setPixmap(iRow, 0, pmChannel); |
853 |
QTable::setText(iRow, 0, pDevice->deviceTypeName() |
QTable::setText(iRow, 0, pDevice->deviceTypeName() |
854 |
+ ' ' + QString::number(iter.key())); |
+ ' ' + QString::number(iter.key())); |
855 |
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
qsamplerChannelRoutingComboBox *pComboItem = |
856 |
|
new qsamplerChannelRoutingComboBox(this, opts, pmDevice); |
857 |
pComboItem->setCurrentItem(iter.data()); |
pComboItem->setCurrentItem(iter.data()); |
858 |
QTable::setItem(iRow, 1, pComboItem); |
QTable::setItem(iRow, 1, pComboItem); |
859 |
++iRow; |
++iRow; |
868 |
} |
} |
869 |
|
|
870 |
|
|
871 |
|
// Commit any pending editing. |
872 |
|
void qsamplerChannelRoutingTable::flush (void) |
873 |
|
{ |
874 |
|
if (QTable::isEditing()) |
875 |
|
QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true); |
876 |
|
} |
877 |
|
|
878 |
|
|
879 |
|
//------------------------------------------------------------------------- |
880 |
|
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
881 |
|
// |
882 |
|
|
883 |
|
// Constructor. |
884 |
|
qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox ( |
885 |
|
QTable *pTable, const QStringList& list, const QPixmap& pixmap ) |
886 |
|
: QTableItem(pTable, QTableItem::WhenCurrent, QString::null, pixmap), |
887 |
|
m_list(list) |
888 |
|
{ |
889 |
|
m_iCurrentItem = 0; |
890 |
|
} |
891 |
|
|
892 |
|
// Public accessors. |
893 |
|
void qsamplerChannelRoutingComboBox::setCurrentItem ( int iCurrentItem ) |
894 |
|
{ |
895 |
|
m_iCurrentItem = iCurrentItem; |
896 |
|
|
897 |
|
QTableItem::setText(m_list[iCurrentItem]); |
898 |
|
} |
899 |
|
|
900 |
|
int qsamplerChannelRoutingComboBox::currentItem (void) const |
901 |
|
{ |
902 |
|
return m_iCurrentItem; |
903 |
|
} |
904 |
|
|
905 |
|
// Virtual implemetations. |
906 |
|
QWidget *qsamplerChannelRoutingComboBox::createEditor (void) const |
907 |
|
{ |
908 |
|
QComboBox *pComboBox = new QComboBox(QTableItem::table()->viewport()); |
909 |
|
QObject::connect(pComboBox, SIGNAL(activated(int)), |
910 |
|
QTableItem::table(), SLOT(doValueChanged())); |
911 |
|
for (QStringList::ConstIterator iter = m_list.begin(); |
912 |
|
iter != m_list.end(); iter++) { |
913 |
|
pComboBox->insertItem(QTableItem::pixmap(), *iter); |
914 |
|
} |
915 |
|
pComboBox->setCurrentItem(m_iCurrentItem); |
916 |
|
return pComboBox; |
917 |
|
} |
918 |
|
|
919 |
|
void qsamplerChannelRoutingComboBox::setContentFromEditor ( QWidget *pWidget ) |
920 |
|
{ |
921 |
|
if (pWidget->inherits("QComboBox")) { |
922 |
|
QComboBox *pComboBox = (QComboBox *) pWidget; |
923 |
|
m_iCurrentItem = pComboBox->currentItem(); |
924 |
|
QTableItem::setText(pComboBox->currentText()); |
925 |
|
} |
926 |
|
else QTableItem::setContentFromEditor(pWidget); |
927 |
|
} |
928 |
|
|
929 |
|
|
930 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |