62 |
m_iMidiMap = -1; |
m_iMidiMap = -1; |
63 |
m_sAudioDriver = "ALSA"; |
m_sAudioDriver = "ALSA"; |
64 |
m_iAudioDevice = -1; |
m_iAudioDevice = -1; |
65 |
m_fVolume = 0.0; |
m_fVolume = 0.0f; |
66 |
m_bMute = false; |
m_bMute = false; |
67 |
m_bSolo = false; |
m_bSolo = false; |
68 |
} |
} |
835 |
RIFF::File *pRiff |
RIFF::File *pRiff |
836 |
= new RIFF::File(sInstrumentFile.toUtf8().constData()); |
= new RIFF::File(sInstrumentFile.toUtf8().constData()); |
837 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
838 |
|
#if HAVE_LIBGIG_SETAUTOLOAD |
839 |
|
// prevent sleepy response time on large .gig files |
840 |
|
pGig->SetAutoLoad(false); |
841 |
|
#endif |
842 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
843 |
while (pInstrument) { |
while (pInstrument) { |
844 |
instlist.append((pInstrument->pInfo)->Name.c_str()); |
instlist.append((pInstrument->pInfo)->Name.c_str()); |
871 |
RIFF::File *pRiff |
RIFF::File *pRiff |
872 |
= new RIFF::File(sInstrumentFile.toUtf8().constData()); |
= new RIFF::File(sInstrumentFile.toUtf8().constData()); |
873 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
874 |
|
#if HAVE_LIBGIG_SETAUTOLOAD |
875 |
|
// prevent sleepy response time on large .gig files |
876 |
|
pGig->SetAutoLoad(false); |
877 |
|
#endif |
878 |
int iIndex = 0; |
int iIndex = 0; |
879 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
880 |
while (pInstrument) { |
while (pInstrument) { |
918 |
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
919 |
// |
// |
920 |
|
|
921 |
ChannelRoutingModel::ChannelRoutingModel(QObject* parent) : QAbstractTableModel(parent), pDevice(NULL) { |
ChannelRoutingModel::ChannelRoutingModel ( QObject *pParent ) |
922 |
|
: QAbstractTableModel(pParent), m_pDevice(NULL) |
923 |
|
{ |
924 |
} |
} |
925 |
|
|
926 |
int ChannelRoutingModel::rowCount(const QModelIndex& /*parent*/) const { |
|
927 |
return routing.size(); |
int ChannelRoutingModel::rowCount ( const QModelIndex& /*parent*/) const |
928 |
|
{ |
929 |
|
return m_routing.size(); |
930 |
} |
} |
931 |
|
|
932 |
int ChannelRoutingModel::columnCount(const QModelIndex& /*parent*/) const { |
|
933 |
return 1; |
int ChannelRoutingModel::columnCount ( const QModelIndex& /*parent*/) const |
934 |
|
{ |
935 |
|
return 1; |
936 |
} |
} |
937 |
|
|
938 |
Qt::ItemFlags ChannelRoutingModel::flags(const QModelIndex& /*index*/) const { |
|
939 |
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; |
Qt::ItemFlags ChannelRoutingModel::flags ( const QModelIndex& /*index*/) const |
940 |
|
{ |
941 |
|
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; |
942 |
} |
} |
943 |
|
|
|
bool ChannelRoutingModel::setData(const QModelIndex& index, const QVariant& value, int /*role*/) { |
|
|
if (!index.isValid()) { |
|
|
return false; |
|
|
} |
|
944 |
|
|
945 |
routing[index.row()] = value.toInt(); |
bool ChannelRoutingModel::setData ( const QModelIndex& index, |
946 |
|
const QVariant& value, int /*role*/) |
947 |
|
{ |
948 |
|
if (!index.isValid()) |
949 |
|
return false; |
950 |
|
|
951 |
emit dataChanged(index, index); |
m_routing[index.row()] = value.toInt(); |
952 |
return true; |
|
953 |
|
emit dataChanged(index, index); |
954 |
|
return true; |
955 |
} |
} |
956 |
|
|
|
QVariant ChannelRoutingModel::data(const QModelIndex &index, int role) const { |
|
|
if (!index.isValid()) |
|
|
return QVariant(); |
|
|
if (role != Qt::DisplayRole) |
|
|
return QVariant(); |
|
|
if (index.column() != 0) |
|
|
return QVariant(); |
|
957 |
|
|
958 |
ChannelRoutingItem item; |
QVariant ChannelRoutingModel::data ( const QModelIndex &index, int role ) const |
959 |
|
{ |
960 |
|
if (!index.isValid()) |
961 |
|
return QVariant(); |
962 |
|
if (role != Qt::DisplayRole) |
963 |
|
return QVariant(); |
964 |
|
if (index.column() != 0) |
965 |
|
return QVariant(); |
966 |
|
|
967 |
|
ChannelRoutingItem item; |
968 |
|
|
969 |
// The common device port item list. |
// The common device port item list. |
970 |
qsamplerDevicePortList& ports = pDevice->ports(); |
qsamplerDevicePortList& ports = m_pDevice->ports(); |
971 |
QListIterator<qsamplerDevicePort *> iter(ports); |
QListIterator<qsamplerDevicePort *> iter(ports); |
972 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
973 |
qsamplerDevicePort *pPort = iter.next(); |
qsamplerDevicePort *pPort = iter.next(); |
974 |
item.options.append( |
item.options.append( |
975 |
pDevice->deviceTypeName() |
m_pDevice->deviceTypeName() |
976 |
+ ' ' + pDevice->driverName() |
+ ' ' + m_pDevice->driverName() |
977 |
+ ' ' + pPort->portName() |
+ ' ' + pPort->portName() |
978 |
); |
); |
979 |
} |
} |
980 |
|
|
981 |
item.selection = routing[index.row()]; |
item.selection = m_routing[index.row()]; |
982 |
|
|
983 |
return QVariant::fromValue(item); |
return QVariant::fromValue(item); |
|
} |
|
|
|
|
|
QVariant ChannelRoutingModel::headerData(int section, Qt::Orientation orientation, int role) const { |
|
|
if (role != Qt::DisplayRole) return QVariant(); |
|
|
|
|
|
switch (orientation) { |
|
|
case Qt::Horizontal: |
|
|
return UNICODE_RIGHT_ARROW + QObject::tr(" Device Channel"); |
|
|
case Qt::Vertical: |
|
|
return QObject::tr("Sampler Channel ") + |
|
|
QString::number(section) + " " + UNICODE_RIGHT_ARROW; |
|
|
default: |
|
|
return QVariant(); |
|
|
} |
|
984 |
} |
} |
985 |
|
|
986 |
|
|
987 |
|
QVariant ChannelRoutingModel::headerData ( int section, |
988 |
|
Qt::Orientation orientation, int role) const |
989 |
|
{ |
990 |
|
if (role != Qt::DisplayRole) |
991 |
|
return QVariant(); |
992 |
|
|
993 |
|
switch (orientation) { |
994 |
|
case Qt::Horizontal: |
995 |
|
return UNICODE_RIGHT_ARROW + QObject::tr(" Device Channel"); |
996 |
|
case Qt::Vertical: |
997 |
|
return QObject::tr("Sampler Channel ") + |
998 |
|
QString::number(section) + " " + UNICODE_RIGHT_ARROW; |
999 |
|
default: |
1000 |
|
return QVariant(); |
1001 |
|
} |
1002 |
|
} |
1003 |
|
|
1004 |
|
|
1005 |
void ChannelRoutingModel::refresh ( qsamplerDevice *pDevice, |
void ChannelRoutingModel::refresh ( qsamplerDevice *pDevice, |
1006 |
const qsamplerChannelRoutingMap& routing ) |
const qsamplerChannelRoutingMap& routing ) |
1007 |
{ |
{ |
1008 |
this->pDevice = pDevice; |
m_pDevice = pDevice; |
1009 |
this->routing = routing; |
m_routing = routing; |
1010 |
// inform the outer world (QTableView) that our data changed |
// inform the outer world (QTableView) that our data changed |
1011 |
QAbstractTableModel::reset(); |
QAbstractTableModel::reset(); |
1012 |
} |
} |
1013 |
|
|
1014 |
|
|
1016 |
// ChannelRoutingDelegate - table cell renderer for audio routing |
// ChannelRoutingDelegate - table cell renderer for audio routing |
1017 |
// |
// |
1018 |
|
|
1019 |
ChannelRoutingDelegate::ChannelRoutingDelegate(QObject *parent) : QItemDelegate(parent) { |
ChannelRoutingDelegate::ChannelRoutingDelegate ( QObject *pParent ) |
1020 |
|
: QItemDelegate(pParent) |
1021 |
|
{ |
1022 |
} |
} |
1023 |
|
|
1024 |
QWidget* ChannelRoutingDelegate::createEditor(QWidget *parent, |
|
1025 |
const QStyleOptionViewItem & option , |
QWidget* ChannelRoutingDelegate::createEditor ( QWidget *pParent, |
1026 |
const QModelIndex& index) const |
const QStyleOptionViewItem & option, const QModelIndex& index ) const |
1027 |
{ |
{ |
1028 |
if (!index.isValid()) { |
if (!index.isValid()) |
1029 |
return NULL; |
return NULL; |
|
} |
|
1030 |
|
|
1031 |
if (index.column() != 0) { |
if (index.column() != 0) |
1032 |
return NULL; |
return NULL; |
|
} |
|
1033 |
|
|
1034 |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
1035 |
|
|
1036 |
QComboBox* pComboBox = new QComboBox(parent); |
QComboBox* pComboBox = new QComboBox(pParent); |
1037 |
pComboBox->addItems(item.options); |
pComboBox->addItems(item.options); |
1038 |
pComboBox->setCurrentIndex(item.selection); |
pComboBox->setCurrentIndex(item.selection); |
1039 |
pComboBox->setEnabled(true); |
pComboBox->setEnabled(true); |
1040 |
pComboBox->setGeometry(option.rect); |
pComboBox->setGeometry(option.rect); |
1041 |
return pComboBox; |
return pComboBox; |
1042 |
} |
} |
1043 |
|
|
1044 |
void ChannelRoutingDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { |
|
1045 |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
void ChannelRoutingDelegate::setEditorData ( QWidget *pEditor, |
1046 |
QComboBox* comboBox = static_cast<QComboBox*>(editor); |
const QModelIndex &index) const |
1047 |
comboBox->setCurrentIndex(item.selection); |
{ |
1048 |
|
ChannelRoutingItem item = index.model()->data(index, |
1049 |
|
Qt::DisplayRole).value<ChannelRoutingItem> (); |
1050 |
|
QComboBox* pComboBox = static_cast<QComboBox*> (pEditor); |
1051 |
|
pComboBox->setCurrentIndex(item.selection); |
1052 |
} |
} |
1053 |
|
|
1054 |
void ChannelRoutingDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { |
|
1055 |
QComboBox* comboBox = static_cast<QComboBox*>(editor); |
void ChannelRoutingDelegate::setModelData ( QWidget* pEditor, |
1056 |
model->setData(index, comboBox->currentIndex()); |
QAbstractItemModel *pModel, const QModelIndex& index ) const |
1057 |
|
{ |
1058 |
|
QComboBox *pComboBox = static_cast<QComboBox*> (pEditor); |
1059 |
|
pModel->setData(index, pComboBox->currentIndex()); |
1060 |
} |
} |
1061 |
|
|
1062 |
void ChannelRoutingDelegate::updateEditorGeometry(QWidget *editor, |
|
1063 |
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const |
void ChannelRoutingDelegate::updateEditorGeometry ( QWidget *pEditor, |
1064 |
|
const QStyleOptionViewItem& option, const QModelIndex &/* index */) const |
1065 |
{ |
{ |
1066 |
editor->setGeometry(option.rect); |
pEditor->setGeometry(option.rect); |
1067 |
} |
} |
1068 |
|
|
1069 |
|
|
1070 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |