From 95c8f460a30e3adfdccc359eb0dbac8e4f45e7ee Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 26 Mar 2014 08:49:34 +0100 Subject: [PATCH] Issue #855 fixed --- .../src/firmwares/opentx/opentxinterface.cpp | 2 + companion/src/modeledit/mixes.cpp | 75 ++++++++----------- companion/src/modeledit/mixes.h | 2 +- 3 files changed, 33 insertions(+), 46 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 61b30e027..7fa477c22 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -491,6 +491,8 @@ int OpenTxInterface::getCapability(const Capability capability) case FlightModesName: case GvarsName: return (IS_TARANIS(board) ? 10 : 6); + case HasChNames: + return (IS_TARANIS(board) ? 1 : 0); case GvarsInCS: case HasFAIMode: return 1; diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index df92f5ecb..44569b9ee 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -43,6 +43,29 @@ MixesPanel::~MixesPanel() { } +QString MixesPanel::getChannelLabel(int curDest) +{ + QString str; + unsigned int outputs = GetEepromInterface()->getCapability(Outputs); + if (curDest > outputs) { + str = QObject::tr("X%1 ").arg(curDest-outputs); + } + else { + str = QObject::tr("CH%1").arg(curDest); + str.append(" "); + str = str.left(4); + if (GetEepromInterface()->getCapability(HasChNames)) { + QString name = model.limitData[curDest-1].name; + if (!name.isEmpty()) { + name = QString("(") + name + QString(")"); + } + name.append(" "); + str += name.left(8); + } + } + return str; +} + void MixesPanel::update() { // curDest -> destination channel4 @@ -52,26 +75,13 @@ void MixesPanel::update() unsigned int curDest = 0; int i; unsigned int outputs = GetEepromInterface()->getCapability(Outputs); - int showNames = false; // TODO in a menu ui->showNames_Ckb->isChecked(); for (i=0; igetCapability(Mixes); i++) { MixData *md = &model.mixData[i]; if ((md->destCh==0) || (md->destCh>outputs+(unsigned int)GetEepromInterface()->getCapability(ExtraChannels))) continue; QString str = ""; - while (curDest<(md->destCh-1)) { + while (curDest < md->destCh-1) { curDest++; - if (curDest > outputs) { - str = tr("X%1 ").arg(curDest-outputs); - } - else { - str = tr("CH%1%2").arg(curDest/10).arg(curDest%10); - if (GetEepromInterface()->getCapability(HasChNames) && showNames) { - QString name=model.limitData[curDest-1].name; - if (!name.isEmpty()) { - name.append(" "); - str=name.left(6); - } - } - } + str = getChannelLabel(curDest); qba.clear(); qba.append((quint8)-curDest); QListWidgetItem *itm = new QListWidgetItem(str); @@ -79,23 +89,12 @@ void MixesPanel::update() MixerlistWidget->addItem(itm); } - if (md->destCh > outputs) { - str = tr("X%1 ").arg(md->destCh-outputs); - } - else { - str = tr("CH%1%2").arg(md->destCh/10).arg(md->destCh%10); - str.append(" "); - if (GetEepromInterface()->getCapability(HasChNames) && showNames) { - QString name=model.limitData[md->destCh-1].name; - if (!name.isEmpty()) { - name.append(" "); - str=name.left(6); - } - } - } + str = getChannelLabel(md->destCh); + if (curDest != md->destCh) { curDest = md->destCh; - } else { + } + else { str.fill(' '); } @@ -154,21 +153,7 @@ void MixesPanel::update() while(curDestgetCapability(ExtraChannels)) { curDest++; - QString str; - - if (curDest > outputs) { - str = tr("X%1 ").arg(curDest-outputs); - } - else { - str = tr("CH%1%2").arg(curDest/10).arg(curDest%10); - if (GetEepromInterface()->getCapability(HasChNames) && showNames) { - QString name=model.limitData[curDest-1].name; - if (!name.isEmpty()) { - name.append(" "); - str=name.left(6); - } - } - } + QString str = getChannelLabel(curDest); qba.clear(); qba.append((quint8)-curDest); QListWidgetItem *itm = new QListWidgetItem(str); diff --git a/companion/src/modeledit/mixes.h b/companion/src/modeledit/mixes.h index 5e5dc4e80..1fbbe9da7 100644 --- a/companion/src/modeledit/mixes.h +++ b/companion/src/modeledit/mixes.h @@ -50,7 +50,7 @@ class MixesPanel : public ModelPanel void mixersDeleteList(QList list); QList createMixListFromSelected(); void setSelectedByMixList(QList list); - + QString getChannelLabel(int curDest); }; #endif // MIXES_H