2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-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 |
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 "qsamplerUtilities.h" |
24 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
25 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
26 |
|
|
36 |
|
|
37 |
#define QSAMPLER_INSTRUMENT_MAX 100 |
#define QSAMPLER_INSTRUMENT_MAX 100 |
38 |
|
|
39 |
|
using namespace QSampler; |
40 |
|
|
41 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
42 |
// qsamplerChannel - Sampler channel structure. |
// qsamplerChannel - Sampler channel structure. |
73 |
// Create a new sampler channel, if not already. |
// Create a new sampler channel, if not already. |
74 |
bool qsamplerChannel::addChannel (void) |
bool qsamplerChannel::addChannel (void) |
75 |
{ |
{ |
76 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
77 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
78 |
return false; |
return false; |
79 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
98 |
// Remove sampler channel. |
// Remove sampler channel. |
99 |
bool qsamplerChannel::removeChannel (void) |
bool qsamplerChannel::removeChannel (void) |
100 |
{ |
{ |
101 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
102 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
103 |
return false; |
return false; |
104 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
148 |
|
|
149 |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
150 |
{ |
{ |
151 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
152 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
153 |
return false; |
return false; |
154 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
195 |
// Instrument file loader. |
// Instrument file loader. |
196 |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
197 |
{ |
{ |
198 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
199 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
200 |
return false; |
return false; |
201 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
205 |
if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr) |
if (m_iInstrumentStatus == 100 && m_sInstrumentFile == sInstrumentFile && m_iInstrumentNr == iInstrumentNr) |
206 |
return true; |
return true; |
207 |
|
|
208 |
if (::lscp_load_instrument_non_modal(pMainForm->client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
if ( |
209 |
|
::lscp_load_instrument_non_modal( |
210 |
|
pMainForm->client(), |
211 |
|
qsamplerUtilities::lscpEscapePath(sInstrumentFile).latin1(), |
212 |
|
iInstrumentNr, m_iChannelID |
213 |
|
) != LSCP_OK |
214 |
|
) { |
215 |
appendMessagesClient("lscp_load_instrument"); |
appendMessagesClient("lscp_load_instrument"); |
216 |
return false; |
return false; |
217 |
} |
} |
247 |
|
|
248 |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
249 |
{ |
{ |
250 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
251 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
252 |
return false; |
return false; |
253 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
275 |
|
|
276 |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
277 |
{ |
{ |
278 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
279 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
280 |
return false; |
return false; |
281 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
303 |
|
|
304 |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
305 |
{ |
{ |
306 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
307 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
308 |
return false; |
return false; |
309 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
331 |
|
|
332 |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
333 |
{ |
{ |
334 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
335 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
336 |
return false; |
return false; |
337 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
359 |
|
|
360 |
bool qsamplerChannel::setMidiMap ( int iMidiMap ) |
bool qsamplerChannel::setMidiMap ( int iMidiMap ) |
361 |
{ |
{ |
362 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
363 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
364 |
return false; |
return false; |
365 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
387 |
|
|
388 |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
389 |
{ |
{ |
390 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
391 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
392 |
return false; |
return false; |
393 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
415 |
|
|
416 |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
417 |
{ |
{ |
418 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
419 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
420 |
return false; |
return false; |
421 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
443 |
|
|
444 |
bool qsamplerChannel::setVolume ( float fVolume ) |
bool qsamplerChannel::setVolume ( float fVolume ) |
445 |
{ |
{ |
446 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
447 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
448 |
return false; |
return false; |
449 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
471 |
|
|
472 |
bool qsamplerChannel::setChannelMute ( bool bMute ) |
bool qsamplerChannel::setChannelMute ( bool bMute ) |
473 |
{ |
{ |
474 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
475 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
476 |
return false; |
return false; |
477 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
501 |
|
|
502 |
bool qsamplerChannel::setChannelSolo ( bool bSolo ) |
bool qsamplerChannel::setChannelSolo ( bool bSolo ) |
503 |
{ |
{ |
504 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
505 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
506 |
return false; |
return false; |
507 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
531 |
|
|
532 |
bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
533 |
{ |
{ |
534 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
535 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
536 |
return false; |
return false; |
537 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
573 |
// Update whole channel info state. |
// Update whole channel info state. |
574 |
bool qsamplerChannel::updateChannelInfo (void) |
bool qsamplerChannel::updateChannelInfo (void) |
575 |
{ |
{ |
576 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
577 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
578 |
return false; |
return false; |
579 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
589 |
|
|
590 |
#ifdef CONFIG_INSTRUMENT_NAME |
#ifdef CONFIG_INSTRUMENT_NAME |
591 |
// We got all actual instrument datum... |
// We got all actual instrument datum... |
592 |
m_sInstrumentFile = pChannelInfo->instrument_file; |
m_sInstrumentFile = |
593 |
|
qsamplerUtilities::lscpEscapedPathToPosix(pChannelInfo->instrument_file); |
594 |
m_iInstrumentNr = pChannelInfo->instrument_nr; |
m_iInstrumentNr = pChannelInfo->instrument_nr; |
595 |
m_sInstrumentName = pChannelInfo->instrument_name; |
m_sInstrumentName = |
596 |
|
qsamplerUtilities::lscpEscapedTextToRaw(pChannelInfo->instrument_name); |
597 |
#else |
#else |
598 |
// First, check if intrument name has changed, |
// First, check if intrument name has changed, |
599 |
// taking care that instrument name lookup might be expensive, |
// taking care that instrument name lookup might be expensive, |
667 |
// Reset channel method. |
// Reset channel method. |
668 |
bool qsamplerChannel::channelReset (void) |
bool qsamplerChannel::channelReset (void) |
669 |
{ |
{ |
670 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
671 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
672 |
return false; |
return false; |
673 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
688 |
bool qsamplerChannel::editChannel (void) |
bool qsamplerChannel::editChannel (void) |
689 |
{ |
{ |
690 |
#ifdef CONFIG_EDIT_INSTRUMENT |
#ifdef CONFIG_EDIT_INSTRUMENT |
691 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
|
692 |
|
MainForm *pMainForm = MainForm::getInstance(); |
693 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
694 |
return false; |
return false; |
695 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
696 |
return false; |
return false; |
697 |
|
|
698 |
if (::lscp_edit_instrument(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
if (::lscp_edit_channel_instrument(pMainForm->client(), m_iChannelID) |
699 |
appendMessagesClient("lscp_edit_instrument"); |
!= LSCP_OK) { |
700 |
appendMessagesError( |
appendMessagesClient("lscp_edit_channel_instrument"); |
701 |
"Could not launch an appropriate instrument editor for the\n" |
appendMessagesError(QObject::tr( |
702 |
"given instrument! Make sure you have an appropriate\n" |
"Could not launch an appropriate instrument editor " |
703 |
"instrument editor like 'gigedit' installed and that it placed\n" |
"for the given instrument!\n" |
704 |
"its mandatory DLL file into the sampler's plugin directory." |
"Make sure you have an appropriate " |
705 |
|
"instrument editor like 'gigedit' installed\n" |
706 |
|
"and that it placed its mandatory DLL file " |
707 |
|
"into the sampler's plugin directory.") |
708 |
); |
); |
709 |
return false; |
return false; |
710 |
} |
} |
712 |
appendMessages(QObject::tr("edit instrument.")); |
appendMessages(QObject::tr("edit instrument.")); |
713 |
|
|
714 |
return true; |
return true; |
715 |
|
|
716 |
#else |
#else |
717 |
appendMessagesError( |
|
718 |
"Sorry, QSampler was compiled for a version of liblscp which lacks\n" |
appendMessagesError(QObject::tr( |
719 |
"this feature. You may want to update liblscp and recompile\n" |
"Sorry, QSampler was compiled for a version of liblscp " |
720 |
"QSampler afterwards." |
"which lacks this feature.\n" |
721 |
|
"You may want to update liblscp and recompile QSampler afterwards.") |
722 |
); |
); |
723 |
|
|
724 |
return false; |
return false; |
725 |
|
|
726 |
#endif |
#endif |
727 |
} |
} |
728 |
|
|
730 |
// Channel setup dialog form. |
// Channel setup dialog form. |
731 |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
732 |
{ |
{ |
733 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
734 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
735 |
return false; |
return false; |
736 |
|
|
738 |
|
|
739 |
appendMessages(QObject::tr("setup...")); |
appendMessages(QObject::tr("setup...")); |
740 |
|
|
741 |
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
ChannelForm *pChannelForm = new ChannelForm(pParent); |
742 |
if (pChannelForm) { |
if (pChannelForm) { |
743 |
pChannelForm->setup(this); |
pChannelForm->setup(this); |
744 |
bResult = pChannelForm->exec(); |
bResult = pChannelForm->exec(); |
752 |
// Redirected messages output methods. |
// Redirected messages output methods. |
753 |
void qsamplerChannel::appendMessages( const QString& s ) const |
void qsamplerChannel::appendMessages( const QString& s ) const |
754 |
{ |
{ |
755 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
756 |
if (pMainForm) |
if (pMainForm) |
757 |
pMainForm->appendMessages(channelName() + ' ' + s); |
pMainForm->appendMessages(channelName() + ' ' + s); |
758 |
} |
} |
760 |
void qsamplerChannel::appendMessagesColor( const QString& s, |
void qsamplerChannel::appendMessagesColor( const QString& s, |
761 |
const QString& c ) const |
const QString& c ) const |
762 |
{ |
{ |
763 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
764 |
if (pMainForm) |
if (pMainForm) |
765 |
pMainForm->appendMessagesColor(channelName() + ' ' + s, c); |
pMainForm->appendMessagesColor(channelName() + ' ' + s, c); |
766 |
} |
} |
767 |
|
|
768 |
void qsamplerChannel::appendMessagesText( const QString& s ) const |
void qsamplerChannel::appendMessagesText( const QString& s ) const |
769 |
{ |
{ |
770 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
771 |
if (pMainForm) |
if (pMainForm) |
772 |
pMainForm->appendMessagesText(channelName() + ' ' + s); |
pMainForm->appendMessagesText(channelName() + ' ' + s); |
773 |
} |
} |
774 |
|
|
775 |
void qsamplerChannel::appendMessagesError( const QString& s ) const |
void qsamplerChannel::appendMessagesError( const QString& s ) const |
776 |
{ |
{ |
777 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
778 |
if (pMainForm) |
if (pMainForm) |
779 |
pMainForm->appendMessagesError(channelName() + "\n\n" + s); |
pMainForm->appendMessagesError(channelName() + "\n\n" + s); |
780 |
} |
} |
781 |
|
|
782 |
void qsamplerChannel::appendMessagesClient( const QString& s ) const |
void qsamplerChannel::appendMessagesClient( const QString& s ) const |
783 |
{ |
{ |
784 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
785 |
if (pMainForm) |
if (pMainForm) |
786 |
pMainForm->appendMessagesClient(channelName() + ' ' + s); |
pMainForm->appendMessagesClient(channelName() + ' ' + s); |
787 |
} |
} |
790 |
// Context menu event handler. |
// Context menu event handler. |
791 |
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
792 |
{ |
{ |
793 |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
794 |
if (pMainForm) |
if (pMainForm) |
795 |
pMainForm->contextMenuEvent(pEvent); |
pMainForm->contextMenuEvent(pEvent); |
796 |
} |
} |
901 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
902 |
// qsamplerChannelRoutingTable - Channel routing table. |
// qsamplerChannelRoutingTable - Channel routing table. |
903 |
// |
// |
904 |
|
#if 0 |
905 |
// Constructor. |
// Constructor. |
906 |
qsamplerChannelRoutingTable::qsamplerChannelRoutingTable ( |
qsamplerChannelRoutingTable::qsamplerChannelRoutingTable ( |
907 |
QWidget *pParent, const char *pszName ) |
QWidget *pParent, const char *pszName ) |
954 |
} |
} |
955 |
|
|
956 |
// Those items shall have a proper pixmap... |
// Those items shall have a proper pixmap... |
957 |
QPixmap pmChannel = QPixmap::fromMimeSource("qsamplerChannel.png"); |
QPixmap pmChannel = QPixmap(":/icons/qsamplerChannel.png"); |
958 |
QPixmap pmDevice; |
QPixmap pmDevice; |
959 |
switch (pDevice->deviceType()) { |
switch (pDevice->deviceType()) { |
960 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
961 |
pmDevice = QPixmap::fromMimeSource("audio2.png"); |
pmDevice = QPixmap(":/icons/audio2.png"); |
962 |
break; |
break; |
963 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
964 |
pmDevice = QPixmap::fromMimeSource("midi2.png"); |
pmDevice = QPixmap(":/icons/midi2.png"); |
965 |
break; |
break; |
966 |
case qsamplerDevice::None: |
case qsamplerDevice::None: |
967 |
break; |
break; |
997 |
if (QTable::isEditing()) |
if (QTable::isEditing()) |
998 |
QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true); |
QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true); |
999 |
} |
} |
1000 |
|
#endif |
1001 |
|
|
1002 |
|
ChannelRoutingModel::ChannelRoutingModel(QObject* parent) : QAbstractTableModel(parent), pDevice(NULL) { |
1003 |
|
} |
1004 |
|
|
1005 |
|
int ChannelRoutingModel::rowCount(const QModelIndex& /*parent*/) const { |
1006 |
|
return routing.size(); |
1007 |
|
} |
1008 |
|
|
1009 |
|
int ChannelRoutingModel::columnCount(const QModelIndex& /*parent*/) const { |
1010 |
|
return 1; |
1011 |
|
} |
1012 |
|
|
1013 |
|
QVariant ChannelRoutingModel::data(const QModelIndex &index, int role) const { |
1014 |
|
if (!index.isValid()) |
1015 |
|
return QVariant(); |
1016 |
|
if (role != Qt::DisplayRole) |
1017 |
|
return QVariant(); |
1018 |
|
|
1019 |
|
ChannelRoutingItem item; |
1020 |
|
|
1021 |
|
// The common device port item list. |
1022 |
|
qsamplerDevicePortList& ports = pDevice->ports(); |
1023 |
|
qsamplerDevicePort* pPort; |
1024 |
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
1025 |
|
item.options.append( |
1026 |
|
pDevice->deviceTypeName() |
1027 |
|
+ ' ' + pDevice->driverName() |
1028 |
|
+ ' ' + pPort->portName() |
1029 |
|
); |
1030 |
|
} |
1031 |
|
|
1032 |
|
item.selection = routing[index.column()]; |
1033 |
|
|
1034 |
|
return QVariant::fromValue(item); |
1035 |
|
} |
1036 |
|
|
1037 |
|
QVariant ChannelRoutingModel::headerData(int section, Qt::Orientation orientation, int role) const { |
1038 |
|
if (role != Qt::DisplayRole) return QVariant(); |
1039 |
|
|
1040 |
|
if (orientation == Qt::Horizontal) |
1041 |
|
return QObject::tr("Device Channel"); |
1042 |
|
|
1043 |
|
if (orientation == Qt::Vertical) |
1044 |
|
return QObject::tr("Sampler Channel Output ") + |
1045 |
|
QString(section); |
1046 |
|
|
1047 |
|
return QVariant(); |
1048 |
|
} |
1049 |
|
|
1050 |
|
void ChannelRoutingModel::refresh ( qsamplerDevice *pDevice, |
1051 |
|
const qsamplerChannelRoutingMap& routing ) |
1052 |
|
{ |
1053 |
|
this->pDevice = pDevice; |
1054 |
|
this->routing = routing; |
1055 |
|
} |
1056 |
|
|
1057 |
|
|
1058 |
|
|
1059 |
|
|
1060 |
|
ChannelRoutingDelegate::ChannelRoutingDelegate(QObject *parent) : QItemDelegate(parent) { |
1061 |
|
} |
1062 |
|
|
1063 |
|
QWidget* ChannelRoutingDelegate::createEditor(QWidget *parent, |
1064 |
|
const QStyleOptionViewItem &/* option */, |
1065 |
|
const QModelIndex& index) const |
1066 |
|
{ |
1067 |
|
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
1068 |
|
|
1069 |
|
QComboBox* editor = new QComboBox(parent); |
1070 |
|
editor->addItems(item.options); |
1071 |
|
editor->setCurrentIndex(item.selection); |
1072 |
|
editor->installEventFilter(const_cast<ChannelRoutingDelegate*>(this)); |
1073 |
|
return editor; |
1074 |
|
} |
1075 |
|
|
1076 |
|
void ChannelRoutingDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { |
1077 |
|
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
1078 |
|
QComboBox* comboBox = static_cast<QComboBox*>(editor); |
1079 |
|
comboBox->setCurrentIndex(item.selection); |
1080 |
|
} |
1081 |
|
|
1082 |
|
void ChannelRoutingDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { |
1083 |
|
QComboBox* comboBox = static_cast<QComboBox*>(editor); |
1084 |
|
model->setData(index, comboBox->currentIndex()); |
1085 |
|
} |
1086 |
|
|
1087 |
|
void ChannelRoutingDelegate::updateEditorGeometry(QWidget *editor, |
1088 |
|
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const |
1089 |
|
{ |
1090 |
|
editor->setGeometry(option.rect); |
1091 |
|
} |
1092 |
|
|
1093 |
|
|
1094 |
|
|
1095 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
1096 |
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
1097 |
// |
// |
1098 |
|
|
1099 |
|
#if 0 |
1100 |
// Constructor. |
// Constructor. |
1101 |
qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox ( |
qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox ( |
1102 |
QTable *pTable, const QStringList& list, const QPixmap& pixmap ) |
QTable *pTable, const QStringList& list, const QPixmap& pixmap ) |
1143 |
else QTableItem::setContentFromEditor(pWidget); |
else QTableItem::setContentFromEditor(pWidget); |
1144 |
} |
} |
1145 |
|
|
1146 |
|
#endif |
1147 |
|
|
1148 |
|
|
1149 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |