--- qsampler/trunk/src/qsamplerChannel.cpp 2005/08/28 00:31:34 758 +++ qsampler/trunk/src/qsamplerChannel.cpp 2006/09/24 12:47:51 920 @@ -1,7 +1,7 @@ // qsamplerChannel.cpp // /**************************************************************************** - Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *****************************************************************************/ @@ -26,12 +26,13 @@ #include "qsamplerChannelForm.h" #include +#include #ifdef CONFIG_LIBGIG #include "gig.h" #endif -#define QSAMPLER_INSTRUMENT_MAX 8 +#define QSAMPLER_INSTRUMENT_MAX 100 //------------------------------------------------------------------------- @@ -788,7 +789,7 @@ QTable::setShowGrid(false); QTable::setSorting(false); QTable::setFocusStyle(QTable::FollowStyle); - QTable::setSelectionMode(QTable::SingleRow); + QTable::setSelectionMode(QTable::NoSelection); // No vertical header. QTable::verticalHeader()->hide(); QTable::setLeftMargin(0); @@ -830,6 +831,7 @@ } // Those items shall have a proper pixmap... + QPixmap pmChannel = QPixmap::fromMimeSource("qsamplerChannel.png"); QPixmap pmDevice; switch (pDevice->deviceType()) { case qsamplerDevice::Audio: @@ -847,10 +849,11 @@ int iRow = 0; qsamplerChannelRoutingMap::ConstIterator iter; for (iter = routing.begin(); iter != routing.end(); ++iter) { - QTable::setPixmap(iRow, 0, pmDevice); + QTable::setPixmap(iRow, 0, pmChannel); QTable::setText(iRow, 0, pDevice->deviceTypeName() + ' ' + QString::number(iter.key())); - QComboTableItem *pComboItem = new QComboTableItem(this, opts); + qsamplerChannelRoutingComboBox *pComboItem = + new qsamplerChannelRoutingComboBox(this, opts, pmDevice); pComboItem->setCurrentItem(iter.data()); QTable::setItem(iRow, 1, pComboItem); ++iRow; @@ -865,4 +868,63 @@ } +// Commit any pending editing. +void qsamplerChannelRoutingTable::flush (void) +{ + if (QTable::isEditing()) + QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true); +} + + +//------------------------------------------------------------------------- +// qsamplerChannelRoutingComboBox - Custom combo box for routing table. +// + +// Constructor. +qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox ( + QTable *pTable, const QStringList& list, const QPixmap& pixmap ) + : QTableItem(pTable, QTableItem::WhenCurrent, QString::null, pixmap), + m_list(list) +{ + m_iCurrentItem = 0; +} + +// Public accessors. +void qsamplerChannelRoutingComboBox::setCurrentItem ( int iCurrentItem ) +{ + m_iCurrentItem = iCurrentItem; + + QTableItem::setText(m_list[iCurrentItem]); +} + +int qsamplerChannelRoutingComboBox::currentItem (void) const +{ + return m_iCurrentItem; +} + +// Virtual implemetations. +QWidget *qsamplerChannelRoutingComboBox::createEditor (void) const +{ + QComboBox *pComboBox = new QComboBox(QTableItem::table()->viewport()); + QObject::connect(pComboBox, SIGNAL(activated(int)), + QTableItem::table(), SLOT(doValueChanged())); + for (QStringList::ConstIterator iter = m_list.begin(); + iter != m_list.end(); iter++) { + pComboBox->insertItem(QTableItem::pixmap(), *iter); + } + pComboBox->setCurrentItem(m_iCurrentItem); + return pComboBox; +} + +void qsamplerChannelRoutingComboBox::setContentFromEditor ( QWidget *pWidget ) +{ + if (pWidget->inherits("QComboBox")) { + QComboBox *pComboBox = (QComboBox *) pWidget; + m_iCurrentItem = pComboBox->currentItem(); + QTableItem::setText(pComboBox->currentText()); + } + else QTableItem::setContentFromEditor(pWidget); +} + + // end of qsamplerChannel.cpp