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 |
} |
} |
910 |
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
// ChannelRoutingModel - data model for audio routing (used for QTableView) |
911 |
// |
// |
912 |
|
|
913 |
ChannelRoutingModel::ChannelRoutingModel(QObject* parent) : QAbstractTableModel(parent), pDevice(NULL) { |
ChannelRoutingModel::ChannelRoutingModel ( QObject *pParent ) |
914 |
|
: QAbstractTableModel(pParent), m_pDevice(NULL) |
915 |
|
{ |
916 |
} |
} |
917 |
|
|
918 |
int ChannelRoutingModel::rowCount(const QModelIndex& /*parent*/) const { |
|
919 |
return routing.size(); |
int ChannelRoutingModel::rowCount ( const QModelIndex& /*parent*/) const |
920 |
|
{ |
921 |
|
return m_routing.size(); |
922 |
} |
} |
923 |
|
|
924 |
int ChannelRoutingModel::columnCount(const QModelIndex& /*parent*/) const { |
|
925 |
return 1; |
int ChannelRoutingModel::columnCount ( const QModelIndex& /*parent*/) const |
926 |
|
{ |
927 |
|
return 1; |
928 |
} |
} |
929 |
|
|
930 |
Qt::ItemFlags ChannelRoutingModel::flags(const QModelIndex& /*index*/) const { |
|
931 |
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; |
Qt::ItemFlags ChannelRoutingModel::flags ( const QModelIndex& /*index*/) const |
932 |
|
{ |
933 |
|
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled; |
934 |
} |
} |
935 |
|
|
|
bool ChannelRoutingModel::setData(const QModelIndex& index, const QVariant& value, int /*role*/) { |
|
|
if (!index.isValid()) { |
|
|
return false; |
|
|
} |
|
936 |
|
|
937 |
routing[index.row()] = value.toInt(); |
bool ChannelRoutingModel::setData ( const QModelIndex& index, |
938 |
|
const QVariant& value, int /*role*/) |
939 |
|
{ |
940 |
|
if (!index.isValid()) |
941 |
|
return false; |
942 |
|
|
943 |
|
m_routing[index.row()] = value.toInt(); |
944 |
|
|
945 |
emit dataChanged(index, index); |
emit dataChanged(index, index); |
946 |
return true; |
return true; |
947 |
} |
} |
948 |
|
|
|
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(); |
|
949 |
|
|
950 |
ChannelRoutingItem item; |
QVariant ChannelRoutingModel::data ( const QModelIndex &index, int role ) const |
951 |
|
{ |
952 |
|
if (!index.isValid()) |
953 |
|
return QVariant(); |
954 |
|
if (role != Qt::DisplayRole) |
955 |
|
return QVariant(); |
956 |
|
if (index.column() != 0) |
957 |
|
return QVariant(); |
958 |
|
|
959 |
|
ChannelRoutingItem item; |
960 |
|
|
961 |
// The common device port item list. |
// The common device port item list. |
962 |
qsamplerDevicePortList& ports = pDevice->ports(); |
qsamplerDevicePortList& ports = m_pDevice->ports(); |
963 |
QListIterator<qsamplerDevicePort *> iter(ports); |
QListIterator<qsamplerDevicePort *> iter(ports); |
964 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
965 |
qsamplerDevicePort *pPort = iter.next(); |
qsamplerDevicePort *pPort = iter.next(); |
966 |
item.options.append( |
item.options.append( |
967 |
pDevice->deviceTypeName() |
m_pDevice->deviceTypeName() |
968 |
+ ' ' + pDevice->driverName() |
+ ' ' + m_pDevice->driverName() |
969 |
+ ' ' + pPort->portName() |
+ ' ' + pPort->portName() |
970 |
); |
); |
971 |
} |
} |
972 |
|
|
973 |
item.selection = routing[index.row()]; |
item.selection = m_routing[index.row()]; |
974 |
|
|
975 |
return QVariant::fromValue(item); |
return QVariant::fromValue(item); |
976 |
} |
} |
977 |
|
|
978 |
QVariant ChannelRoutingModel::headerData(int section, Qt::Orientation orientation, int role) const { |
|
979 |
if (role != Qt::DisplayRole) return QVariant(); |
QVariant ChannelRoutingModel::headerData ( int section, |
980 |
|
Qt::Orientation orientation, int role) const |
981 |
switch (orientation) { |
{ |
982 |
case Qt::Horizontal: |
if (role != Qt::DisplayRole) |
983 |
return UNICODE_RIGHT_ARROW + QObject::tr(" Device Channel"); |
return QVariant(); |
984 |
case Qt::Vertical: |
|
985 |
return QObject::tr("Sampler Channel ") + |
switch (orientation) { |
986 |
QString::number(section) + " " + UNICODE_RIGHT_ARROW; |
case Qt::Horizontal: |
987 |
default: |
return UNICODE_RIGHT_ARROW + QObject::tr(" Device Channel"); |
988 |
return QVariant(); |
case Qt::Vertical: |
989 |
} |
return QObject::tr("Sampler Channel ") + |
990 |
|
QString::number(section) + " " + UNICODE_RIGHT_ARROW; |
991 |
|
default: |
992 |
|
return QVariant(); |
993 |
|
} |
994 |
} |
} |
995 |
|
|
996 |
|
|
997 |
void ChannelRoutingModel::refresh ( qsamplerDevice *pDevice, |
void ChannelRoutingModel::refresh ( qsamplerDevice *pDevice, |
998 |
const qsamplerChannelRoutingMap& routing ) |
const qsamplerChannelRoutingMap& routing ) |
999 |
{ |
{ |
1000 |
this->pDevice = pDevice; |
m_pDevice = pDevice; |
1001 |
this->routing = routing; |
m_routing = routing; |
1002 |
// inform the outer world (QTableView) that our data changed |
// inform the outer world (QTableView) that our data changed |
1003 |
QAbstractTableModel::reset(); |
QAbstractTableModel::reset(); |
1004 |
} |
} |
1005 |
|
|
1006 |
|
|
1008 |
// ChannelRoutingDelegate - table cell renderer for audio routing |
// ChannelRoutingDelegate - table cell renderer for audio routing |
1009 |
// |
// |
1010 |
|
|
1011 |
ChannelRoutingDelegate::ChannelRoutingDelegate(QObject *parent) : QItemDelegate(parent) { |
ChannelRoutingDelegate::ChannelRoutingDelegate ( QObject *pParent ) |
1012 |
|
: QItemDelegate(pParent) |
1013 |
|
{ |
1014 |
} |
} |
1015 |
|
|
1016 |
QWidget* ChannelRoutingDelegate::createEditor(QWidget *parent, |
|
1017 |
const QStyleOptionViewItem & option , |
QWidget* ChannelRoutingDelegate::createEditor ( QWidget *pParent, |
1018 |
const QModelIndex& index) const |
const QStyleOptionViewItem & option, const QModelIndex& index ) const |
1019 |
{ |
{ |
1020 |
if (!index.isValid()) { |
if (!index.isValid()) |
1021 |
return NULL; |
return NULL; |
|
} |
|
1022 |
|
|
1023 |
if (index.column() != 0) { |
if (index.column() != 0) |
1024 |
return NULL; |
return NULL; |
|
} |
|
1025 |
|
|
1026 |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
1027 |
|
|
1028 |
QComboBox* pComboBox = new QComboBox(parent); |
QComboBox* pComboBox = new QComboBox(pParent); |
1029 |
pComboBox->addItems(item.options); |
pComboBox->addItems(item.options); |
1030 |
pComboBox->setCurrentIndex(item.selection); |
pComboBox->setCurrentIndex(item.selection); |
1031 |
pComboBox->setEnabled(true); |
pComboBox->setEnabled(true); |
1032 |
pComboBox->setGeometry(option.rect); |
pComboBox->setGeometry(option.rect); |
1033 |
return pComboBox; |
return pComboBox; |
1034 |
} |
} |
1035 |
|
|
1036 |
void ChannelRoutingDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { |
|
1037 |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
void ChannelRoutingDelegate::setEditorData ( QWidget *pEditor, |
1038 |
QComboBox* comboBox = static_cast<QComboBox*>(editor); |
const QModelIndex &index) const |
1039 |
comboBox->setCurrentIndex(item.selection); |
{ |
1040 |
|
ChannelRoutingItem item = index.model()->data(index, |
1041 |
|
Qt::DisplayRole).value<ChannelRoutingItem> (); |
1042 |
|
QComboBox* pComboBox = static_cast<QComboBox*> (pEditor); |
1043 |
|
pComboBox->setCurrentIndex(item.selection); |
1044 |
} |
} |
1045 |
|
|
1046 |
void ChannelRoutingDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { |
|
1047 |
QComboBox* comboBox = static_cast<QComboBox*>(editor); |
void ChannelRoutingDelegate::setModelData ( QWidget* pEditor, |
1048 |
model->setData(index, comboBox->currentIndex()); |
QAbstractItemModel *pModel, const QModelIndex& index ) const |
1049 |
|
{ |
1050 |
|
QComboBox *pComboBox = static_cast<QComboBox*> (pEditor); |
1051 |
|
pModel->setData(index, pComboBox->currentIndex()); |
1052 |
} |
} |
1053 |
|
|
1054 |
void ChannelRoutingDelegate::updateEditorGeometry(QWidget *editor, |
|
1055 |
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const |
void ChannelRoutingDelegate::updateEditorGeometry ( QWidget *pEditor, |
1056 |
|
const QStyleOptionViewItem& option, const QModelIndex &/* index */) const |
1057 |
{ |
{ |
1058 |
editor->setGeometry(option.rect); |
pEditor->setGeometry(option.rect); |
1059 |
} |
} |
1060 |
|
|
1061 |
|
|
1062 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |