1 |
// qsamplerChannel.cpp |
// qsamplerChannel.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007, 2008 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 |
31 |
#include <QComboBox> |
#include <QComboBox> |
32 |
|
|
33 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
34 |
|
#if defined(Q_CC_GNU) || defined(Q_CC_MINGW) |
35 |
|
#pragma GCC diagnostic push |
36 |
|
#pragma GCC diagnostic ignored "-Wunused-parameter" |
37 |
|
#endif |
38 |
#include "gig.h" |
#include "gig.h" |
39 |
#ifdef CONFIG_LIBGIG_SF_H |
#ifdef CONFIG_LIBGIG_SF2 |
40 |
|
#pragma GCC diagnostic ignored "-Wunused-variable" |
41 |
#include "SF.h" |
#include "SF.h" |
42 |
#endif |
#endif |
43 |
|
#if defined(Q_CC_GNU) || defined(Q_CC_MINGW) |
44 |
|
#pragma GCC diagnostic pop |
45 |
|
#endif |
46 |
#endif |
#endif |
47 |
|
|
48 |
namespace QSampler { |
namespace QSampler { |
88 |
bool Channel::addChannel (void) |
bool Channel::addChannel (void) |
89 |
{ |
{ |
90 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
91 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
92 |
return false; |
return false; |
93 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == nullptr) |
94 |
return false; |
return false; |
95 |
|
|
96 |
// Are we a new channel? |
// Are we a new channel? |
113 |
bool Channel::removeChannel (void) |
bool Channel::removeChannel (void) |
114 |
{ |
{ |
115 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
116 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
117 |
return false; |
return false; |
118 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == nullptr) |
119 |
return false; |
return false; |
120 |
|
|
121 |
// Are we an existing channel? |
// Are we an existing channel? |
163 |
bool Channel::loadEngine ( const QString& sEngineName ) |
bool Channel::loadEngine ( const QString& sEngineName ) |
164 |
{ |
{ |
165 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
166 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
167 |
return false; |
return false; |
168 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
169 |
return false; |
return false; |
170 |
if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName) |
if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName) |
171 |
return true; |
return true; |
211 |
bool Channel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
bool Channel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
212 |
{ |
{ |
213 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
214 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
215 |
return false; |
return false; |
216 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
217 |
return false; |
return false; |
218 |
if (!QFileInfo(sInstrumentFile).exists()) |
if (!QFileInfo(sInstrumentFile).exists()) |
219 |
return false; |
return false; |
225 |
if (::lscp_load_instrument_non_modal( |
if (::lscp_load_instrument_non_modal( |
226 |
pMainForm->client(), |
pMainForm->client(), |
227 |
qsamplerUtilities::lscpEscapePath( |
qsamplerUtilities::lscpEscapePath( |
228 |
sInstrumentFile).toUtf8().constData(), |
sInstrumentFile).constData(), |
229 |
iInstrumentNr, m_iChannelID |
iInstrumentNr, m_iChannelID |
230 |
) != LSCP_OK) { |
) != LSCP_OK) { |
231 |
appendMessagesClient("lscp_load_instrument"); |
appendMessagesClient("lscp_load_instrument"); |
245 |
m_sInstrumentFile = sInstrumentFile; |
m_sInstrumentFile = sInstrumentFile; |
246 |
m_iInstrumentNr = iInstrumentNr; |
m_iInstrumentNr = iInstrumentNr; |
247 |
#ifdef CONFIG_INSTRUMENT_NAME |
#ifdef CONFIG_INSTRUMENT_NAME |
248 |
m_sInstrumentName = QString::null; // We'll get it, maybe later, on channel_info... |
m_sInstrumentName.clear(); // We'll get it, maybe later, on channel_info... |
249 |
#else |
#else |
250 |
m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true); |
m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true); |
251 |
#endif |
#endif |
264 |
bool Channel::setMidiDriver ( const QString& sMidiDriver ) |
bool Channel::setMidiDriver ( const QString& sMidiDriver ) |
265 |
{ |
{ |
266 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
267 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
268 |
return false; |
return false; |
269 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
270 |
return false; |
return false; |
271 |
if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver) |
if (m_iInstrumentStatus == 100 && m_sMidiDriver == sMidiDriver) |
272 |
return true; |
return true; |
293 |
bool Channel::setMidiDevice ( int iMidiDevice ) |
bool Channel::setMidiDevice ( int iMidiDevice ) |
294 |
{ |
{ |
295 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
296 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
297 |
return false; |
return false; |
298 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
299 |
return false; |
return false; |
300 |
if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice) |
if (m_iInstrumentStatus == 100 && m_iMidiDevice == iMidiDevice) |
301 |
return true; |
return true; |
321 |
bool Channel::setMidiPort ( int iMidiPort ) |
bool Channel::setMidiPort ( int iMidiPort ) |
322 |
{ |
{ |
323 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
324 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
325 |
return false; |
return false; |
326 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
327 |
return false; |
return false; |
328 |
if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort) |
if (m_iInstrumentStatus == 100 && m_iMidiPort == iMidiPort) |
329 |
return true; |
return true; |
349 |
bool Channel::setMidiChannel ( int iMidiChannel ) |
bool Channel::setMidiChannel ( int iMidiChannel ) |
350 |
{ |
{ |
351 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
352 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
353 |
return false; |
return false; |
354 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
355 |
return false; |
return false; |
356 |
if (m_iInstrumentStatus == 100 && m_iMidiChannel == iMidiChannel) |
if (m_iInstrumentStatus == 100 && m_iMidiChannel == iMidiChannel) |
357 |
return true; |
return true; |
377 |
bool Channel::setMidiMap ( int iMidiMap ) |
bool Channel::setMidiMap ( int iMidiMap ) |
378 |
{ |
{ |
379 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
380 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
381 |
return false; |
return false; |
382 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
383 |
return false; |
return false; |
384 |
if (m_iInstrumentStatus == 100 && m_iMidiMap == iMidiMap) |
if (m_iInstrumentStatus == 100 && m_iMidiMap == iMidiMap) |
385 |
return true; |
return true; |
405 |
bool Channel::setAudioDevice ( int iAudioDevice ) |
bool Channel::setAudioDevice ( int iAudioDevice ) |
406 |
{ |
{ |
407 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
408 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
409 |
return false; |
return false; |
410 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
411 |
return false; |
return false; |
412 |
if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice) |
if (m_iInstrumentStatus == 100 && m_iAudioDevice == iAudioDevice) |
413 |
return true; |
return true; |
433 |
bool Channel::setAudioDriver ( const QString& sAudioDriver ) |
bool Channel::setAudioDriver ( const QString& sAudioDriver ) |
434 |
{ |
{ |
435 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
436 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
437 |
return false; |
return false; |
438 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
439 |
return false; |
return false; |
440 |
if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver) |
if (m_iInstrumentStatus == 100 && m_sAudioDriver == sAudioDriver) |
441 |
return true; |
return true; |
462 |
bool Channel::setVolume ( float fVolume ) |
bool Channel::setVolume ( float fVolume ) |
463 |
{ |
{ |
464 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
465 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
466 |
return false; |
return false; |
467 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
468 |
return false; |
return false; |
469 |
if (m_iInstrumentStatus == 100 && m_fVolume == fVolume) |
if (m_iInstrumentStatus == 100 && m_fVolume == fVolume) |
470 |
return true; |
return true; |
490 |
bool Channel::setChannelMute ( bool bMute ) |
bool Channel::setChannelMute ( bool bMute ) |
491 |
{ |
{ |
492 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
493 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
494 |
return false; |
return false; |
495 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
496 |
return false; |
return false; |
497 |
if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute))) |
if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute))) |
498 |
return true; |
return true; |
520 |
bool Channel::setChannelSolo ( bool bSolo ) |
bool Channel::setChannelSolo ( bool bSolo ) |
521 |
{ |
{ |
522 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
523 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
524 |
return false; |
return false; |
525 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
526 |
return false; |
return false; |
527 |
if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo))) |
if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo))) |
528 |
return true; |
return true; |
550 |
bool Channel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
bool Channel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
551 |
{ |
{ |
552 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
553 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
554 |
return false; |
return false; |
555 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
556 |
return false; |
return false; |
557 |
if (m_iInstrumentStatus == 100 && |
if (m_iInstrumentStatus == 100 && |
558 |
m_audioRouting[iAudioOut] == iAudioIn) |
m_audioRouting[iAudioOut] == iAudioIn) |
582 |
void Channel::updateInstrumentName (void) |
void Channel::updateInstrumentName (void) |
583 |
{ |
{ |
584 |
#ifndef CONFIG_INSTRUMENT_NAME |
#ifndef CONFIG_INSTRUMENT_NAME |
585 |
|
Options *pOptions = nullptr; |
586 |
|
MainForm *pMainForm = MainForm::getInstance(); |
587 |
|
if (pMainForm) |
588 |
|
pOptions = pMainForm->options(); |
589 |
m_sInstrumentName = getInstrumentName(m_sInstrumentFile, |
m_sInstrumentName = getInstrumentName(m_sInstrumentFile, |
590 |
m_iInstrumentNr, (options() && options()->bInstrumentNames)); |
m_iInstrumentNr, (pOptions && pOptions->bInstrumentNames)); |
591 |
#endif |
#endif |
592 |
} |
} |
593 |
|
|
596 |
bool Channel::updateChannelInfo (void) |
bool Channel::updateChannelInfo (void) |
597 |
{ |
{ |
598 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
599 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
600 |
return false; |
return false; |
601 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
602 |
return false; |
return false; |
603 |
|
|
604 |
// Read channel information. |
// Read channel information. |
605 |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(pMainForm->client(), m_iChannelID); |
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(pMainForm->client(), m_iChannelID); |
606 |
if (pChannelInfo == NULL) { |
if (pChannelInfo == nullptr) { |
607 |
appendMessagesClient("lscp_get_channel_info"); |
appendMessagesClient("lscp_get_channel_info"); |
608 |
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
609 |
return false; |
return false; |
644 |
#endif |
#endif |
645 |
// Some sanity checks. |
// Some sanity checks. |
646 |
if (m_sEngineName == "NONE" || m_sEngineName.isEmpty()) |
if (m_sEngineName == "NONE" || m_sEngineName.isEmpty()) |
647 |
m_sEngineName = QString::null; |
m_sEngineName.clear(); |
648 |
if (m_sInstrumentFile == "NONE" || m_sInstrumentFile.isEmpty()) { |
if (m_sInstrumentFile == "NONE" || m_sInstrumentFile.isEmpty()) { |
649 |
m_sInstrumentFile = QString::null; |
m_sInstrumentFile.clear(); |
650 |
m_sInstrumentName = QString::null; |
m_sInstrumentName.clear(); |
651 |
} |
} |
652 |
|
|
653 |
// Time for device info grabbing... |
// Time for device info grabbing... |
655 |
const QString sNone = QObject::tr("(none)"); |
const QString sNone = QObject::tr("(none)"); |
656 |
// Audio device driver type. |
// Audio device driver type. |
657 |
pDeviceInfo = ::lscp_get_audio_device_info(pMainForm->client(), m_iAudioDevice); |
pDeviceInfo = ::lscp_get_audio_device_info(pMainForm->client(), m_iAudioDevice); |
658 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == nullptr) { |
659 |
appendMessagesClient("lscp_get_audio_device_info"); |
appendMessagesClient("lscp_get_audio_device_info"); |
660 |
m_sAudioDriver = sNone; |
m_sAudioDriver = sNone; |
661 |
} else { |
} else { |
663 |
} |
} |
664 |
// MIDI device driver type. |
// MIDI device driver type. |
665 |
pDeviceInfo = ::lscp_get_midi_device_info(pMainForm->client(), m_iMidiDevice); |
pDeviceInfo = ::lscp_get_midi_device_info(pMainForm->client(), m_iMidiDevice); |
666 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == nullptr) { |
667 |
appendMessagesClient("lscp_get_midi_device_info"); |
appendMessagesClient("lscp_get_midi_device_info"); |
668 |
m_sMidiDriver = sNone; |
m_sMidiDriver = sNone; |
669 |
} else { |
} else { |
690 |
bool Channel::channelReset (void) |
bool Channel::channelReset (void) |
691 |
{ |
{ |
692 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
693 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
694 |
return false; |
return false; |
695 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
696 |
return false; |
return false; |
697 |
|
|
698 |
if (::lscp_reset_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
if (::lscp_reset_channel(pMainForm->client(), m_iChannelID) != LSCP_OK) { |
712 |
#ifdef CONFIG_EDIT_INSTRUMENT |
#ifdef CONFIG_EDIT_INSTRUMENT |
713 |
|
|
714 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
715 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
716 |
return false; |
return false; |
717 |
if (pMainForm->client() == NULL || m_iChannelID < 0) |
if (pMainForm->client() == nullptr || m_iChannelID < 0) |
718 |
return false; |
return false; |
719 |
|
|
720 |
if (::lscp_edit_channel_instrument(pMainForm->client(), m_iChannelID) |
if (::lscp_edit_channel_instrument(pMainForm->client(), m_iChannelID) |
753 |
bool Channel::channelSetup ( QWidget *pParent ) |
bool Channel::channelSetup ( QWidget *pParent ) |
754 |
{ |
{ |
755 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
756 |
if (pMainForm == NULL) |
if (pMainForm == nullptr) |
757 |
return false; |
return false; |
758 |
|
|
759 |
bool bResult = false; |
bool bResult = false; |
772 |
|
|
773 |
|
|
774 |
// Redirected messages output methods. |
// Redirected messages output methods. |
775 |
void Channel::appendMessages( const QString& s ) const |
void Channel::appendMessages ( const QString& sText ) const |
776 |
{ |
{ |
777 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
778 |
if (pMainForm) |
if (pMainForm) |
779 |
pMainForm->appendMessages(channelName() + ' ' + s); |
pMainForm->appendMessages(channelName() + ' ' + sText); |
780 |
} |
} |
781 |
|
|
782 |
void Channel::appendMessagesColor( const QString& s, |
void Channel::appendMessagesColor ( |
783 |
const QString& c ) const |
const QString& sText, const QColor& rgb ) const |
784 |
{ |
{ |
785 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
786 |
if (pMainForm) |
if (pMainForm) |
787 |
pMainForm->appendMessagesColor(channelName() + ' ' + s, c); |
pMainForm->appendMessagesColor(channelName() + ' ' + sText, rgb); |
788 |
} |
} |
789 |
|
|
790 |
void Channel::appendMessagesText( const QString& s ) const |
void Channel::appendMessagesText ( const QString& sText ) const |
791 |
{ |
{ |
792 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
793 |
if (pMainForm) |
if (pMainForm) |
794 |
pMainForm->appendMessagesText(channelName() + ' ' + s); |
pMainForm->appendMessagesText(channelName() + ' ' + sText); |
795 |
} |
} |
796 |
|
|
797 |
void Channel::appendMessagesError( const QString& s ) const |
void Channel::appendMessagesError ( const QString& sText ) const |
798 |
{ |
{ |
799 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
800 |
if (pMainForm) |
if (pMainForm) |
801 |
pMainForm->appendMessagesError(channelName() + "\n\n" + s); |
pMainForm->appendMessagesError(channelName() + "\n\n" + sText); |
802 |
} |
} |
803 |
|
|
804 |
void Channel::appendMessagesClient( const QString& s ) const |
void Channel::appendMessagesClient ( const QString& sText ) const |
805 |
{ |
{ |
806 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
807 |
if (pMainForm) |
if (pMainForm) |
808 |
pMainForm->appendMessagesClient(channelName() + ' ' + s); |
pMainForm->appendMessagesClient(channelName() + ' ' + sText); |
809 |
} |
} |
810 |
|
|
811 |
|
|
812 |
// Context menu event handler. |
// Context menu event handler. |
813 |
void Channel::contextMenuEvent( QContextMenuEvent *pEvent ) |
void Channel::contextMenuEvent ( QContextMenuEvent *pEvent ) |
814 |
{ |
{ |
815 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
816 |
if (pMainForm) |
if (pMainForm) |
999 |
// (used for QTableView) |
// (used for QTableView) |
1000 |
|
|
1001 |
ChannelRoutingModel::ChannelRoutingModel ( QObject *pParent ) |
ChannelRoutingModel::ChannelRoutingModel ( QObject *pParent ) |
1002 |
: QAbstractTableModel(pParent), m_pDevice(NULL) |
: QAbstractTableModel(pParent), m_pDevice(nullptr) |
1003 |
{ |
{ |
1004 |
} |
} |
1005 |
|
|
1088 |
m_pDevice = pDevice; |
m_pDevice = pDevice; |
1089 |
m_routing = routing; |
m_routing = routing; |
1090 |
// inform the outer world (QTableView) that our data changed |
// inform the outer world (QTableView) that our data changed |
1091 |
#if QT_VERSION < 0x050000 |
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) |
1092 |
QAbstractTableModel::reset(); |
QAbstractTableModel::reset(); |
1093 |
#else |
#else |
1094 |
QAbstractTableModel::beginResetModel(); |
QAbstractTableModel::beginResetModel(); |
1111 |
const QStyleOptionViewItem & option, const QModelIndex& index ) const |
const QStyleOptionViewItem & option, const QModelIndex& index ) const |
1112 |
{ |
{ |
1113 |
if (!index.isValid()) |
if (!index.isValid()) |
1114 |
return NULL; |
return nullptr; |
1115 |
|
|
1116 |
if (index.column() != 0) |
if (index.column() != 0) |
1117 |
return NULL; |
return nullptr; |
1118 |
|
|
1119 |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>(); |
1120 |
|
|
1122 |
pComboBox->addItems(item.options); |
pComboBox->addItems(item.options); |
1123 |
pComboBox->setCurrentIndex(item.selection); |
pComboBox->setCurrentIndex(item.selection); |
1124 |
pComboBox->setEnabled(true); |
pComboBox->setEnabled(true); |
1125 |
|
pComboBox->setEditable(true); |
1126 |
pComboBox->setGeometry(option.rect); |
pComboBox->setGeometry(option.rect); |
1127 |
return pComboBox; |
return pComboBox; |
1128 |
} |
} |