From 1e0e22955da0bf2fe3e6c7b8b1b136e3580aa1c0 Mon Sep 17 00:00:00 2001 From: elecpower Date: Thu, 17 Sep 2020 14:23:00 +1000 Subject: [PATCH 001/231] Refactor to Model level ui datamodels for sources, switches and curves --- .../src/datamodels/rawitemdatamodels.cpp | 59 ++- companion/src/datamodels/rawitemdatamodels.h | 30 +- .../src/datamodels/rawitemfilteredmodel.cpp | 16 +- .../src/datamodels/rawitemfilteredmodel.h | 43 +- companion/src/firmwares/curvereference.h | 17 + companion/src/firmwares/modeldata.h | 2 +- companion/src/generaledit/CMakeLists.txt | 2 +- companion/src/generaledit/generaledit.cpp | 6 +- companion/src/modeledit/channels.cpp | 117 +++-- companion/src/modeledit/channels.h | 15 +- companion/src/modeledit/curves.cpp | 95 ++-- companion/src/modeledit/curves.h | 9 +- companion/src/modeledit/customfunctions.cpp | 462 +++++++++--------- companion/src/modeledit/customfunctions.h | 23 +- companion/src/modeledit/expodialog.cpp | 10 +- companion/src/modeledit/expodialog.h | 8 +- companion/src/modeledit/flightmodes.cpp | 118 +++-- companion/src/modeledit/flightmodes.h | 22 +- companion/src/modeledit/heli.cpp | 33 +- companion/src/modeledit/heli.h | 10 +- companion/src/modeledit/inputs.cpp | 10 +- companion/src/modeledit/inputs.h | 9 +- companion/src/modeledit/logicalswitches.cpp | 129 ++--- companion/src/modeledit/logicalswitches.h | 20 +- companion/src/modeledit/mixerdialog.cpp | 10 +- companion/src/modeledit/mixerdialog.h | 8 +- companion/src/modeledit/mixes.cpp | 9 +- companion/src/modeledit/mixes.h | 6 +- companion/src/modeledit/modeledit.cpp | 97 +++- companion/src/modeledit/modeledit.h | 6 + companion/src/modeledit/setup.cpp | 44 +- companion/src/modeledit/setup.h | 18 +- companion/src/modeledit/telemetry.cpp | 142 +++--- companion/src/modeledit/telemetry.h | 12 +- 34 files changed, 994 insertions(+), 623 deletions(-) diff --git a/companion/src/datamodels/rawitemdatamodels.cpp b/companion/src/datamodels/rawitemdatamodels.cpp index 1cba1c180..4edd26c76 100644 --- a/companion/src/datamodels/rawitemdatamodels.cpp +++ b/companion/src/datamodels/rawitemdatamodels.cpp @@ -30,7 +30,7 @@ RawSourceItemModel::RawSourceItemModel(const GeneralSettings * const generalSett Firmware * fw = getCurrentFirmware(); addItems(SOURCE_TYPE_NONE, RawSource::NoneGroup, 1); - for (int i=0; i < fw->getCapability(LuaScripts); i++) + for (int i = 0; i < fw->getCapability(LuaScripts); i++) addItems(SOURCE_TYPE_LUA_OUTPUT, RawSource::ScriptsGroup, fw->getCapability(LuaOutputsPerScript), i * 16); addItems(SOURCE_TYPE_VIRTUAL_INPUT, RawSource::InputsGroup, fw->getCapability(VirtualInputs)); addItems(SOURCE_TYPE_STICK, RawSource::SourcesGroup, board.getCapability(Board::MaxAnalogs)); @@ -67,10 +67,14 @@ void RawSourceItemModel::addItems(const RawSourceType & type, const int group, c } } -void RawSourceItemModel::update() const +void RawSourceItemModel::update() { - for (int i=0; i < rowCount(); ++i) + emit dataAboutToBeUpdated(); + + for (int i = 0; i < rowCount(); ++i) setDynamicItemData(item(i), RawSource(item(i)->data(ItemIdRole).toInt())); + + emit dataUpdateComplete(); } @@ -166,8 +170,53 @@ void RawSwitchItemModel::addItems(const RawSwitchType & type, int count) } } -void RawSwitchItemModel::update() const +void RawSwitchItemModel::update() { - for (int i=0; i < rowCount(); ++i) + emit dataAboutToBeUpdated(); + + for (int i = 0; i < rowCount(); ++i) setDynamicItemData(item(i), RawSwitch(item(i)->data(ItemIdRole).toInt())); + + emit dataUpdateComplete(); +} + +// +// CurveItemModel +// + +CurveItemModel::CurveItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent) : + AbstractRawItemDataModel(generalSettings, modelData, parent) +{ + const int count = getCurrentFirmware()->getCapability(NumCurves); + + for (int i = -count ; i <= count; ++i) { + QStandardItem * modelItem = new QStandardItem(); + modelItem->setData(i, ItemIdRole); + int flags; + if (i < 0) + flags = DataGroups::NegativeGroup; + else if (i > 0) + flags = DataGroups::PositiveGroup; + else + flags = DataGroups::NoneGroup; + modelItem->setData(flags, ItemFlagsRole); + setDynamicItemData(modelItem, i); + appendRow(modelItem); + } +} + +void CurveItemModel::setDynamicItemData(QStandardItem * item, int index) const +{ + item->setText(CurveReference(CurveReference::CURVE_REF_CUSTOM, index).toString(modelData, false)); + item->setData(true, IsAvailableRole); +} + +void CurveItemModel::update() +{ + emit dataAboutToBeUpdated(); + + for (int i = 0; i < rowCount(); ++i) + setDynamicItemData(item(i), item(i)->data(ItemIdRole).toInt()); + + emit dataUpdateComplete(); } diff --git a/companion/src/datamodels/rawitemdatamodels.h b/companion/src/datamodels/rawitemdatamodels.h index 59eb6025e..30a9b54e9 100644 --- a/companion/src/datamodels/rawitemdatamodels.h +++ b/companion/src/datamodels/rawitemdatamodels.h @@ -36,6 +36,13 @@ class AbstractRawItemDataModel: public QStandardItemModel enum DataRoles { ItemIdRole = Qt::UserRole, ItemTypeRole, ItemFlagsRole, IsAvailableRole }; Q_ENUM(DataRoles) + enum DataGroups { + NoneGroup = 0x01, + NegativeGroup = 0x02, + PositiveGroup = 0x04 + }; + Q_ENUM(DataGroups) + explicit AbstractRawItemDataModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr) : QStandardItemModel(parent), generalSettings(generalSettings), @@ -43,7 +50,11 @@ class AbstractRawItemDataModel: public QStandardItemModel {} public slots: - virtual void update() const = 0; + virtual void update() = 0; + + signals: + void dataAboutToBeUpdated(); + void dataUpdateComplete(); protected: const GeneralSettings * generalSettings; @@ -58,7 +69,7 @@ class RawSourceItemModel: public AbstractRawItemDataModel explicit RawSourceItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr); public slots: - void update() const override; + void update() override; protected: void setDynamicItemData(QStandardItem * item, const RawSource & src) const; @@ -73,7 +84,7 @@ class RawSwitchItemModel: public AbstractRawItemDataModel explicit RawSwitchItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr); public slots: - void update() const override; + void update() override; protected: void setDynamicItemData(QStandardItem * item, const RawSwitch & rsw) const; @@ -81,4 +92,17 @@ class RawSwitchItemModel: public AbstractRawItemDataModel }; +class CurveItemModel: public AbstractRawItemDataModel +{ + Q_OBJECT + public: + explicit CurveItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr); + + public slots: + void update() override; + + protected: + void setDynamicItemData(QStandardItem * item, int index) const; +}; + #endif // RAWITEMDATAMODELS_H diff --git a/companion/src/datamodels/rawitemfilteredmodel.cpp b/companion/src/datamodels/rawitemfilteredmodel.cpp index 1de9e26b2..775b85fc4 100644 --- a/companion/src/datamodels/rawitemfilteredmodel.cpp +++ b/companion/src/datamodels/rawitemfilteredmodel.cpp @@ -30,6 +30,12 @@ RawItemFilteredModel::RawItemFilteredModel(QAbstractItemModel * sourceModel, int setFilterFlags(flags); setDynamicSortFilter(true); setSourceModel(sourceModel); + + AbstractRawItemDataModel * model = qobject_cast(sourceModel); + if (model) { + connect(model, &AbstractRawItemDataModel::dataAboutToBeUpdated, this, &RawItemFilteredModel::onDataAboutToBeUpdated); + connect(model, &AbstractRawItemDataModel::dataUpdateComplete, this, &RawItemFilteredModel::onDataUpdateComplete); + } } void RawItemFilteredModel::setFilterFlags(int flags) @@ -61,14 +67,12 @@ void RawItemFilteredModel::update() const model->update(); } - -RawSourceFilterItemModel::RawSourceFilterItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, int flags, QObject * parent) : - RawItemFilteredModel(new RawSourceItemModel(generalSettings, modelData, parent), flags, parent) +void RawItemFilteredModel::onDataAboutToBeUpdated() { + emit dataAboutToBeUpdated(); } - -RawSwitchFilterItemModel::RawSwitchFilterItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, int context, QObject * parent) : - RawItemFilteredModel(new RawSwitchItemModel(generalSettings, modelData, parent), context, parent) +void RawItemFilteredModel::onDataUpdateComplete() { + emit dataUpdateComplete(); } diff --git a/companion/src/datamodels/rawitemfilteredmodel.h b/companion/src/datamodels/rawitemfilteredmodel.h index 2d95dff71..f8bf22c19 100644 --- a/companion/src/datamodels/rawitemfilteredmodel.h +++ b/companion/src/datamodels/rawitemfilteredmodel.h @@ -21,6 +21,8 @@ #ifndef RAWITEMFILTEREDMODEL_H #define RAWITEMFILTEREDMODEL_H +#include "rawitemdatamodels.h" + #include class GeneralSettings; @@ -32,43 +34,30 @@ class RawItemFilteredModel: public QSortFilterProxyModel { Q_OBJECT public: + enum DataFilters { + AllFilter = AbstractRawItemDataModel::NegativeGroup | AbstractRawItemDataModel::NoneGroup | AbstractRawItemDataModel::PositiveGroup, + HideNegativeFilter = AllFilter &~ AbstractRawItemDataModel::NegativeGroup, + NonePositiveFilter = AbstractRawItemDataModel::NoneGroup | AbstractRawItemDataModel::PositiveGroup, + PositiveFilter = AbstractRawItemDataModel::PositiveGroup + }; + Q_ENUM(DataFilters) + explicit RawItemFilteredModel(QAbstractItemModel * sourceModel, int flags, QObject * parent = nullptr); explicit RawItemFilteredModel(QAbstractItemModel * sourceModel, QObject * parent = nullptr) : RawItemFilteredModel(sourceModel, 0, parent) {} public slots: void setFilterFlags(int flags); void update() const; + void onDataAboutToBeUpdated(); + void onDataUpdateComplete(); + + signals: + void dataAboutToBeUpdated(); + void dataUpdateComplete(); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const override; int filterFlags; }; - - -// The specialized "convenience" types below can go away once centralalized RawSource/RawSwitch item models are established. -// These proxy classes will automatically create a source model of the corresponding type. - -class RawSwitchFilterItemModel: public RawItemFilteredModel -{ - Q_OBJECT - public: - using RawItemFilteredModel::RawItemFilteredModel; - - explicit RawSwitchFilterItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, int context, QObject * parent = nullptr); -}; - - -class RawSourceFilterItemModel: public RawItemFilteredModel -{ - Q_OBJECT - public: - using RawItemFilteredModel::RawItemFilteredModel; - - explicit RawSourceFilterItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, int flags, QObject * parent = nullptr); - - explicit RawSourceFilterItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr) : - RawSourceFilterItemModel(generalSettings, modelData, 0, parent) {} -}; - #endif // RAWITEMFILTEREDMODEL_H diff --git a/companion/src/firmwares/curvereference.h b/companion/src/firmwares/curvereference.h index cb5be4e73..c6984d7ae 100644 --- a/companion/src/firmwares/curvereference.h +++ b/companion/src/firmwares/curvereference.h @@ -36,6 +36,15 @@ class CurveReference { CURVE_REF_CUSTOM }; + enum CurveRefGroups { + NoneGroup = 0x001, + NegativeGroup = 0x002, + PositiveGroup = 0x004, + + AllCurveRefGroups = NoneGroup | NegativeGroup | PositiveGroup, + PositiveCurveRefGroups = AllCurveRefGroups &~ NegativeGroup + }; + CurveReference() { clear(); } CurveReference(CurveRefType type, int value): @@ -51,6 +60,14 @@ class CurveReference { QString toString(const ModelData * model = NULL, bool verbose = true) const; bool isSet() const { return type != CURVE_REF_DIFF || value != 0; } + + bool operator == ( const CurveReference & other) const { + return (this->type == other.type) && (this->value == other.value); + } + + bool operator != ( const CurveReference & other) const { + return (this->type != other.type) || (this->value != other.value); + } }; #endif // CURVEREFERENCE_H diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 558b848df..51efcc333 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -321,7 +321,7 @@ class ModelData { void updateModuleFailsafes(ModuleData * md); inline void updateSourceRef(RawSource & src) { updateTypeIndexRef(src, updRefInfo.srcType); } inline void updateSwitchRef(RawSwitch & swtch) { updateTypeIndexRef(swtch, updRefInfo.swtchType, 1); } - inline void updateTimerMode(RawSwitch & swtch) { updateTypeIndexRef(swtch, updRefInfo.swtchType, 1, false, (int)SWITCH_TYPE_TIMER_MODE, 0); } + inline void updateTimerMode(RawSwitch & swtch) { updateTypeIndexRef(swtch, updRefInfo.swtchType, 1, false, (int)SWITCH_TYPE_TIMER_MODE, -1 /*adjusted by offset*/); } inline void updateSourceIntRef(int & value) { RawSource src = RawSource(value); diff --git a/companion/src/generaledit/CMakeLists.txt b/companion/src/generaledit/CMakeLists.txt index 827c37ddf..2c458c719 100644 --- a/companion/src/generaledit/CMakeLists.txt +++ b/companion/src/generaledit/CMakeLists.txt @@ -28,4 +28,4 @@ qt5_wrap_ui(generaledit_SRCS ${generaledit_UIS}) qt5_wrap_cpp(generaledit_SRCS ${generaledit_HDRS}) add_library(generaledit ${generaledit_SRCS}) -target_link_libraries(generaledit PRIVATE ${CPN_COMMON_LIB} Qt5::Multimedia) +target_link_libraries(generaledit PRIVATE datamodels ${CPN_COMMON_LIB} Qt5::Multimedia) diff --git a/companion/src/generaledit/generaledit.cpp b/companion/src/generaledit/generaledit.cpp index 34d090e65..a31fee359 100644 --- a/companion/src/generaledit/generaledit.cpp +++ b/companion/src/generaledit/generaledit.cpp @@ -28,6 +28,7 @@ #include "hardware.h" #include "../modeledit/customfunctions.h" #include "verticalscrollarea.h" +#include "rawitemdatamodels.h" GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * firmware) : QDialog(parent), @@ -55,8 +56,11 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir } } + RawSourceItemModel *rawSourceModel = new RawSourceItemModel(&generalSettings, nullptr, this); + RawSwitchItemModel *rawSwitchModel = new RawSwitchItemModel(&generalSettings, nullptr, this); + addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup")); - addTab(new CustomFunctionsPanel(this, NULL, generalSettings, firmware), tr("Global Functions")); + addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, rawSourceModel, rawSwitchModel), tr("Global Functions")); addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer")); addTab(new HardwarePanel(this, generalSettings, firmware), tr("Hardware")); addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration")); diff --git a/companion/src/modeledit/channels.cpp b/companion/src/modeledit/channels.cpp index 6442cc2fb..1371d3fab 100644 --- a/companion/src/modeledit/channels.cpp +++ b/companion/src/modeledit/channels.cpp @@ -20,6 +20,7 @@ #include "channels.h" #include "helpers.h" +#include "rawitemfilteredmodel.h" LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt, ModelPanel * panel): firmware(firmware), @@ -95,15 +96,16 @@ void LimitsGroup::updateMinMax(int max) } } } - -Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CurveItemModel * curveItemModel): ModelPanel(parent, model, generalSettings, firmware) { - Stopwatch s1("Channels"); - chnCapability = firmware->getCapability(Outputs); int channelNameMaxLen = firmware->getCapability(ChannelsName); + curveModel = new RawItemFilteredModel(curveItemModel, RawItemFilteredModel::AllFilter, this); + connect(curveModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &ChannelsPanel::onModelDataAboutToBeUpdated); + connect(curveModel, &RawItemFilteredModel::dataUpdateComplete, this, &ChannelsPanel::onModelDataUpdateComplete); + QStringList headerLabels; headerLabels << "#"; if (channelNameMaxLen > 0) { @@ -118,8 +120,6 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera headerLabels << tr("Linear Subtrim"); TableLayout *tableLayout = new TableLayout(this, chnCapability, headerLabels); - s1.report("header"); - for (int i = 0; i < chnCapability; i++) { int col = 0; @@ -165,6 +165,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera if (IS_HORUS_OR_TARANIS(firmware->getBoard())) { curveCB[i] = new QComboBox(this); curveCB[i]->setProperty("index", i); + curveCB[i]->setModel(curveModel); connect(curveCB[i], SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited())); tableLayout->addWidget(i, col++, curveCB[i]); } @@ -193,15 +194,13 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera } } update(); - s1.report("add elements"); disableMouseScrolling(); tableLayout->resizeColumnsToContents(); tableLayout->pushRowsUp(chnCapability+1); - s1.report("end"); } -Channels::~Channels() +ChannelsPanel::~ChannelsPanel() { // compiler warning if delete[] for (int i = 0; i < CPN_MAX_CHNOUT; i++) { @@ -214,9 +213,10 @@ Channels::~Channels() delete centerSB[i]; delete symlimitsChk[i]; } + delete curveModel; } -void Channels::symlimitsEdited() +void ChannelsPanel::symlimitsEdited() { if (!lock) { QCheckBox *ckb = qobject_cast(sender()); @@ -226,17 +226,20 @@ void Channels::symlimitsEdited() } } -void Channels::nameEdited() +void ChannelsPanel::nameEdited() { if (!lock) { QLineEdit *le = qobject_cast(sender()); int index = le->property("index").toInt(); - strcpy(model->limitData[index].name, le->text().toLatin1()); - emit modified(); + if (model->limitData[index].name != le->text()) { + strcpy(model->limitData[index].name, le->text().toLatin1()); + emit updateDataModels(); + emit modified(); + } } } -void Channels::refreshExtendedLimits() +void ChannelsPanel::refreshExtendedLimits() { int channelMax = model->getChannelsMax(); @@ -248,7 +251,7 @@ void Channels::refreshExtendedLimits() emit modified(); } -void Channels::invEdited() +void ChannelsPanel::invEdited() { if (!lock) { QComboBox *cb = qobject_cast(sender()); @@ -258,17 +261,20 @@ void Channels::invEdited() } } -void Channels::curveEdited() +void ChannelsPanel::curveEdited() { if (!lock) { QComboBox *cb = qobject_cast(sender()); int index = cb->property("index").toInt(); - model->limitData[index].curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt()); - emit modified(); + // ignore unnecessary updates that could be triggered by updates to the data model + if (model->limitData[index].curve != CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt())) { + model->limitData[index].curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt()); + emit modified(); + } } } -void Channels::ppmcenterEdited() +void ChannelsPanel::ppmcenterEdited() { if (!lock) { QSpinBox *sb = qobject_cast(sender()); @@ -278,51 +284,49 @@ void Channels::ppmcenterEdited() } } -void Channels::update() +void ChannelsPanel::update() { for (int i = 0; i < chnCapability; i++) { updateLine(i); } } -void Channels::updateLine(int i) +void ChannelsPanel::updateLine(int i) { lock = true; + LimitData &chn = model->limitData[i]; + if (firmware->getCapability(ChannelsName) > 0) { - name[i]->setText(model->limitData[i].name); + name[i]->setText(chn.name); } - chnOffset[i]->setValue(model->limitData[i].offset); - chnMin[i]->setValue(model->limitData[i].min); - chnMax[i]->setValue(model->limitData[i].max); - invCB[i]->setCurrentIndex((model->limitData[i].revert) ? 1 : 0); + chnOffset[i]->setValue(chn.offset); + chnMin[i]->setValue(chn.min); + chnMax[i]->setValue(chn.max); + invCB[i]->setCurrentIndex((chn.revert) ? 1 : 0); if (IS_HORUS_OR_TARANIS(firmware->getBoard())) { - int numcurves = firmware->getCapability(NumCurves); - curveCB[i]->clear(); - for (int j = -numcurves; j <= numcurves; j++) { - curveCB[i]->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, j).toString(model, false), j); - } - curveCB[i]->setCurrentIndex(model->limitData[i].curve.value + numcurves); + curveCB[i]->setCurrentIndex(curveCB[i]->findData(chn.curve.value)); } if (firmware->getCapability(PPMCenter)) { - centerSB[i]->setValue(model->limitData[i].ppmCenter + 1500); + centerSB[i]->setValue(chn.ppmCenter + 1500); } if (firmware->getCapability(SYMLimits)) { - symlimitsChk[i]->setChecked(model->limitData[i].symetrical); + symlimitsChk[i]->setChecked(chn.symetrical); } lock = false; } -void Channels::cmPaste() +void ChannelsPanel::cmPaste() { QByteArray data; if (hasClipboardData(&data)) { memcpy(&model->limitData[selectedIndex], data.constData(), sizeof(LimitData)); updateLine(selectedIndex); + emit updateDataModels(); emit modified(); } } -void Channels::cmDelete() +void ChannelsPanel::cmDelete() { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete Channel. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; @@ -335,10 +339,11 @@ void Channels::cmDelete() updateLine(i); } + emit updateDataModels(); emit modified(); } -void Channels::cmCopy() +void ChannelsPanel::cmCopy() { QByteArray data; data.append((char*)&model->limitData[selectedIndex], sizeof(LimitData)); @@ -347,7 +352,7 @@ void Channels::cmCopy() QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); } -void Channels::cmCut() +void ChannelsPanel::cmCut() { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Channel. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; @@ -356,7 +361,7 @@ void Channels::cmCut() cmClear(false); } -void Channels::onCustomContextMenuRequested(QPoint pos) +void ChannelsPanel::onCustomContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); selectedIndex = label->property("index").toInt(); @@ -378,7 +383,7 @@ void Channels::onCustomContextMenuRequested(QPoint pos) contextMenu.exec(globalPos); } -bool Channels::hasClipboardData(QByteArray * data) const +bool ChannelsPanel::hasClipboardData(QByteArray * data) const { const QClipboard * clipboard = QApplication::clipboard(); const QMimeData * mimeData = clipboard->mimeData(); @@ -390,32 +395,32 @@ bool Channels::hasClipboardData(QByteArray * data) const return false; } -bool Channels::insertAllowed() const +bool ChannelsPanel::insertAllowed() const { return ((selectedIndex < chnCapability - 1) && (model->limitData[chnCapability - 1].isEmpty())); } -bool Channels::moveDownAllowed() const +bool ChannelsPanel::moveDownAllowed() const { return selectedIndex < chnCapability - 1; } -bool Channels::moveUpAllowed() const +bool ChannelsPanel::moveUpAllowed() const { return selectedIndex > 0; } -void Channels::cmMoveUp() +void ChannelsPanel::cmMoveUp() { swapData(selectedIndex, selectedIndex - 1); } -void Channels::cmMoveDown() +void ChannelsPanel::cmMoveDown() { swapData(selectedIndex, selectedIndex + 1); } -void Channels::cmClear(bool prompt) +void ChannelsPanel::cmClear(bool prompt) { if (prompt) { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Channel. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) @@ -425,10 +430,11 @@ void Channels::cmClear(bool prompt) model->limitData[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); updateLine(selectedIndex); + emit updateDataModels(); emit modified(); } -void Channels::cmClearAll() +void ChannelsPanel::cmClearAll() { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Channels. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; @@ -438,19 +444,21 @@ void Channels::cmClearAll() model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_CLEAR, i); updateLine(i); } + emit updateDataModels(); emit modified(); } -void Channels::cmInsert() +void ChannelsPanel::cmInsert() { memmove(&model->limitData[selectedIndex + 1], &model->limitData[selectedIndex], (CPN_MAX_CHNOUT - (selectedIndex + 1)) * sizeof(LimitData)); model->limitData[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); + emit updateDataModels(); emit modified(); } -void Channels::swapData(int idx1, int idx2) +void ChannelsPanel::swapData(int idx1, int idx2) { if ((idx1 != idx2) && (!model->limitData[idx1].isEmpty() || !model->limitData[idx2].isEmpty())) { LimitData chntmp = model->limitData[idx2]; @@ -461,6 +469,17 @@ void Channels::swapData(int idx1, int idx2) model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); updateLine(idx1); updateLine(idx2); + emit updateDataModels(); emit modified(); } } + +void ChannelsPanel::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void ChannelsPanel::onModelDataUpdateComplete() +{ + update(); +} diff --git a/companion/src/modeledit/channels.h b/companion/src/modeledit/channels.h index d20923a35..0583b1d7c 100644 --- a/companion/src/modeledit/channels.h +++ b/companion/src/modeledit/channels.h @@ -26,6 +26,9 @@ #include +class CurveItemModel; +class RawItemFilteredModel; + constexpr char MIMETYPE_CHANNEL[] = "application/x-companion-channel"; class GVarGroup; @@ -49,13 +52,13 @@ class LimitsGroup double displayStep; }; -class Channels : public ModelPanel +class ChannelsPanel : public ModelPanel { Q_OBJECT public: - Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); - ~Channels(); + ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CurveItemModel * curveItemModel); + ~ChannelsPanel(); public slots: void refreshExtendedLimits(); @@ -78,6 +81,11 @@ class Channels : public ModelPanel void cmClear(bool prompt = true); void cmClearAll(); void onCustomContextMenuRequested(QPoint pos); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); + + signals: + void updateDataModels(); private: bool hasClipboardData(QByteArray * data = nullptr) const; @@ -95,6 +103,7 @@ class Channels : public ModelPanel QCheckBox *symlimitsChk[CPN_MAX_CHNOUT]; int selectedIndex; int chnCapability; + RawItemFilteredModel *curveModel; }; #endif // _CHANNELS_H_ diff --git a/companion/src/modeledit/curves.cpp b/companion/src/modeledit/curves.cpp index 662dc61c4..81da85a02 100644 --- a/companion/src/modeledit/curves.cpp +++ b/companion/src/modeledit/curves.cpp @@ -108,7 +108,7 @@ float curveSymmetricalX(float x, float coeff, float yMin, float yMid, float yMax return y; } -Curves::Curves(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::Curves), currentCurve(0) @@ -230,12 +230,12 @@ Curves::Curves(QWidget * parent, ModelData & model, GeneralSettings & generalSet lock = false; } -Curves::~Curves() +CurvesPanel::~CurvesPanel() { delete ui; } -void Curves::editCurve() +void CurvesPanel::editCurve() { QPushButton *button = (QPushButton *)sender(); int index = button->property("index").toInt(); @@ -243,7 +243,7 @@ void Curves::editCurve() update(); } -void Curves::plotCurve(bool checked) +void CurvesPanel::plotCurve(bool checked) { QCheckBox *chk = (QCheckBox *)sender(); int index = chk->property("index").toInt(); @@ -251,7 +251,7 @@ void Curves::plotCurve(bool checked) updateCurve(); } -void Curves::update() +void CurvesPanel::update() { lock = true; @@ -266,12 +266,12 @@ void Curves::update() lock = false; } -void Curves::setCurrentCurve(int index) +void CurvesPanel::setCurrentCurve(int index) { currentCurve = index; } -void Curves::updateCurveType() +void CurvesPanel::updateCurveType() { lock = true; @@ -297,7 +297,7 @@ void Curves::updateCurveType() lock = false; } -void Curves::updateCurve() +void CurvesPanel::updateCurve() { lock = true; @@ -371,7 +371,7 @@ void Curves::updateCurve() lock = false; } -void Curves::updateCurvePoints() +void CurvesPanel::updateCurvePoints() { lock = true; @@ -405,7 +405,7 @@ void Curves::updateCurvePoints() lock = false; } -void Curves::onPointEdited() +void CurvesPanel::onPointEdited() { if (!lock) { int index = sender()->property("index").toInt(); @@ -416,7 +416,7 @@ void Curves::onPointEdited() } } -void Curves::onNodeMoved(int x, int y) +void CurvesPanel::onNodeMoved(int x, int y) { if (!lock) { lock = true; @@ -434,20 +434,20 @@ void Curves::onNodeMoved(int x, int y) } } -void Curves::onNodeFocus() +void CurvesPanel::onNodeFocus() { int index = sender()->property("index").toInt(); spny[index]->setFocus(); } -void Curves::onNodeUnfocus() +void CurvesPanel::onNodeUnfocus() { int index = sender()->property("index").toInt(); spny[index]->clearFocus(); updateCurve(); } -bool Curves::allowCurveType(int points, CurveData::CurveType type) +bool CurvesPanel::allowCurveType(int points, CurveData::CurveType type) { int totalpoints = 0; for (int i = 0; i < maxCurves; i++) { @@ -465,7 +465,7 @@ bool Curves::allowCurveType(int points, CurveData::CurveType type) } } -void Curves::on_curvePoints_currentIndexChanged(int index) +void CurvesPanel::on_curvePoints_currentIndexChanged(int index) { if (!lock) { int numpoints = ((QComboBox *)sender())->itemData(index).toInt(); @@ -488,7 +488,7 @@ void Curves::on_curvePoints_currentIndexChanged(int index) } } -void Curves::on_curveCustom_currentIndexChanged(int index) +void CurvesPanel::on_curveCustom_currentIndexChanged(int index) { if (!lock) { CurveData::CurveType type = (CurveData::CurveType)index; @@ -512,20 +512,23 @@ void Curves::on_curveCustom_currentIndexChanged(int index) } } -void Curves::on_curveSmooth_currentIndexChanged(int index) +void CurvesPanel::on_curveSmooth_currentIndexChanged(int index) { model->curves[currentCurve].smooth = index; update(); } -void Curves::on_curveName_editingFinished() +void CurvesPanel::on_curveName_editingFinished() { - memset(model->curves[currentCurve].name, 0, sizeof(model->curves[currentCurve].name)); - strcpy(model->curves[currentCurve].name, ui->curveName->text().toLatin1()); - emit modified(); + if (ui->curveName->text() != model->curves[currentCurve].name) { + memset(model->curves[currentCurve].name, 0, sizeof(model->curves[currentCurve].name)); + strcpy(model->curves[currentCurve].name, ui->curveName->text().toLatin1()); + emit updateDataModels(); + emit modified(); + } } -void Curves::resizeEvent(QResizeEvent *event) +void CurvesPanel::resizeEvent(QResizeEvent *event) { QRect qr = ui->curvePreview->contentsRect(); ui->curvePreview->scene()->setSceneRect(GFX_MARGIN, GFX_MARGIN, qr.width() - GFX_MARGIN * 2, qr.height() - GFX_MARGIN * 2); @@ -533,7 +536,7 @@ void Curves::resizeEvent(QResizeEvent *event) ModelPanel::resizeEvent(event); } -void Curves::on_curveType_currentIndexChanged(int index) +void CurvesPanel::on_curveType_currentIndexChanged(int index) { unsigned int flags = templates[index].flags; ui->curveCoeffLabel->setVisible(flags & CURVE_COEFF_ENABLE); @@ -547,7 +550,7 @@ void Curves::on_curveType_currentIndexChanged(int index) ui->yMin->setValue(-100); } -void Curves::addTemplate(QString name, unsigned int flags, curveFunction function) +void CurvesPanel::addTemplate(QString name, unsigned int flags, curveFunction function) { CurveCreatorTemplate tmpl; tmpl.name = name; @@ -557,7 +560,7 @@ void Curves::addTemplate(QString name, unsigned int flags, curveFunction functio ui->curveType->addItem(name); } -void Curves::on_curveApply_clicked() +void CurvesPanel::on_curveApply_clicked() { int index = ui->curveType->currentIndex(); int numpoints = model->curves[currentCurve].count; @@ -594,14 +597,14 @@ void Curves::on_curveApply_clicked() emit modified(); } -void Curves::onPointSizeEdited() +void CurvesPanel::onPointSizeEdited() { if (!lock) { update(); } } -void Curves::onNodeDelete() +void CurvesPanel::onNodeDelete() { int index = sender()->property("index").toInt(); int numpoints = model->curves[currentCurve].count; @@ -619,7 +622,7 @@ void Curves::onNodeDelete() } } -void Curves::onSceneNewPoint(int x, int y) +void CurvesPanel::onSceneNewPoint(int x, int y) { if ((model->curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) && (model->curves[currentCurve].count < CPN_MAX_POINTS)) { int newidx = 0; @@ -650,7 +653,7 @@ void Curves::onSceneNewPoint(int x, int y) } } -void Curves::onCustomContextMenuRequested(QPoint pos) +void CurvesPanel::onCustomContextMenuRequested(QPoint pos) { QPushButton *button = (QPushButton *)sender(); selectedIndex = button->property("index").toInt(); @@ -672,7 +675,7 @@ void Curves::onCustomContextMenuRequested(QPoint pos) contextMenu.exec(globalPos); } -bool Curves::hasClipboardData(QByteArray * data) const +bool CurvesPanel::hasClipboardData(QByteArray * data) const { const QClipboard * clipboard = QApplication::clipboard(); const QMimeData * mimeData = clipboard->mimeData(); @@ -684,22 +687,22 @@ bool Curves::hasClipboardData(QByteArray * data) const return false; } -bool Curves::insertAllowed() const +bool CurvesPanel::insertAllowed() const { return ((selectedIndex < maxCurves - 1) && (model->curves[maxCurves - 1].isEmpty())); } -bool Curves::moveDownAllowed() const +bool CurvesPanel::moveDownAllowed() const { return selectedIndex < maxCurves - 1; } -bool Curves::moveUpAllowed() const +bool CurvesPanel::moveUpAllowed() const { return selectedIndex > 0; } -void Curves::cmClear(bool prompt) +void CurvesPanel::cmClear(bool prompt) { if (prompt) { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear Curve. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) @@ -709,10 +712,11 @@ void Curves::cmClear(bool prompt) model->curves[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); update(); + emit updateDataModels(); emit modified(); } -void Curves::cmClearAll() +void CurvesPanel::cmClearAll() { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Curves. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; @@ -722,10 +726,11 @@ void Curves::cmClearAll() model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_CLEAR, i); } update(); + emit updateDataModels(); emit modified(); } -void Curves::cmCopy() +void CurvesPanel::cmCopy() { QByteArray data; data.append((char*)&model->curves[selectedIndex], sizeof(CurveData)); @@ -734,7 +739,7 @@ void Curves::cmCopy() QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); } -void Curves::cmCut() +void CurvesPanel::cmCut() { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Cut Curve. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; @@ -742,7 +747,7 @@ void Curves::cmCut() cmClear(false); } -void Curves::cmDelete() +void CurvesPanel::cmDelete() { if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete Curve. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; @@ -751,40 +756,43 @@ void Curves::cmDelete() model->curves[maxCurves - 1].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); update(); + emit updateDataModels(); emit modified(); } -void Curves::cmInsert() +void CurvesPanel::cmInsert() { memmove(&model->curves[selectedIndex + 1], &model->curves[selectedIndex], (CPN_MAX_CURVES - (selectedIndex + 1)) * sizeof(CurveData)); model->curves[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); + emit updateDataModels(); emit modified(); } -void Curves::cmMoveDown() +void CurvesPanel::cmMoveDown() { swapData(selectedIndex, selectedIndex + 1); } -void Curves::cmMoveUp() +void CurvesPanel::cmMoveUp() { swapData(selectedIndex, selectedIndex - 1); } -void Curves::cmPaste() +void CurvesPanel::cmPaste() { QByteArray data; if (hasClipboardData(&data)) { CurveData *cd = &model->curves[selectedIndex]; memcpy(cd, data.constData(), sizeof(CurveData)); update(); + emit updateDataModels(); emit modified(); } } -void Curves::swapData(int idx1, int idx2) +void CurvesPanel::swapData(int idx1, int idx2) { if ((idx1 != idx2) && (!model->curves[idx1].isEmpty() || !model->curves[idx2].isEmpty())) { CurveData cdtmp = model->curves[idx2]; @@ -794,6 +802,7 @@ void Curves::swapData(int idx1, int idx2) memcpy(cd1, &cdtmp, sizeof(CurveData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); + emit updateDataModels(); emit modified(); } } diff --git a/companion/src/modeledit/curves.h b/companion/src/modeledit/curves.h index 34d1a675e..2e08dbbd4 100644 --- a/companion/src/modeledit/curves.h +++ b/companion/src/modeledit/curves.h @@ -54,13 +54,13 @@ class CustomScene : public QGraphicsScene virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event) override; }; -class Curves : public ModelPanel +class CurvesPanel : public ModelPanel { Q_OBJECT public: - Curves(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); - virtual ~Curves(); + CurvesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + virtual ~CurvesPanel(); virtual void update(); @@ -91,6 +91,9 @@ class Curves : public ModelPanel void cmMoveDown(); void cmMoveUp(); + signals: + void updateDataModels(); + protected: virtual void resizeEvent(QResizeEvent *event); void addTemplate(QString name, unsigned int flags, curveFunction function); diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 36dba9c97..ddbf724f0 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -41,7 +41,7 @@ RepeatComboBox::RepeatComboBox(QWidget *parent, int & repeatParam): addItem(tr("No repeat"), 0); - for (unsigned int i=step; i<=60; i+=step) { + for (unsigned int i = step; i <= 60; i += step) { addItem(tr("%1s").arg(i), i); } @@ -66,24 +66,36 @@ void RepeatComboBox::update() setCurrentIndex(value); } -CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware): +CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): GenericPanel(parent, model, generalSettings, firmware), functions(model ? model->customFn : generalSettings.customFn), mediaPlayerCurrent(-1), - mediaPlayer(nullptr) + mediaPlayer(nullptr), + modelsUpdateCnt(0) { - Stopwatch s1("CustomFunctionsPanel - populate"); lock = true; fswCapability = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions); - rawSwitchItemModel = new RawSwitchFilterItemModel(&generalSettings, model, model ? RawSwitch::SpecialFunctionsContext : RawSwitch::GlobalFunctionsContext, this); - rawSrcAllItemModel = new RawSourceFilterItemModel(&generalSettings, model, this); - rawSrcInputsItemModel = new RawSourceFilterItemModel(rawSrcAllItemModel->sourceModel(), RawSource::InputSourceGroups, this); - rawSrcGVarsItemModel = new RawSourceFilterItemModel(rawSrcAllItemModel->sourceModel(), RawSource::GVarsGroup, this); + rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, model ? RawSwitch::SpecialFunctionsContext : RawSwitch::GlobalFunctionsContext); + connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); + + rawSrcAllModel = new RawItemFilteredModel(rawSourceItemModel); + connect(rawSrcAllModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSrcAllModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); + + rawSrcInputsModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups); + connect(rawSrcInputsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSrcInputsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); + + rawSrcGVarsModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::GVarsGroup); + connect(rawSrcGVarsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSrcGVarsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); if (!firmware->getCapability(VoicesAsNumbers)) { tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength)); - for (int i=0; igetBoard())) { scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/FUNCTIONS", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength)); - for (int i=0; isetContextMenuPolicy(Qt::CustomContextMenu); @@ -123,9 +132,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, label->setMouseTracking(true); label->setProperty("index", i); if (model) - label->setText(tr("SF%1").arg(i+1)); + label->setText(tr("SF%1").arg(i + 1)); else - label->setText(tr("GF%1").arg(i+1)); + label->setText(tr("GF%1").arg(i + 1)); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenuRequested(QPoint))); tableLayout->addWidget(i, 0, label); @@ -133,7 +142,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, // The switch fswtchSwtch[i] = new QComboBox(this); - fswtchSwtch[i]->setModel(rawSwitchItemModel); + fswtchSwtch[i]->setModel(rawSwitchModel); fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue())); fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); @@ -198,7 +207,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, fswtchParamArmT[i]->setEditable(true); fswtchParamArmT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); paramLayout->addWidget(fswtchParamArmT[i]); - connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); @@ -221,46 +229,34 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, QHBoxLayout * repeatLayout = new QHBoxLayout(); tableLayout->addLayout(i, 4, repeatLayout); fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam); - repeatLayout->addWidget(fswtchRepeat[i], i+1); - connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified())); + repeatLayout->addWidget(fswtchRepeat[i], i + 1); + connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onRepeatModified())); fswtchEnable[i] = new QCheckBox(this); fswtchEnable[i]->setProperty("index", i); fswtchEnable[i]->setText(tr("ON")); fswtchEnable[i]->setFixedWidth(200); - repeatLayout->addWidget(fswtchEnable[i], i+1); + repeatLayout->addWidget(fswtchEnable[i], i + 1); connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); } - s1.report("add items"); - disableMouseScrolling(); - s1.report("disableMouseScrolling"); - - lock = false; + tableLayout->resizeColumnsToContents(); + tableLayout->setColumnWidth(3, 300); + tableLayout->pushRowsUp(fswCapability + 1); update(); - s1.report("update"); - tableLayout->resizeColumnsToContents(); - s1.report("resizeColumnsToContents"); - tableLayout->setColumnWidth(3, 300); - tableLayout->pushRowsUp(fswCapability+1); - s1.report("end"); + lock = false; } CustomFunctionsPanel::~CustomFunctionsPanel() { if (mediaPlayer) stopSound(mediaPlayerCurrent); -} - -void CustomFunctionsPanel::updateDataModels() -{ - const bool oldLock = lock; - lock = true; - rawSwitchItemModel->update(); - rawSrcAllItemModel->update(); - lock = oldLock; + delete rawSwitchModel; + delete rawSrcAllModel; + delete rawSrcInputsModel; + delete rawSrcGVarsModel; } void CustomFunctionsPanel::onMediaPlayerStateChanged(QMediaPlayer::State state) @@ -343,6 +339,7 @@ void CustomFunctionsPanel::toggleSound(bool play) #define CUSTOM_FUNCTION_BL_COLOR (1<<9) #define CUSTOM_FUNCTION_SHOW_FUNC (1<<10) + void CustomFunctionsPanel::customFunctionEdited() { if (!lock) { @@ -369,162 +366,151 @@ void CustomFunctionsPanel::functionEdited() } } -void CustomFunctionsPanel::onChildModified() +void CustomFunctionsPanel::onRepeatModified() { emit modified(); } void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) { - CustomFunctionData & cfn = functions[i]; - AssignFunc func = (AssignFunc)fswtchFunc[i]->currentData().toInt(); + CustomFunctionData & cfn = functions[i]; + AssignFunc func = (AssignFunc)fswtchFunc[i]->currentData().toInt(); - unsigned int widgetsMask = 0; - if (modified) { - cfn.swtch = RawSwitch(fswtchSwtch[i]->currentData().toInt()); - cfn.func = func; - cfn.enabled = fswtchEnable[i]->isChecked(); - } + unsigned int widgetsMask = 0; + if (modified) { + cfn.swtch = RawSwitch(fswtchSwtch[i]->currentData().toInt()); + cfn.func = func; + cfn.enabled = fswtchEnable[i]->isChecked(); + } - if (!cfn.isEmpty()) { - widgetsMask |= CUSTOM_FUNCTION_SHOW_FUNC; + if (!cfn.isEmpty()) { + widgetsMask |= CUSTOM_FUNCTION_SHOW_FUNC; - if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32) { - if (model) { - int channelsMax = model->getChannelsMax(true); - fswtchParam[i]->setDecimals(0); - fswtchParam[i]->setSingleStep(1); - fswtchParam[i]->setMinimum(-channelsMax); - fswtchParam[i]->setMaximum(channelsMax); - if (modified) { - cfn.param = fswtchParam[i]->value(); - } - fswtchParam[i]->setValue(cfn.param); - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM | CUSTOM_FUNCTION_ENABLE; + if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32) { + if (model) { + int channelsMax = model->getChannelsMax(true); + fswtchParam[i]->setDecimals(0); + fswtchParam[i]->setSingleStep(1); + fswtchParam[i]->setMinimum(-channelsMax); + fswtchParam[i]->setMaximum(channelsMax); + if (modified) { + cfn.param = fswtchParam[i]->value(); } + fswtchParam[i]->setValue(cfn.param); + widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM | CUSTOM_FUNCTION_ENABLE; } - else if (func == FuncLogs) { - fswtchParam[i]->setDecimals(1); - fswtchParam[i]->setMinimum(0); - fswtchParam[i]->setMaximum(25.5); - fswtchParam[i]->setSingleStep(0.1); + } + else if (func == FuncLogs) { + fswtchParam[i]->setDecimals(1); + fswtchParam[i]->setMinimum(0); + fswtchParam[i]->setMaximum(25.5); + fswtchParam[i]->setSingleStep(0.1); + if (modified) + cfn.param = fswtchParam[i]->value() * 10.0; + fswtchParam[i]->setValue(cfn.param / 10.0); + widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; + } + else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) { + int gvidx = func - FuncAdjustGV1; + if (modified) + cfn.adjustMode = fswtchGVmode[i]->currentIndex(); + fswtchGVmode[i]->setCurrentIndex(cfn.adjustMode); + widgetsMask |= CUSTOM_FUNCTION_GV_MODE | CUSTOM_FUNCTION_ENABLE; + if (cfn.adjustMode == FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode == FUNC_ADJUST_GVAR_INCDEC) { if (modified) - cfn.param = fswtchParam[i]->value()*10.0; - fswtchParam[i]->setValue(cfn.param/10.0); - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; - } - else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) { - int gvidx = func - FuncAdjustGV1; - if (modified) - cfn.adjustMode = fswtchGVmode[i]->currentIndex(); - fswtchGVmode[i]->setCurrentIndex(cfn.adjustMode); - widgetsMask |= CUSTOM_FUNCTION_GV_MODE | CUSTOM_FUNCTION_ENABLE; - if (cfn.adjustMode == FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode == FUNC_ADJUST_GVAR_INCDEC) { - if (modified) - cfn.param = fswtchParam[i]->value() * model->gvarData[gvidx].multiplierSet(); - fswtchParam[i]->setDecimals(model->gvarData[gvidx].prec); - fswtchParam[i]->setSingleStep(model->gvarData[gvidx].multiplierGet()); - fswtchParam[i]->setSuffix(model->gvarData[gvidx].unitToString()); - if (cfn.adjustMode==FUNC_ADJUST_GVAR_INCDEC) { - double rng = abs(model->gvarData[gvidx].getMax() - model->gvarData[gvidx].getMin()); - rng *= model->gvarData[gvidx].multiplierGet(); - fswtchParam[i]->setMinimum(-rng); - fswtchParam[i]->setMaximum(rng); - } - else { - fswtchParam[i]->setMinimum(model->gvarData[gvidx].getMinPrec()); - fswtchParam[i]->setMaximum(model->gvarData[gvidx].getMaxPrec()); - } - fswtchParam[i]->setValue(cfn.param * model->gvarData[gvidx].multiplierGet()); - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; + cfn.param = fswtchParam[i]->value() * model->gvarData[gvidx].multiplierSet(); + fswtchParam[i]->setDecimals(model->gvarData[gvidx].prec); + fswtchParam[i]->setSingleStep(model->gvarData[gvidx].multiplierGet()); + fswtchParam[i]->setSuffix(model->gvarData[gvidx].unitToString()); + if (cfn.adjustMode == FUNC_ADJUST_GVAR_INCDEC) { + double rng = abs(model->gvarData[gvidx].getMax() - model->gvarData[gvidx].getMin()); + rng *= model->gvarData[gvidx].multiplierGet(); + fswtchParam[i]->setMinimum(-rng); + fswtchParam[i]->setMaximum(rng); } else { - if (modified) - cfn.param = fswtchParamT[i]->currentData().toInt(); - populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; + fswtchParam[i]->setMinimum(model->gvarData[gvidx].getMinPrec()); + fswtchParam[i]->setMaximum(model->gvarData[gvidx].getMaxPrec()); } + fswtchParam[i]->setValue(cfn.param * model->gvarData[gvidx].multiplierGet()); + widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } - else if (func == FuncReset) { + else { + if (modified) + cfn.param = fswtchParamT[i]->currentData().toInt(); + populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; + } + } + else if (func == FuncReset) { + if (modified) + cfn.param = fswtchParamT[i]->currentData().toInt(); + populateFuncParamCB(fswtchParamT[i], func, cfn.param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; + } + else if (func >= FuncSetTimer1 && func <= FuncSetTimer3) { + if (modified) + cfn.param = fswtchParamTime[i]->timeInSeconds(); + RawSourceRange range = RawSource(SOURCE_TYPE_SPECIAL, func - FuncSetTimer1 + 2).getRange(model, generalSettings); + fswtchParamTime[i]->setTimeRange((int)range.min, (int)range.max); + fswtchParamTime[i]->setTime(cfn.param); + widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM | CUSTOM_FUNCTION_ENABLE; + } + else if (func >= FuncSetFailsafeInternalModule && func <= FuncBindExternalModule) { + widgetsMask |= CUSTOM_FUNCTION_ENABLE; + } + else if (func == FuncVolume || func == FuncBacklight) { + if (modified) + cfn.param = fswtchParamT[i]->currentData().toInt(); + populateFuncParamCB(fswtchParamT[i], func, cfn.param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; + } + else if (func == FuncPlaySound || func == FuncPlayHaptic || func == FuncPlayValue || func == FuncPlayPrompt || func == FuncPlayBoth || func == FuncBackgroundMusic) { + if (func != FuncBackgroundMusic) { + widgetsMask |= CUSTOM_FUNCTION_REPEAT; + fswtchRepeat[i]->update(); + } + if (func == FuncPlayValue) { if (modified) cfn.param = fswtchParamT[i]->currentData().toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_REPEAT; } - else if (func >= FuncSetTimer1 && func <= FuncSetTimer3) { - if (modified) - cfn.param = fswtchParamTime[i]->timeInSeconds(); - RawSourceRange range = RawSource(SOURCE_TYPE_SPECIAL, func - FuncSetTimer1 + 2).getRange(model, generalSettings); - fswtchParamTime[i]->setTimeRange((int)range.min, (int)range.max); - fswtchParamTime[i]->setTime(cfn.param); - widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM | CUSTOM_FUNCTION_ENABLE; - } - else if (func >= FuncSetFailsafeInternalModule && func <= FuncBindExternalModule) { - widgetsMask |= CUSTOM_FUNCTION_ENABLE; - } - else if (func == FuncVolume || func == FuncBacklight) { - if (modified) - cfn.param = fswtchParamT[i]->currentData().toInt(); - populateFuncParamCB(fswtchParamT[i], func, cfn.param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; - } - else if (func == FuncPlaySound || func == FuncPlayHaptic || func == FuncPlayValue || func == FuncPlayPrompt || func == FuncPlayBoth || func == FuncBackgroundMusic) { - if (func != FuncBackgroundMusic) { - widgetsMask |= CUSTOM_FUNCTION_REPEAT; - fswtchRepeat[i]->update(); - } - if (func == FuncPlayValue) { - if (modified) - cfn.param = fswtchParamT[i]->currentData().toInt(); - populateFuncParamCB(fswtchParamT[i], func, cfn.param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_REPEAT; - } - else if (func == FuncPlayPrompt || func == FuncPlayBoth) { - if (firmware->getCapability(VoicesAsNumbers)) { - fswtchParam[i]->setDecimals(0); - fswtchParam[i]->setSingleStep(1); - fswtchParam[i]->setMinimum(0); - if (func == FuncPlayPrompt) { - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM | CUSTOM_FUNCTION_REPEAT | CUSTOM_FUNCTION_GV_TOOGLE; - } - else { - widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM | CUSTOM_FUNCTION_REPEAT; - fswtchParamGV[i]->setChecked(false); - } - fswtchParam[i]->setMaximum(func == FuncPlayBoth ? 254 : 255); - if (modified) { - if (fswtchParamGV[i]->isChecked()) { - fswtchParam[i]->setMinimum(1); - cfn.param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); - } - else { - cfn.param = fswtchParam[i]->value(); - } - } - if (cfn.param>250 && (func!=FuncPlayBoth)) { - fswtchParamGV[i]->setChecked(true); - fswtchParam[i]->setValue(cfn.param-250); - fswtchParam[i]->setMaximum(5); - } - else { - fswtchParamGV[i]->setChecked(false); - fswtchParam[i]->setValue(cfn.param); - } - if (cfn.param < 251) - widgetsMask |= CUSTOM_FUNCTION_PLAY; + else if (func == FuncPlayPrompt || func == FuncPlayBoth) { + if (firmware->getCapability(VoicesAsNumbers)) { + fswtchParam[i]->setDecimals(0); + fswtchParam[i]->setSingleStep(1); + fswtchParam[i]->setMinimum(0); + if (func == FuncPlayPrompt) { + widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM | CUSTOM_FUNCTION_REPEAT | CUSTOM_FUNCTION_GV_TOOGLE; } else { - widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; - if (modified) { - Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength)); + widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM | CUSTOM_FUNCTION_REPEAT; + fswtchParamGV[i]->setChecked(false); + } + fswtchParam[i]->setMaximum(func == FuncPlayBoth ? 254 : 255); + if (modified) { + if (fswtchParamGV[i]->isChecked()) { + fswtchParam[i]->setMinimum(1); + cfn.param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); } - Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm); - if (fswtchParamArmT[i]->currentText() != "----") { - widgetsMask |= CUSTOM_FUNCTION_PLAY; + else { + cfn.param = fswtchParam[i]->value(); } } + if (cfn.param > 250 && (func != FuncPlayBoth)) { + fswtchParamGV[i]->setChecked(true); + fswtchParam[i]->setValue(cfn.param - 250); + fswtchParam[i]->setMaximum(5); + } + else { + fswtchParamGV[i]->setChecked(false); + fswtchParam[i]->setValue(cfn.param); + } + if (cfn.param < 251) + widgetsMask |= CUSTOM_FUNCTION_PLAY; } - else if (func == FuncBackgroundMusic) { + else { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength)); @@ -534,58 +520,68 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) widgetsMask |= CUSTOM_FUNCTION_PLAY; } } - else if (func == FuncPlaySound) { - if (modified) - cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], func, cfn.param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } - else if (func == FuncPlayHaptic) { - if (modified) - cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); - populateFuncParamCB(fswtchParamT[i], func, cfn.param); - widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; - } } - else if (func == FuncPlayScript) { + else if (func == FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { - Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8); + Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength)); + } + Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm); + if (fswtchParamArmT[i]->currentText() != "----") { + widgetsMask |= CUSTOM_FUNCTION_PLAY; } - Helpers::populateFileComboBox(fswtchParamArmT[i], scriptsSet, cfn.paramarm); } - else { + else if (func == FuncPlaySound) { if (modified) - cfn.param = fswtchParam[i]->value(); - fswtchParam[i]->setDecimals(0); - fswtchParam[i]->setSingleStep(1); - fswtchParam[i]->setValue(cfn.param); - if (func <= FuncInstantTrim) { - widgetsMask |= CUSTOM_FUNCTION_ENABLE; - } + cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); + populateFuncParamCB(fswtchParamT[i], func, cfn.param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; + } + else if (func == FuncPlayHaptic) { + if (modified) + cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); + populateFuncParamCB(fswtchParamT[i], func, cfn.param); + widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } + else if (func == FuncPlayScript) { + widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; + if (modified) { + Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8); + } + Helpers::populateFileComboBox(fswtchParamArmT[i], scriptsSet, cfn.paramarm); + } + else { + if (modified) + cfn.param = fswtchParam[i]->value(); + fswtchParam[i]->setDecimals(0); + fswtchParam[i]->setSingleStep(1); + fswtchParam[i]->setValue(cfn.param); + if (func <= FuncInstantTrim) { + widgetsMask |= CUSTOM_FUNCTION_ENABLE; + } + } + } - fswtchFunc[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SHOW_FUNC); - fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM); - fswtchParamTime[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_TIME_PARAM); - fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE); - fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM); - fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM); - fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE); - if (widgetsMask & CUSTOM_FUNCTION_ENABLE) - fswtchEnable[i]->setChecked(cfn.enabled); - else - fswtchEnable[i]->setChecked(false); - fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); - fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); - fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR); - playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); + fswtchFunc[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SHOW_FUNC); + fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM); + fswtchParamTime[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_TIME_PARAM); + fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE); + fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM); + fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM); + fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE); + if (widgetsMask & CUSTOM_FUNCTION_ENABLE) + fswtchEnable[i]->setChecked(cfn.enabled); + else + fswtchEnable[i]->setChecked(false); + fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); + fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); + fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR); + playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); } void CustomFunctionsPanel::update() { - updateDataModels(); lock = true; for (int i = 0; i < fswCapability; i++) { refreshCustomFunction(i); @@ -660,16 +656,16 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value) { b->clear(); for (unsigned int i = 0; i < FuncCount; i++) { - if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && (!model || !firmware->getCapability(SafetyChannelCustomFunction))) || - ((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) || - ((i==FuncPlayScript && !IS_HORUS_OR_TARANIS(firmware->getBoard()))) || - ((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) || - ((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) || - ((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) || - ((i==FuncSetTimer3) && firmware->getCapability(Timers) < 3) || - ((i==FuncScreenshot) && !IS_HORUS_OR_TARANIS(firmware->getBoard())) || - ((i>=FuncRangeCheckInternalModule && i<=FuncBindExternalModule) && (!model || !firmware->getCapability(DangerousFunctions))) || - ((i>=FuncAdjustGV1 && i<=FuncAdjustGVLast) && (!model || !firmware->getCapability(Gvars))) + if (((i >= FuncOverrideCH1 && i <= FuncOverrideCH32) && (!model || !firmware->getCapability(SafetyChannelCustomFunction))) || + ((i == FuncVolume || i == FuncBackgroundMusic || i == FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) || + ((i == FuncPlayScript && !IS_HORUS_OR_TARANIS(firmware->getBoard()))) || + ((i == FuncPlayHaptic) && !firmware->getCapability(Haptic)) || + ((i == FuncPlayBoth) && !firmware->getCapability(HasBeeper)) || + ((i == FuncLogs) && !firmware->getCapability(HasSDLogs)) || + ((i == FuncSetTimer3) && firmware->getCapability(Timers) < 3) || + ((i == FuncScreenshot) && !IS_HORUS_OR_TARANIS(firmware->getBoard())) || + ((i >= FuncRangeCheckInternalModule && i <= FuncBindExternalModule) && (!model || !firmware->getCapability(DangerousFunctions))) || + ((i >= FuncAdjustGV1 && i <= FuncAdjustGVLast) && (!model || !firmware->getCapability(Gvars))) ) { // skipped continue; @@ -711,21 +707,21 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi CustomFunctionData::populateResetParams(model, b, value); } else if (function == FuncVolume || function == FuncBacklight) { - b->setModel(rawSrcInputsItemModel); + b->setModel(rawSrcInputsModel); b->setCurrentIndex(b->findData(value)); } else if (function == FuncPlayValue) { - b->setModel(rawSrcAllItemModel); + b->setModel(rawSrcAllModel); b->setCurrentIndex(b->findData(value)); } else if (function >= FuncAdjustGV1 && function <= FuncAdjustGVLast) { switch (adjustmode) { case 1: - b->setModel(rawSrcInputsItemModel); + b->setModel(rawSrcInputsModel); b->setCurrentIndex(b->findData(value)); break; case 2: - b->setModel(rawSrcGVarsItemModel); + b->setModel(rawSrcGVarsModel); b->setCurrentIndex(b->findData(value)); break; } @@ -830,3 +826,21 @@ bool CustomFunctionsPanel::moveUpAllowed() const { return selectedIndex > 0; } + +void CustomFunctionsPanel::onModelDataAboutToBeUpdated() +{ + lock = true; + modelsUpdateCnt++; +} + +void CustomFunctionsPanel::onModelDataUpdateComplete() +{ + modelsUpdateCnt--; + if (modelsUpdateCnt < 1) + lock = true; + for (int i = 0; i < fswCapability; i++) { + fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue())); + fswtchFunc[i]->setCurrentIndex(fswtchFunc[i]->findData(functions[i].func)); + } + update(); +} diff --git a/companion/src/modeledit/customfunctions.h b/companion/src/modeledit/customfunctions.h index 54a83ddcf..98b173ee5 100644 --- a/companion/src/modeledit/customfunctions.h +++ b/companion/src/modeledit/customfunctions.h @@ -26,8 +26,9 @@ #include -class RawSourceFilterItemModel; -class RawSwitchFilterItemModel; +class RawSourceItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; class TimerEdit; constexpr char MIMETYPE_CUSTOM_FUNCTION[] = "application/x-companion-custom-function"; @@ -55,7 +56,8 @@ class CustomFunctionsPanel : public GenericPanel Q_OBJECT public: - CustomFunctionsPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware); + CustomFunctionsPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); ~CustomFunctionsPanel(); virtual void update(); @@ -64,12 +66,11 @@ class CustomFunctionsPanel : public GenericPanel CustomFunctionData * functions; private slots: - void updateDataModels(); void customFunctionEdited(); void functionEdited(); void onCustomContextMenuRequested(QPoint pos); void refreshCustomFunction(int index, bool modified=false); - void onChildModified(); + void onRepeatModified(); bool playSound(int index); void stopSound(int index); void toggleSound(bool play); @@ -84,6 +85,8 @@ class CustomFunctionsPanel : public GenericPanel void cmInsert(); void cmClear(bool prompt = true); void cmClearAll(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); private: void populateFuncCB(QComboBox *b, unsigned int value); @@ -95,10 +98,10 @@ class CustomFunctionsPanel : public GenericPanel bool moveUpAllowed() const; void swapData(int idx1, int idx2); void resetCBsAndRefresh(int idx); - RawSwitchFilterItemModel * rawSwitchItemModel; - RawSourceFilterItemModel * rawSrcAllItemModel; - RawSourceFilterItemModel * rawSrcInputsItemModel; - RawSourceFilterItemModel * rawSrcGVarsItemModel; + RawItemFilteredModel * rawSwitchModel; + RawItemFilteredModel * rawSrcAllModel; + RawItemFilteredModel * rawSrcInputsModel; + RawItemFilteredModel * rawSrcGVarsModel; QSet tracksSet; QSet scriptsSet; @@ -119,7 +122,7 @@ class CustomFunctionsPanel : public GenericPanel int selectedIndex; int fswCapability; - + int modelsUpdateCnt; }; #endif // _CUSTOMFUNCTIONS_H_ diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index 95aaeca66..1df0ffaf0 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -24,7 +24,8 @@ #include "helpers.h" ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, GeneralSettings & generalSettings, - Firmware * firmware, QString & inputName) : + Firmware * firmware, QString & inputName, RawSourceItemModel * rawSourceItemModel, + RawSwitchItemModel * rawSwitchItemModel) : QDialog(parent), ui(new Ui::ExpoDialog), model(model), @@ -36,6 +37,9 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G lock(false) { ui->setupUi(this); + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~RawSource::InputsGroup) | RawSource::TelemGroup, this); + rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); + QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; for (int i=0; icurveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, model, firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES)); - ui->switchesCB->setModel(new RawSwitchFilterItemModel(&generalSettings, &model, RawSwitch::MixesContext, this)); + ui->switchesCB->setModel(rawSwitchModel); ui->switchesCB->setCurrentIndex(ui->switchesCB->findData(ed->swtch.toValue())); ui->sideCB->setCurrentIndex(ed->mode-1); @@ -83,7 +87,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G if (firmware->getCapability(VirtualInputs)) { ui->inputName->setMaxLength(firmware->getCapability(InputsLength)); - ui->sourceCB->setModel(new RawSourceFilterItemModel(&generalSettings, &model, (RawSource::InputSourceGroups & ~RawSource::InputsGroup) | RawSource::TelemGroup, this)); + ui->sourceCB->setModel(rawSourceModel); ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(ed->srcRaw.toValue())); ui->sourceCB->removeItem(0); ui->inputName->setValidator(new QRegExpValidator(rx, this)); diff --git a/companion/src/modeledit/expodialog.h b/companion/src/modeledit/expodialog.h index e1355e147..1a3cc26af 100644 --- a/companion/src/modeledit/expodialog.h +++ b/companion/src/modeledit/expodialog.h @@ -27,6 +27,9 @@ class GVarGroup; class CurveGroup; +class RawSourceItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; namespace Ui { class ExpoDialog; @@ -36,7 +39,8 @@ class ExpoDialog : public QDialog { Q_OBJECT public: ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expodata, GeneralSettings & generalSettings, - Firmware * firmware, QString & inputName); + Firmware * firmware, QString & inputName, RawSourceItemModel * rawSourceItemModel, + RawSwitchItemModel * rawSwitchItemModel); ~ExpoDialog(); protected: @@ -63,6 +67,8 @@ class ExpoDialog : public QDialog { ModelPrinter modelPrinter; bool lock; QCheckBox * cb_fp[CPN_MAX_FLIGHT_MODES]; + RawItemFilteredModel * rawSourceModel; + RawItemFilteredModel * rawSwitchModel; }; #endif // _EXPODIALOG_H_ diff --git a/companion/src/modeledit/flightmodes.cpp b/companion/src/modeledit/flightmodes.cpp index 12082091d..92d69e5e7 100644 --- a/companion/src/modeledit/flightmodes.cpp +++ b/companion/src/modeledit/flightmodes.cpp @@ -24,14 +24,15 @@ #include "helpers.h" #include "customdebug.h" -FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchFilterItemModel * switchModel): +FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * switchModel): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::FlightMode), phaseIdx(phaseIdx), - phase(model.flightModeData[phaseIdx]), - rawSwitchItemModel(NULL) + phase(model.flightModeData[phaseIdx]) { ui->setupUi(this); + connect(switchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &FlightModePanel::onModelDataAboutToBeUpdated); + connect(switchModel, &RawItemFilteredModel::dataUpdateComplete, this, &FlightModePanel::onModelDataUpdateComplete); ui->labelName->setContextMenuPolicy(Qt::CustomContextMenu); ui->labelName->setToolTip(tr("Popup menu available")); @@ -316,8 +317,6 @@ void FlightModePanel::update() for (int i = 0; i < reCount; i++) { updateRotaryEncoder(i); } - - emit nameModified(); } void FlightModePanel::updateGVar(int index) @@ -390,8 +389,8 @@ void FlightModePanel::phaseName_editingFinished() { QLineEdit *lineEdit = qobject_cast(sender()); strcpy(phase.name, lineEdit->text().toLatin1()); + emit phaseNameChanged(); emit modified(); - emit nameModified(); } void FlightModePanel::phaseSwitchChanged(int index) @@ -401,6 +400,8 @@ void FlightModePanel::phaseSwitchChanged(int index) const RawSwitch rs(ui->swtch->itemData(index).toInt(&ok)); if (ok && phase.swtch.toValue() != rs.toValue()) { phase.swtch = rs; + if (!rs.isSet()) + emit phaseNoSwitchSet(); emit modified(); } } @@ -457,7 +458,7 @@ void FlightModePanel::phaseGVValue_editingFinished() QDoubleSpinBox *spinBox = qobject_cast(sender()); int gvar = spinBox->property("index").toInt(); phase.gvars[gvar] = spinBox->value() * model->gvarData[gvar].multiplierSet(); - emit datachanged(); + updateGVar(gvar); emit modified(); } } @@ -469,7 +470,7 @@ void FlightModePanel::GVName_editingFinished() int gvar = lineedit->property("index").toInt(); memset(&model->gvarData[gvar].name, 0, sizeof(model->gvarData[gvar].name)); strcpy(model->gvarData[gvar].name, lineedit->text().toLatin1()); - emit datachanged(); + emit gvNameChanged(); emit modified(); } } @@ -488,7 +489,7 @@ void FlightModePanel::phaseGVUse_currentIndexChanged(int index) } if (model->isGVarLinkedCircular(phaseIdx, gvar)) QMessageBox::warning(this, "Companion", tr("Warning: Global variable links back to itself. Flight Mode 0 value used.")); - emit datachanged(); + updateGVar(gvar); emit modified(); lock = false; } @@ -500,7 +501,7 @@ void FlightModePanel::phaseGVUnit_currentIndexChanged(int index) QComboBox *comboBox = qobject_cast(sender()); int gvar = comboBox->property("index").toInt(); model->gvarData[gvar].unit = index; - emit datachanged(); + updateGVar(gvar); emit modified(); } } @@ -511,7 +512,7 @@ void FlightModePanel::phaseGVPrec_currentIndexChanged(int index) QComboBox *comboBox = qobject_cast(sender()); int gvar = comboBox->property("index").toInt(); model->gvarData[gvar].prec = index; - emit datachanged(); + updateGVar(gvar); emit modified(); } } @@ -534,7 +535,7 @@ void FlightModePanel::phaseGVMin_editingFinished() } } } - emit datachanged(); + updateGVar(gvar); emit modified(); } } @@ -557,7 +558,7 @@ void FlightModePanel::phaseGVMax_editingFinished() } } } - emit datachanged(); + updateGVar(gvar); emit modified(); } } @@ -741,7 +742,8 @@ void FlightModePanel::cmClear(bool prompt) model->updateAllReferences(ModelData::REF_UPD_TYPE_FLIGHT_MODE, ModelData::REF_UPD_ACT_CLEAR, phaseIdx); - emit datachanged(); + update(); + emit phaseDataChanged(); emit modified(); } @@ -767,7 +769,7 @@ void FlightModePanel::cmClearAll() model->updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE, ModelData::REF_UPD_ACT_CLEAR, i); } - emit datachanged(); + emit phaseDataChanged(); emit modified(); } @@ -846,7 +848,7 @@ void FlightModePanel::cmDelete() model->updateAllReferences(ModelData::REF_UPD_TYPE_FLIGHT_MODE, ModelData::REF_UPD_ACT_SHIFT, phaseIdx, 0, -1); - emit datachanged(); + emit phaseDataChanged(); emit modified(); } @@ -897,7 +899,7 @@ void FlightModePanel::cmInsert() model->updateAllReferences(ModelData::REF_UPD_TYPE_FLIGHT_MODE, ModelData::REF_UPD_ACT_SHIFT, phaseIdx, 0, 1); - emit datachanged(); + emit phaseDataChanged(); emit modified(); } @@ -946,7 +948,7 @@ void FlightModePanel::cmPaste() } } - emit datachanged(); + emit phaseDataChanged(); emit modified(); } } @@ -1035,7 +1037,7 @@ void FlightModePanel::swapData(int idx1, int idx2) } model->updateAllReferences(ModelData::REF_UPD_TYPE_FLIGHT_MODE, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); - emit datachanged(); + emit phaseDataChanged(); emit modified(); } @@ -1162,7 +1164,8 @@ void FlightModePanel::gvCmClear(bool prompt) } phase.gvars[gvIdx] = phase.linkedGVarFlightModeZero(phaseIdx); } - emit datachanged(); + updateGVar(gvIdx); + emit gvNameChanged(); emit modified(); } @@ -1186,7 +1189,10 @@ void FlightModePanel::gvCmClearAll() phase.gvars[i] = phase.linkedGVarFlightModeZero(phaseIdx); } } - emit datachanged(); + for (int i = 0; i < gvCount; i++) { + updateGVar(i); + } + emit gvNameChanged(); emit modified(); } @@ -1261,8 +1267,13 @@ void FlightModePanel::gvCmDelete() for (int j = 0; j < fmCount; j++) { model->flightModeData[j].gvars[maxidx] = model->flightModeData[j].linkedGVarFlightModeZero(j); } + model->updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE, ModelData::REF_UPD_ACT_SHIFT, gvIdx, 0, -1); - emit datachanged(); + + for (int i = 0; i < gvCount; i++) { + updateGVar(i); + } + emit gvNameChanged(); emit modified(); } @@ -1279,7 +1290,10 @@ void FlightModePanel::gvCmInsert() model->flightModeData[j].gvars[gvIdx] = model->flightModeData[j].linkedGVarFlightModeZero(j); } model->updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE, ModelData::REF_UPD_ACT_SHIFT, gvIdx, 0, 1); - emit datachanged(); + for (int i = 0; i < gvCount; i++) { + updateGVar(i); + } + emit gvNameChanged(); emit modified(); } @@ -1322,7 +1336,8 @@ void FlightModePanel::gvCmPaste() else phase.gvars[gvIdx] = val; } - emit datachanged(); + updateGVar(gvIdx); + emit gvNameChanged(); emit modified(); } @@ -1340,37 +1355,57 @@ void FlightModePanel::gvSwapData(int idx1, int idx2) model->flightModeData[j].gvars[idx1] = valtmp; } model->updateAllReferences(ModelData::REF_UPD_TYPE_GLOBAL_VARIABLE, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); - emit datachanged(); + updateGVar(idx1); + updateGVar(idx2); + emit gvNameChanged(); emit modified(); } } +void FlightModePanel::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void FlightModePanel::onModelDataUpdateComplete() +{ + update(); + lock = false; +} + /**********************************************************/ -FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): - ModelPanel(parent, model, generalSettings, firmware), - modesCount(firmware->getCapability(FlightModes)) +FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel): + ModelPanel(parent, model, generalSettings, firmware) { - - RawSwitchFilterItemModel * swModel = new RawSwitchFilterItemModel(&generalSettings, &model, RawSwitch::MixesContext, this); - connect(this, &FlightModesPanel::updated, swModel, &RawSwitchFilterItemModel::update); + rawSwitchFilteredModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); + modesCount = firmware->getCapability(FlightModes); QGridLayout * gridLayout = new QGridLayout(this); tabWidget = new QTabWidget(this); for (int i = 0; i < modesCount; i++) { - FlightModePanel * tab = new FlightModePanel(tabWidget, model, i, generalSettings, firmware, swModel); + FlightModePanel * tab = new FlightModePanel(tabWidget, model, i, generalSettings, firmware, rawSwitchFilteredModel); tab->setProperty("index", i); - connect(tab, &FlightModePanel::datachanged, this, &FlightModesPanel::update); - connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified); - connect(tab, &FlightModePanel::nameModified, this, &FlightModesPanel::onPhaseNameChanged); - connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update); + connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified); + connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::onPhaseNameChanged); + connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::update); + connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::refreshDataModels); + connect(tab, &FlightModePanel::phaseNameChanged, this, &FlightModesPanel::onPhaseNameChanged); + connect(tab, &FlightModePanel::phaseNoSwitchSet, this, &FlightModesPanel::refreshDataModels); + connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::refreshDataModels); + + connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update); tabWidget->addTab(tab, getTabName(i)); + panels << tab; } + connect(tabWidget, &QTabWidget::currentChanged, this, &FlightModesPanel::onTabIndexChanged); gridLayout->addWidget(tabWidget, 0, 0, 1, 1); + onTabIndexChanged(0); } FlightModesPanel::~FlightModesPanel() { + delete rawSwitchFilteredModel; } QString FlightModesPanel::getTabName(int index) @@ -1397,3 +1432,14 @@ void FlightModesPanel::update() { emit updated(); } + +void FlightModesPanel::refreshDataModels() +{ + emit updateDataModels(); +} + +void FlightModesPanel::onTabIndexChanged(int index) +{ + if (index < panels.size()) + panels.at(index)->update(); +} diff --git a/companion/src/modeledit/flightmodes.h b/companion/src/modeledit/flightmodes.h index 61e25c59a..2579538fc 100644 --- a/companion/src/modeledit/flightmodes.h +++ b/companion/src/modeledit/flightmodes.h @@ -24,7 +24,8 @@ #include "modeledit.h" #include "eeprominterface.h" -class RawSwitchFilterItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; constexpr char MIMETYPE_FLIGHTMODE[] = "application/x-companion-flightmode"; constexpr char MIMETYPE_GVAR_PARAMS[] = "application/x-companion-gvar-params"; @@ -40,14 +41,16 @@ class FlightModePanel : public ModelPanel Q_OBJECT public: - FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchFilterItemModel * switchModel); + FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * switchModel); virtual ~FlightModePanel(); virtual void update(); signals: - void nameModified(); - void datachanged(); + void gvNameChanged(); + void phaseDataChanged(); + void phaseNameChanged(); + void phaseNoSwitchSet(); private slots: void phaseName_editingFinished(); @@ -87,6 +90,8 @@ class FlightModePanel : public ModelPanel void gvCmPaste(); void gvCmMoveDown(); void gvCmMoveUp(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); private: Ui::FlightMode *ui; @@ -111,7 +116,6 @@ class FlightModePanel : public ModelPanel QVector trimsUse; QVector trimsValue; QVector trimsSlider; - RawSwitchFilterItemModel * rawSwitchItemModel; Board::Type board; void trimUpdate(unsigned int trim); @@ -141,24 +145,28 @@ class FlightModesPanel : public ModelPanel Q_OBJECT public: - FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel); virtual ~FlightModesPanel(); public slots: virtual void update() override; signals: + void updateDataModels(); void updated(); private slots: void onPhaseNameChanged(); + void refreshDataModels(); + void onTabIndexChanged(int index); private: QString getTabName(int index); int modesCount; QTabWidget *tabWidget; - + RawItemFilteredModel *rawSwitchFilteredModel; + QVector panels; }; #endif // _FLIGHTMODES_H_ diff --git a/companion/src/modeledit/heli.cpp b/companion/src/modeledit/heli.cpp index c0a4e39d8..9574feeed 100644 --- a/companion/src/modeledit/heli.cpp +++ b/companion/src/modeledit/heli.cpp @@ -23,17 +23,20 @@ #include "helpers.h" #include "rawitemfilteredmodel.h" -HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::Heli) { ui->setupUi(this); - rawSourceItemModel = new RawSourceFilterItemModel(&generalSettings, &model, RawSource::InputSourceGroups, this); + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups, this); + connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &HeliPanel::onModelDataAboutToBeUpdated); + connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &HeliPanel::onModelDataUpdateComplete); connect(ui->swashType, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(ui->swashRingVal, SIGNAL(editingFinished()), this, SLOT(edited())); connect(ui->swashCollectiveSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + if (firmware->getCapability(VirtualInputs)) { connect(ui->swashAileronSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(ui->swashElevatorSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); @@ -63,30 +66,22 @@ HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & gener HeliPanel::~HeliPanel() { + delete rawSourceModel; delete ui; } -void HeliPanel::updateDataModels() -{ - const bool oldLock = lock; - lock = true; - rawSourceItemModel->update(); - lock = oldLock; -} - void HeliPanel::update() { lock = true; - updateDataModels(); ui->swashType->setCurrentIndex(model->swashRingData.type); - ui->swashCollectiveSource->setModel(rawSourceItemModel); + ui->swashCollectiveSource->setModel(rawSourceModel); ui->swashCollectiveSource->setCurrentIndex(ui->swashCollectiveSource->findData(model->swashRingData.collectiveSource.toValue())); ui->swashRingVal->setValue(model->swashRingData.value); if (firmware->getCapability(VirtualInputs)) { - ui->swashElevatorSource->setModel(rawSourceItemModel); + ui->swashElevatorSource->setModel(rawSourceModel); ui->swashElevatorSource->setCurrentIndex(ui->swashElevatorSource->findData(model->swashRingData.elevatorSource.toValue())); - ui->swashAileronSource->setModel(rawSourceItemModel); + ui->swashAileronSource->setModel(rawSourceModel); ui->swashAileronSource->setCurrentIndex(ui->swashAileronSource->findData(model->swashRingData.aileronSource.toValue())); ui->swashElevatorWeight->setValue(model->swashRingData.elevatorWeight); ui->swashAileronWeight->setValue(model->swashRingData.aileronWeight); @@ -122,3 +117,13 @@ void HeliPanel::edited() emit modified(); } } + +void HeliPanel::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void HeliPanel::onModelDataUpdateComplete() +{ + update(); +} diff --git a/companion/src/modeledit/heli.h b/companion/src/modeledit/heli.h index 5a27c7c26..97552778a 100644 --- a/companion/src/modeledit/heli.h +++ b/companion/src/modeledit/heli.h @@ -23,7 +23,8 @@ #include "modeledit.h" -class RawSourceFilterItemModel; +class RawSourceItemModel; +class RawItemFilteredModel; namespace Ui { class Heli; @@ -34,17 +35,18 @@ class HeliPanel : public ModelPanel Q_OBJECT public: - HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel); ~HeliPanel(); void update(); private slots: - void updateDataModels(); void edited(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); private: Ui::Heli *ui; - RawSourceFilterItemModel * rawSourceItemModel; + RawItemFilteredModel * rawSourceModel; }; #endif // _HELI_H_ diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index 2e65c788c..624f1fdbd 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -22,10 +22,13 @@ #include "expodialog.h" #include "helpers.h" -InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): ModelPanel(parent, model, generalSettings, firmware), expoInserted(false), - modelPrinter(firmware, generalSettings, model) + modelPrinter(firmware, generalSettings, model), + rawSourceItemModel(rawSourceItemModel), + rawSwitchItemModel(rawSwitchItemModel) { inputsCount = firmware->getCapability(VirtualInputs); if (inputsCount == 0) @@ -180,11 +183,12 @@ void InputsPanel::gm_openExpo(int index) if (firmware->getCapability(VirtualInputs)) inputName = model->inputNames[ed.chn]; - ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName); + ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceItemModel, rawSwitchItemModel); if (g->exec()) { model->expoData[index] = ed; if (firmware->getCapability(VirtualInputs)) strncpy(model->inputNames[ed.chn], inputName.toLatin1().data(), INPUT_NAME_LEN); + emit updateDataModels(); emit modified(); update(); } diff --git a/companion/src/modeledit/inputs.h b/companion/src/modeledit/inputs.h index 9922f2873..0922305ce 100644 --- a/companion/src/modeledit/inputs.h +++ b/companion/src/modeledit/inputs.h @@ -24,6 +24,7 @@ #include "modeledit.h" #include "mixerslistwidget.h" #include "modelprinter.h" +#include "rawitemdatamodels.h" constexpr char MIMETYPE_EXPO[] = "application/x-companion-expo"; @@ -32,7 +33,8 @@ class InputsPanel : public ModelPanel Q_OBJECT public: - InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); virtual ~InputsPanel(); virtual void update(); @@ -60,6 +62,9 @@ class InputsPanel : public ModelPanel void cmInputMoveDown(); void cmInputMoveUp(); + signals: + void updateDataModels(); + private: bool expoInserted; MixersListWidget *ExposlistWidget; @@ -67,6 +72,8 @@ class InputsPanel : public ModelPanel ModelPrinter modelPrinter; int selectedIdx; int inputIdx; + RawSourceItemModel *rawSourceItemModel; + RawSwitchItemModel *rawSwitchItemModel; int getExpoIndex(unsigned int dch); bool gm_insertExpo(int idx); diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index e70d63568..109e09ecf 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -24,16 +24,20 @@ #include -LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): ModelPanel(parent, model, generalSettings, firmware), - selectedIndex(0) + selectedIndex(0), + modelsUpdateCnt(0) { - Stopwatch s1("LogicalSwitchesPanel"); - - rawSwitchItemModel = new RawSwitchFilterItemModel(&generalSettings, &model, RawSwitch::LogicalSwitchesContext, this); + rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::LogicalSwitchesContext); + connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete); const int srcGroups = firmware->getCapability(GvarsInCS) ? 0 : (RawSource::AllSourceGroups & ~RawSource::GVarsGroup); - rawSourceItemModel = new RawSourceFilterItemModel(&generalSettings, &model, srcGroups, this); + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, srcGroups, this); + connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated); + connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete); lsCapability = firmware->getCapability(LogicalSwitches); lsCapabilityExt = firmware->getCapability(LogicalSwitchesExt); @@ -45,16 +49,14 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, } TableLayout * tableLayout = new TableLayout(this, lsCapability, headerLabels); - s1.report("header"); - const int channelsMax = model.getChannelsMax(true); lock = true; - for (int i=0; isetProperty("index", i); - label->setText(RawSwitch(SWITCH_TYPE_VIRTUAL, i+1).toString()); + label->setText(RawSwitch(SWITCH_TYPE_VIRTUAL, i + 1).toString()); label->setContextMenuPolicy(Qt::CustomContextMenu); label->setToolTip(tr("Popup menu available")); label->setMouseTracking(true); @@ -123,7 +125,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, // AND cbAndSwitch[i] = new QComboBox(this); cbAndSwitch[i]->setProperty("index", i); - populateAndSwitchCB(cbAndSwitch[i]); + cbAndSwitch[i]->setModel(rawSwitchModel); + cbAndSwitch[i]->setVisible(true); connect(cbAndSwitch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(onAndSwitchChanged(int))); tableLayout->addWidget(i, 4, cbAndSwitch[i]); @@ -152,27 +155,16 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, } } - s1.report("added elements"); - disableMouseScrolling(); lock = false; - update(); tableLayout->resizeColumnsToContents(); tableLayout->pushRowsUp(lsCapability+1); - s1.report("end"); } LogicalSwitchesPanel::~LogicalSwitchesPanel() { -} - -void LogicalSwitchesPanel::updateDataModels() -{ - const bool oldLock = lock; - lock = true; - rawSwitchItemModel->update(); - rawSourceItemModel->update(); - lock = oldLock; + delete rawSourceModel; + delete rawSwitchModel; } void LogicalSwitchesPanel::onFunctionChanged() @@ -199,8 +191,10 @@ void LogicalSwitchesPanel::onFunctionChanged() model->logicalSw[i].val2 = -129; } } - if (bool(oldFunc) != bool(newFunc)) + if (bool(oldFunc) != bool(newFunc)) { + emit updateDataModels(); update(); + } else updateLine(i); @@ -211,13 +205,15 @@ void LogicalSwitchesPanel::onV1Changed(int value) { if (!lock) { int i = sender()->property("index").toInt(); - model->logicalSw[i].val1 = cbSource1[i]->itemData(value).toInt(); - if (model->logicalSw[i].getFunctionFamily() == LS_FAMILY_VOFS) { - if (!offsetChangedAt(i)) - updateLine(i); - } - else { - emit modified(); + if (model->logicalSw[i].val1 != cbSource1[i]->itemData(value).toInt()) { + model->logicalSw[i].val1 = cbSource1[i]->itemData(value).toInt(); + if (model->logicalSw[i].getFunctionFamily() == LS_FAMILY_VOFS) { + if (!offsetChangedAt(i)) + updateLine(i); + } + else { + emit modified(); + } } } } @@ -226,8 +222,10 @@ void LogicalSwitchesPanel::onV2Changed(int value) { if (!lock) { int i = sender()->property("index").toInt(); - model->logicalSw[i].val2 = cbSource2[i]->itemData(value).toInt(); - emit modified(); + if (model->logicalSw[i].val2 != cbSource2[i]->itemData(value).toInt()) { + model->logicalSw[i].val2 = cbSource2[i]->itemData(value).toInt(); + emit modified(); + } } } @@ -235,8 +233,10 @@ void LogicalSwitchesPanel::onAndSwitchChanged(int value) { if (!lock) { int index = sender()->property("index").toInt(); - model->logicalSw[index].andsw = cbAndSwitch[index]->itemData(value).toInt(); - emit modified(); + if (model->logicalSw[index].andsw != cbAndSwitch[index]->itemData(value).toInt()) { + model->logicalSw[index].andsw = cbAndSwitch[index]->itemData(value).toInt(); + emit modified(); + } } } @@ -244,7 +244,7 @@ void LogicalSwitchesPanel::onDurationChanged(double duration) { if (!lock) { int index = sender()->property("index").toInt(); - model->logicalSw[index].duration = (uint8_t)round(duration*10); + model->logicalSw[index].duration = (uint8_t)round(duration * 10); emit modified(); } } @@ -253,7 +253,7 @@ void LogicalSwitchesPanel::onDelayChanged(double delay) { if (!lock) { int index = sender()->property("index").toInt(); - model->logicalSw[index].delay = (uint8_t)round(delay*10); + model->logicalSw[index].delay = (uint8_t)round(delay * 10); emit modified(); } } @@ -326,9 +326,9 @@ void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, doubl sb->setMinimum(minimum); sb->setMaximum(175); float value = ValToTim(timer); - if (value>=60) + if (value >= 60) sb->setSingleStep(1); - else if (value>=2) + else if (value >= 2) sb->setSingleStep(0.5); else sb->setSingleStep(0.1); @@ -367,7 +367,7 @@ void LogicalSwitchesPanel::updateLine(int i) RawSource source = RawSource(model->logicalSw[i].val1); RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags()); double value = range.step * model->logicalSw[i].val2 + range.offset; /* TODO+source.getRawOffset(model)*/ - cbSource1[i]->setModel(rawSourceItemModel); + cbSource1[i]->setModel(rawSourceModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(source.toValue())); if (source.isTimeBased()) { mask |= VALUE_TO_VISIBLE; @@ -396,16 +396,16 @@ void LogicalSwitchesPanel::updateLine(int i) case LS_FAMILY_STICKY: // no break case LS_FAMILY_VBOOL: mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE; - cbSource1[i]->setModel(rawSwitchItemModel); + cbSource1[i]->setModel(rawSwitchModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1)); - cbSource2[i]->setModel(rawSwitchItemModel); + cbSource2[i]->setModel(rawSwitchModel); cbSource2[i]->setCurrentIndex(cbSource2[i]->findData(model->logicalSw[i].val2)); break; case LS_FAMILY_EDGE: mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE; mask &= ~DELAY_ENABLED; - cbSource1[i]->setModel(rawSwitchItemModel); + cbSource1[i]->setModel(rawSwitchModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1)); updateTimerParam(dsbOffset[i], model->logicalSw[i].val2, 0.0); updateTimerParam(dsbOffset2[i], model->logicalSw[i].val2+model->logicalSw[i].val3, ValToTim(TimToVal(dsbOffset[i]->value())-1)); @@ -414,9 +414,9 @@ void LogicalSwitchesPanel::updateLine(int i) case LS_FAMILY_VCOMP: mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE; - cbSource1[i]->setModel(rawSourceItemModel); + cbSource1[i]->setModel(rawSourceModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1)); - cbSource2[i]->setModel(rawSourceItemModel); + cbSource2[i]->setModel(rawSourceModel); cbSource2[i]->setCurrentIndex(cbSource2[i]->findData(model->logicalSw[i].val2)); break; @@ -439,9 +439,9 @@ void LogicalSwitchesPanel::updateLine(int i) dsbDuration[i]->setVisible(mask & DURATION_ENABLED); dsbDelay[i]->setVisible(mask & DELAY_ENABLED); if (mask & DURATION_ENABLED) - dsbDuration[i]->setValue(model->logicalSw[i].duration/10.0); + dsbDuration[i]->setValue(model->logicalSw[i].duration / 10.0); if (mask & DELAY_ENABLED) - dsbDelay[i]->setValue(model->logicalSw[i].delay/10.0); + dsbDelay[i]->setValue(model->logicalSw[i].delay / 10.0); } lock = false; @@ -475,7 +475,7 @@ void LogicalSwitchesPanel::populateFunctionCB(QComboBox *b) }; b->clear(); - for (int i=0; isetMaxVisibleItems(10); } -void LogicalSwitchesPanel::populateAndSwitchCB(QComboBox *b) -{ - b->setModel(rawSwitchItemModel); - b->setVisible(true); -} - void LogicalSwitchesPanel::update() { - updateDataModels(); - for (int i=0; ilogicalSw[selectedIndex], data.constData(), sizeof(LogicalSwitchData)); - updateDataModels(); + emit updateDataModels(); updateLine(selectedIndex); emit modified(); } @@ -518,6 +511,7 @@ void LogicalSwitchesPanel::cmDelete() model->logicalSw[lsCapability - 1].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); + emit updateDataModels(); update(); emit modified(); } @@ -609,6 +603,7 @@ void LogicalSwitchesPanel::cmClear(bool prompt) model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); update(); + emit updateDataModels(); emit modified(); } @@ -617,11 +612,12 @@ void LogicalSwitchesPanel::cmClearAll() if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all Logical Switches. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; - for (int i=0; ilogicalSw[i].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, i); } update(); + emit updateDataModels(); emit modified(); } @@ -631,6 +627,7 @@ void LogicalSwitchesPanel::cmInsert() model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); + emit updateDataModels(); emit modified(); } @@ -644,6 +641,20 @@ void LogicalSwitchesPanel::swapData(int idx1, int idx2) memcpy(lsw1, &lstmp, sizeof(LogicalSwitchData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); + emit updateDataModels(); emit modified(); } } + +void LogicalSwitchesPanel::onModelDataAboutToBeUpdated() +{ + lock = true; + modelsUpdateCnt++; +} + +void LogicalSwitchesPanel::onModelDataUpdateComplete() +{ + modelsUpdateCnt--; + if (modelsUpdateCnt < 1) + update(); +} diff --git a/companion/src/modeledit/logicalswitches.h b/companion/src/modeledit/logicalswitches.h index 62aa69f30..b73bd8034 100644 --- a/companion/src/modeledit/logicalswitches.h +++ b/companion/src/modeledit/logicalswitches.h @@ -24,8 +24,9 @@ #include "modeledit.h" #include "radiodata.h" -class RawSwitchFilterItemModel; -class RawSourceFilterItemModel; +class RawSourceItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; class TimerEdit; constexpr char MIMETYPE_LOGICAL_SWITCH[] = "application/x-companion-logical-switch"; @@ -35,13 +36,13 @@ class LogicalSwitchesPanel : public ModelPanel Q_OBJECT public: - LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); virtual ~LogicalSwitchesPanel(); virtual void update(); private slots: - void updateDataModels(); void onFunctionChanged(); void onV1Changed(int value); void onV2Changed(int value); @@ -61,6 +62,11 @@ class LogicalSwitchesPanel : public ModelPanel void cmInsert(); void cmClear(bool prompt = true); void cmClearAll(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); + + signals: + void updateDataModels(); private: QComboBox * cbFunction[CPN_MAX_LOGICAL_SWITCHES]; @@ -73,11 +79,10 @@ class LogicalSwitchesPanel : public ModelPanel QDoubleSpinBox * dsbDelay[CPN_MAX_LOGICAL_SWITCHES]; QComboBox * cbSource1[CPN_MAX_LOGICAL_SWITCHES]; QComboBox * cbSource2[CPN_MAX_LOGICAL_SWITCHES]; - RawSwitchFilterItemModel * rawSwitchItemModel; - RawSourceFilterItemModel * rawSourceItemModel; + RawItemFilteredModel * rawSwitchModel; + RawItemFilteredModel * rawSourceModel; int selectedIndex; void populateFunctionCB(QComboBox *b); - void populateAndSwitchCB(QComboBox *b); void updateTimerParam(QDoubleSpinBox *sb, int timer, double minimum=0); int lsCapability; int lsCapabilityExt; @@ -86,6 +91,7 @@ class LogicalSwitchesPanel : public ModelPanel bool insertAllowed() const; bool moveDownAllowed() const; bool moveUpAllowed() const; + int modelsUpdateCnt; }; #endif // _LOGICALSWITCHES_H_ diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 1b17e9471..5727f2495 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -24,7 +24,8 @@ #include "rawitemfilteredmodel.h" #include "helpers.h" -MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, GeneralSettings & generalSettings, Firmware * firmware) : +MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel) : QDialog(parent), ui(new Ui::MixerDialog), model(model), @@ -34,6 +35,9 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, lock(false) { ui->setupUi(this); + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups | RawSource::ScriptsGroup, this); + rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); + QRegExp rx(CHAR_FOR_NAMES_REGEX); QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; @@ -43,7 +47,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, this->setWindowTitle(tr("DEST -> %1").arg(RawSource(SOURCE_TYPE_CH, md->destCh-1).toString(&model, &generalSettings))); - ui->sourceCB->setModel(new RawSourceFilterItemModel(&generalSettings, &model, RawSource::InputSourceGroups | RawSource::ScriptsGroup, this)); + ui->sourceCB->setModel(rawSourceModel); ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(md->srcRaw.toValue())); ui->sourceCB->removeItem(0); @@ -104,7 +108,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, } } - ui->switchesCB->setModel(new RawSwitchFilterItemModel(&generalSettings, &model, RawSwitch::MixesContext, this)); + ui->switchesCB->setModel(rawSwitchModel); ui->switchesCB->setCurrentIndex(ui->switchesCB->findData(md->swtch.toValue())); ui->warningCB->setCurrentIndex(md->mixWarn); ui->mltpxCB->setCurrentIndex(md->mltpx); diff --git a/companion/src/modeledit/mixerdialog.h b/companion/src/modeledit/mixerdialog.h index 93f061d0d..2b89cd00e 100644 --- a/companion/src/modeledit/mixerdialog.h +++ b/companion/src/modeledit/mixerdialog.h @@ -26,6 +26,9 @@ class GVarGroup; class CurveGroup; +class RawSourceItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; namespace Ui { class MixerDialog; @@ -34,7 +37,8 @@ namespace Ui { class MixerDialog : public QDialog { Q_OBJECT public: - MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, GeneralSettings & generalSettings, Firmware * firmware); + MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); ~MixerDialog(); protected: @@ -59,6 +63,8 @@ class MixerDialog : public QDialog { GVarGroup * gvOffsetGroup; CurveGroup * curveGroup; QCheckBox * cb_fp[CPN_MAX_FLIGHT_MODES]; + RawItemFilteredModel * rawSourceModel; + RawItemFilteredModel * rawSwitchModel; }; #endif // _MIXERDIALOG_H_ diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index 4d0f5f4cd..52f6ba51c 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -21,11 +21,14 @@ #include "mixes.h" #include "helpers.h" -MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): ModelPanel(parent, model, generalSettings, firmware), mixInserted(false), highlightedSource(0), - modelPrinter(firmware, generalSettings, model) + modelPrinter(firmware, generalSettings, model), + rawSourceItemModel(rawSourceItemModel), + rawSwitchItemModel(rawSwitchItemModel) { QGridLayout * mixesLayout = new QGridLayout(this); @@ -175,7 +178,7 @@ void MixesPanel::gm_openMix(int index) MixData mixd(model->mixData[index]); - MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware); + MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware, rawSourceItemModel, rawSwitchItemModel); if(g->exec()) { model->mixData[index] = mixd; emit modified(); diff --git a/companion/src/modeledit/mixes.h b/companion/src/modeledit/mixes.h index 95765465e..15cb0bd54 100644 --- a/companion/src/modeledit/mixes.h +++ b/companion/src/modeledit/mixes.h @@ -25,13 +25,15 @@ #include "mixerslistwidget.h" #include "mixerdialog.h" #include "modelprinter.h" +#include "rawitemdatamodels.h" class MixesPanel : public ModelPanel { Q_OBJECT public: - MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, + RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); virtual ~MixesPanel(); virtual void update(); @@ -63,6 +65,8 @@ class MixesPanel : public ModelPanel bool mixInserted; unsigned int highlightedSource; ModelPrinter modelPrinter; + RawSourceItemModel *rawSourceItemModel; + RawSwitchItemModel *rawSwitchItemModel; int getMixerIndex(unsigned int dch); bool gm_insertMix(int idx); diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index af3166c7f..9b6d1727c 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -33,6 +33,7 @@ #include "customfunctions.h" #include "telemetry.h" #include "appdata.h" +#include "rawitemdatamodels.h" ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmware * firmware) : QDialog(parent), @@ -48,38 +49,96 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw setWindowIcon(CompanionIcon("edit.png")); restoreGeometry(g.modelEditGeo()); ui->pushButton->setIcon(CompanionIcon("simulate.png")); - SetupPanel * setupPanel = new SetupPanel(this, radioData.models[modelId], radioData.generalSettings, firmware); + + GeneralSettings &generalSettings = radioData.generalSettings; + ModelData &model = radioData.models[modelId]; + + /* + Create reusable model specific ui datamodels here and pass pointers as needed + They should be referenced through filters in each use case + Code that updates the source for one or more ui datamodels should emit a SIGNAL that can be trapped (see below) and the datamodels refreshed + WARNING: beware of looping signals and slots and unnecessary data field updates from refreshing datamodels + where practical make signals granular to only those fields that affect datamodels thus needing to be refreshed + */ + rawSourceModel = new RawSourceItemModel(&generalSettings, &model, this); + rawSwitchModel = new RawSwitchItemModel(&generalSettings, &model, this); + curveModel = new CurveItemModel(&generalSettings, &model, this); + s1.report("Init"); + + SetupPanel * setupPanel = new SetupPanel(this, model, generalSettings, firmware, rawSwitchModel); addTab(setupPanel, tr("Setup")); - if (firmware->getCapability(Heli)) - addTab(new HeliPanel(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Heli")); - addTab(new FlightModesPanel(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Flight Modes")); - addTab(new InputsPanel(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Inputs")); - s1.report("inputs"); - addTab(new MixesPanel(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Mixes")); + s1.report("Setup"); + + if (firmware->getCapability(Heli)) { + HeliPanel * heliPanel = new HeliPanel(this, model, generalSettings, firmware, rawSourceModel); + addTab(heliPanel, tr("Heli")); + s1.report("Heli"); + } + + FlightModesPanel * flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, rawSwitchModel); + addTab(flightModesPanel, tr("Flight Modes")); + s1.report("Flight Modes"); + + InputsPanel * inputsPanel = new InputsPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + addTab(inputsPanel, tr("Inputs")); + s1.report("Inputs"); + + MixesPanel * mixesPanel = new MixesPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + addTab(mixesPanel, tr("Mixes")); s1.report("Mixes"); - Channels * chnPanel = new Channels(this, radioData.models[modelId], radioData.generalSettings, firmware); - addTab(chnPanel, tr("Outputs")); + + ChannelsPanel * channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, curveModel); + addTab(channelsPanel, tr("Outputs")); s1.report("Outputs"); - addTab(new Curves(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Curves")); - addTab(new LogicalSwitchesPanel(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Logical Switches")); - s1.report("LS"); - addTab(new CustomFunctionsPanel(this, &radioData.models[modelId], radioData.generalSettings, firmware), tr("Special Functions")); - s1.report("CF"); - if (firmware->getCapability(Telemetry)) - addTab(new TelemetryPanel(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Telemetry")); - onTabIndexChanged(ui->tabWidget->currentIndex()); // make sure to trigger update on default tab panel + CurvesPanel * curvesPanel = new CurvesPanel(this, model, generalSettings, firmware); + addTab(curvesPanel, tr("Curves")); + s1.report("Curves"); + + LogicalSwitchesPanel * logicalSwitchesPanel = new LogicalSwitchesPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + addTab(logicalSwitchesPanel, tr("Logical Switches")); + s1.report("Logical Switches"); + + CustomFunctionsPanel * customFunctionsPanel = new CustomFunctionsPanel(this, &model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + addTab(customFunctionsPanel, tr("Special Functions")); + s1.report("Special Functions"); + + if (firmware->getCapability(Telemetry)) { + TelemetryPanel * telemetryPanel = new TelemetryPanel(this, model, generalSettings, firmware, rawSourceModel); + addTab(telemetryPanel, tr("Telemetry")); + connect(telemetryPanel, &TelemetryPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); + s1.report("Telemetry"); + } + + connect(setupPanel, &SetupPanel::extendedLimitsToggled, channelsPanel, &ChannelsPanel::refreshExtendedLimits); + connect(setupPanel, &SetupPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); + + connect(flightModesPanel, &FlightModesPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); + connect(flightModesPanel, &FlightModesPanel::updateDataModels, rawSwitchModel, &RawSwitchItemModel::update); + + connect(inputsPanel, &InputsPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); + + connect(channelsPanel, &ChannelsPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); + + connect(curvesPanel, &CurvesPanel::updateDataModels, curveModel, &CurveItemModel::update); + + connect(logicalSwitchesPanel, &LogicalSwitchesPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); + connect(logicalSwitchesPanel, &LogicalSwitchesPanel::updateDataModels, rawSwitchModel, &RawSwitchItemModel::update); - connect(setupPanel, &SetupPanel::extendedLimitsToggled, chnPanel, &Channels::refreshExtendedLimits); connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged); connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation); - s1.report("end"); + onTabIndexChanged(ui->tabWidget->currentIndex()); // make sure to trigger update on default tab panel + + s1.report("Signals and Slots"); gStopwatch.report("ModelEdit end constructor"); } ModelEdit::~ModelEdit() { + delete rawSourceModel; + delete rawSwitchModel; + delete curveModel; delete ui; } diff --git a/companion/src/modeledit/modeledit.h b/companion/src/modeledit/modeledit.h index 969ae85d7..87c07759b 100644 --- a/companion/src/modeledit/modeledit.h +++ b/companion/src/modeledit/modeledit.h @@ -25,6 +25,9 @@ #include "genericpanel.h" class RadioData; +class RawSourceItemModel; +class RawSwitchItemModel; +class CurveItemModel; namespace Ui { class ModelEdit; @@ -62,6 +65,9 @@ class ModelEdit : public QDialog RadioData & radioData; Firmware * firmware; QVector panels; + RawSourceItemModel *rawSourceModel; + RawSwitchItemModel *rawSwitchModel; + CurveItemModel *curveModel; void addTab(GenericPanel *panel, QString text); void launchSimulation(); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index dcbe4f101..a83aeff69 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -31,13 +31,15 @@ #include -TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, RawSwitchFilterItemModel * switchModel): +TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, RawItemFilteredModel * rawSwitchModel): ModelPanel(parent, model, generalSettings, firmware), timer(timer), ui(new Ui::Timer) { ui->setupUi(this); + connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &TimerPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &TimerPanel::onModelDataUpdateComplete); lock = true; @@ -52,7 +54,7 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge } // Mode - ui->mode->setModel(switchModel); + ui->mode->setModel(rawSwitchModel); ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue())); connect(ui->mode, SIGNAL(activated(int)), this, SLOT(onModeChanged(int))); @@ -165,11 +167,22 @@ void TimerPanel::on_name_editingFinished() if (QString(timer.name) != ui->name->text()) { int length = ui->name->maxLength(); strncpy(timer.name, ui->name->text().toLatin1(), length); + emit nameChanged(); emit modified(); } } } +void TimerPanel::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void TimerPanel::onModelDataUpdateComplete() +{ + update(); +} + /******************************************************************************/ #define FAILSAFE_CHANNEL_HOLD 2000 @@ -978,7 +991,7 @@ void ModulePanel::onClearAccessRxClicked() /******************************************************************************/ -SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::Setup) { @@ -1062,18 +1075,17 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge } QWidget * prevFocus = ui->image; - RawSwitchFilterItemModel * swModel = new RawSwitchFilterItemModel(&generalSettings, &model, RawSwitch::TimersContext, this); - connect(this, &SetupPanel::updated, swModel, &RawSwitchFilterItemModel::update); + rawSwitchFilteredModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::TimersContext, this); timersCount = firmware->getCapability(Timers); for (int i = 0; i < CPN_MAX_TIMERS; i++) { if (i < timersCount) { - timers[i] = new TimerPanel(this, model, model.timers[i], generalSettings, firmware, prevFocus, swModel); + timers[i] = new TimerPanel(this, model, model.timers[i], generalSettings, firmware, prevFocus, rawSwitchFilteredModel); ui->gridLayout->addWidget(timers[i], 1+i, 1); connect(timers[i], &TimerPanel::modified, this, &SetupPanel::modified); + connect(timers[i], &TimerPanel::nameChanged, this, &SetupPanel::onTimerNameChanged); connect(this, &SetupPanel::updated, timers[i], &TimerPanel::update); - connect(this, &SetupPanel::timerUpdated, timers[i], &TimerPanel::update); prevFocus = timers[i]->getLastFocus(); // TODO more reliable method required QLabel *label = findChild(QString("label_timer%1").arg(i + 1)); @@ -1234,6 +1246,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge SetupPanel::~SetupPanel() { + delete rawSwitchFilteredModel; delete ui; } @@ -1601,7 +1614,7 @@ void SetupPanel::cmTimerClear(bool prompt) model->timers[selectedTimerIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_CLEAR, selectedTimerIndex); - emit timerUpdated(); + emit updateDataModels(); emit modified(); } @@ -1614,7 +1627,7 @@ void SetupPanel::cmTimerClearAll() model->timers[i].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_CLEAR, i); } - emit timerUpdated(); + emit updateDataModels(); emit modified(); } @@ -1648,7 +1661,7 @@ void SetupPanel::cmTimerDelete() } model->timers[maxidx].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SHIFT, selectedTimerIndex, 0, -1); - emit timerUpdated(); + emit updateDataModels(); emit modified(); } @@ -1661,7 +1674,7 @@ void SetupPanel::cmTimerInsert() } model->timers[selectedTimerIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SHIFT, selectedTimerIndex, 0, 1); - emit timerUpdated(); + emit updateDataModels(); emit modified(); } @@ -1681,7 +1694,7 @@ void SetupPanel::cmTimerPaste() if (hasTimerClipboardData(&data)) { TimerData *td = &model->timers[selectedTimerIndex]; memcpy(td, data.constData(), sizeof(TimerData)); - emit timerUpdated(); + emit updateDataModels(); emit modified(); } } @@ -1695,7 +1708,12 @@ void SetupPanel::swapTimerData(int idx1, int idx2) memcpy(td2, td1, sizeof(TimerData)); memcpy(td1, &tdtmp, sizeof(TimerData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); - emit timerUpdated(); + emit updateDataModels(); emit modified(); } } + +void SetupPanel::onTimerNameChanged() +{ + emit updateDataModels(); +} diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 0aa48ea76..6f4a95922 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -26,7 +26,8 @@ constexpr char MIMETYPE_TIMER[] = "application/x-companion-timer"; -class RawSwitchFilterItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; namespace Ui { class Setup; @@ -39,7 +40,7 @@ class TimerPanel : public ModelPanel Q_OBJECT public: - TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget *prevFocus, RawSwitchFilterItemModel * switchModel); + TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget *prevFocus, RawItemFilteredModel * switchModel); virtual ~TimerPanel(); virtual void update(); @@ -50,6 +51,11 @@ class TimerPanel : public ModelPanel void on_value_editingFinished(); void on_minuteBeep_toggled(bool checked); void on_name_editingFinished(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); + + signals: + void nameChanged(); private: TimerData & timer; @@ -125,7 +131,7 @@ class SetupPanel : public ModelPanel Q_OBJECT public: - SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel); virtual ~SetupPanel(); virtual void update(); @@ -133,7 +139,7 @@ class SetupPanel : public ModelPanel signals: void extendedLimitsToggled(); void updated(); - void timerUpdated(); + void updateDataModels(); private slots: void on_name_editingFinished(); @@ -163,6 +169,7 @@ class SetupPanel : public ModelPanel void cmTimerPaste(); void cmTimerMoveDown(); void cmTimerMoveUp(); + void onTimerNameChanged(); private: Ui::Setup *ui; @@ -183,6 +190,7 @@ class SetupPanel : public ModelPanel bool moveTimerDownAllowed() const; bool moveTimerUpAllowed() const; void swapTimerData(int idx1, int idx2); -}; + RawItemFilteredModel * rawSwitchFilteredModel; + }; #endif // _SETUP_H_ diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index b34caa89e..0b6ad58b7 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -28,18 +28,20 @@ #include -TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware, RawSourceFilterItemModel * srcModel): +TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * rawSourceModel): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::TelemetryCustomScreen), screen(screen) { ui->setupUi(this); + connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &TelemetryCustomScreen::onModelDataAboutToBeUpdated); + connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &TelemetryCustomScreen::onModelDataUpdateComplete); for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensLines); l++) { for (int c = 0; c < firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) { fieldsCB[l][c] = new QComboBox(this); fieldsCB[l][c]->setProperty("index", c + (l << 8)); - fieldsCB[l][c]->setModel(srcModel); + fieldsCB[l][c]->setModel(rawSourceModel); ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1); connect(fieldsCB[l][c], SIGNAL(activated(int)), this, SLOT(customFieldChanged(int))); } @@ -48,7 +50,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensBars); l++) { barsCB[l] = new QComboBox(this); barsCB[l]->setProperty("index", l); - barsCB[l]->setModel(srcModel); + barsCB[l]->setModel(rawSourceModel); connect(barsCB[l], SIGNAL(activated(int)), this, SLOT(barSourceChanged(int))); ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1); @@ -287,6 +289,16 @@ void TelemetryCustomScreen::barTimeChanged() } } +void TelemetryCustomScreen::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void TelemetryCustomScreen::onModelDataUpdateComplete() +{ + update(); +} + /******************************************************/ TelemetrySensorPanel::TelemetrySensorPanel(QWidget *parent, SensorData & sensor, int sensorIndex, int sensorCapability, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): @@ -678,11 +690,12 @@ void TelemetrySensorPanel::cmMoveDown() /******************************************************/ -TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::Telemetry) { ui->setupUi(this); + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, this); sensorCapability = firmware->getCapability(Sensors); if (sensorCapability > CPN_MAX_SENSORS) // TODO should be role of getCapability @@ -696,6 +709,7 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin ui->varioCenterSilent->setField(model.frsky.varioCenterSilent, this); ui->A1GB->hide(); ui->A2GB->hide(); + for (int i = 0; i < sensorCapability; ++i) { TelemetrySensorPanel * panel = new TelemetrySensorPanel(this, model.sensorData[i], i, sensorCapability, model, generalSettings, firmware); ui->sensorsLayout->addWidget(panel); @@ -717,15 +731,11 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin ui->topbarGB->hide(); } - RawSourceFilterItemModel * srcModel = (new RawSourceFilterItemModel(&generalSettings, &model, this)); - connect(this, &TelemetryPanel::updated, srcModel, &RawSourceFilterItemModel::update); - for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++) { - TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, srcModel); + TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, rawSourceModel); ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i + 1)); telemetryCustomScreens[i] = tab; connect(tab, &TelemetryCustomScreen::modified, this, &TelemetryPanel::onModified); - connect(this, &TelemetryPanel::updated, tab, &TelemetryCustomScreen::update); } disableMouseScrolling(); @@ -735,6 +745,7 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin TelemetryPanel::~TelemetryPanel() { + delete rawSourceModel; delete ui; } @@ -759,79 +770,78 @@ void TelemetryPanel::update() sensorPanels[i]->update(); } - emit updated(); + for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++) { + telemetryCustomScreens[i]->update(); + } } void TelemetryPanel::setup() { - QString firmware_id = g.profile[g.id()].fwType(); + lock = true; - lock = true; + ui->telemetryProtocol->addItem(tr("FrSky S.PORT"), 0); + ui->telemetryProtocol->addItem(tr("FrSky D"), 1); + if (IS_9XRPRO(firmware->getBoard()) || + (IS_TARANIS(firmware->getBoard()) && generalSettings.auxSerialMode == 2)) { + ui->telemetryProtocol->addItem(tr("FrSky D (cable)"), 2); + } + ui->telemetryProtocol->setCurrentIndex(model->telemetryProtocol); + ui->ignoreSensorIds->setField(model->frsky.ignoreSensorIds, this); + ui->disableTelemetryAlarms->setField(model->rssiAlarms.disabled); - ui->telemetryProtocol->addItem(tr("FrSky S.PORT"), 0); - ui->telemetryProtocol->addItem(tr("FrSky D"), 1); - if (IS_9XRPRO(firmware->getBoard()) || - (IS_TARANIS(firmware->getBoard()) && generalSettings.auxSerialMode == 2)) { - ui->telemetryProtocol->addItem(tr("FrSky D (cable)"), 2); - } - ui->telemetryProtocol->setCurrentIndex(model->telemetryProtocol); - ui->ignoreSensorIds->setField(model->frsky.ignoreSensorIds, this); - ui->disableTelemetryAlarms->setField(model->rssiAlarms.disabled); + ui->rssiAlarmWarningSB->setValue(model->rssiAlarms.warning); + ui->rssiAlarmCriticalSB->setValue(model->rssiAlarms.critical); - ui->rssiAlarmWarningSB->setValue(model->rssiAlarms.warning); - ui->rssiAlarmCriticalSB->setValue(model->rssiAlarms.critical); + ui->rssiSourceLabel->show(); + ui->rssiSourceLabel->setText(tr("Source")); + ui->rssiSourceCB->setField(model->rssiSource, this); + ui->rssiSourceCB->show(); + populateTelemetrySourcesComboBox(ui->rssiSourceCB, model, false); - ui->rssiSourceLabel->show(); - ui->rssiSourceLabel->setText(tr("Source")); - ui->rssiSourceCB->setField(model->rssiSource, this); - ui->rssiSourceCB->show(); - populateTelemetrySourcesComboBox(ui->rssiSourceCB, model, false); + ui->rssiAlarmWarningCB->hide(); + ui->rssiAlarmCriticalCB->hide(); + ui->rssiAlarmWarningLabel->setText(tr("Low Alarm")); + ui->rssiAlarmCriticalLabel->setText(tr("Critical Alarm")); - ui->rssiAlarmWarningCB->hide(); - ui->rssiAlarmCriticalCB->hide(); - ui->rssiAlarmWarningLabel->setText(tr("Low Alarm")); - ui->rssiAlarmCriticalLabel->setText(tr("Critical Alarm")); - - int varioCap = firmware->getCapability(HasVario); - if (!varioCap) { - ui->varioLimitMax_DSB->hide(); + if (!firmware->getCapability(HasVario)) { + ui->varioLimitMax_DSB->hide(); + ui->varioLimitMin_DSB->hide(); + ui->varioLimitCenterMin_DSB->hide(); + ui->varioLimitCenterMax_DSB->hide(); + ui->varioLimit_label->hide(); + ui->VarioLabel_1->hide(); + ui->VarioLabel_2->hide(); + ui->VarioLabel_3->hide(); + ui->VarioLabel_4->hide(); + ui->varioSource->hide(); + ui->varioSource_label->hide(); + } + else { + if (!firmware->getCapability(HasVarioSink)) { ui->varioLimitMin_DSB->hide(); ui->varioLimitCenterMin_DSB->hide(); - ui->varioLimitCenterMax_DSB->hide(); - ui->varioLimit_label->hide(); ui->VarioLabel_1->hide(); ui->VarioLabel_2->hide(); - ui->VarioLabel_3->hide(); - ui->VarioLabel_4->hide(); - ui->varioSource->hide(); - ui->varioSource_label->hide(); - } - else { - if (!firmware->getCapability(HasVarioSink)) { - ui->varioLimitMin_DSB->hide(); - ui->varioLimitCenterMin_DSB->hide(); - ui->VarioLabel_1->hide(); - ui->VarioLabel_2->hide(); - } - ui->varioLimitMin_DSB->setValue(model->frsky.varioMin - 10); - ui->varioLimitMax_DSB->setValue(model->frsky.varioMax + 10); - ui->varioLimitCenterMax_DSB->setValue((model->frsky.varioCenterMax / 10.0) + 0.5); - ui->varioLimitCenterMin_DSB->setValue((model->frsky.varioCenterMin / 10.0) - 0.5); } + ui->varioLimitMin_DSB->setValue(model->frsky.varioMin - 10); + ui->varioLimitMax_DSB->setValue(model->frsky.varioMax + 10); + ui->varioLimitCenterMax_DSB->setValue((model->frsky.varioCenterMax / 10.0) + 0.5); + ui->varioLimitCenterMin_DSB->setValue((model->frsky.varioCenterMin / 10.0) - 0.5); + } - ui->altimetryGB->setVisible(firmware->getCapability(HasVario)), - ui->frskyProtoCB->setDisabled(firmware->getCapability(NoTelemetryProtocol)); + ui->altimetryGB->setVisible(firmware->getCapability(HasVario)), + ui->frskyProtoCB->setDisabled(firmware->getCapability(NoTelemetryProtocol)); - if (firmware->getCapability(Telemetry)) { - ui->frskyProtoCB->addItem(tr("Winged Shadow How High")); - } - else { - ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)")); - } + if (firmware->getCapability(Telemetry)) { + ui->frskyProtoCB->addItem(tr("Winged Shadow How High")); + } + else { + ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)")); + } - ui->variousGB->hide(); + ui->variousGB->hide(); - lock = false; + lock = false; } void TelemetryPanel::populateVarioSource() @@ -973,6 +983,7 @@ void TelemetryPanel::on_clearAllSensors() } update(); + emit updateDataModels(); emit modified(); } @@ -983,6 +994,7 @@ void TelemetryPanel::on_insertSensor(int selectedIndex) model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); + emit updateDataModels(); emit modified(); } @@ -996,6 +1008,7 @@ void TelemetryPanel::on_deleteSensor(int selectedIndex) model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); update(); + emit updateDataModels(); emit modified(); } @@ -1019,6 +1032,7 @@ void TelemetryPanel::swapData(int idx1, int idx2) memcpy(sd1, &sdtmp, sizeof(SensorData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); + emit updateDataModels(); emit modified(); } } diff --git a/companion/src/modeledit/telemetry.h b/companion/src/modeledit/telemetry.h index cddade217..758c0bc51 100644 --- a/companion/src/modeledit/telemetry.h +++ b/companion/src/modeledit/telemetry.h @@ -27,7 +27,8 @@ constexpr char MIMETYPE_TELE_SENSOR[] = "application/x-companion-tele-sensor"; class AutoComboBox; -class RawSourceFilterItemModel; +class RawSourceItemModel; +class RawItemFilteredModel; class TimerEdit; namespace Ui { @@ -41,7 +42,7 @@ class TelemetryCustomScreen: public ModelPanel Q_OBJECT public: - TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware, RawSourceFilterItemModel * srcModel); + TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * rawSourceModel); ~TelemetryCustomScreen(); void update(); @@ -53,6 +54,8 @@ class TelemetryCustomScreen: public ModelPanel void barMinChanged(double value); void barMaxChanged(double value); void barTimeChanged(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); private: void updateBar(int line); @@ -122,12 +125,14 @@ class TelemetryPanel : public ModelPanel Q_OBJECT public: - TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel); virtual ~TelemetryPanel(); virtual void update(); signals: void updated(); + void updateDataModels(); + private slots: void on_telemetryProtocol_currentIndexChanged(int index); @@ -154,6 +159,7 @@ class TelemetryPanel : public ModelPanel TelemetryCustomScreen * telemetryCustomScreens[4]; TelemetrySensorPanel * sensorPanels[CPN_MAX_SENSORS]; int sensorCapability; + RawItemFilteredModel * rawSourceModel; void setup(); void telBarUpdate(); From 26b7f26660fcf58d176d0585d0adb6347eb9ae61 Mon Sep 17 00:00:00 2001 From: elecpower Date: Sat, 19 Sep 2020 20:58:50 +1000 Subject: [PATCH 002/231] FM refresh --- companion/src/modeledit/flightmodes.cpp | 22 ++++++++++------------ companion/src/modeledit/flightmodes.h | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/companion/src/modeledit/flightmodes.cpp b/companion/src/modeledit/flightmodes.cpp index 92d69e5e7..48af23957 100644 --- a/companion/src/modeledit/flightmodes.cpp +++ b/companion/src/modeledit/flightmodes.cpp @@ -58,7 +58,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI // Flight mode switch if (phaseIdx > 0) { ui->swtch->setModel(switchModel); - connect(ui->swtch, SIGNAL(activated(int)), this, SLOT(phaseSwitchChanged(int))); + connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int))); } else { ui->swtch->hide(); @@ -393,15 +393,14 @@ void FlightModePanel::phaseName_editingFinished() emit modified(); } -void FlightModePanel::phaseSwitchChanged(int index) +void FlightModePanel::phaseSwitch_currentIndexChanged(int index) { if (!lock) { bool ok; const RawSwitch rs(ui->swtch->itemData(index).toInt(&ok)); if (ok && phase.swtch.toValue() != rs.toValue()) { phase.swtch = rs; - if (!rs.isSet()) - emit phaseNoSwitchSet(); + emit phaseSwitchChanged(); emit modified(); } } @@ -1386,15 +1385,13 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS for (int i = 0; i < modesCount; i++) { FlightModePanel * tab = new FlightModePanel(tabWidget, model, i, generalSettings, firmware, rawSwitchFilteredModel); tab->setProperty("index", i); - connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified); - connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::onPhaseNameChanged); - connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::update); - connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::refreshDataModels); - connect(tab, &FlightModePanel::phaseNameChanged, this, &FlightModesPanel::onPhaseNameChanged); - connect(tab, &FlightModePanel::phaseNoSwitchSet, this, &FlightModesPanel::refreshDataModels); - connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::refreshDataModels); + connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified); + connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::onPhaseNameChanged); + connect(tab, &FlightModePanel::phaseNameChanged, this, &FlightModesPanel::onPhaseNameChanged); + connect(tab, &FlightModePanel::phaseSwitchChanged, this, &FlightModesPanel::refreshDataModels); + connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::refreshDataModels); - connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update); + connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update); tabWidget->addTab(tab, getTabName(i)); panels << tab; } @@ -1426,6 +1423,7 @@ void FlightModesPanel::onPhaseNameChanged() { int index = sender()->property("index").toInt(); tabWidget->setTabText(index, getTabName(index)); + refreshDataModels(); } void FlightModesPanel::update() diff --git a/companion/src/modeledit/flightmodes.h b/companion/src/modeledit/flightmodes.h index 2579538fc..dda7a279d 100644 --- a/companion/src/modeledit/flightmodes.h +++ b/companion/src/modeledit/flightmodes.h @@ -50,11 +50,11 @@ class FlightModePanel : public ModelPanel void gvNameChanged(); void phaseDataChanged(); void phaseNameChanged(); - void phaseNoSwitchSet(); + void phaseSwitchChanged(); private slots: void phaseName_editingFinished(); - void phaseSwitchChanged(int index); + void phaseSwitch_currentIndexChanged(int index); void phaseFadeIn_editingFinished(); void phaseFadeOut_editingFinished(); void phaseTrimUse_currentIndexChanged(int index); From ff64a949a5af8233b36110b9cfaa0ff5d45ecd11 Mon Sep 17 00:00:00 2001 From: elecpower Date: Sat, 19 Sep 2020 21:07:20 +1000 Subject: [PATCH 003/231] Model upd refs do not apply offset on custom clear --- companion/src/firmwares/modeldata.cpp | 4 ++-- companion/src/firmwares/modeldata.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/modeldata.cpp b/companion/src/firmwares/modeldata.cpp index e38958249..9f67233d6 100644 --- a/companion/src/firmwares/modeldata.cpp +++ b/companion/src/firmwares/modeldata.cpp @@ -847,7 +847,7 @@ void ModelData::updateTypeIndexRef(R & curRef, const T type, const int idxAdj, c newRef.clear(); else { newRef.type = (T)defType; - newRef.index = defIndex + idxAdj; + newRef.index = defIndex; } break; case REF_UPD_ACT_SHIFT: @@ -904,7 +904,7 @@ void ModelData::updateTypeValueRef(R & curRef, const T type, const int idxAdj, c newRef.clear(); else { newRef.type = (T)defType; - newRef.value = defValue + idxAdj; + newRef.value = defValue; } break; case REF_UPD_ACT_SHIFT: diff --git a/companion/src/firmwares/modeldata.h b/companion/src/firmwares/modeldata.h index 51efcc333..558b848df 100644 --- a/companion/src/firmwares/modeldata.h +++ b/companion/src/firmwares/modeldata.h @@ -321,7 +321,7 @@ class ModelData { void updateModuleFailsafes(ModuleData * md); inline void updateSourceRef(RawSource & src) { updateTypeIndexRef(src, updRefInfo.srcType); } inline void updateSwitchRef(RawSwitch & swtch) { updateTypeIndexRef(swtch, updRefInfo.swtchType, 1); } - inline void updateTimerMode(RawSwitch & swtch) { updateTypeIndexRef(swtch, updRefInfo.swtchType, 1, false, (int)SWITCH_TYPE_TIMER_MODE, -1 /*adjusted by offset*/); } + inline void updateTimerMode(RawSwitch & swtch) { updateTypeIndexRef(swtch, updRefInfo.swtchType, 1, false, (int)SWITCH_TYPE_TIMER_MODE, 0); } inline void updateSourceIntRef(int & value) { RawSource src = RawSource(value); From e534749940605c2d3e6b310f7f9bdd7a938327ff Mon Sep 17 00:00:00 2001 From: elecpower Date: Sat, 19 Sep 2020 21:25:58 +1000 Subject: [PATCH 004/231] Release memory --- companion/src/modeledit/mixerdialog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 5727f2495..af21bbbb9 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -154,6 +154,8 @@ MixerDialog::~MixerDialog() delete gvWeightGroup; delete gvOffsetGroup; delete curveGroup; + delete rawSourceModel; + delete rawSwitchModel; delete ui; } From 775d8db1e9c87f13dd2c756a6df408934c8a86ab Mon Sep 17 00:00:00 2001 From: elecpower Date: Sun, 20 Sep 2020 05:36:55 +1000 Subject: [PATCH 005/231] Mixes create filtered lists once --- companion/src/modeledit/mixerdialog.cpp | 68 ++++++++++++------------- companion/src/modeledit/mixerdialog.h | 6 +-- companion/src/modeledit/mixes.cpp | 27 ++++++++-- companion/src/modeledit/mixes.h | 13 +++-- 4 files changed, 65 insertions(+), 49 deletions(-) diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index af21bbbb9..e17771838 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -25,7 +25,7 @@ #include "helpers.h" MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel) : + RawItemFilteredModel * rawSourceModel, RawItemFilteredModel * rawSwitchModel) : QDialog(parent), ui(new Ui::MixerDialog), model(model), @@ -35,17 +35,15 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, lock(false) { ui->setupUi(this); - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups | RawSource::ScriptsGroup, this); - rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); QRegExp rx(CHAR_FOR_NAMES_REGEX); - QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; - QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; - for (int i=0; ilb_FP0, ui->lb_FP1, ui->lb_FP2, ui->lb_FP3, ui->lb_FP4, ui->lb_FP5, ui->lb_FP6, ui->lb_FP7, ui->lb_FP8 }; + QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0, ui->cb_FP1, ui->cb_FP2, ui->cb_FP3, ui->cb_FP4, ui->cb_FP5, ui->cb_FP6, ui->cb_FP7, ui->cb_FP8 }; + for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) { cb_fp[i] = tmp[i]; } - this->setWindowTitle(tr("DEST -> %1").arg(RawSource(SOURCE_TYPE_CH, md->destCh-1).toString(&model, &generalSettings))); + this->setWindowTitle(tr("DEST -> %1").arg(RawSource(SOURCE_TYPE_CH, md->destCh - 1).toString(&model, &generalSettings))); ui->sourceCB->setModel(rawSourceModel); ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(md->srcRaw.toValue())); @@ -66,7 +64,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, } if (!firmware->getCapability(VirtualInputs)) { - for(int i=0; i < CPN_MAX_STICKS; i++) { + for(int i = 0; i < CPN_MAX_STICKS; i++) { ui->trimCB->addItem(firmware->getAnalogInputName(i)); } } @@ -86,7 +84,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, if (!firmware->getCapability(FlightModes)) { ui->label_phases->hide(); - for (int i=0; ihide(); cb_fp[i]->hide(); } @@ -96,13 +94,13 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, ui->label_phases->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->label_phases, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(label_phases_customContextMenuRequested(const QPoint &))); int mask = 1; - for (int i=0; iflightModes & mask) == 0) { cb_fp[i]->setChecked(true); } mask <<= 1; } - for (int i=firmware->getCapability(FlightModes); igetCapability(FlightModes); i < CPN_MAX_FLIGHT_MODES; i++) { lb_fp[i]->hide(); cb_fp[i]->hide(); } @@ -114,22 +112,22 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, ui->mltpxCB->setCurrentIndex(md->mltpx); int scale=firmware->getCapability(SlowScale); float range=firmware->getCapability(SlowRange); - ui->slowDownSB->setMaximum(range/scale); - ui->slowDownSB->setSingleStep(1.0/scale); - ui->slowDownSB->setDecimals((scale==1 ? 0 :1)); + ui->slowDownSB->setMaximum(range / scale); + ui->slowDownSB->setSingleStep(1.0 / scale); + ui->slowDownSB->setDecimals((scale == 1 ? 0 : 1)); ui->slowDownSB->setValue((float)md->speedDown/scale); - ui->slowUpSB->setMaximum(range/scale); - ui->slowUpSB->setSingleStep(1.0/scale); - ui->slowUpSB->setDecimals((scale==1 ? 0 :1)); + ui->slowUpSB->setMaximum(range / scale); + ui->slowUpSB->setSingleStep(1.0 / scale); + ui->slowUpSB->setDecimals((scale == 1 ? 0 : 1)); ui->slowUpSB->setValue((float)md->speedUp/scale); - ui->delayDownSB->setMaximum(range/scale); - ui->delayDownSB->setSingleStep(1.0/scale); - ui->delayDownSB->setDecimals((scale==1 ? 0 :1)); - ui->delayDownSB->setValue((float)md->delayDown/scale); - ui->delayUpSB->setMaximum(range/scale); - ui->delayUpSB->setSingleStep(1.0/scale); - ui->delayUpSB->setDecimals((scale==1 ? 0 :1)); - ui->delayUpSB->setValue((float)md->delayUp/scale); + ui->delayDownSB->setMaximum(range / scale); + ui->delayDownSB->setSingleStep(1.0 / scale); + ui->delayDownSB->setDecimals((scale == 1 ? 0 : 1)); + ui->delayDownSB->setValue((float)md->delayDown / scale); + ui->delayUpSB->setMaximum(range / scale); + ui->delayUpSB->setSingleStep(1.0 / scale); + ui->delayUpSB->setDecimals((scale == 1 ? 0 : 1)); + ui->delayUpSB->setValue((float)md->delayUp / scale); QTimer::singleShot(0, this, SLOT(shrink())); valuesChanged(); @@ -154,8 +152,6 @@ MixerDialog::~MixerDialog() delete gvWeightGroup; delete gvOffsetGroup; delete curveGroup; - delete rawSourceModel; - delete rawSwitchModel; delete ui; } @@ -182,20 +178,20 @@ void MixerDialog::valuesChanged() ui->MixDR_CB->setEnabled(drVisible); ui->label_MixDR->setEnabled(drVisible); } - md->carryTrim = -(ui->trimCB->currentIndex()-1); + md->carryTrim = -(ui->trimCB->currentIndex() - 1); md->noExpo = ui->MixDR_CB->checkState() ? 0 : 1; md->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt()); md->mixWarn = ui->warningCB->currentIndex(); md->mltpx = (MltpxValue)ui->mltpxCB->currentIndex(); int scale = firmware->getCapability(SlowScale); - md->delayDown = round(ui->delayDownSB->value()*scale); - md->delayUp = round(ui->delayUpSB->value()*scale); - md->speedDown = round(ui->slowDownSB->value()*scale); - md->speedUp = round(ui->slowUpSB->value()*scale); + md->delayDown = round(ui->delayDownSB->value() * scale); + md->delayUp = round(ui->delayUpSB->value() * scale); + md->speedDown = round(ui->slowDownSB->value() * scale); + md->speedUp = round(ui->slowUpSB->value() * scale); strcpy(md->name, ui->mixerName->text().toLatin1()); md->flightModes = 0; - for (int i=CPN_MAX_FLIGHT_MODES-1; i>=0 ; i--) { + for (int i = CPN_MAX_FLIGHT_MODES-1; i >= 0 ; i--) { if (!cb_fp[i]->checkState()) { md->flightModes++; } @@ -226,7 +222,7 @@ void MixerDialog::label_phases_customContextMenuRequested(const QPoint & pos) void MixerDialog::fmClearAll() { lock = true; - for (int i=0; isetChecked(false); } lock = false; @@ -236,7 +232,7 @@ void MixerDialog::fmClearAll() void MixerDialog::fmSetAll() { lock = true; - for (int i=0; isetChecked(true); } lock = false; @@ -246,7 +242,7 @@ void MixerDialog::fmSetAll() void MixerDialog::fmInvertAll() { lock = true; - for (int i=0; isetChecked(!cb_fp[i]->isChecked()); } lock = false; diff --git a/companion/src/modeledit/mixerdialog.h b/companion/src/modeledit/mixerdialog.h index 2b89cd00e..a49a87e8f 100644 --- a/companion/src/modeledit/mixerdialog.h +++ b/companion/src/modeledit/mixerdialog.h @@ -26,8 +26,6 @@ class GVarGroup; class CurveGroup; -class RawSourceItemModel; -class RawSwitchItemModel; class RawItemFilteredModel; namespace Ui { @@ -38,7 +36,7 @@ class MixerDialog : public QDialog { Q_OBJECT public: MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); + RawItemFilteredModel * rawSourceModel, RawItemFilteredModel * rawSwitchModel); ~MixerDialog(); protected: @@ -63,8 +61,6 @@ class MixerDialog : public QDialog { GVarGroup * gvOffsetGroup; CurveGroup * curveGroup; QCheckBox * cb_fp[CPN_MAX_FLIGHT_MODES]; - RawItemFilteredModel * rawSourceModel; - RawItemFilteredModel * rawSwitchModel; }; #endif // _MIXERDIALOG_H_ diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index 52f6ba51c..16f8faeb1 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -20,16 +20,23 @@ #include "mixes.h" #include "helpers.h" +#include "rawitemfilteredmodel.h" MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): ModelPanel(parent, model, generalSettings, firmware), mixInserted(false), highlightedSource(0), - modelPrinter(firmware, generalSettings, model), - rawSourceItemModel(rawSourceItemModel), - rawSwitchItemModel(rawSwitchItemModel) + modelPrinter(firmware, generalSettings, model) { + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups | RawSource::ScriptsGroup, this); + connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated); + connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete); + + rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); + connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete); + QGridLayout * mixesLayout = new QGridLayout(this); mixersListWidget = new MixersListWidget(this, false); // TODO enum @@ -63,6 +70,8 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen MixesPanel::~MixesPanel() { + delete rawSourceModel; + delete rawSwitchModel; } void MixesPanel::update() @@ -178,7 +187,7 @@ void MixesPanel::gm_openMix(int index) MixData mixd(model->mixData[index]); - MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware, rawSourceItemModel, rawSwitchItemModel); + MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware, rawSourceModel, rawSwitchModel); if(g->exec()) { model->mixData[index] = mixd; emit modified(); @@ -532,3 +541,13 @@ void MixesPanel::clearMixes() update(); } } + +void MixesPanel::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void MixesPanel::onModelDataUpdateComplete() +{ + update(); +} diff --git a/companion/src/modeledit/mixes.h b/companion/src/modeledit/mixes.h index 15cb0bd54..7fca577be 100644 --- a/companion/src/modeledit/mixes.h +++ b/companion/src/modeledit/mixes.h @@ -25,7 +25,10 @@ #include "mixerslistwidget.h" #include "mixerdialog.h" #include "modelprinter.h" -#include "rawitemdatamodels.h" + +class RawSourceItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; class MixesPanel : public ModelPanel { @@ -52,7 +55,6 @@ class MixesPanel : public ModelPanel void moveMixDown(); void mixerHighlight(); - void mixerlistWidget_customContextMenuRequested(QPoint pos); void mixerlistWidget_doubleClicked(QModelIndex index); void mixerlistWidget_KeyPress(QKeyEvent *event); @@ -60,13 +62,16 @@ class MixesPanel : public ModelPanel void mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction action); void pasteMixerMimeData(const QMimeData * mimeData, int destIdx); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); + private: MixersListWidget * mixersListWidget; bool mixInserted; unsigned int highlightedSource; ModelPrinter modelPrinter; - RawSourceItemModel *rawSourceItemModel; - RawSwitchItemModel *rawSwitchItemModel; + RawItemFilteredModel *rawSourceModel; + RawItemFilteredModel *rawSwitchModel; int getMixerIndex(unsigned int dch); bool gm_insertMix(int idx); From 4feee9c66553d435446e12d9ea31af3cadb277ed Mon Sep 17 00:00:00 2001 From: elecpower Date: Sun, 20 Sep 2020 05:48:49 +1000 Subject: [PATCH 006/231] Inputs create filtered list once --- companion/src/modeledit/expodialog.cpp | 6 ++---- companion/src/modeledit/expodialog.h | 8 ++------ companion/src/modeledit/inputs.cpp | 27 ++++++++++++++++++++++---- companion/src/modeledit/inputs.h | 11 ++++++++--- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index 1df0ffaf0..fc336bfb9 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -24,8 +24,8 @@ #include "helpers.h" ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, GeneralSettings & generalSettings, - Firmware * firmware, QString & inputName, RawSourceItemModel * rawSourceItemModel, - RawSwitchItemModel * rawSwitchItemModel) : + Firmware * firmware, QString & inputName, RawItemFilteredModel * rawSourceModel, + RawItemFilteredModel * rawSwitchModel) : QDialog(parent), ui(new Ui::ExpoDialog), model(model), @@ -37,8 +37,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G lock(false) { ui->setupUi(this); - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~RawSource::InputsGroup) | RawSource::TelemGroup, this); - rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; diff --git a/companion/src/modeledit/expodialog.h b/companion/src/modeledit/expodialog.h index 1a3cc26af..8bd0f52e4 100644 --- a/companion/src/modeledit/expodialog.h +++ b/companion/src/modeledit/expodialog.h @@ -27,8 +27,6 @@ class GVarGroup; class CurveGroup; -class RawSourceItemModel; -class RawSwitchItemModel; class RawItemFilteredModel; namespace Ui { @@ -39,8 +37,8 @@ class ExpoDialog : public QDialog { Q_OBJECT public: ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expodata, GeneralSettings & generalSettings, - Firmware * firmware, QString & inputName, RawSourceItemModel * rawSourceItemModel, - RawSwitchItemModel * rawSwitchItemModel); + Firmware * firmware, QString & inputName, RawItemFilteredModel * rawSourceItemModel, + RawItemFilteredModel * rawSwitchItemModel); ~ExpoDialog(); protected: @@ -67,8 +65,6 @@ class ExpoDialog : public QDialog { ModelPrinter modelPrinter; bool lock; QCheckBox * cb_fp[CPN_MAX_FLIGHT_MODES]; - RawItemFilteredModel * rawSourceModel; - RawItemFilteredModel * rawSwitchModel; }; #endif // _EXPODIALOG_H_ diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index 624f1fdbd..ebdd5ecf1 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -21,15 +21,22 @@ #include "inputs.h" #include "expodialog.h" #include "helpers.h" +#include "rawitemfilteredmodel.h" InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): ModelPanel(parent, model, generalSettings, firmware), expoInserted(false), - modelPrinter(firmware, generalSettings, model), - rawSourceItemModel(rawSourceItemModel), - rawSwitchItemModel(rawSwitchItemModel) + modelPrinter(firmware, generalSettings, model) { + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~RawSource::InputsGroup), this); + connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); + connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); + + rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); + connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); + inputsCount = firmware->getCapability(VirtualInputs); if (inputsCount == 0) inputsCount = CPN_MAX_STICKS; @@ -68,6 +75,8 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g InputsPanel::~InputsPanel() { + delete rawSourceModel; + delete rawSwitchModel; } void InputsPanel::update() @@ -183,7 +192,7 @@ void InputsPanel::gm_openExpo(int index) if (firmware->getCapability(VirtualInputs)) inputName = model->inputNames[ed.chn]; - ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceItemModel, rawSwitchItemModel); + ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceModel, rawSwitchModel); if (g->exec()) { model->expoData[index] = ed; if (firmware->getCapability(VirtualInputs)) @@ -709,3 +718,13 @@ int InputsPanel::getInputIndexFromSelected() } return idx; } + +void InputsPanel::onModelDataAboutToBeUpdated() +{ + lock = true; +} + +void InputsPanel::onModelDataUpdateComplete() +{ + update(); +} diff --git a/companion/src/modeledit/inputs.h b/companion/src/modeledit/inputs.h index 0922305ce..5a31592b7 100644 --- a/companion/src/modeledit/inputs.h +++ b/companion/src/modeledit/inputs.h @@ -24,7 +24,10 @@ #include "modeledit.h" #include "mixerslistwidget.h" #include "modelprinter.h" -#include "rawitemdatamodels.h" + +class RawSourceItemModel; +class RawSwitchItemModel; +class RawItemFilteredModel; constexpr char MIMETYPE_EXPO[] = "application/x-companion-expo"; @@ -61,6 +64,8 @@ class InputsPanel : public ModelPanel void cmInputInsert(); void cmInputMoveDown(); void cmInputMoveUp(); + void onModelDataAboutToBeUpdated(); + void onModelDataUpdateComplete(); signals: void updateDataModels(); @@ -72,8 +77,8 @@ class InputsPanel : public ModelPanel ModelPrinter modelPrinter; int selectedIdx; int inputIdx; - RawSourceItemModel *rawSourceItemModel; - RawSwitchItemModel *rawSwitchItemModel; + RawItemFilteredModel *rawSourceModel; + RawItemFilteredModel *rawSwitchModel; int getExpoIndex(unsigned int dch); bool gm_insertExpo(int idx); From 1b40c6959308f4b0a2be482ff8cecf38702ee36e Mon Sep 17 00:00:00 2001 From: elecpower Date: Sun, 20 Sep 2020 07:43:54 +1000 Subject: [PATCH 007/231] Input and mix source list use filter to remove none entry --- companion/src/modeledit/expodialog.cpp | 29 ++++++++++++------------- companion/src/modeledit/inputs.cpp | 2 +- companion/src/modeledit/mixerdialog.cpp | 3 +-- companion/src/modeledit/mixes.cpp | 2 +- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index fc336bfb9..5206fc08a 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -38,9 +38,9 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G { ui->setupUi(this); - QLabel * lb_fp[CPN_MAX_FLIGHT_MODES] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; - QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; - for (int i=0; ilb_FP0, ui->lb_FP1, ui->lb_FP2, ui->lb_FP3, ui->lb_FP4, ui->lb_FP5, ui->lb_FP6, ui->lb_FP7, ui->lb_FP8 }; + QCheckBox * tmp[CPN_MAX_FLIGHT_MODES] = {ui->cb_FP0, ui->cb_FP1, ui->cb_FP2, ui->cb_FP3, ui->cb_FP4, ui->cb_FP5, ui->cb_FP6, ui->cb_FP7, ui->cb_FP8 }; + for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) { cb_fp[i] = tmp[i]; } @@ -57,11 +57,11 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G ui->switchesCB->setModel(rawSwitchModel); ui->switchesCB->setCurrentIndex(ui->switchesCB->findData(ed->swtch.toValue())); - ui->sideCB->setCurrentIndex(ed->mode-1); + ui->sideCB->setCurrentIndex(ed->mode - 1); if (!firmware->getCapability(FlightModes)) { ui->label_phases->hide(); - for (int i=0; ihide(); cb_fp[i]->hide(); } @@ -71,13 +71,13 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G ui->label_phases->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->label_phases, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(label_phases_customContextMenuRequested(const QPoint &))); int mask = 1; - for (int i=0; iflightModes & mask) == 0) { cb_fp[i]->setChecked(true); } mask <<= 1; } - for (int i=firmware->getCapability(FlightModes); igetCapability(FlightModes); i < CPN_MAX_FLIGHT_MODES; i++) { lb_fp[i]->hide(); cb_fp[i]->hide(); } @@ -87,7 +87,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G ui->inputName->setMaxLength(firmware->getCapability(InputsLength)); ui->sourceCB->setModel(rawSourceModel); ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(ed->srcRaw.toValue())); - ui->sourceCB->removeItem(0); ui->inputName->setValidator(new QRegExpValidator(rx, this)); ui->inputName->setText(inputName); } @@ -100,8 +99,8 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G ui->trimCB->hide(); } - for(int i=0; i < getBoardCapability(getCurrentBoard(), Board::NumTrims); i++) { - ui->trimCB->addItem(RawSource(SOURCE_TYPE_TRIM, i).toString(), i+1); + for(int i = 0; i < getBoardCapability(getCurrentBoard(), Board::NumTrims); i++) { + ui->trimCB->addItem(RawSource(SOURCE_TYPE_TRIM, i).toString(), i + 1); } ui->trimCB->setCurrentIndex(1 - ed->carryTrim); @@ -126,7 +125,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G connect(ui->trimCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged())); connect(ui->switchesCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged())); connect(ui->sideCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged())); - for (int i=0; igetCapability(VirtualInputs)) { @@ -183,7 +182,7 @@ void ExpoDialog::valuesChanged() } ed->flightModes = 0; - for (int i=CPN_MAX_FLIGHT_MODES-1; i>=0 ; i--) { + for (int i = CPN_MAX_FLIGHT_MODES - 1; i >= 0 ; i--) { if (!cb_fp[i]->checkState()) { ed->flightModes++; } @@ -214,7 +213,7 @@ void ExpoDialog::label_phases_customContextMenuRequested(const QPoint & pos) void ExpoDialog::fmClearAll() { lock = true; - for (int i=0; isetChecked(false); } lock = false; @@ -224,7 +223,7 @@ void ExpoDialog::fmClearAll() void ExpoDialog::fmSetAll() { lock = true; - for (int i=0; isetChecked(true); } lock = false; @@ -234,7 +233,7 @@ void ExpoDialog::fmSetAll() void ExpoDialog::fmInvertAll() { lock = true; - for (int i=0; isetChecked(!cb_fp[i]->isChecked()); } lock = false; diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index ebdd5ecf1..a79a3d28f 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -29,7 +29,7 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g expoInserted(false), modelPrinter(firmware, generalSettings, model) { - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~RawSource::InputsGroup), this); + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~ RawSource::NoneGroup & ~RawSource::InputsGroup), this); connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index e17771838..9eda88677 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -47,7 +47,6 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, ui->sourceCB->setModel(rawSourceModel); ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(md->srcRaw.toValue())); - ui->sourceCB->removeItem(0); int limit = firmware->getCapability(OffsetWeight); @@ -191,7 +190,7 @@ void MixerDialog::valuesChanged() strcpy(md->name, ui->mixerName->text().toLatin1()); md->flightModes = 0; - for (int i = CPN_MAX_FLIGHT_MODES-1; i >= 0 ; i--) { + for (int i = CPN_MAX_FLIGHT_MODES - 1; i >= 0 ; i--) { if (!cb_fp[i]->checkState()) { md->flightModes++; } diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index 16f8faeb1..3b8da2c99 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -29,7 +29,7 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen highlightedSource(0), modelPrinter(firmware, generalSettings, model) { - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups | RawSource::ScriptsGroup, this); + rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, ((RawSource::InputSourceGroups | RawSource::ScriptsGroup) & ~ RawSource::NoneGroup), this); connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated); connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete); From eb69f2c9505ebae9a6e1b28858b74c261b4a522f Mon Sep 17 00:00:00 2001 From: elecpower Date: Sun, 20 Sep 2020 07:58:43 +1000 Subject: [PATCH 008/231] Cosmetic --- companion/src/modeledit/logicalswitches.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 109e09ecf..8c5fe63d1 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -408,7 +408,7 @@ void LogicalSwitchesPanel::updateLine(int i) cbSource1[i]->setModel(rawSwitchModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1)); updateTimerParam(dsbOffset[i], model->logicalSw[i].val2, 0.0); - updateTimerParam(dsbOffset2[i], model->logicalSw[i].val2+model->logicalSw[i].val3, ValToTim(TimToVal(dsbOffset[i]->value())-1)); + updateTimerParam(dsbOffset2[i], model->logicalSw[i].val2 + model->logicalSw[i].val3, ValToTim(TimToVal(dsbOffset[i]->value()) - 1)); dsbOffset2[i]->setSuffix((model->logicalSw[i].val3) ? "" : tr(" (infinite)")); break; From 12d8d1118fd49abe9ede5fa398585ca4623d3477 Mon Sep 17 00:00:00 2001 From: elecpower Date: Tue, 22 Sep 2020 22:56:14 +1000 Subject: [PATCH 009/231] Inputs signal changes and LS try to solve timing crash --- companion/src/modeledit/inputs.cpp | 18 ++++++-- companion/src/modeledit/logicalswitches.cpp | 51 ++++++++++----------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index a79a3d28f..53b016610 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -197,9 +197,9 @@ void InputsPanel::gm_openExpo(int index) model->expoData[index] = ed; if (firmware->getCapability(VirtualInputs)) strncpy(model->inputNames[ed.chn], inputName.toLatin1().data(), INPUT_NAME_LEN); + update(); emit updateDataModels(); emit modified(); - update(); } else { if (expoInserted) { @@ -252,8 +252,9 @@ void InputsPanel::exposDelete(bool prompt) } exposDeleteList(list, prompt); - emit modified(); update(); + emit updateDataModels(); + emit modified(); } void InputsPanel::exposCut() @@ -326,8 +327,9 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx) i += sizeof(ExpoData); } - emit modified(); update(); + emit updateDataModels(); + emit modified(); } } @@ -494,8 +496,9 @@ void InputsPanel::moveExpoList(bool down) } } if (mod) { - emit modified(); update(); + emit updateDataModels(); + emit modified(); } setSelectedByExpoList(highlightList); } @@ -533,8 +536,9 @@ void InputsPanel::clearExpos() for (int i = 0; i < inputsCount; i++) { model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, i); } - emit modified(); update(); + emit updateDataModels(); + emit modified(); } } @@ -582,6 +586,7 @@ void InputsPanel::cmInputClear() } model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, inputIdx); update(); + emit updateDataModels(); emit modified(); } @@ -605,6 +610,7 @@ void InputsPanel::cmInputDelete() model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, -1); update(); + emit updateDataModels(); emit modified(); } @@ -623,6 +629,7 @@ void InputsPanel::cmInputInsert() model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, 1); update(); + emit updateDataModels(); emit modified(); } @@ -684,6 +691,7 @@ void InputsPanel::cmInputSwapData(int idx1, int idx2) model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); + emit updateDataModels(); emit modified(); } diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 8c5fe63d1..d3111a1ed 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -169,36 +169,33 @@ LogicalSwitchesPanel::~LogicalSwitchesPanel() void LogicalSwitchesPanel::onFunctionChanged() { - int i = sender()->property("index").toInt(); - unsigned newFunc = cbFunction[i]->currentData().toUInt(); + if (!lock) { + int i = sender()->property("index").toInt(); + unsigned newFunc = cbFunction[i]->currentData().toUInt(); - if (model->logicalSw[i].func == newFunc) - return; + if (model->logicalSw[i].func == newFunc) + return; - const unsigned oldFunc = model->logicalSw[i].func; - CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); - model->logicalSw[i].func = newFunc; - CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); - - if (oldFuncFamily != newFuncFamily) { - model->logicalSw[i].clear(); + const unsigned oldFunc = model->logicalSw[i].func; + CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); model->logicalSw[i].func = newFunc; - if (newFuncFamily == LS_FAMILY_TIMER) { - model->logicalSw[i].val1 = -119; - model->logicalSw[i].val2 = -119; - } - else if (newFuncFamily == LS_FAMILY_EDGE) { - model->logicalSw[i].val2 = -129; - } - } - if (bool(oldFunc) != bool(newFunc)) { - emit updateDataModels(); - update(); - } - else - updateLine(i); + CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); - emit modified(); + if (oldFuncFamily != newFuncFamily) { + model->logicalSw[i].clear(); + model->logicalSw[i].func = newFunc; + if (newFuncFamily == LS_FAMILY_TIMER) { + model->logicalSw[i].val1 = -119; + model->logicalSw[i].val2 = -119; + } + else if (newFuncFamily == LS_FAMILY_EDGE) { + model->logicalSw[i].val2 = -129; + } + } + + updateLine(i); + emit modified(); + } } void LogicalSwitchesPanel::onV1Changed(int value) @@ -353,7 +350,7 @@ void LogicalSwitchesPanel::updateLine(int i) cbFunction[i]->setCurrentIndex(cbFunction[i]->findData(model->logicalSw[i].func)); cbAndSwitch[i]->setCurrentIndex(cbAndSwitch[i]->findData(RawSwitch(model->logicalSw[i].andsw).toValue())); - if (!model->logicalSw[i].func) { + if (model->logicalSw[i].isEmpty()) { mask = 0; } else { From 0922e56f0b637a4a602fdc0e5e9bef99add790c0 Mon Sep 17 00:00:00 2001 From: elecpower Date: Wed, 23 Sep 2020 06:37:04 +1000 Subject: [PATCH 010/231] More attempts to stop LS crash --- companion/src/modeledit/logicalswitches.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index d3111a1ed..11c019ee3 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -51,7 +51,6 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, const int channelsMax = model.getChannelsMax(true); - lock = true; for (int i = 0; i < lsCapability; i++) { // The label QLabel * label = new QLabel(this); @@ -156,7 +155,6 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, } disableMouseScrolling(); - lock = false; tableLayout->resizeColumnsToContents(); tableLayout->pushRowsUp(lsCapability+1); } @@ -176,12 +174,11 @@ void LogicalSwitchesPanel::onFunctionChanged() if (model->logicalSw[i].func == newFunc) return; - const unsigned oldFunc = model->logicalSw[i].func; CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); model->logicalSw[i].func = newFunc; CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); - if (oldFuncFamily != newFuncFamily) { + if (oldFuncFamily != newFuncFamily || newFunc == LS_FN_OFF) { model->logicalSw[i].clear(); model->logicalSw[i].func = newFunc; if (newFuncFamily == LS_FAMILY_TIMER) { @@ -345,15 +342,12 @@ void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, doubl void LogicalSwitchesPanel::updateLine(int i) { lock = true; - unsigned int mask; + unsigned int mask = 0; cbFunction[i]->setCurrentIndex(cbFunction[i]->findData(model->logicalSw[i].func)); cbAndSwitch[i]->setCurrentIndex(cbAndSwitch[i]->findData(RawSwitch(model->logicalSw[i].andsw).toValue())); - if (model->logicalSw[i].isEmpty()) { - mask = 0; - } - else { + //if (!model->logicalSw[i].isEmpty()) { mask = LINE_ENABLED | DELAY_ENABLED | DURATION_ENABLED; switch (model->logicalSw[i].getFunctionFamily()) @@ -423,7 +417,7 @@ void LogicalSwitchesPanel::updateLine(int i) updateTimerParam(dsbOffset[i], model->logicalSw[i].val2, 0.1); break; } - } + //} cbSource1[i]->setVisible(mask & SOURCE1_VISIBLE); cbSource2[i]->setVisible(mask & SOURCE2_VISIBLE); From 8eceebd779a2748234e06c61569dab604f7fc183 Mon Sep 17 00:00:00 2001 From: elecpower Date: Thu, 24 Sep 2020 06:24:12 +1000 Subject: [PATCH 011/231] Workaround for LS ui data model updates --- companion/src/modeledit/logicalswitches.cpp | 44 ++++++++++++++------- companion/src/modeledit/logicalswitches.h | 5 +-- companion/src/modeledit/modeledit.cpp | 3 -- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 11c019ee3..0c1071249 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -174,6 +174,7 @@ void LogicalSwitchesPanel::onFunctionChanged() if (model->logicalSw[i].func == newFunc) return; + unsigned oldFunc = model->logicalSw[i].func; CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); model->logicalSw[i].func = newFunc; CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); @@ -190,11 +191,30 @@ void LogicalSwitchesPanel::onFunctionChanged() } } - updateLine(i); + if (oldFunc == LS_FN_OFF || newFunc == LS_FN_OFF) + updateCBLists(); emit modified(); } } +void LogicalSwitchesPanel::updateCBLists() +{ + // We need to update the data models as (de)activating the current LS needs to be reflected in all LS source and switch lists + // However triggering after the input or mix edit dialogs displayed causes the application to crash + // So this workaround gives time for other events to be processed before refreshing + // Not sure if this an OS related issue or a QT bug in QT 5.7 (and higher?) + // The delay is abitary + QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateDataModels); +} + +void LogicalSwitchesPanel::updateDataModels() +{ + // This is inconsistent but needed as part of the workaround + //emit updateCBLists(); adds to the event stack so call direct + rawSourceModel->update(); + rawSwitchModel->update(); +} + void LogicalSwitchesPanel::onV1Changed(int value) { if (!lock) { @@ -347,7 +367,7 @@ void LogicalSwitchesPanel::updateLine(int i) cbFunction[i]->setCurrentIndex(cbFunction[i]->findData(model->logicalSw[i].func)); cbAndSwitch[i]->setCurrentIndex(cbAndSwitch[i]->findData(RawSwitch(model->logicalSw[i].andsw).toValue())); - //if (!model->logicalSw[i].isEmpty()) { + if (!model->logicalSw[i].isEmpty()) { mask = LINE_ENABLED | DELAY_ENABLED | DURATION_ENABLED; switch (model->logicalSw[i].getFunctionFamily()) @@ -417,7 +437,7 @@ void LogicalSwitchesPanel::updateLine(int i) updateTimerParam(dsbOffset[i], model->logicalSw[i].val2, 0.1); break; } - //} + } cbSource1[i]->setVisible(mask & SOURCE1_VISIBLE); cbSource2[i]->setVisible(mask & SOURCE2_VISIBLE); @@ -487,8 +507,7 @@ void LogicalSwitchesPanel::cmPaste() QByteArray data; if (hasClipboardData(&data)) { memcpy(&model->logicalSw[selectedIndex], data.constData(), sizeof(LogicalSwitchData)); - emit updateDataModels(); - updateLine(selectedIndex); + updateCBLists(); emit modified(); } } @@ -502,8 +521,7 @@ void LogicalSwitchesPanel::cmDelete() model->logicalSw[lsCapability - 1].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); - emit updateDataModels(); - update(); + updateCBLists(); emit modified(); } @@ -593,8 +611,7 @@ void LogicalSwitchesPanel::cmClear(bool prompt) model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); - update(); - emit updateDataModels(); + updateCBLists(); emit modified(); } @@ -607,8 +624,7 @@ void LogicalSwitchesPanel::cmClearAll() model->logicalSw[i].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, i); } - update(); - emit updateDataModels(); + updateCBLists(); emit modified(); } @@ -617,8 +633,7 @@ void LogicalSwitchesPanel::cmInsert() memmove(&model->logicalSw[selectedIndex + 1], &model->logicalSw[selectedIndex], (CPN_MAX_LOGICAL_SWITCHES - (selectedIndex + 1)) * sizeof(LogicalSwitchData)); model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); - update(); - emit updateDataModels(); + updateCBLists(); emit modified(); } @@ -631,8 +646,7 @@ void LogicalSwitchesPanel::swapData(int idx1, int idx2) memcpy(lsw2, lsw1, sizeof(LogicalSwitchData)); memcpy(lsw1, &lstmp, sizeof(LogicalSwitchData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); - update(); - emit updateDataModels(); + updateCBLists(); emit modified(); } } diff --git a/companion/src/modeledit/logicalswitches.h b/companion/src/modeledit/logicalswitches.h index b73bd8034..b267c8906 100644 --- a/companion/src/modeledit/logicalswitches.h +++ b/companion/src/modeledit/logicalswitches.h @@ -65,9 +65,6 @@ class LogicalSwitchesPanel : public ModelPanel void onModelDataAboutToBeUpdated(); void onModelDataUpdateComplete(); - signals: - void updateDataModels(); - private: QComboBox * cbFunction[CPN_MAX_LOGICAL_SWITCHES]; QDoubleSpinBox * dsbValue[CPN_MAX_LOGICAL_SWITCHES]; @@ -92,6 +89,8 @@ class LogicalSwitchesPanel : public ModelPanel bool moveDownAllowed() const; bool moveUpAllowed() const; int modelsUpdateCnt; + void updateCBLists(); + void updateDataModels(); }; #endif // _LOGICALSWITCHES_H_ diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 9b6d1727c..1b256c493 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -122,9 +122,6 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw connect(curvesPanel, &CurvesPanel::updateDataModels, curveModel, &CurveItemModel::update); - connect(logicalSwitchesPanel, &LogicalSwitchesPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); - connect(logicalSwitchesPanel, &LogicalSwitchesPanel::updateDataModels, rawSwitchModel, &RawSwitchItemModel::update); - connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged); connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation); From 1364a88eb0224c3803ff663dc5dad569b090e3d1 Mon Sep 17 00:00:00 2001 From: elecpower Date: Thu, 24 Sep 2020 06:42:10 +1000 Subject: [PATCH 012/231] Add back refresh line on LS func change and cosmetics --- companion/src/modeledit/logicalswitches.cpp | 38 +++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 0c1071249..0e58ad06a 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -193,28 +193,12 @@ void LogicalSwitchesPanel::onFunctionChanged() if (oldFunc == LS_FN_OFF || newFunc == LS_FN_OFF) updateCBLists(); + else + updateLine(i); emit modified(); } } -void LogicalSwitchesPanel::updateCBLists() -{ - // We need to update the data models as (de)activating the current LS needs to be reflected in all LS source and switch lists - // However triggering after the input or mix edit dialogs displayed causes the application to crash - // So this workaround gives time for other events to be processed before refreshing - // Not sure if this an OS related issue or a QT bug in QT 5.7 (and higher?) - // The delay is abitary - QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateDataModels); -} - -void LogicalSwitchesPanel::updateDataModels() -{ - // This is inconsistent but needed as part of the workaround - //emit updateCBLists(); adds to the event stack so call direct - rawSourceModel->update(); - rawSwitchModel->update(); -} - void LogicalSwitchesPanel::onV1Changed(int value) { if (!lock) { @@ -651,6 +635,24 @@ void LogicalSwitchesPanel::swapData(int idx1, int idx2) } } +void LogicalSwitchesPanel::updateCBLists() +{ + // We need to update the data models as (de)activating the current LS needs to be reflected in all LS source and switch lists + // However triggering after the input or mix edit dialogs displayed causes the application to crash + // So this workaround gives time for other events to be processed before refreshing + // Not sure if this an OS related issue or a QT bug in QT 5.7 (and higher?) + // The delay is abitary + QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateDataModels); +} + +void LogicalSwitchesPanel::updateDataModels() +{ + // This is inconsistent but needed as part of the workaround + //emit updateCBLists(); adds to the event stack so call direct + rawSourceModel->update(); + rawSwitchModel->update(); +} + void LogicalSwitchesPanel::onModelDataAboutToBeUpdated() { lock = true; From af4c5524b17c9dfa775cc0d9f5c4cb743834ef88 Mon Sep 17 00:00:00 2001 From: elecpower Date: Wed, 30 Sep 2020 07:52:57 +1000 Subject: [PATCH 013/231] Refactor to directly call updates to data models --- .../src/datamodels/rawitemdatamodels.cpp | 47 +++++- companion/src/datamodels/rawitemdatamodels.h | 32 ++++ .../src/datamodels/rawitemfilteredmodel.cpp | 15 +- .../src/datamodels/rawitemfilteredmodel.h | 10 +- companion/src/firmwares/rawswitch.cpp | 2 +- companion/src/generaledit/generaledit.cpp | 5 +- companion/src/generaledit/generaledit.h | 6 +- companion/src/modeledit/channels.cpp | 34 +++-- companion/src/modeledit/channels.h | 11 +- companion/src/modeledit/curves.cpp | 25 ++-- companion/src/modeledit/curves.h | 9 +- companion/src/modeledit/customfunctions.cpp | 46 +++--- companion/src/modeledit/customfunctions.h | 15 +- companion/src/modeledit/flightmodes.cpp | 27 ++-- companion/src/modeledit/flightmodes.h | 10 +- companion/src/modeledit/heli.cpp | 19 +-- companion/src/modeledit/heli.h | 7 +- companion/src/modeledit/inputs.cpp | 46 +++--- companion/src/modeledit/inputs.h | 15 +- companion/src/modeledit/logicalswitches.cpp | 66 ++++---- companion/src/modeledit/logicalswitches.h | 13 +- companion/src/modeledit/mixerdialog.cpp | 2 +- companion/src/modeledit/mixes.cpp | 23 ++- companion/src/modeledit/mixes.h | 11 +- companion/src/modeledit/modeledit.cpp | 46 ++---- companion/src/modeledit/modeledit.h | 8 +- companion/src/modeledit/setup.cpp | 141 +++++++++--------- companion/src/modeledit/setup.h | 7 +- companion/src/modeledit/telemetry.cpp | 24 +-- companion/src/modeledit/telemetry.h | 10 +- 30 files changed, 401 insertions(+), 331 deletions(-) diff --git a/companion/src/datamodels/rawitemdatamodels.cpp b/companion/src/datamodels/rawitemdatamodels.cpp index 4edd26c76..837416d68 100644 --- a/companion/src/datamodels/rawitemdatamodels.cpp +++ b/companion/src/datamodels/rawitemdatamodels.cpp @@ -43,7 +43,7 @@ RawSourceItemModel::RawSourceItemModel(const GeneralSettings * const generalSett addItems(SOURCE_TYPE_PPM, RawSource::SourcesGroup, fw->getCapability(TrainerInputs)); addItems(SOURCE_TYPE_CH, RawSource::SourcesGroup, fw->getCapability(Outputs)); addItems(SOURCE_TYPE_SPECIAL, RawSource::TelemGroup, 5); - addItems(SOURCE_TYPE_TELEMETRY, RawSource::TelemGroup, CPN_MAX_SENSORS * 3); + addItems(SOURCE_TYPE_TELEMETRY, RawSource::TelemGroup, fw->getCapability(Sensors) * 3); addItems(SOURCE_TYPE_GVAR, RawSource::GVarsGroup, fw->getCapability(Gvars)); } @@ -90,7 +90,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett // Descending switch direction: NOT (!) switches addItems(SWITCH_TYPE_ACT, -1); - addItems(SWITCH_TYPE_SENSOR, -CPN_MAX_SENSORS); + addItems(SWITCH_TYPE_SENSOR, -fw->getCapability(Sensors)); addItems(SWITCH_TYPE_TELEMETRY, -1); addItems(SWITCH_TYPE_FLIGHT_MODE, -fw->getCapability(FlightModes)); addItems(SWITCH_TYPE_VIRTUAL, -fw->getCapability(LogicalSwitches)); @@ -109,7 +109,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett addItems(SWITCH_TYPE_VIRTUAL, fw->getCapability(LogicalSwitches)); addItems(SWITCH_TYPE_FLIGHT_MODE, fw->getCapability(FlightModes)); addItems(SWITCH_TYPE_TELEMETRY, 1); - addItems(SWITCH_TYPE_SENSOR, CPN_MAX_SENSORS); + addItems(SWITCH_TYPE_SENSOR, fw->getCapability(Sensors)); addItems(SWITCH_TYPE_ON, 1); addItems(SWITCH_TYPE_ONE, 1); addItems(SWITCH_TYPE_ACT, 1); @@ -220,3 +220,44 @@ void CurveItemModel::update() emit dataUpdateComplete(); } + +// +// CommonItemModels +// + +CommonItemModels::CommonItemModels(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent) +{ + m_rawSourceItemModel = new RawSourceItemModel(generalSettings, modelData, parent); + m_rawSwitchItemModel = new RawSwitchItemModel(generalSettings, modelData, parent); + m_curveItemModel = new CurveItemModel(generalSettings, modelData, parent); +} + +CommonItemModels::~CommonItemModels() +{ +} + +void CommonItemModels::update(const RadioModelObjects radioModelObjects) +{ + switch (radioModelObjects) { + case RMO_CHANNELS: + case RMO_INPUTS: + case RMO_TELEMETRY_SENSORS: + case RMO_TIMERS: + m_rawSourceItemModel->update(); + break; + case RMO_FLIGHT_MODES: + case RMO_GLOBAL_VARIABLES: + case RMO_LOGICAL_SWITCHES: + m_rawSourceItemModel->update(); + m_rawSwitchItemModel->update(); + break; + case RMO_CURVES: + m_curveItemModel->update(); + break; + case RMO_SCRIPTS: + // no need to refresh + break; + default: + qDebug() << "Unknown RadioModelObject:" << radioModelObjects; + } +} diff --git a/companion/src/datamodels/rawitemdatamodels.h b/companion/src/datamodels/rawitemdatamodels.h index 30a9b54e9..48cb55fd2 100644 --- a/companion/src/datamodels/rawitemdatamodels.h +++ b/companion/src/datamodels/rawitemdatamodels.h @@ -105,4 +105,36 @@ class CurveItemModel: public AbstractRawItemDataModel void setDynamicItemData(QStandardItem * item, int index) const; }; + +class CommonItemModels: public QObject +{ + Q_OBJECT + public: + enum RadioModelObjects { + RMO_CHANNELS, + RMO_CURVES, + RMO_FLIGHT_MODES, + RMO_GLOBAL_VARIABLES, + RMO_INPUTS, + RMO_LOGICAL_SWITCHES, + RMO_SCRIPTS, + RMO_TELEMETRY_SENSORS, + RMO_TIMERS + }; + Q_ENUM(RadioModelObjects) + + explicit CommonItemModels(const GeneralSettings * const generalSettings, const ModelData * const modelData, QObject * parent = nullptr); + ~CommonItemModels(); + + void update(const RadioModelObjects radioModelObjects); + RawSourceItemModel * rawSourceItemModel() const { return m_rawSourceItemModel; } + RawSwitchItemModel * rawSwitchItemModel() const { return m_rawSwitchItemModel; } + CurveItemModel * curveItemModel() const { return m_curveItemModel; } + + private: + RawSourceItemModel *m_rawSourceItemModel; + RawSwitchItemModel *m_rawSwitchItemModel; + CurveItemModel *m_curveItemModel; +}; + #endif // RAWITEMDATAMODELS_H diff --git a/companion/src/datamodels/rawitemfilteredmodel.cpp b/companion/src/datamodels/rawitemfilteredmodel.cpp index 775b85fc4..abe9ca08e 100644 --- a/companion/src/datamodels/rawitemfilteredmodel.cpp +++ b/companion/src/datamodels/rawitemfilteredmodel.cpp @@ -19,7 +19,6 @@ */ #include "rawitemfilteredmodel.h" -#include "rawitemdatamodels.h" RawItemFilteredModel::RawItemFilteredModel(QAbstractItemModel * sourceModel, int flags, QObject * parent) : QSortFilterProxyModel(parent), @@ -31,10 +30,10 @@ RawItemFilteredModel::RawItemFilteredModel(QAbstractItemModel * sourceModel, int setDynamicSortFilter(true); setSourceModel(sourceModel); - AbstractRawItemDataModel * model = qobject_cast(sourceModel); - if (model) { - connect(model, &AbstractRawItemDataModel::dataAboutToBeUpdated, this, &RawItemFilteredModel::onDataAboutToBeUpdated); - connect(model, &AbstractRawItemDataModel::dataUpdateComplete, this, &RawItemFilteredModel::onDataUpdateComplete); + AbstractRawItemDataModel * itemModel = qobject_cast(sourceModel); + if (itemModel) { + connect(itemModel, &AbstractRawItemDataModel::dataAboutToBeUpdated, this, &RawItemFilteredModel::onDataAboutToBeUpdated); + connect(itemModel, &AbstractRawItemDataModel::dataUpdateComplete, this, &RawItemFilteredModel::onDataUpdateComplete); } } @@ -62,9 +61,9 @@ bool RawItemFilteredModel::filterAcceptsRow(int sourceRow, const QModelIndex & s void RawItemFilteredModel::update() const { - AbstractRawItemDataModel * model = qobject_cast(sourceModel()); - if (model) - model->update(); + AbstractRawItemDataModel * itemModel = qobject_cast(sourceModel()); + if (itemModel) + itemModel->update(); } void RawItemFilteredModel::onDataAboutToBeUpdated() diff --git a/companion/src/datamodels/rawitemfilteredmodel.h b/companion/src/datamodels/rawitemfilteredmodel.h index f8bf22c19..3274460f7 100644 --- a/companion/src/datamodels/rawitemfilteredmodel.h +++ b/companion/src/datamodels/rawitemfilteredmodel.h @@ -27,8 +27,6 @@ class GeneralSettings; class ModelData; -class RawSourceItemModel; -class RawSwitchItemModel; class RawItemFilteredModel: public QSortFilterProxyModel { @@ -36,9 +34,11 @@ class RawItemFilteredModel: public QSortFilterProxyModel public: enum DataFilters { AllFilter = AbstractRawItemDataModel::NegativeGroup | AbstractRawItemDataModel::NoneGroup | AbstractRawItemDataModel::PositiveGroup, - HideNegativeFilter = AllFilter &~ AbstractRawItemDataModel::NegativeGroup, - NonePositiveFilter = AbstractRawItemDataModel::NoneGroup | AbstractRawItemDataModel::PositiveGroup, - PositiveFilter = AbstractRawItemDataModel::PositiveGroup + AllExcludeNoneFilter = AllFilter &~ AbstractRawItemDataModel::NoneGroup, + NegativeFilter = AbstractRawItemDataModel::NegativeGroup | AbstractRawItemDataModel::NoneGroup, + NegativeExcludeNoneFilter = AbstractRawItemDataModel::NegativeGroup, + PositiveFilter = AbstractRawItemDataModel::PositiveGroup | AbstractRawItemDataModel::NoneGroup, + PositiveExcludeNoneFilter = AbstractRawItemDataModel::PositiveGroup }; Q_ENUM(DataFilters) diff --git a/companion/src/firmwares/rawswitch.cpp b/companion/src/firmwares/rawswitch.cpp index 8c1685a25..bc30b7f5a 100644 --- a/companion/src/firmwares/rawswitch.cpp +++ b/companion/src/firmwares/rawswitch.cpp @@ -59,7 +59,7 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen tr("THs"), tr("TH%"), tr("THt") }; - const QStringList directionIndicators = QStringList() + static const QStringList directionIndicators = QStringList() << CPN_STR_SW_INDICATOR_UP << CPN_STR_SW_INDICATOR_NEUT << CPN_STR_SW_INDICATOR_DN; diff --git a/companion/src/generaledit/generaledit.cpp b/companion/src/generaledit/generaledit.cpp index a31fee359..bff9d3f83 100644 --- a/companion/src/generaledit/generaledit.cpp +++ b/companion/src/generaledit/generaledit.cpp @@ -56,11 +56,10 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir } } - RawSourceItemModel *rawSourceModel = new RawSourceItemModel(&generalSettings, nullptr, this); - RawSwitchItemModel *rawSwitchModel = new RawSwitchItemModel(&generalSettings, nullptr, this); + commonItemModels = new CommonItemModels(&generalSettings, nullptr, this); addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup")); - addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, rawSourceModel, rawSwitchModel), tr("Global Functions")); + addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, commonItemModels), tr("Global Functions")); addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer")); addTab(new HardwarePanel(this, generalSettings, firmware), tr("Hardware")); addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration")); diff --git a/companion/src/generaledit/generaledit.h b/companion/src/generaledit/generaledit.h index 1c1d096a5..3f73a9e01 100644 --- a/companion/src/generaledit/generaledit.h +++ b/companion/src/generaledit/generaledit.h @@ -25,6 +25,8 @@ #include "eeprominterface.h" #include "genericpanel.h" +class CommonItemModels; + namespace Ui { class GeneralEdit; } @@ -56,7 +58,7 @@ class GeneralEdit : public QDialog void getGeneralSwitchDefPos(int i, bool val); void setSwitchDefPos(); void updateVarioPitchRange(); - + signals: void modified(); @@ -71,7 +73,7 @@ class GeneralEdit : public QDialog QVector panels; void addTab(GenericPanel *panel, QString text); void closeEvent(QCloseEvent *event); - + CommonItemModels *commonItemModels; }; #endif // _GENERALEDIT_H_ diff --git a/companion/src/modeledit/channels.cpp b/companion/src/modeledit/channels.cpp index 1371d3fab..d2818368e 100644 --- a/companion/src/modeledit/channels.cpp +++ b/companion/src/modeledit/channels.cpp @@ -96,15 +96,16 @@ void LimitsGroup::updateMinMax(int max) } } } -ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CurveItemModel * curveItemModel): - ModelPanel(parent, model, generalSettings, firmware) +ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): + ModelPanel(parent, model, generalSettings, firmware), + commonItemModels(commonItemModels) { chnCapability = firmware->getCapability(Outputs); int channelNameMaxLen = firmware->getCapability(ChannelsName); - curveModel = new RawItemFilteredModel(curveItemModel, RawItemFilteredModel::AllFilter, this); - connect(curveModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &ChannelsPanel::onModelDataAboutToBeUpdated); - connect(curveModel, &RawItemFilteredModel::dataUpdateComplete, this, &ChannelsPanel::onModelDataUpdateComplete); + curveFilteredModel = new RawItemFilteredModel(commonItemModels->curveItemModel(), RawItemFilteredModel::AllFilter, this); + connect(curveFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &ChannelsPanel::onModelDataAboutToBeUpdated); + connect(curveFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &ChannelsPanel::onModelDataUpdateComplete); QStringList headerLabels; headerLabels << "#"; @@ -165,7 +166,7 @@ ChannelsPanel::ChannelsPanel(QWidget * parent, ModelData & model, GeneralSetting if (IS_HORUS_OR_TARANIS(firmware->getBoard())) { curveCB[i] = new QComboBox(this); curveCB[i]->setProperty("index", i); - curveCB[i]->setModel(curveModel); + curveCB[i]->setModel(curveFilteredModel); connect(curveCB[i], SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited())); tableLayout->addWidget(i, col++, curveCB[i]); } @@ -213,7 +214,6 @@ ChannelsPanel::~ChannelsPanel() delete centerSB[i]; delete symlimitsChk[i]; } - delete curveModel; } void ChannelsPanel::symlimitsEdited() @@ -233,7 +233,7 @@ void ChannelsPanel::nameEdited() int index = le->property("index").toInt(); if (model->limitData[index].name != le->text()) { strcpy(model->limitData[index].name, le->text().toLatin1()); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -321,7 +321,7 @@ void ChannelsPanel::cmPaste() if (hasClipboardData(&data)) { memcpy(&model->limitData[selectedIndex], data.constData(), sizeof(LimitData)); updateLine(selectedIndex); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -339,7 +339,7 @@ void ChannelsPanel::cmDelete() updateLine(i); } - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -430,7 +430,7 @@ void ChannelsPanel::cmClear(bool prompt) model->limitData[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); updateLine(selectedIndex); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -444,7 +444,7 @@ void ChannelsPanel::cmClearAll() model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_CLEAR, i); updateLine(i); } - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -454,7 +454,7 @@ void ChannelsPanel::cmInsert() model->limitData[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -469,7 +469,7 @@ void ChannelsPanel::swapData(int idx1, int idx2) model->updateAllReferences(ModelData::REF_UPD_TYPE_CHANNEL, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); updateLine(idx1); updateLine(idx2); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -482,4 +482,10 @@ void ChannelsPanel::onModelDataAboutToBeUpdated() void ChannelsPanel::onModelDataUpdateComplete() { update(); + lock = false; +} + +void ChannelsPanel::updateItemModels() +{ + commonItemModels->update(CommonItemModels::RMO_CHANNELS); } diff --git a/companion/src/modeledit/channels.h b/companion/src/modeledit/channels.h index 0583b1d7c..a481feec2 100644 --- a/companion/src/modeledit/channels.h +++ b/companion/src/modeledit/channels.h @@ -26,7 +26,7 @@ #include -class CurveItemModel; +class CommonItemModels; class RawItemFilteredModel; constexpr char MIMETYPE_CHANNEL[] = "application/x-companion-channel"; @@ -57,7 +57,7 @@ class ChannelsPanel : public ModelPanel Q_OBJECT public: - ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CurveItemModel * curveItemModel); + ChannelsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); ~ChannelsPanel(); public slots: @@ -84,9 +84,6 @@ class ChannelsPanel : public ModelPanel void onModelDataAboutToBeUpdated(); void onModelDataUpdateComplete(); - signals: - void updateDataModels(); - private: bool hasClipboardData(QByteArray * data = nullptr) const; bool insertAllowed() const; @@ -103,7 +100,9 @@ class ChannelsPanel : public ModelPanel QCheckBox *symlimitsChk[CPN_MAX_CHNOUT]; int selectedIndex; int chnCapability; - RawItemFilteredModel *curveModel; + CommonItemModels * commonItemModels; + RawItemFilteredModel *curveFilteredModel; + void updateItemModels(); }; #endif // _CHANNELS_H_ diff --git a/companion/src/modeledit/curves.cpp b/companion/src/modeledit/curves.cpp index 81da85a02..1490515fb 100644 --- a/companion/src/modeledit/curves.cpp +++ b/companion/src/modeledit/curves.cpp @@ -23,6 +23,7 @@ #include "node.h" #include "edge.h" #include "helpers.h" +#include "rawitemfilteredmodel.h" #define GFX_MARGIN 16 @@ -108,10 +109,11 @@ float curveSymmetricalX(float x, float coeff, float yMin, float yMid, float yMax return y; } -CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): +CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::Curves), - currentCurve(0) + currentCurve(0), + commonItemModels(commonItemModels) { ui->setupUi(this); @@ -523,7 +525,7 @@ void CurvesPanel::on_curveName_editingFinished() if (ui->curveName->text() != model->curves[currentCurve].name) { memset(model->curves[currentCurve].name, 0, sizeof(model->curves[currentCurve].name)); strcpy(model->curves[currentCurve].name, ui->curveName->text().toLatin1()); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -712,7 +714,7 @@ void CurvesPanel::cmClear(bool prompt) model->curves[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -726,7 +728,7 @@ void CurvesPanel::cmClearAll() model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_CLEAR, i); } update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -756,7 +758,7 @@ void CurvesPanel::cmDelete() model->curves[maxCurves - 1].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -766,7 +768,7 @@ void CurvesPanel::cmInsert() model->curves[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -787,7 +789,7 @@ void CurvesPanel::cmPaste() CurveData *cd = &model->curves[selectedIndex]; memcpy(cd, data.constData(), sizeof(CurveData)); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -802,11 +804,16 @@ void CurvesPanel::swapData(int idx1, int idx2) memcpy(cd1, &cdtmp, sizeof(CurveData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_CURVE, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } } +void CurvesPanel::updateItemModels() +{ + commonItemModels->update(CommonItemModels::RMO_CURVES); +} + CustomScene::CustomScene(QGraphicsView * view) : QGraphicsScene(view) { diff --git a/companion/src/modeledit/curves.h b/companion/src/modeledit/curves.h index 2e08dbbd4..8df3a8528 100644 --- a/companion/src/modeledit/curves.h +++ b/companion/src/modeledit/curves.h @@ -26,6 +26,8 @@ #include #include +class CommonItemModels; + constexpr char MIMETYPE_CURVE[] = "application/x-companion-curve"; namespace Ui { @@ -59,7 +61,7 @@ class CurvesPanel : public ModelPanel Q_OBJECT public: - CurvesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware); + CurvesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); virtual ~CurvesPanel(); virtual void update(); @@ -91,9 +93,6 @@ class CurvesPanel : public ModelPanel void cmMoveDown(); void cmMoveUp(); - signals: - void updateDataModels(); - protected: virtual void resizeEvent(QResizeEvent *event); void addTemplate(QString name, unsigned int flags, curveFunction function); @@ -122,6 +121,8 @@ class CurvesPanel : public ModelPanel bool moveDownAllowed() const; bool moveUpAllowed() const; void swapData(int idx1, int idx2); + CommonItemModels * commonItemModels; + void updateItemModels(); }; #endif // _CURVES_H_ diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index ddbf724f0..b3662f964 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -66,10 +66,10 @@ void RepeatComboBox::update() setCurrentIndex(value); } -CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): +CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): GenericPanel(parent, model, generalSettings, firmware), functions(model ? model->customFn : generalSettings.customFn), + commonItemModels(commonItemModels), mediaPlayerCurrent(-1), mediaPlayer(nullptr), modelsUpdateCnt(0) @@ -77,21 +77,21 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, lock = true; fswCapability = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions); - rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, model ? RawSwitch::SpecialFunctionsContext : RawSwitch::GlobalFunctionsContext); - connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); - connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); + rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), model ? RawSwitch::SpecialFunctionsContext : RawSwitch::GlobalFunctionsContext, this); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); - rawSrcAllModel = new RawItemFilteredModel(rawSourceItemModel); - connect(rawSrcAllModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); - connect(rawSrcAllModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); + rawSourceAllModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), this); + connect(rawSourceAllModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSourceAllModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); - rawSrcInputsModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups); - connect(rawSrcInputsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); - connect(rawSrcInputsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); + rawSourceInputsModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), RawSource::InputSourceGroups, this); + connect(rawSourceInputsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSourceInputsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); - rawSrcGVarsModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::GVarsGroup); - connect(rawSrcGVarsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); - connect(rawSrcGVarsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); + rawSourceGVarsModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), RawSource::GVarsGroup, this); + connect(rawSourceGVarsModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &CustomFunctionsPanel::onModelDataAboutToBeUpdated); + connect(rawSourceGVarsModel, &RawItemFilteredModel::dataUpdateComplete, this, &CustomFunctionsPanel::onModelDataUpdateComplete); if (!firmware->getCapability(VoicesAsNumbers)) { tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength)); @@ -142,7 +142,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, // The switch fswtchSwtch[i] = new QComboBox(this); - fswtchSwtch[i]->setModel(rawSwitchModel); + fswtchSwtch[i]->setModel(rawSwitchFilteredModel); fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue())); fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); @@ -253,10 +253,6 @@ CustomFunctionsPanel::~CustomFunctionsPanel() { if (mediaPlayer) stopSound(mediaPlayerCurrent); - delete rawSwitchModel; - delete rawSrcAllModel; - delete rawSrcInputsModel; - delete rawSrcGVarsModel; } void CustomFunctionsPanel::onMediaPlayerStateChanged(QMediaPlayer::State state) @@ -707,21 +703,21 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi CustomFunctionData::populateResetParams(model, b, value); } else if (function == FuncVolume || function == FuncBacklight) { - b->setModel(rawSrcInputsModel); + b->setModel(rawSourceInputsModel); b->setCurrentIndex(b->findData(value)); } else if (function == FuncPlayValue) { - b->setModel(rawSrcAllModel); + b->setModel(rawSourceAllModel); b->setCurrentIndex(b->findData(value)); } else if (function >= FuncAdjustGV1 && function <= FuncAdjustGVLast) { switch (adjustmode) { case 1: - b->setModel(rawSrcInputsModel); + b->setModel(rawSourceInputsModel); b->setCurrentIndex(b->findData(value)); break; case 2: - b->setModel(rawSrcGVarsModel); + b->setModel(rawSourceGVarsModel); b->setCurrentIndex(b->findData(value)); break; } @@ -836,11 +832,13 @@ void CustomFunctionsPanel::onModelDataAboutToBeUpdated() void CustomFunctionsPanel::onModelDataUpdateComplete() { modelsUpdateCnt--; - if (modelsUpdateCnt < 1) + if (modelsUpdateCnt < 1) { lock = true; for (int i = 0; i < fswCapability; i++) { fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue())); fswtchFunc[i]->setCurrentIndex(fswtchFunc[i]->findData(functions[i].func)); } update(); + lock = false; + } } diff --git a/companion/src/modeledit/customfunctions.h b/companion/src/modeledit/customfunctions.h index 98b173ee5..9b3e3d238 100644 --- a/companion/src/modeledit/customfunctions.h +++ b/companion/src/modeledit/customfunctions.h @@ -26,8 +26,7 @@ #include -class RawSourceItemModel; -class RawSwitchItemModel; +class CommonItemModels; class RawItemFilteredModel; class TimerEdit; @@ -56,8 +55,7 @@ class CustomFunctionsPanel : public GenericPanel Q_OBJECT public: - CustomFunctionsPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); + CustomFunctionsPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); ~CustomFunctionsPanel(); virtual void update(); @@ -98,10 +96,11 @@ class CustomFunctionsPanel : public GenericPanel bool moveUpAllowed() const; void swapData(int idx1, int idx2); void resetCBsAndRefresh(int idx); - RawItemFilteredModel * rawSwitchModel; - RawItemFilteredModel * rawSrcAllModel; - RawItemFilteredModel * rawSrcInputsModel; - RawItemFilteredModel * rawSrcGVarsModel; + CommonItemModels * commonItemModels; + RawItemFilteredModel * rawSwitchFilteredModel; + RawItemFilteredModel * rawSourceAllModel; + RawItemFilteredModel * rawSourceInputsModel; + RawItemFilteredModel * rawSourceGVarsModel; QSet tracksSet; QSet scriptsSet; diff --git a/companion/src/modeledit/flightmodes.cpp b/companion/src/modeledit/flightmodes.cpp index 48af23957..32188feea 100644 --- a/companion/src/modeledit/flightmodes.cpp +++ b/companion/src/modeledit/flightmodes.cpp @@ -24,15 +24,15 @@ #include "helpers.h" #include "customdebug.h" -FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * switchModel): +FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * rawSwitchFilteredModel): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::FlightMode), phaseIdx(phaseIdx), phase(model.flightModeData[phaseIdx]) { ui->setupUi(this); - connect(switchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &FlightModePanel::onModelDataAboutToBeUpdated); - connect(switchModel, &RawItemFilteredModel::dataUpdateComplete, this, &FlightModePanel::onModelDataUpdateComplete); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &FlightModePanel::onModelDataAboutToBeUpdated); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &FlightModePanel::onModelDataUpdateComplete); ui->labelName->setContextMenuPolicy(Qt::CustomContextMenu); ui->labelName->setToolTip(tr("Popup menu available")); @@ -57,7 +57,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI // Flight mode switch if (phaseIdx > 0) { - ui->swtch->setModel(switchModel); + ui->swtch->setModel(rawSwitchFilteredModel); connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int))); } else { @@ -1374,10 +1374,11 @@ void FlightModePanel::onModelDataUpdateComplete() /**********************************************************/ -FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel): - ModelPanel(parent, model, generalSettings, firmware) +FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): + ModelPanel(parent, model, generalSettings, firmware), + commonItemModels(commonItemModels) { - rawSwitchFilteredModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); + rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::MixesContext, this); modesCount = firmware->getCapability(FlightModes); QGridLayout * gridLayout = new QGridLayout(this); @@ -1388,8 +1389,8 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS connect(tab, &FlightModePanel::modified, this, &FlightModesPanel::modified); connect(tab, &FlightModePanel::phaseDataChanged, this, &FlightModesPanel::onPhaseNameChanged); connect(tab, &FlightModePanel::phaseNameChanged, this, &FlightModesPanel::onPhaseNameChanged); - connect(tab, &FlightModePanel::phaseSwitchChanged, this, &FlightModesPanel::refreshDataModels); - connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::refreshDataModels); + connect(tab, &FlightModePanel::phaseSwitchChanged, this, &FlightModesPanel::updateItemModels); + connect(tab, &FlightModePanel::gvNameChanged, this, &FlightModesPanel::updateItemModels); connect(this, &FlightModesPanel::updated, tab, &FlightModePanel::update); tabWidget->addTab(tab, getTabName(i)); @@ -1402,7 +1403,6 @@ FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralS FlightModesPanel::~FlightModesPanel() { - delete rawSwitchFilteredModel; } QString FlightModesPanel::getTabName(int index) @@ -1423,7 +1423,7 @@ void FlightModesPanel::onPhaseNameChanged() { int index = sender()->property("index").toInt(); tabWidget->setTabText(index, getTabName(index)); - refreshDataModels(); + updateItemModels(); } void FlightModesPanel::update() @@ -1431,9 +1431,10 @@ void FlightModesPanel::update() emit updated(); } -void FlightModesPanel::refreshDataModels() +void FlightModesPanel::updateItemModels() { - emit updateDataModels(); + commonItemModels->update(CommonItemModels::RMO_FLIGHT_MODES); + commonItemModels->update(CommonItemModels::RMO_GLOBAL_VARIABLES); } void FlightModesPanel::onTabIndexChanged(int index) diff --git a/companion/src/modeledit/flightmodes.h b/companion/src/modeledit/flightmodes.h index dda7a279d..ca3619c6c 100644 --- a/companion/src/modeledit/flightmodes.h +++ b/companion/src/modeledit/flightmodes.h @@ -24,7 +24,7 @@ #include "modeledit.h" #include "eeprominterface.h" -class RawSwitchItemModel; +class CommonItemModels; class RawItemFilteredModel; constexpr char MIMETYPE_FLIGHTMODE[] = "application/x-companion-flightmode"; @@ -41,7 +41,7 @@ class FlightModePanel : public ModelPanel Q_OBJECT public: - FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * switchModel); + FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware, RawItemFilteredModel * rawSwitchFilteredModel); virtual ~FlightModePanel(); virtual void update(); @@ -145,19 +145,17 @@ class FlightModesPanel : public ModelPanel Q_OBJECT public: - FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel); + FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); virtual ~FlightModesPanel(); public slots: virtual void update() override; signals: - void updateDataModels(); void updated(); private slots: void onPhaseNameChanged(); - void refreshDataModels(); void onTabIndexChanged(int index); private: @@ -165,8 +163,10 @@ class FlightModesPanel : public ModelPanel int modesCount; QTabWidget *tabWidget; + CommonItemModels *commonItemModels; RawItemFilteredModel *rawSwitchFilteredModel; QVector panels; + void updateItemModels(); }; #endif // _FLIGHTMODES_H_ diff --git a/companion/src/modeledit/heli.cpp b/companion/src/modeledit/heli.cpp index 9574feeed..1b8607799 100644 --- a/companion/src/modeledit/heli.cpp +++ b/companion/src/modeledit/heli.cpp @@ -23,22 +23,26 @@ #include "helpers.h" #include "rawitemfilteredmodel.h" -HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel): +HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): ModelPanel(parent, model, generalSettings, firmware), - ui(new Ui::Heli) + ui(new Ui::Heli), + commonItemModels(commonItemModels) { ui->setupUi(this); - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, RawSource::InputSourceGroups, this); - connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &HeliPanel::onModelDataAboutToBeUpdated); - connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &HeliPanel::onModelDataUpdateComplete); + rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), RawSource::InputSourceGroups, this); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &HeliPanel::onModelDataAboutToBeUpdated); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &HeliPanel::onModelDataUpdateComplete); connect(ui->swashType, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(ui->swashRingVal, SIGNAL(editingFinished()), this, SLOT(edited())); + ui->swashCollectiveSource->setModel(rawSourceFilteredModel); connect(ui->swashCollectiveSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); if (firmware->getCapability(VirtualInputs)) { + ui->swashAileronSource->setModel(rawSourceFilteredModel); connect(ui->swashAileronSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); + ui->swashElevatorSource->setModel(rawSourceFilteredModel); connect(ui->swashElevatorSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(ui->swashAileronWeight, SIGNAL(editingFinished()), this, SLOT(edited())); connect(ui->swashElevatorWeight, SIGNAL(editingFinished()), this, SLOT(edited())); @@ -66,7 +70,6 @@ HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & gener HeliPanel::~HeliPanel() { - delete rawSourceModel; delete ui; } @@ -75,13 +78,10 @@ void HeliPanel::update() lock = true; ui->swashType->setCurrentIndex(model->swashRingData.type); - ui->swashCollectiveSource->setModel(rawSourceModel); ui->swashCollectiveSource->setCurrentIndex(ui->swashCollectiveSource->findData(model->swashRingData.collectiveSource.toValue())); ui->swashRingVal->setValue(model->swashRingData.value); if (firmware->getCapability(VirtualInputs)) { - ui->swashElevatorSource->setModel(rawSourceModel); ui->swashElevatorSource->setCurrentIndex(ui->swashElevatorSource->findData(model->swashRingData.elevatorSource.toValue())); - ui->swashAileronSource->setModel(rawSourceModel); ui->swashAileronSource->setCurrentIndex(ui->swashAileronSource->findData(model->swashRingData.aileronSource.toValue())); ui->swashElevatorWeight->setValue(model->swashRingData.elevatorWeight); ui->swashAileronWeight->setValue(model->swashRingData.aileronWeight); @@ -126,4 +126,5 @@ void HeliPanel::onModelDataAboutToBeUpdated() void HeliPanel::onModelDataUpdateComplete() { update(); + lock = false; } diff --git a/companion/src/modeledit/heli.h b/companion/src/modeledit/heli.h index 97552778a..ee9a3ac36 100644 --- a/companion/src/modeledit/heli.h +++ b/companion/src/modeledit/heli.h @@ -23,7 +23,7 @@ #include "modeledit.h" -class RawSourceItemModel; +class CommonItemModels; class RawItemFilteredModel; namespace Ui { @@ -35,7 +35,7 @@ class HeliPanel : public ModelPanel Q_OBJECT public: - HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel); + HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); ~HeliPanel(); void update(); @@ -46,7 +46,8 @@ class HeliPanel : public ModelPanel private: Ui::Heli *ui; - RawItemFilteredModel * rawSourceModel; + CommonItemModels * commonItemModels; + RawItemFilteredModel * rawSourceFilteredModel; }; #endif // _HELI_H_ diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index 53b016610..7c6635c4c 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -23,19 +23,19 @@ #include "helpers.h" #include "rawitemfilteredmodel.h" -InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): +InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): ModelPanel(parent, model, generalSettings, firmware), expoInserted(false), - modelPrinter(firmware, generalSettings, model) + modelPrinter(firmware, generalSettings, model), + commonItemModels(commonItemModels) { - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, (RawSource::InputSourceGroups & ~ RawSource::NoneGroup & ~RawSource::InputsGroup), this); - connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); - connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); + rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), (RawSource::InputSourceGroups & ~ RawSource::NoneGroup & ~RawSource::InputsGroup), this); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); - rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); - connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); - connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); + rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::MixesContext, this); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &InputsPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &InputsPanel::onModelDataUpdateComplete); inputsCount = firmware->getCapability(VirtualInputs); if (inputsCount == 0) @@ -75,8 +75,6 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g InputsPanel::~InputsPanel() { - delete rawSourceModel; - delete rawSwitchModel; } void InputsPanel::update() @@ -192,13 +190,13 @@ void InputsPanel::gm_openExpo(int index) if (firmware->getCapability(VirtualInputs)) inputName = model->inputNames[ed.chn]; - ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceModel, rawSwitchModel); + ExpoDialog *g = new ExpoDialog(this, *model, &ed, generalSettings, firmware, inputName, rawSourceFilteredModel, rawSwitchFilteredModel); if (g->exec()) { model->expoData[index] = ed; if (firmware->getCapability(VirtualInputs)) strncpy(model->inputNames[ed.chn], inputName.toLatin1().data(), INPUT_NAME_LEN); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } else { @@ -253,7 +251,7 @@ void InputsPanel::exposDelete(bool prompt) exposDeleteList(list, prompt); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -328,7 +326,7 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx) } update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -497,7 +495,7 @@ void InputsPanel::moveExpoList(bool down) } if (mod) { update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } setSelectedByExpoList(highlightList); @@ -537,7 +535,7 @@ void InputsPanel::clearExpos() model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, i); } update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -586,7 +584,7 @@ void InputsPanel::cmInputClear() } model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, inputIdx); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -610,7 +608,7 @@ void InputsPanel::cmInputDelete() model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, -1); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -629,7 +627,7 @@ void InputsPanel::cmInputInsert() model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, 1); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -691,7 +689,7 @@ void InputsPanel::cmInputSwapData(int idx1, int idx2) model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -735,4 +733,10 @@ void InputsPanel::onModelDataAboutToBeUpdated() void InputsPanel::onModelDataUpdateComplete() { update(); + lock = false; +} + +void InputsPanel::updateItemModels() +{ + commonItemModels->update(CommonItemModels::RMO_INPUTS); } diff --git a/companion/src/modeledit/inputs.h b/companion/src/modeledit/inputs.h index 5a31592b7..436d61278 100644 --- a/companion/src/modeledit/inputs.h +++ b/companion/src/modeledit/inputs.h @@ -25,8 +25,7 @@ #include "mixerslistwidget.h" #include "modelprinter.h" -class RawSourceItemModel; -class RawSwitchItemModel; +class CommonItemModels; class RawItemFilteredModel; constexpr char MIMETYPE_EXPO[] = "application/x-companion-expo"; @@ -36,8 +35,7 @@ class InputsPanel : public ModelPanel Q_OBJECT public: - InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); + InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); virtual ~InputsPanel(); virtual void update(); @@ -67,9 +65,6 @@ class InputsPanel : public ModelPanel void onModelDataAboutToBeUpdated(); void onModelDataUpdateComplete(); - signals: - void updateDataModels(); - private: bool expoInserted; MixersListWidget *ExposlistWidget; @@ -77,8 +72,9 @@ class InputsPanel : public ModelPanel ModelPrinter modelPrinter; int selectedIdx; int inputIdx; - RawItemFilteredModel *rawSourceModel; - RawItemFilteredModel *rawSwitchModel; + CommonItemModels * commonItemModels; + RawItemFilteredModel *rawSourceFilteredModel; + RawItemFilteredModel *rawSwitchFilteredModel; int getExpoIndex(unsigned int dch); bool gm_insertExpo(int idx); @@ -99,6 +95,7 @@ class InputsPanel : public ModelPanel bool isExpoIndex(const int index); int getIndexFromSelected(); int getInputIndexFromSelected(); + void updateItemModels(); }; #endif // _INPUTS_H_ diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 0e58ad06a..ad440c177 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -24,20 +24,20 @@ #include -LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): +LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): ModelPanel(parent, model, generalSettings, firmware), + commonItemModels(commonItemModels), selectedIndex(0), modelsUpdateCnt(0) { - rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::LogicalSwitchesContext); - connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated); - connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete); + rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::LogicalSwitchesContext, this); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete); const int srcGroups = firmware->getCapability(GvarsInCS) ? 0 : (RawSource::AllSourceGroups & ~RawSource::GVarsGroup); - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, srcGroups, this); - connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated); - connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete); + rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), srcGroups, this); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &LogicalSwitchesPanel::onModelDataAboutToBeUpdated); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &LogicalSwitchesPanel::onModelDataUpdateComplete); lsCapability = firmware->getCapability(LogicalSwitches); lsCapabilityExt = firmware->getCapability(LogicalSwitchesExt); @@ -124,7 +124,7 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, // AND cbAndSwitch[i] = new QComboBox(this); cbAndSwitch[i]->setProperty("index", i); - cbAndSwitch[i]->setModel(rawSwitchModel); + cbAndSwitch[i]->setModel(rawSwitchFilteredModel); cbAndSwitch[i]->setVisible(true); connect(cbAndSwitch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(onAndSwitchChanged(int))); tableLayout->addWidget(i, 4, cbAndSwitch[i]); @@ -161,8 +161,6 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, LogicalSwitchesPanel::~LogicalSwitchesPanel() { - delete rawSourceModel; - delete rawSwitchModel; } void LogicalSwitchesPanel::onFunctionChanged() @@ -174,7 +172,6 @@ void LogicalSwitchesPanel::onFunctionChanged() if (model->logicalSw[i].func == newFunc) return; - unsigned oldFunc = model->logicalSw[i].func; CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); model->logicalSw[i].func = newFunc; CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); @@ -191,10 +188,7 @@ void LogicalSwitchesPanel::onFunctionChanged() } } - if (oldFunc == LS_FN_OFF || newFunc == LS_FN_OFF) - updateCBLists(); - else - updateLine(i); + updateLine(i); emit modified(); } } @@ -345,6 +339,7 @@ void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, doubl void LogicalSwitchesPanel::updateLine(int i) { + const bool savelock = lock; lock = true; unsigned int mask = 0; @@ -362,7 +357,7 @@ void LogicalSwitchesPanel::updateLine(int i) RawSource source = RawSource(model->logicalSw[i].val1); RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags()); double value = range.step * model->logicalSw[i].val2 + range.offset; /* TODO+source.getRawOffset(model)*/ - cbSource1[i]->setModel(rawSourceModel); + cbSource1[i]->setModel(rawSourceFilteredModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(source.toValue())); if (source.isTimeBased()) { mask |= VALUE_TO_VISIBLE; @@ -391,16 +386,16 @@ void LogicalSwitchesPanel::updateLine(int i) case LS_FAMILY_STICKY: // no break case LS_FAMILY_VBOOL: mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE; - cbSource1[i]->setModel(rawSwitchModel); + cbSource1[i]->setModel(rawSwitchFilteredModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1)); - cbSource2[i]->setModel(rawSwitchModel); + cbSource2[i]->setModel(rawSwitchFilteredModel); cbSource2[i]->setCurrentIndex(cbSource2[i]->findData(model->logicalSw[i].val2)); break; case LS_FAMILY_EDGE: mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE; mask &= ~DELAY_ENABLED; - cbSource1[i]->setModel(rawSwitchModel); + cbSource1[i]->setModel(rawSwitchFilteredModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1)); updateTimerParam(dsbOffset[i], model->logicalSw[i].val2, 0.0); updateTimerParam(dsbOffset2[i], model->logicalSw[i].val2 + model->logicalSw[i].val3, ValToTim(TimToVal(dsbOffset[i]->value()) - 1)); @@ -409,9 +404,9 @@ void LogicalSwitchesPanel::updateLine(int i) case LS_FAMILY_VCOMP: mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE; - cbSource1[i]->setModel(rawSourceModel); + cbSource1[i]->setModel(rawSourceFilteredModel); cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(model->logicalSw[i].val1)); - cbSource2[i]->setModel(rawSourceModel); + cbSource2[i]->setModel(rawSourceFilteredModel); cbSource2[i]->setCurrentIndex(cbSource2[i]->findData(model->logicalSw[i].val2)); break; @@ -439,7 +434,7 @@ void LogicalSwitchesPanel::updateLine(int i) dsbDelay[i]->setValue(model->logicalSw[i].delay / 10.0); } - lock = false; + lock = savelock; } void LogicalSwitchesPanel::populateFunctionCB(QComboBox *b) @@ -491,6 +486,7 @@ void LogicalSwitchesPanel::cmPaste() QByteArray data; if (hasClipboardData(&data)) { memcpy(&model->logicalSw[selectedIndex], data.constData(), sizeof(LogicalSwitchData)); + updateLine(selectedIndex); updateCBLists(); emit modified(); } @@ -505,6 +501,7 @@ void LogicalSwitchesPanel::cmDelete() model->logicalSw[lsCapability - 1].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); + update(); updateCBLists(); emit modified(); } @@ -515,7 +512,7 @@ void LogicalSwitchesPanel::cmCopy() data.append((char*)&model->logicalSw[selectedIndex], sizeof(LogicalSwitchData)); QMimeData *mimeData = new QMimeData; mimeData->setData(MIMETYPE_LOGICAL_SWITCH, data); - QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); + QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); } void LogicalSwitchesPanel::cmCut() @@ -526,7 +523,6 @@ void LogicalSwitchesPanel::cmCut() cmClear(false); } -// TODO make something generic here! void LogicalSwitchesPanel::onCustomContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); @@ -595,6 +591,7 @@ void LogicalSwitchesPanel::cmClear(bool prompt) model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, selectedIndex); + updateLine(selectedIndex); updateCBLists(); emit modified(); } @@ -608,6 +605,7 @@ void LogicalSwitchesPanel::cmClearAll() model->logicalSw[i].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_CLEAR, i); } + update(); updateCBLists(); emit modified(); } @@ -617,6 +615,7 @@ void LogicalSwitchesPanel::cmInsert() memmove(&model->logicalSw[selectedIndex + 1], &model->logicalSw[selectedIndex], (CPN_MAX_LOGICAL_SWITCHES - (selectedIndex + 1)) * sizeof(LogicalSwitchData)); model->logicalSw[selectedIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); + update(); updateCBLists(); emit modified(); } @@ -630,6 +629,8 @@ void LogicalSwitchesPanel::swapData(int idx1, int idx2) memcpy(lsw2, lsw1, sizeof(LogicalSwitchData)); memcpy(lsw1, &lstmp, sizeof(LogicalSwitchData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_LOGICAL_SWITCH, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); + updateLine(idx1); + updateLine(idx2); updateCBLists(); emit modified(); } @@ -642,15 +643,14 @@ void LogicalSwitchesPanel::updateCBLists() // So this workaround gives time for other events to be processed before refreshing // Not sure if this an OS related issue or a QT bug in QT 5.7 (and higher?) // The delay is abitary - QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateDataModels); + //QTimer::singleShot(1000, this, &LogicalSwitchesPanel::updateItemModels); + updateItemModels(); } -void LogicalSwitchesPanel::updateDataModels() +void LogicalSwitchesPanel::updateItemModels() { - // This is inconsistent but needed as part of the workaround - //emit updateCBLists(); adds to the event stack so call direct - rawSourceModel->update(); - rawSwitchModel->update(); + lock = true; + commonItemModels->update(CommonItemModels::RMO_LOGICAL_SWITCHES); } void LogicalSwitchesPanel::onModelDataAboutToBeUpdated() @@ -662,6 +662,8 @@ void LogicalSwitchesPanel::onModelDataAboutToBeUpdated() void LogicalSwitchesPanel::onModelDataUpdateComplete() { modelsUpdateCnt--; - if (modelsUpdateCnt < 1) + if (modelsUpdateCnt < 1) { update(); + lock = false; + } } diff --git a/companion/src/modeledit/logicalswitches.h b/companion/src/modeledit/logicalswitches.h index b267c8906..61837a372 100644 --- a/companion/src/modeledit/logicalswitches.h +++ b/companion/src/modeledit/logicalswitches.h @@ -24,8 +24,7 @@ #include "modeledit.h" #include "radiodata.h" -class RawSourceItemModel; -class RawSwitchItemModel; +class CommonItemModels; class RawItemFilteredModel; class TimerEdit; @@ -36,8 +35,7 @@ class LogicalSwitchesPanel : public ModelPanel Q_OBJECT public: - LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); + LogicalSwitchesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); virtual ~LogicalSwitchesPanel(); virtual void update(); @@ -76,8 +74,9 @@ class LogicalSwitchesPanel : public ModelPanel QDoubleSpinBox * dsbDelay[CPN_MAX_LOGICAL_SWITCHES]; QComboBox * cbSource1[CPN_MAX_LOGICAL_SWITCHES]; QComboBox * cbSource2[CPN_MAX_LOGICAL_SWITCHES]; - RawItemFilteredModel * rawSwitchModel; - RawItemFilteredModel * rawSourceModel; + CommonItemModels * commonItemModels; + RawItemFilteredModel * rawSwitchFilteredModel; + RawItemFilteredModel * rawSourceFilteredModel; int selectedIndex; void populateFunctionCB(QComboBox *b); void updateTimerParam(QDoubleSpinBox *sb, int timer, double minimum=0); @@ -90,7 +89,7 @@ class LogicalSwitchesPanel : public ModelPanel bool moveUpAllowed() const; int modelsUpdateCnt; void updateCBLists(); - void updateDataModels(); + void updateItemModels(); }; #endif // _LOGICALSWITCHES_H_ diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 9eda88677..dd2aa121d 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -148,10 +148,10 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, MixerDialog::~MixerDialog() { + delete ui; delete gvWeightGroup; delete gvOffsetGroup; delete curveGroup; - delete ui; } void MixerDialog::changeEvent(QEvent *e) diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index 3b8da2c99..3aee21727 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -22,20 +22,20 @@ #include "helpers.h" #include "rawitemfilteredmodel.h" -MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel): +MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,CommonItemModels * commonItemModels): ModelPanel(parent, model, generalSettings, firmware), mixInserted(false), highlightedSource(0), - modelPrinter(firmware, generalSettings, model) + modelPrinter(firmware, generalSettings, model), + commonItemModels(commonItemModels) { - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, ((RawSource::InputSourceGroups | RawSource::ScriptsGroup) & ~ RawSource::NoneGroup), this); - connect(rawSourceModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated); - connect(rawSourceModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete); + rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), ((RawSource::InputSourceGroups | RawSource::ScriptsGroup) & ~ RawSource::NoneGroup), this); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated); + connect(rawSourceFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete); - rawSwitchModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::MixesContext, this); - connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated); - connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete); + rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::MixesContext, this); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &MixesPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &MixesPanel::onModelDataUpdateComplete); QGridLayout * mixesLayout = new QGridLayout(this); @@ -70,8 +70,6 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen MixesPanel::~MixesPanel() { - delete rawSourceModel; - delete rawSwitchModel; } void MixesPanel::update() @@ -187,7 +185,7 @@ void MixesPanel::gm_openMix(int index) MixData mixd(model->mixData[index]); - MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware, rawSourceModel, rawSwitchModel); + MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware, rawSourceFilteredModel, rawSwitchFilteredModel); if(g->exec()) { model->mixData[index] = mixd; emit modified(); @@ -550,4 +548,5 @@ void MixesPanel::onModelDataAboutToBeUpdated() void MixesPanel::onModelDataUpdateComplete() { update(); + lock = false; } diff --git a/companion/src/modeledit/mixes.h b/companion/src/modeledit/mixes.h index 7fca577be..cba4ed556 100644 --- a/companion/src/modeledit/mixes.h +++ b/companion/src/modeledit/mixes.h @@ -26,8 +26,7 @@ #include "mixerdialog.h" #include "modelprinter.h" -class RawSourceItemModel; -class RawSwitchItemModel; +class CommonItemModels; class RawItemFilteredModel; class MixesPanel : public ModelPanel @@ -35,8 +34,7 @@ class MixesPanel : public ModelPanel Q_OBJECT public: - MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, - RawSourceItemModel * rawSourceItemModel, RawSwitchItemModel * rawSwitchItemModel); + MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); virtual ~MixesPanel(); virtual void update(); @@ -70,8 +68,9 @@ class MixesPanel : public ModelPanel bool mixInserted; unsigned int highlightedSource; ModelPrinter modelPrinter; - RawItemFilteredModel *rawSourceModel; - RawItemFilteredModel *rawSwitchModel; + CommonItemModels * commonItemModels; + RawItemFilteredModel *rawSourceFilteredModel; + RawItemFilteredModel *rawSwitchFilteredModel; int getMixerIndex(unsigned int dch); bool gm_insertMix(int idx); diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 1b256c493..7bcf804fd 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -53,89 +53,65 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw GeneralSettings &generalSettings = radioData.generalSettings; ModelData &model = radioData.models[modelId]; - /* - Create reusable model specific ui datamodels here and pass pointers as needed - They should be referenced through filters in each use case - Code that updates the source for one or more ui datamodels should emit a SIGNAL that can be trapped (see below) and the datamodels refreshed - WARNING: beware of looping signals and slots and unnecessary data field updates from refreshing datamodels - where practical make signals granular to only those fields that affect datamodels thus needing to be refreshed - */ - rawSourceModel = new RawSourceItemModel(&generalSettings, &model, this); - rawSwitchModel = new RawSwitchItemModel(&generalSettings, &model, this); - curveModel = new CurveItemModel(&generalSettings, &model, this); + commonItemModels = new CommonItemModels(&generalSettings, &model, this); s1.report("Init"); - SetupPanel * setupPanel = new SetupPanel(this, model, generalSettings, firmware, rawSwitchModel); + SetupPanel * setupPanel = new SetupPanel(this, model, generalSettings, firmware, commonItemModels); addTab(setupPanel, tr("Setup")); s1.report("Setup"); if (firmware->getCapability(Heli)) { - HeliPanel * heliPanel = new HeliPanel(this, model, generalSettings, firmware, rawSourceModel); + HeliPanel * heliPanel = new HeliPanel(this, model, generalSettings, firmware, commonItemModels); addTab(heliPanel, tr("Heli")); s1.report("Heli"); } - FlightModesPanel * flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, rawSwitchModel); + FlightModesPanel * flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, commonItemModels); addTab(flightModesPanel, tr("Flight Modes")); s1.report("Flight Modes"); - InputsPanel * inputsPanel = new InputsPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + InputsPanel * inputsPanel = new InputsPanel(this, model, generalSettings, firmware, commonItemModels); addTab(inputsPanel, tr("Inputs")); s1.report("Inputs"); - MixesPanel * mixesPanel = new MixesPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + MixesPanel * mixesPanel = new MixesPanel(this, model, generalSettings, firmware, commonItemModels); addTab(mixesPanel, tr("Mixes")); s1.report("Mixes"); - ChannelsPanel * channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, curveModel); + ChannelsPanel * channelsPanel = new ChannelsPanel(this, model, generalSettings, firmware, commonItemModels); addTab(channelsPanel, tr("Outputs")); s1.report("Outputs"); - CurvesPanel * curvesPanel = new CurvesPanel(this, model, generalSettings, firmware); + CurvesPanel * curvesPanel = new CurvesPanel(this, model, generalSettings, firmware, commonItemModels); addTab(curvesPanel, tr("Curves")); s1.report("Curves"); - LogicalSwitchesPanel * logicalSwitchesPanel = new LogicalSwitchesPanel(this, model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + LogicalSwitchesPanel * logicalSwitchesPanel = new LogicalSwitchesPanel(this, model, generalSettings, firmware, commonItemModels); addTab(logicalSwitchesPanel, tr("Logical Switches")); s1.report("Logical Switches"); - CustomFunctionsPanel * customFunctionsPanel = new CustomFunctionsPanel(this, &model, generalSettings, firmware, rawSourceModel, rawSwitchModel); + CustomFunctionsPanel * customFunctionsPanel = new CustomFunctionsPanel(this, &model, generalSettings, firmware, commonItemModels); addTab(customFunctionsPanel, tr("Special Functions")); s1.report("Special Functions"); if (firmware->getCapability(Telemetry)) { - TelemetryPanel * telemetryPanel = new TelemetryPanel(this, model, generalSettings, firmware, rawSourceModel); + TelemetryPanel * telemetryPanel = new TelemetryPanel(this, model, generalSettings, firmware, commonItemModels); addTab(telemetryPanel, tr("Telemetry")); - connect(telemetryPanel, &TelemetryPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); s1.report("Telemetry"); } connect(setupPanel, &SetupPanel::extendedLimitsToggled, channelsPanel, &ChannelsPanel::refreshExtendedLimits); - connect(setupPanel, &SetupPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); - - connect(flightModesPanel, &FlightModesPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); - connect(flightModesPanel, &FlightModesPanel::updateDataModels, rawSwitchModel, &RawSwitchItemModel::update); - - connect(inputsPanel, &InputsPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); - - connect(channelsPanel, &ChannelsPanel::updateDataModels, rawSourceModel, &RawSourceItemModel::update); - - connect(curvesPanel, &CurvesPanel::updateDataModels, curveModel, &CurveItemModel::update); connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged); connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation); onTabIndexChanged(ui->tabWidget->currentIndex()); // make sure to trigger update on default tab panel - s1.report("Signals and Slots"); gStopwatch.report("ModelEdit end constructor"); } ModelEdit::~ModelEdit() { - delete rawSourceModel; - delete rawSwitchModel; - delete curveModel; delete ui; } diff --git a/companion/src/modeledit/modeledit.h b/companion/src/modeledit/modeledit.h index 87c07759b..9095101bf 100644 --- a/companion/src/modeledit/modeledit.h +++ b/companion/src/modeledit/modeledit.h @@ -25,9 +25,7 @@ #include "genericpanel.h" class RadioData; -class RawSourceItemModel; -class RawSwitchItemModel; -class CurveItemModel; +class CommonItemModels; namespace Ui { class ModelEdit; @@ -65,9 +63,7 @@ class ModelEdit : public QDialog RadioData & radioData; Firmware * firmware; QVector panels; - RawSourceItemModel *rawSourceModel; - RawSwitchItemModel *rawSwitchModel; - CurveItemModel *curveModel; + CommonItemModels * commonItemModels; void addTab(GenericPanel *panel, QString text); void launchSimulation(); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index a83aeff69..0d40c42de 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -31,15 +31,14 @@ #include -TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, RawItemFilteredModel * rawSwitchModel): +TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus, RawItemFilteredModel * rawSwitchFilteredModel): ModelPanel(parent, model, generalSettings, firmware), timer(timer), ui(new Ui::Timer) { - ui->setupUi(this); - connect(rawSwitchModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &TimerPanel::onModelDataAboutToBeUpdated); - connect(rawSwitchModel, &RawItemFilteredModel::dataUpdateComplete, this, &TimerPanel::onModelDataUpdateComplete); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataAboutToBeUpdated, this, &TimerPanel::onModelDataAboutToBeUpdated); + connect(rawSwitchFilteredModel, &RawItemFilteredModel::dataUpdateComplete, this, &TimerPanel::onModelDataUpdateComplete); lock = true; @@ -50,11 +49,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge } else { ui->name->setMaxLength(length); - //ui->name->setText(timer.name); } // Mode - ui->mode->setModel(rawSwitchModel); + ui->mode->setModel(rawSwitchFilteredModel); ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue())); connect(ui->mode, SIGNAL(activated(int)), this, SLOT(onModeChanged(int))); @@ -96,6 +94,7 @@ TimerPanel::~TimerPanel() void TimerPanel::update() { lock = true; + ui->name->setText(timer.name); int hour = timer.val / 3600; @@ -116,7 +115,7 @@ void TimerPanel::update() pvalue -= hours * 3600; int minutes = pvalue / 60; int seconds = pvalue % 60; - ui->persistentValue->setText(QString(" %1(%2:%3:%4)").arg(sign<0 ? "-" :" ").arg(hours, 2, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0'))); + ui->persistentValue->setText(QString(" %1(%2:%3:%4)").arg(sign < 0 ? "-" :" ").arg(hours, 2, 10, QLatin1Char('0')).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0'))); } ui->countdownBeep->updateValue(); @@ -133,7 +132,7 @@ QWidget * TimerPanel::getLastFocus() void TimerPanel::on_value_editingFinished() { if (!lock) { - unsigned val = ui->value->time().hour()*3600 + ui->value->time().minute()*60 + ui->value->time().second(); + unsigned val = ui->value->time().hour() * 3600 + ui->value->time().minute() * 60 + ui->value->time().second(); if (timer.val != val) { timer.val = val; emit modified(); @@ -181,6 +180,7 @@ void TimerPanel::onModelDataAboutToBeUpdated() void TimerPanel::onModelDataUpdateComplete() { update(); + lock = false; } /******************************************************************************/ @@ -250,19 +250,19 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul } // The protocols available on this board - for (unsigned int i=0; iisAvailable((PulsesProtocol) i, moduleIdx)) { ui->protocol->addItem(ModuleData::protocolToString(i), i); if (i == module.protocol) - ui->protocol->setCurrentIndex(ui->protocol->count()-1); + ui->protocol->setCurrentIndex(ui->protocol->count() - 1); } } - for (int i=0; i<=MODULE_SUBTYPE_MULTI_LAST; i++) { + for (int i = 0; i <= MODULE_SUBTYPE_MULTI_LAST; i++) { if (i == MODULE_SUBTYPE_MULTI_SCANNER) continue; ui->multiProtocol->addItem(Multiprotocols::protocolToString(i), i); } - for (int i=MODULE_SUBTYPE_MULTI_LAST + 1; i <= 124; i++) { + for (int i = MODULE_SUBTYPE_MULTI_LAST + 1; i <= 124; i++) { ui->multiProtocol->addItem(QString::number(i + 3), i); } @@ -340,7 +340,7 @@ void ModulePanel::setupFailsafes() else { QLabel * label = new QLabel(this); label->setProperty("index", i); - label->setText(QString::number(i+1)); + label->setText(QString::number(i + 1)); QComboBox * combo = new QComboBox(this); combo->setProperty("index", i); @@ -519,7 +519,7 @@ void ModulePanel::update() ui->ppmFrameLength->setVisible(mask & MASK_SBUSPPM_FIELDS); ui->ppmFrameLength->setMinimum(module.channelsCount * (model->extendedLimits ? 2.250 : 2)+3.5); ui->ppmFrameLength->setMaximum(firmware->getCapability(PPMFrameLength)); - ui->ppmFrameLength->setValue(22.5+((double)module.ppm.frameLength)*0.5); + ui->ppmFrameLength->setValue(22.5 + ((double)module.ppm.frameLength) * 0.5); // Antenna mode on Horus and XLite if (mask & MASK_ANTENNA) { @@ -613,17 +613,17 @@ void ModulePanel::update() ui->registrationIdLabel->setVisible(mask & MASK_ACCESS); ui->registrationId->setVisible(mask & MASK_ACCESS); - ui->rx1Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0))); - ui->clearRx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0))); - ui->rx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0))); + ui->rx1Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 0))); + ui->clearRx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 0))); + ui->rx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 0))); - ui->rx2Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1))); - ui->clearRx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1))); - ui->rx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1))); + ui->rx2Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 1))); + ui->clearRx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 1))); + ui->rx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 1))); - ui->rx3Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2))); - ui->clearRx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2))); - ui->rx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2))); + ui->rx3Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2))); + ui->clearRx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2))); + ui->rx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1 << 2))); // Failsafes ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES); @@ -751,7 +751,7 @@ void ModulePanel::on_rxNumber_editingFinished() void ModulePanel::on_ppmFrameLength_editingFinished() { - int val = (ui->ppmFrameLength->value()-22.5) / 0.5; + int val = (ui->ppmFrameLength->value() - 22.5) / 0.5; if (module.ppm.frameLength != val) { module.ppm.frameLength = val; emit modified(); @@ -775,8 +775,8 @@ void ModulePanel::onMultiProtocolChanged(int index) module.multi.rfProtocol = (unsigned int)rfProtocol; unsigned int maxSubTypes = multiProtocols.getProtocol(index).numSubTypes(); if (rfProtocol > MODULE_SUBTYPE_MULTI_LAST) - maxSubTypes=8; - module.subType = std::min(module.subType, maxSubTypes -1); + maxSubTypes = 8; + module.subType = std::min(module.subType, maxSubTypes - 1); module.channelsCount = module.getMaxChannelCount(); update(); emit modified(); @@ -970,19 +970,19 @@ void ModulePanel::onClearAccessRxClicked() QPushButton *button = qobject_cast(sender()); if (button == ui->clearRx1) { - module.access.receivers &= ~(1<<0); + module.access.receivers &= ~(1 << 0); ui->rx1->clear(); update(); emit modified(); } else if (button == ui->clearRx2) { - module.access.receivers &= ~(1<<1); + module.access.receivers &= ~(1 << 1); ui->rx2->clear(); update(); emit modified(); } else if (button == ui->clearRx3) { - module.access.receivers &= ~(1<<2); + module.access.receivers &= ~(1 << 2); ui->rx3->clear(); update(); emit modified(); @@ -991,18 +991,20 @@ void ModulePanel::onClearAccessRxClicked() /******************************************************************************/ -SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel): +SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): ModelPanel(parent, model, generalSettings, firmware), - ui(new Ui::Setup) + ui(new Ui::Setup), + commonItemModels(commonItemModels) { + ui->setupUi(this); + rawSwitchFilteredModel = new RawItemFilteredModel(commonItemModels->rawSwitchItemModel(), RawSwitch::TimersContext, this); + Board::Type board = firmware->getBoard(); lock = true; memset(modules, 0, sizeof(modules)); - ui->setupUi(this); - QRegExp rx(CHAR_FOR_NAMES_REGEX); ui->name->setValidator(new QRegExpValidator(rx, this)); ui->name->setMaxLength(firmware->getCapability(ModelName)); @@ -1020,7 +1022,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge foreach ( QString file, qd.entryList(filters, QDir::Files) ) { QFileInfo fi(file); QString temp = fi.fileName(); - if (!items.contains(temp) && temp.length() <= 6+4) { + if (!items.contains(temp) && temp.length() <= 6 + 4) { items.append(temp); } } @@ -1030,7 +1032,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge foreach (QString file, qd.entryList(filters, QDir::Files)) { QFileInfo fi(file); QString temp = fi.completeBaseName(); - if (!items.contains(temp) && temp.length() <= 10+4) { + if (!items.contains(temp) && temp.length() <= 10 + 4) { items.append(temp); } } @@ -1043,7 +1045,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge foreach (QString file, items) { ui->image->addItem(file); if (file == model.bitmap) { - ui->image->setCurrentIndex(ui->image->count()-1); + ui->image->setCurrentIndex(ui->image->count() - 1); QString fileName = path; fileName.append(model.bitmap); if (!IS_FAMILY_HORUS_OR_T16(board)) @@ -1075,7 +1077,6 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge } QWidget * prevFocus = ui->image; - rawSwitchFilteredModel = new RawItemFilteredModel(rawSwitchItemModel, RawSwitch::TimersContext, this); timersCount = firmware->getCapability(Timers); @@ -1107,7 +1108,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge if (firmware->getCapability(HasTopLcd)) { ui->toplcdTimer->setField(model.toplcdTimer, this); for (int i = 0; i < CPN_MAX_TIMERS; i++) { - if (itoplcdTimer->addItem(tr("Timer %1").arg(i + 1), i); } } @@ -1130,12 +1131,12 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge prevFocus = ui->trimsDisplay; int analogs = CPN_MAX_STICKS + getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders); int genAryIdx = 0; - for (int i=0; i < analogs + firmware->getCapability(RotaryEncoders); i++) { + for (int i = 0; i < analogs + firmware->getCapability(RotaryEncoders); i++) { RawSource src((i < analogs) ? SOURCE_TYPE_STICK : SOURCE_TYPE_ROTARY_ENCODER, (i < analogs) ? i : analogs - i); QCheckBox * checkbox = new QCheckBox(this); checkbox->setProperty("index", i); checkbox->setText(src.toString(&model, &generalSettings)); - ui->centerBeepLayout->addWidget(checkbox, 0, i+1); + ui->centerBeepLayout->addWidget(checkbox, 0, i + 1); connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool))); centerBeepCheckboxes << checkbox; if (IS_HORUS_OR_TARANIS(board)) { @@ -1151,7 +1152,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge } // Startup switches warnings - for (int i=0; isetText(src.toString(&model, &generalSettings)); slider->setMaximum(switchInfo.config == Board::SWITCH_3POS ? 2 : 1); cb->setProperty("index", i); - ui->switchesStartupLayout->addWidget(label, 0, i+1); + ui->switchesStartupLayout->addWidget(label, 0, i + 1); ui->switchesStartupLayout->setAlignment(label, Qt::AlignCenter); - ui->switchesStartupLayout->addWidget(slider, 1, i+1); + ui->switchesStartupLayout->addWidget(slider, 1, i + 1); ui->switchesStartupLayout->setAlignment(slider, Qt::AlignCenter); - ui->switchesStartupLayout->addWidget(cb, 2, i+1); + ui->switchesStartupLayout->addWidget(cb, 2, i + 1); ui->switchesStartupLayout->setAlignment(cb, Qt::AlignCenter); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int))); connect(cb, SIGNAL(toggled(bool)), this, SLOT(startupSwitchToggled(bool))); @@ -1193,12 +1194,12 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge // Pot warnings prevFocus = ui->potWarningMode; if (IS_HORUS_OR_TARANIS(board)) { - for (int i=0; isetProperty("index", i); cb->setText(src.toString(&model, &generalSettings)); - ui->potWarningLayout->addWidget(cb, 0, i+1); + ui->potWarningLayout->addWidget(cb, 0, i + 1); connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool))); potWarningCheckboxes << cb; if (src.isPot(&genAryIdx) && !generalSettings.isPotAvailable(genAryIdx)) { @@ -1246,7 +1247,6 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge SetupPanel::~SetupPanel() { - delete rawSwitchFilteredModel; delete ui; } @@ -1277,7 +1277,7 @@ void SetupPanel::on_extendedTrims_toggled(bool checked) void SetupPanel::on_trimIncrement_currentIndexChanged(int index) { - model->trimInc = index-2; + model->trimInc = index - 2; emit modified(); } @@ -1346,13 +1346,13 @@ void SetupPanel::populateThrottleSourceCB() ui->throttleSource->clear(); ui->throttleSource->addItem(tr("THR"), 0); - int idx=1; - for (int i=0; ithrottleSource->addItem(firmware->getAnalogInputName(4+i), idx); + int idx = 1; + for (int i = 0; i < getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders); i++, idx++) { + if (RawSource(SOURCE_TYPE_STICK, 4 + i).isAvailable(model, &generalSettings, board)) { + ui->throttleSource->addItem(firmware->getAnalogInputName(4 + i), idx); } } - for (int i=0; igetCapability(Outputs); i++, idx++) { + for (int i = 0; i < firmware->getCapability(Outputs); i++, idx++) { ui->throttleSource->addItem(RawSource(SOURCE_TYPE_CH, i).toString(model, &generalSettings), idx); } @@ -1381,7 +1381,7 @@ void SetupPanel::update() updatePotWarnings(); } - for (int i=0; iupdate(); } @@ -1392,7 +1392,7 @@ void SetupPanel::update() void SetupPanel::updateBeepCenter() { - for (int i=0; isetChecked(model->beepANACenter & (0x01 << i)); } } @@ -1404,20 +1404,20 @@ void SetupPanel::updateStartupSwitches() uint64_t switchStates = model->switchWarningStates; uint64_t value; - for (int i=0; iproperty("index").toInt(); bool enabled = !(model->switchWarningEnable & (1 << index)); if (IS_HORUS_OR_TARANIS(firmware->getBoard())) { - value = (switchStates >> (2*index)) & 0x03; + value = (switchStates >> (2 * index)) & 0x03; if (generalSettings.switchConfig[index] != Board::SWITCH_3POS && value == 2) { value = 1; } } else { - value = (i==0 ? switchStates & 0x3 : switchStates & 0x1); - switchStates >>= (i==0 ? 2 : 1); + value = (i == 0 ? switchStates & 0x3 : switchStates & 0x1); + switchStates >>= (i == 0 ? 2 : 1); } slider->setValue(value); slider->setEnabled(enabled); @@ -1443,7 +1443,7 @@ void SetupPanel::startupSwitchEdited(int value) mask = 0x03; } else { - shift = index+1; + shift = index + 1; mask = 0x01ull << shift; } } @@ -1484,7 +1484,7 @@ void SetupPanel::updatePotWarnings() { lock = true; ui->potWarningMode->setCurrentIndex(model->potsWarningMode); - for (int i=0; iproperty("index").toInt(); checkbox->setChecked(!model->potsWarnEnabled[index]); @@ -1614,7 +1614,7 @@ void SetupPanel::cmTimerClear(bool prompt) model->timers[selectedTimerIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_CLEAR, selectedTimerIndex); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -1627,7 +1627,7 @@ void SetupPanel::cmTimerClearAll() model->timers[i].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_CLEAR, i); } - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -1661,7 +1661,7 @@ void SetupPanel::cmTimerDelete() } model->timers[maxidx].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SHIFT, selectedTimerIndex, 0, -1); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -1674,7 +1674,7 @@ void SetupPanel::cmTimerInsert() } model->timers[selectedTimerIndex].clear(); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SHIFT, selectedTimerIndex, 0, 1); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -1694,7 +1694,7 @@ void SetupPanel::cmTimerPaste() if (hasTimerClipboardData(&data)) { TimerData *td = &model->timers[selectedTimerIndex]; memcpy(td, data.constData(), sizeof(TimerData)); - emit updateDataModels(); + updateItemModels(); emit modified(); } } @@ -1708,12 +1708,17 @@ void SetupPanel::swapTimerData(int idx1, int idx2) memcpy(td2, td1, sizeof(TimerData)); memcpy(td1, &tdtmp, sizeof(TimerData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_TIMER, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); - emit updateDataModels(); + updateItemModels(); emit modified(); } } void SetupPanel::onTimerNameChanged() { - emit updateDataModels(); + updateItemModels(); +} + +void SetupPanel::updateItemModels() +{ + commonItemModels->update(CommonItemModels::RMO_TIMERS); } diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index 6f4a95922..b7b38eaf4 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -26,7 +26,7 @@ constexpr char MIMETYPE_TIMER[] = "application/x-companion-timer"; -class RawSwitchItemModel; +class CommonItemModels; class RawItemFilteredModel; namespace Ui { @@ -131,7 +131,7 @@ class SetupPanel : public ModelPanel Q_OBJECT public: - SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSwitchItemModel * rawSwitchItemModel); + SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); virtual ~SetupPanel(); virtual void update(); @@ -139,7 +139,6 @@ class SetupPanel : public ModelPanel signals: void extendedLimitsToggled(); void updated(); - void updateDataModels(); private slots: void on_name_editingFinished(); @@ -190,7 +189,9 @@ class SetupPanel : public ModelPanel bool moveTimerDownAllowed() const; bool moveTimerUpAllowed() const; void swapTimerData(int idx1, int idx2); + CommonItemModels * commonItemModels; RawItemFilteredModel * rawSwitchFilteredModel; + void updateItemModels(); }; #endif // _SETUP_H_ diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 0b6ad58b7..b2aa23ea2 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -297,6 +297,7 @@ void TelemetryCustomScreen::onModelDataAboutToBeUpdated() void TelemetryCustomScreen::onModelDataUpdateComplete() { update(); + lock = false; } /******************************************************/ @@ -690,12 +691,13 @@ void TelemetrySensorPanel::cmMoveDown() /******************************************************/ -TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel): +TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels): ModelPanel(parent, model, generalSettings, firmware), - ui(new Ui::Telemetry) + ui(new Ui::Telemetry), + commonItemModels(commonItemModels) { ui->setupUi(this); - rawSourceModel = new RawItemFilteredModel(rawSourceItemModel, this); + rawSourceFilteredModel = new RawItemFilteredModel(commonItemModels->rawSourceItemModel(), this); sensorCapability = firmware->getCapability(Sensors); if (sensorCapability > CPN_MAX_SENSORS) // TODO should be role of getCapability @@ -732,7 +734,7 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin } for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++) { - TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, rawSourceModel); + TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, rawSourceFilteredModel); ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i + 1)); telemetryCustomScreens[i] = tab; connect(tab, &TelemetryCustomScreen::modified, this, &TelemetryPanel::onModified); @@ -745,7 +747,6 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin TelemetryPanel::~TelemetryPanel() { - delete rawSourceModel; delete ui; } @@ -983,7 +984,7 @@ void TelemetryPanel::on_clearAllSensors() } update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -994,7 +995,7 @@ void TelemetryPanel::on_insertSensor(int selectedIndex) model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, 1); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -1008,7 +1009,7 @@ void TelemetryPanel::on_deleteSensor(int selectedIndex) model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SHIFT, selectedIndex, 0, -1); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } @@ -1032,7 +1033,12 @@ void TelemetryPanel::swapData(int idx1, int idx2) memcpy(sd1, &sdtmp, sizeof(SensorData)); model->updateAllReferences(ModelData::REF_UPD_TYPE_SENSOR, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); - emit updateDataModels(); + updateItemModels(); emit modified(); } } + +void TelemetryPanel::updateItemModels() +{ + commonItemModels->update(CommonItemModels::RMO_TELEMETRY_SENSORS); +} diff --git a/companion/src/modeledit/telemetry.h b/companion/src/modeledit/telemetry.h index 758c0bc51..db575b1c3 100644 --- a/companion/src/modeledit/telemetry.h +++ b/companion/src/modeledit/telemetry.h @@ -27,7 +27,7 @@ constexpr char MIMETYPE_TELE_SENSOR[] = "application/x-companion-tele-sensor"; class AutoComboBox; -class RawSourceItemModel; +class CommonItemModels; class RawItemFilteredModel; class TimerEdit; @@ -125,14 +125,12 @@ class TelemetryPanel : public ModelPanel Q_OBJECT public: - TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, RawSourceItemModel * rawSourceItemModel); + TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CommonItemModels * commonItemModels); virtual ~TelemetryPanel(); virtual void update(); signals: void updated(); - void updateDataModels(); - private slots: void on_telemetryProtocol_currentIndexChanged(int index); @@ -159,7 +157,8 @@ class TelemetryPanel : public ModelPanel TelemetryCustomScreen * telemetryCustomScreens[4]; TelemetrySensorPanel * sensorPanels[CPN_MAX_SENSORS]; int sensorCapability; - RawItemFilteredModel * rawSourceModel; + CommonItemModels * commonItemModels; + RawItemFilteredModel * rawSourceFilteredModel; void setup(); void telBarUpdate(); @@ -167,6 +166,7 @@ class TelemetryPanel : public ModelPanel void populateCurrentSource(); void populateVarioSource(); void swapData(int idx1, int idx2); + void updateItemModels(); }; #endif // _TELEMETRY_H_ From 5767e9a7c16f9b4231847ac48126e92bc1fc68e9 Mon Sep 17 00:00:00 2001 From: elecpower Date: Fri, 2 Oct 2020 07:17:36 +1000 Subject: [PATCH 014/231] Do not apply offset when clearing model references --- companion/src/firmwares/modeldata.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/modeldata.cpp b/companion/src/firmwares/modeldata.cpp index e38958249..419418f3b 100644 --- a/companion/src/firmwares/modeldata.cpp +++ b/companion/src/firmwares/modeldata.cpp @@ -847,7 +847,7 @@ void ModelData::updateTypeIndexRef(R & curRef, const T type, const int idxAdj, c newRef.clear(); else { newRef.type = (T)defType; - newRef.index = defIndex + idxAdj; + newRef.index = defIndex; } break; case REF_UPD_ACT_SHIFT: @@ -904,7 +904,7 @@ void ModelData::updateTypeValueRef(R & curRef, const T type, const int idxAdj, c newRef.clear(); else { newRef.type = (T)defType; - newRef.value = defValue + idxAdj; + newRef.value = defValue; } break; case REF_UPD_ACT_SHIFT: @@ -989,7 +989,7 @@ void ModelData::updateAssignFunc(CustomFunctionData * cfd) case REF_UPD_TYPE_TIMER: if (cfd->func < FuncSetTimer1 || cfd->func > FuncSetTimer3) // TODO refactor to FuncSetTimerLast return; - idxAdj = FuncSetTimer1 - 2; // reverse earlier offset requiured for rawsource + idxAdj = FuncSetTimer1 - 2; // reverse earlier offset required for rawsource break; default: return; From 8de491134a70481b6d609a39e43d24df2cd7d016 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 7 Oct 2020 19:34:17 +0200 Subject: [PATCH 015/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index 95dc3e6a3..5787b2614 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1942,3 +1942,4 @@ Miklos Turcsin Edward Skerness Stefano Perinetti Toni Marchante +Stuart Olson From fe80c9ab17ae7caae602c1264d044cc74d88bab8 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 8 Oct 2020 09:01:11 +0200 Subject: [PATCH 016/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index 5787b2614..b2f4a8387 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1943,3 +1943,4 @@ Edward Skerness Stefano Perinetti Toni Marchante Stuart Olson +Peter Campbell From 3fc62fff8380e986e4650a0ec2a5504d5a2bbfd6 Mon Sep 17 00:00:00 2001 From: 3djc Date: Thu, 8 Oct 2020 09:31:46 +0200 Subject: [PATCH 017/231] Default to screen baclight ON --- radio/src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radio/src/main.cpp b/radio/src/main.cpp index 66426fd20..db12ee20f 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -22,8 +22,8 @@ uint8_t currentSpeakerVolume = 255; uint8_t requiredSpeakerVolume = 255; -uint8_t currentBacklightBright = 255; -uint8_t requiredBacklightBright = 255; +uint8_t currentBacklightBright = 0; +uint8_t requiredBacklightBright = 0; uint8_t mainRequestFlags = 0; #if defined(STM32) From 45ad1d2c91137f4c84bcb70b9ad8a208a409890e Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 8 Oct 2020 11:04:16 +0200 Subject: [PATCH 018/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index b2f4a8387..ca318b36f 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1944,3 +1944,4 @@ Stefano Perinetti Toni Marchante Stuart Olson Peter Campbell +Keith Wood From beb0b2e6a27a3078fdb959006789b2e7a71c5bb0 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 8 Oct 2020 15:52:39 +0200 Subject: [PATCH 019/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index ca318b36f..faea3b7e7 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1945,3 +1945,4 @@ Toni Marchante Stuart Olson Peter Campbell Keith Wood +Leo Duflou From fcf8e4f36fdb43922e97ec96e53e7629dc7638ad Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 8 Oct 2020 17:35:17 +0200 Subject: [PATCH 020/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index faea3b7e7..f4c36c5a2 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1946,3 +1946,4 @@ Stuart Olson Peter Campbell Keith Wood Leo Duflou +Michael Florey From 6e8c7835320596c53403b87b38e239d4eae208b2 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 9 Oct 2020 09:46:45 +0200 Subject: [PATCH 021/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index f4c36c5a2..5384c45b1 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1947,3 +1947,4 @@ Peter Campbell Keith Wood Leo Duflou Michael Florey +Gerhard Weixelbaumer From 4c986f0adc48ed1a4b8a9aabdf71d09eea10132b Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 9 Oct 2020 12:33:47 +0200 Subject: [PATCH 022/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index 5384c45b1..19136285b 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1948,3 +1948,4 @@ Keith Wood Leo Duflou Michael Florey Gerhard Weixelbaumer +Peter K Lehotsky From 719375b5797a4d1c9433ca1226712b20ac34f7cf Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 9 Oct 2020 13:38:43 +0200 Subject: [PATCH 023/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index 19136285b..96973332d 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1949,3 +1949,4 @@ Leo Duflou Michael Florey Gerhard Weixelbaumer Peter K Lehotsky +Elisha Jones From b2a4cad5721e8d345bf0b078ef3de9d63aa96002 Mon Sep 17 00:00:00 2001 From: cheki <4509524+ku2works@users.noreply.github.com> Date: Sat, 10 Oct 2020 16:25:09 +0900 Subject: [PATCH 024/231] updated japanese translation. (#8014) Co-authored-by: ku2works --- companion/src/translations/companion_ja.ts | 3006 +++++++++----------- 1 file changed, 1331 insertions(+), 1675 deletions(-) diff --git a/companion/src/translations/companion_ja.ts b/companion/src/translations/companion_ja.ts index da32c47fc..2d7d02b4d 100644 --- a/companion/src/translations/companion_ja.ts +++ b/companion/src/translations/companion_ja.ts @@ -730,58 +730,58 @@ Mode 4: Boards - + Left Horizontal 左・横 - + Left Vertical 左・縦 - + Right Vertical 右・縦 - + Right Horizontal 右・横 - + Aux. 1 AUX. 1 - + Aux. 2 AUX. 2 - - + + Unknown 不明 - + Rud ラダー - + Ele エレベーター - + Thr スロットル - + Ail エルロン @@ -895,57 +895,62 @@ Mode 4: チャンネルを削除します。よろしいですか? - + + Cut Channel. Are you sure? + チャンネルを切り取ります。よろしいですか? + + + Copy コピー - + Cut 切り取り - + Paste 貼り付け - + Clear 消去 - + Insert 挿入 - + Delete 削除 - + Move Up 上へ移動 - + Move Down 下へ移動 - + Clear All すべて消去 - + Clear Channel. Are you sure? チャンネルを消去します。よろしいですか? - + Clear all Channels. Are you sure? チャンネルをすべて消去します。よろしいですか? @@ -1595,17 +1600,22 @@ If you have a settings backup file, you may import that instead. すべて消去 - + Clear Curve. Are you sure? カーブを消去します。よろしいですか? - + Clear all Curves. Are you sure? カーブをすべて消去します。よろしいですか? - + + Cut Curve. Are you sure? + カーブを切り取ります。よろしいですか? + + + Delete Curve. Are you sure? カーブを削除します。よろしいですか? @@ -1629,8 +1639,8 @@ If you have a settings backup file, you may import that instead. - Trainer - トレーナー + Trainer Sticks + トレーナー Sticks @@ -1773,79 +1783,79 @@ If you have a settings backup file, you may import that instead. バインド 外部モジュール - + Timer1 タイマー1 - + Timer2 タイマー2 - + Timer3 タイマー3 - + Flight フライト - + Telemetry テレメトリー - + Rotary Encoder エンコーダ再生 - + REa エンコーダ再生a - + REb エンコーダ再生b - + s s - - - + + + <font color=red><b>Inconsistent parameter</b></font> <font color=red><b>矛盾しているパラメータ</b></font> - + Value - + played once, not during startup 起動時以外 1回実行 - + repeat(%1s) リピート(%1s) - + DISABLED 無効 - + CFN CFN @@ -1905,82 +1915,87 @@ If you have a settings backup file, you may import that instead. %1 - - Delete Special Function. Are you sure? - スペシャルファンクションを削除します。よろしいですか? + + Delete Function. Are you sure? + ファンクションを削除します。よろしいですか? - + + Cut Special Function. Are you sure? + ファンクションを切り取ります。よろしいですか? + + + + Clear Function. Are you sure? + ファンクションを消去します。よろしいですか? + + + + Clear all Functions. Are you sure? + ファンクションをすべて消去します。よろしいですか? + + + Copy コピー - + Cut 切り取り - + Paste 貼り付け - + Clear 消去 - + Insert 挿入 - + Delete 削除 - + Move Up 上へ移動 - + Move Down 下へ移動 - + Clear All すべて消去 - - Clear Special Function. Are you sure? - スペシャルファンクションを消去します。よろしいですか? - - - - Clear all Special Functions. Are you sure? - スペシャルファンクションをすべて消去します。よろしいですか? - - - + Value - + Source 選択元 - + GVAR GVAR - + Increment 増加 @@ -2148,48 +2163,48 @@ If you have a settings backup file, you may import that instead. フィールド %1 変換エラー - + Switch スイッチ - + Switch スイッチ - + cannot be exported on this board! このボードにエクスポートできません! - + Source 選択元 - + Source %1 cannot be exported on this board! このボードでは選択元 %1 をエクスポートできません! - + OpenTX only accepts %1 points in all curves OpenTXはすべてのカーブで %1 点のみを許容します - + OpenTx only accepts %1 points in all curves OpenTxはすべてのカーブで %1 点のみを許容します - - + + OpenTX on this board doesn't accept this function このボード上のOpenTXはこの機能を受け付けません - + OpenTX doesn't accept this radio protocol OpenTXはこの送信機プロトコルを受け付けません @@ -2316,69 +2331,54 @@ To <b>remove a remembered entry</b> from the filter list, first cho - - Eeprom is not from Th9X - - EEPROMはTh9Xからのものではありません - - - - - Eeprom is not from Gruvin9X - - EEPROMはGruvin9Xからのものではありません - - - - Eeprom is not from ErSky9X - EEPROMはErSky9Xからのものではありません - - - Eeprom is not from Er9X - - EEPROMはEr9Xからのものではありません - - - + - Eeprom size is invalid - EEPROMサイズが無効です - + - Eeprom file system is invalid - EEPROMファイルシステムが無効です - + - Eeprom is from a unknown board - EEPROMは不明なボードからのものです - + - Eeprom is from the wrong board - EEPROMは間違ったボードからのものです - + - Eeprom backup not supported - EEPROMバックアップはサポートされていません - + - Something that couldn't be guessed, sorry - 推測できない問題が起きています。申し訳ありません - + Warning: 警告: - - + + - Your radio probably uses a wrong firmware, eeprom size is 4096 but only the first 2048 are used - この送信機は、おそらく間違ったファームウェアを適用しています。 EEPROMサイズは4096ですが、最初の2048しか使用されません - + - Your eeprom is from an old version of OpenTX, upgrading! To keep your original file as a backup, please choose File -> Save As specifying a different name. - このEEPROMは古いバージョンのOpenTXでアップグレードしています。 @@ -2541,22 +2541,22 @@ If blank then the input is considered to be "ON" all the time.編集 %1 - + Popup menu available 利用可能なポップアップメニュー - + Clear All すべて消去 - + Set All すべて設定 - + Invert All すべてリバース @@ -2925,282 +2925,258 @@ Blank means include all. ?, *, and [...] wildcards accepted. Firmware - + Channel values displayed in us 表示されるチャンネル値 - + No OverrideCH functions available 使用可能な上書きチャンネル機能はありません - + Possibility to enable FAI MODE (no telemetry) at field フィールドでFAIモード (テレメトリーなし) を有効にする可能性 - + FAI MODE (no telemetry) always enabled FAIモード (テレメトリーなし) を常に有効 - + Removes D8 FrSky protocol support which is not legal for use in the EU on radios sold after Jan 1st, 2015 2015/01/01以降に販売された送信機に対し、EUでの使用に適さないD8 FrSkyプロトコルサポートを削除 - + Enable non certified firmwares 認定されていないファームウェアを有効にする - - + + Disable HELI menu and cyclic mix support HELIメニューとサイクリックミックスサポートを無効にする - - + + Disable Global variables グローバル変数を無効にする - - + + Enable Lua custom scripts screen Luaカスタムスクリプト画面を有効にする - + Use alternative SQT5 font SQT5 代替フォントを使用する - + Pots use in menus navigation メニューナビゲーションでダイヤルを使用 - + FrSky Taranis X9D+ FrSky Taranis X9D+ - - Support for PPM internal module hack - PPM内部モジュールハックのサポート - - - - + + Disable RAS (SWR) RAS (SWR)を無効にする - + FrSky Taranis X9D+ 2019 - + FrSky Taranis X9D FrSky Taranis X9D - + Haptic module installed タッチパネル対応モジュールをインストール - + FrSky Taranis X9E FrSky Taranis X9E - + Confirmation before radio shutdown 送信機シャットダウン前の確認 - + Horus gimbals installed (Hall sensors) Horusジンバル (ホールセンサー) をインストール - + FrSky Taranis X9-Lite FrSky Taranis X9-Lite - + FrSky Taranis X9-Lite S - + FrSky Taranis X7 / X7S FrSky Taranis X7 / X7S - + FrSky Taranis X-Lite S/PRO FrSky Taranis X-Lite S/PRO - + FrSky Taranis X-Lite FrSky Taranis X-Lite - + FrSky Horus X10 / X10S FrSky Horus X10 / X10S - + FrSky Horus X12S FrSky Horus X12S - + Use ONLY with first DEV pcb version 初期DEV pcbバージョンでのみ使用 - - + + Support for MULTI internal module MULTI内部モジュールのサポート - - + + + Support for bluetooth module Bluetoothモジュールのサポート - + + Radiomaster TX16S / SE / Hall / Masterfire + Radiomaster TX16S / SE / Hall / Masterfire + + + + Jumper T18 + Jumper T18 + + + Turnigy 9XR-PRO Turnigy 9XR-PRO - + Enable HELI menu and cyclic mix support HELIメニューとサイクリックミックスのサポートを有効にする - + + Enable AFHDS3 support + AFHDS3サポート 有効 + + + Global variables グローバル変数 - + In model setup menus automatically set source by moving the control モデル設定メニューでは、コントローラーを動かし自動的に選択元を設定します - + In model setup menus automatically set switch by moving the control モデル設定メニューでは、コントローラーを動かし自動的にスイッチを設定します - + No graphical check boxes and sliders グラフィカルなチェックボックスとスライダーはありません - + Battery graph バッテリーグラフ - + Don't use bold font for highlighting active items 有効なアイテムを強調表示するために太字フォントを使用しない - + FrSky Taranis X7 / X7S Access FrSky Taranis X7 / X7S ACCESS - - + + Support for ACCESS internal module replacement ACCESS内部モジュール変更のサポート - - Turnigy 9XR with m128 chip - Turnigy 9XR m128チップ搭載 - - - - Turnigy 9XR - Turnigy 9XR - - - - 9X with stock board - 9X ストックボード - - - + Enable resetting values by pressing up and down at the same time 上下に同時に押し、値のリセットを有効にする - - 9X with stock board and m128 chip - 9X ストックボード+m128 chip - - - + 9X with AR9X board 9X AR9Xボード - + FrSky Horus X10 Express / X10S Express FrSky Horus X10 Express / X10S Express - + Jumper T12 / T12 Pro Jumper T12 / T12 Pro - + Jumper T16 / T16+ / T16 Pro Jumper T16 / T16+ / T16 Pro - - Radiomaster TX16s / TX16s Hall / TX16s Masterfire - Radiomaster TX16s / TX16s Hall / TX16s Masterfire - - - + Support internal GPS 内蔵GPSサポート - + 9X with Sky9x board 9X Sky9Xボード - - - 9X with Gruvin9x board - 9X Gruvin9X - - - - DIY MEGA2560 radio - DIY MEGA2560 送信機 - FirmwarePreferencesDialog @@ -3459,62 +3435,62 @@ Blank means include all. ?, *, and [...] wildcards accepted. 書き込み - + Open Firmware File FWファイルを開く - + %1 may not be a valid firmware file %1 は有効なファームウェアファイルでない可能性があります - + The firmware file is not valid. ファームウェアファイルが無効です。 - + There is no start screen image in the firmware file. ファームウェアファイルに起動画面のイメージがありません。 - + Profile image %1 is invalid. プロファイルイメージ %1 が無効です。 - + Open image file to use as radio start screen 送信機の起動画面として使用するイメージファイルを開く - + Images (%1) イメージ (%1) - + Image could not be loaded from %1 イメージを %1からロードできませんでした - + The library image could not be loaded ライブラリイメージを読み込めませんでした - + Splash image not found 起動イメージが見つかりません - + Cannot save customized firmware カスタマイズされたファームウェアを保存できません - + Write Firmware to Radio 送信機にファームウェアを書き込みます @@ -3535,27 +3511,27 @@ Blank means include all. ?, *, and [...] wildcards accepted. 新しいファームウェアは現在インストールされているものと互換性がありません! - + Conversion failed 変換に失敗しました - + Cannot convert Models and Settings for use with this firmware, original data will be used このファームウェアで使用するためにモデルと設定を変換することはできません。元のデータが使用されます - + Restore failed 復元に失敗しました - + Could not restore Models and Settings to Radio. The models and settings data file can be found at: %1 モデルと設定を送信機に復元できませんでした。モデルと設定データファイルは %1 にあります - + Flashing done 書き込み完了 @@ -3568,42 +3544,42 @@ Blank means include all. ?, *, and [...] wildcards accepted. 実行可能ファイル %1 が見つかりません - + Writing... 書き込み中... - + Reading... 読み込み中... - + Verifying... 確認中... - + unknown 不明 - + ie: OpenTX for 9X board or OpenTX for 9XR board 例: 9Xボード用のOpenTXまたは9XRボード用のOpenTX - + ie: OpenTX for M128 / 9X board or OpenTX for 9XR board with M128 chip 例: M128 / 9Xボード用のOpenTXまたはM128チップ搭載 9XRボード用のOpenTX - + ie: OpenTX for Gruvin9X board 例: Gruvin9Xボード用OpenTX - + Your radio uses a %1 CPU!!! Please check advanced burn options to set the correct cpu type. @@ -3612,7 +3588,7 @@ Please check advanced burn options to set the correct cpu type. 正しいCPUタイプを設定するには、詳細書き込みオプションを確認してください。 - + Your radio uses a %1 CPU!!! Please select an appropriate firmware type to program it. @@ -3621,7 +3597,7 @@ Please select an appropriate firmware type to program it. 適切なファームウェアタイプを選択してください。 - + You are currently using: %1 @@ -3630,22 +3606,22 @@ You are currently using: %1 - + Your radio does not seem connected to USB or the driver is not initialized!!!. お使いの送信機がUSBに接続されていないか、ドライバが初期化されていません。 - + Flashing done (exit code = %1) 書き込み完了 (終了コード= %1 ) - + Flashing done with errors エラーを含んだ書き込み完了 - + FUSES: Low=%1 High=%2 Ext=%3 FUSES: Low=%1 High=%2 Ext=%3 @@ -3791,85 +3767,115 @@ You are currently using: - + Copy コピー - + Cut 切り取り - + Paste 貼り付け - + Insert 挿入 - + Delete 削除 - + Move Up 上へ移動 - + Move Down 下へ移動 - + Clear All すべて消去 - + Clear Flight Mode. Are you sure? フライトモードを消去します。よろしいですか? - + Clear all Flight Modes. Are you sure? フライトモードをすべて消去します。よろしいですか? - + + Cut Flight Mode. Are you sure? + フライトモードを切り取ります。よろしいですか? + + + Delete Flight Mode. Are you sure? フライトモードを削除します。よろしいですか? - - Clear selected Global Variable across all Flight Modes. Are you sure? - すべてのフライトモードの選択したグローバル変数を消去します。よろしいですか? + + Clear Global Variable across all Flight Modes. Are you sure? + すべてのフライトモードのグローバル変数を消去します。よろしいですか? - + + Clear Global Variable. Are you sure? + グローバル変数を消去します。よろしいですか? + + + + Cut Global Variable across all Flight Modes. Are you sure? + すべてのフライトモードのグローバル変数を切り取ります。よろしいですか? + + + + Cut Global Variable. Are you sure? + グローバル変数を切り取ります。よろしいですか? + + + + Delete Global Variable. Are you sure? + グローバル変数を削除します。よろしいですか? + + + + Paste to selected Global Variable across all Flight Modes. Are you sure? + すべてのフライトモードで選択したグローバル変数を貼り付けます。よろしいですか? + + + Clear all Global Variables for all Flight Modes. Are you sure? すべてのフライトモードのすべてのグローバル変数を消去します。よろしいですか? - + Clear all Global Variables for this Flight Mode. Are you sure? このフライトモードのすべてのグローバル変数を消去します。よろしいですか? - + Clear 消去 @@ -3877,17 +3883,17 @@ You are currently using: FlightModesPanel - + Flight Mode %1 フライトモード %1 - + (%1) (%1) - + (default) (初期値) @@ -4167,47 +4173,47 @@ These will be relevant for all models in the same EEPROM. セットアップ - + Global Functions グローバルファンクション - + Trainer トレーナー - + Hardware ハードウェア - + Calibration 校正 - + Wrong data in profile, radio calibration was not retrieved プロファイルデータが正しくなく、送信機校正情報が取得できませんでした - + Wrong data in profile, Switch/pot config not retrieved プロファイルデータが正しくなく、スイッチ/ダイヤル構成が取得できませんでした - + Wrong data in profile, hw related parameters were not retrieved プロファイルデータが正しくなく、HW関連パラメーターが取得できませんでした - + Do you want to store calibration in %1 profile<br>overwriting existing calibration? 既存の校正情報を上書きして %1 プロファイルに校正情報を保存しますか? - + Calibration and HW parameters saved. 校正情報とHWパラメータが保存されました。 @@ -4215,7 +4221,7 @@ These will be relevant for all models in the same EEPROM. GeneralSettings - + Radio Settings 送信機設定 @@ -4273,161 +4279,161 @@ These will be relevant for all models in the same EEPROM. SG - + Stick reverse スティック リバース - + Country Code 地域 - + If you enable FAI, only RSSI and RxBt sensors will keep working. This function cannot be disabled by the radio. FAIを有効にすると、RSSIとRxBtセンサーのみが機能し続けます。この機能を送信機側で無効にすることはできません。 - + FAI Mode FAIモード - + Automatically adjust the radio's clock if a GPS is connected to telemetry. GPSがテレメトリーに接続されている場合、自動的に送信機側の内蔵時計を調整します。 - + Adjust RTC 時計調整 - + Speaker Volume スピーカー音量 - - + + Hz Hz - + Vario pitch at max バリオピッチ 最大 - + Backlight Switch バックライトスイッチ - + Color 1 カラー 1 - + Color 2 カラー 2 - + Sound Mode サウンドモード - + If this value is not 0, any keypress will turn on the backlight and turn it off after the specified number of seconds. この値が0以外の場合、キーを押すとバックライトが点灯し、指定秒数を経過すると消灯します。 - - - + + + sec - + Backlight color バックライトカラー - + Speaker Pitch (spkr only) 再生ピッチ (対応機のみ) - + Beeper ビープ - + Speaker スピーカー - + BeeperVoice ビープ音声 - + SpeakerVoice スピーカー音声 - + Beep volume ビープ音量 - + Wav volume WAV音量 - + Vario volume バリオVOL - + Background volume バックグランドVOL - - + + ms ms - + Backlight flash on alarm アラーム時ライト点滅 - + Vario pitch at zero バリオピッチ ゼロ - + Vario repeat at zero バリオリピート ゼロ - + Backlight Auto OFF after バックライト 自動消灯 - + This is the switch selectrion for turning on the backlight (if installed). @@ -4436,8 +4442,8 @@ These will be relevant for all models in the same EEPROM. - - + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -4452,49 +4458,49 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">値は20~45です</span></p></body></html> - + RotEnc Navigation Rot Enc ナビゲーション - + Backlight Brightness バックライト 明るさ - + America アメリカ - + Japan 日本 - + Europe ヨーロッパ - + Voice Language 音声言語 - + Timeshift from UTC UTC 時差 - + Backlight OFF Brightness バックライトOFF 明るさ - - - + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -4519,12 +4525,12 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">サイレントモード警告 - ビープ音が消音(0)に設定されていると警告します</p></body></html> - + RSSI Poweroff Warning RSSI 信号切断 警告 - + Beeper volume 0 - Quiet. No beeps at all. @@ -4541,221 +4547,221 @@ p, li { white-space: pre-wrap; } 4 - より大きい音量。 - - + + Quiet 消音 - + Alarms Only アラームのみ - - + + No Keys キーなし - - + + All すべて - + Beeper Mode ビープ モード - + Jack Mode Jackモード - + Audio 音声 - + Trainer トレーナー - - + + X-Short より短い - - + + Short 短い - - + + Normal 通常 - - + + Long 長い - - + + X-Long より長い - + Beeper Length ビープ音の長さ - + Haptic Mode タッチパネルモード - + Measurement Units 計量単位 - + Play Delay (switch mid position) 遅延動作 (スイッチ中央) - + NMEA - + 4800 Baud - + 9600 Baud - + 14400 Baud - + 19200 Baud - + 38400 Baud - + 57600 Baud - + 76800 Baud - + 115200 Baud - - + + Show splash screen on startup 起動時、起動イメージ表示 - + nnnnnnNN nnnnnnNN - + Power On Delay 起動時間 - + --- --- - + 2s 2秒 - + 3s 3秒 - + 4s 4秒 - + 6s 6秒 - + 8s 8秒 - + 10s 10秒 - + 15s 15秒 - + If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. 指定された時間(分)入力がないまま送信機が放置されると、ゼロでない場合はビープ音が鳴ります。 - + min - + Standard 標準 - + Optrex オプトレックス(京セラ) - + Battery warning voltage. This is the threashhold where the battery warning sounds. @@ -4765,243 +4771,248 @@ Acceptable values are 5v..10v 許容値は5~10vです - + Only Alarms アラームのみ - + MAVLink Baud Rate MAVLink ボーレート - + Haptic Length タッチパネル長押し - + Battery Warning バッテリー警告 - + "No Sound" Warning 【無音】警告 - + LCD Display Type 液晶ディスプレイタイプ - + Haptic Strength タッチパネル感度 - + Battery Meter Range バッテリーメーター範囲 - + Contrast コントラスト - + Show Splash Screen on Startup 起動時、起動イメージ表示 - + Low EEPROM Warning EEPROM残量警告 - + Inactivity Timer 非アクティブタイマー - + Min 最小 - - + + v v - + Max 最大 - + GPS Coordinates GPS座標 - + Default Channel Order 初期チャンネルマップ - + Metric メートル法 - + Imperial ヤード・ポンド法 - + Stick Mode スティックモード - + <html><head/><body><p>Channel order</p><p><br/></p><p>Defines the order of the default mixes created on a new model.</p></body></html> <html><head/><body><p>チャンネルマップ</p><p><br/></p><p>モデル作成された際の初期チャンネルマッピングを定義します</p></body></html> - + Owner Registration ID オーナー登録ID - + + Keys Backlight + キー バックライト + + + R E T A ↔RUD ↕ELE ↕THR ↔AIL [R E T A] - + R E A T ↔RUD ↕ELE ↔AIL ↕THR [R E A T] - + R T E A ↔RUD ↕THR ↕ELE ↔AIL [R T E A] - + R T A E ↔RUD ↕THR ↔AIL ↕ELE [R T A E] - + R A E T ↔RUD ↔AIL ↕ELE ↕THR [R A E T] - + R A T E ↔RUD ↔AIL ↕THR ↕ELE [R A T E] - + E R T A ↕ELE ↔RUD ↕THR ↔AIL [E R T A] - + E R A T ↕ELE ↔RUD ↔AIL ↕THR [E R A T] - + E T R A ↕ELE ↕THR ↔RUD ↔AIL [E T R A] - + E T A R ↕ELE ↕THR ↔AIL ↔RUD [E T A R] - + E A R T ↕ELE ↔AIL ↔RUD ↕THR [E A R T] - + E A T R ↕ELE ↔AIL ↕THR ↔RUD [E A T R] - + T R E A ↕THR ↔RUD ↕ELE ↔AIL [T R E A] - + T R A E ↕THR ↔RUD ↔AIL ↕ELE [T R A E] - + T E R A ↕THR ↕ELE ↔RUD ↔AIL [T E R A] - + T E A R ↕THR ↕ELE ↔AIL ↔RUD [T E A R] - + T A R E ↕THR ↔AIL ↔RUD ↕ELE [T A R E] - + T A E R ↕THR ↔AIL ↕ELE ↔RUD [T A E R] - + A R E T ↔AIL ↔RUD ↕ELE ↕THR [A R E T] - + A R T E ↔AIL ↔RUD ↕THR ↕ELE [A R T E] - + A E R T ↔AIL ↕ELE ↔RUD ↕THR [A E R T] - + A E T R ↔AIL ↕ELE ↕THR ↔RUD [A E T R] - + A T R E ↔AIL ↕THR ↔RUD ↕ELE [A T R E] - + A T E R ↔AIL ↕THR ↕ELE ↔RUD [A T E R] - + Power Off Delay 終了時間 - + Mode selection: Mode 1: @@ -5042,53 +5053,53 @@ Mode 4: - + Mode 1 (RUD ELE THR AIL) モード1 (左:エレベーター・ラダー 右:スロットル・エルロン) - + Mode 2 (RUD THR ELE AIL) モード2 (左:スロットル・ラダー 右:エレベーター・エルロン) - + Mode 3 (AIL ELE THR RUD) モード3 (左:エレベーター・エルロン 右:スロットル・ラダー) - + Mode 4 (AIL THR ELE RUD) モード4 (左:スロットル・エルロン 右:エレベーター・ラダー) - + DMS - + USB Mode USBモード - - + + Ask on Connect 接続毎に確認 - + Joystick (HID) ジョイスティック (HID) - + USB Mass Storage USBストレージ - + USB Serial (CDC) USBシリアル (CDC) @@ -5096,127 +5107,127 @@ Mode 4: GeneralSetupPanel - + OFF OFF - + Keys キー - + Sticks スティック - + Keys + Sticks キー+スティック - + ON ON - + English - + Dutch - + French - + Italian - + German - + Czech - + Slovak - + Spanish - + Polish - + Portuguese - + Russian - + Swedish - + Hungarian - + No いいえ - + RotEnc A Rot Enc A - + Rot Enc B - + Rot Enc C - + Rot Enc D - + Rot Enc E - + If you enable FAI, only RSSI and RxBt sensors will keep working. This function cannot be disabled by the radio. Are you sure ? @@ -5748,9 +5759,14 @@ Are you sure ? 入力項目が不足しています! - - Delete selected Inputs. Are you sure? - 選択した入力項目を削除します。よろしいですか? + + Delete selected Input lines. Are you sure? + 選択したInput行を削除します。よろしいですか? + + + + Cut selected Input lines. Are you sure? + 選択したInput行を切り取ります。よろしいですか? @@ -5850,18 +5866,18 @@ Are you sure ? - Clear all Inputs. Are you sure? - すべての入力項目を消去します。よろしいですか? + Clear all Input lines. Are you sure? + すべてのInput行を消去します。よろしいですか? - Clear Input. Are you sure? - 入力項目を消去します。よろしいですか? + Clear all lines for the selected Inputs. Are you sure? + 選択したすべてのInput行を消去します。よろしいですか? - Delete Input. Are you sure? - 入力項目を削除します。よろしいですか? + Delete all lines for the selected Inputs. Are you sure? + 選択したすべてのInput行を削除します。よろしいですか? @@ -6061,57 +6077,67 @@ Are you sure ? (無制限) - + Delete Logical Switch. Are you sure? 論理スイッチを削除します。よろしいですか? - + + Cut Logical Switch. Are you sure? + 論理スイッチを切り取ります。よろしいですか? + + + Copy コピー - + Cut 切り取り - + Paste 貼り付け - + Clear 消去 - + Insert 挿入 - + Delete 削除 - + Move Up 上へ移動 - + Move Down 下へ移動 - + Clear All すべて消去 - + + Clear Logical Switch. Are you sure? + 論理スイッチを消去します。よろしいですか? + + + Clear all Logical Switches. Are you sure? 論理スイッチをすべて消去します。よろしいですか? @@ -6293,123 +6319,123 @@ The columns for altitude "GAlt" and for speed "GSpd" are opt MainWindow - + Diskimage (*.dmg) ディスクイメージ (*.dmg) - + Would you like to open the disk image to install the new version? 新しいバージョンをインストールするためにディスクイメージを開きますか? - + Executable (*.exe) 実行ファイル (*.exe) - - + + Would you like to launch the installer? インストーラを起動しますか? - - + + File loaded ファイルがロードされました - + Checking for updates アップデートの確認 - + A new version of Companion is available (version %1)<br>Would you like to download it? Companionの新しいバージョンがあります。 (version %1)<br>ダウンロードしますか? - - + + Save As 名前を付けて保存 - + New release available 新リリースが利用可能 - + A new release of Companion is available, please check the <a href='%1'>OpenTX website!</a> Companionの新リリースが利用可能です。<a href='%1'>OpenTX Webサイト</a>をチェックしてください - - + + No updates available at this time. 現時点で利用可能なアップデートはありません。 - + Error opening file %1: %2. ファイル %1 を開くときにエラーが発生しました: %2. - + Not enough flash available on this board for all the selected options 選択されたすべてのオプションに対してこのボードでは十分な書き込みが行えません - + Compilation server temporary failure, try later コンパイルサーバが一時的に失敗しました。後程お試しください - + Compilation server too busy, try later コンパイルサーバがビジー状態です。後程お試しください - + Compilation error コンパイルエラー - + Invalid firmware 無効なファームウェア - + Invalid board 無効なボード - + Invalid language 無効な言語 - + Unknown server failure, try later 不明なサーバの障害です。後程お試しください - + Do you want to write the firmware to the radio now ? 今すぐファームウェアを送信機に書き込みますか? - + Firmware update check failed, new version information not found or invalid. ファームウェアアップデートの確認に失敗しました。新しいバージョン情報が見つからないか、または無効です。 - + Firmware %1 does not seem to have ever been downloaded. Version %2 is available. Do you want to download it now? @@ -6422,31 +6448,31 @@ We recommend you view the release notes using the button below to learn about an 重要な変更については、下のボタンをクリックしてリリースノートを参照することをお勧めします。 - - + + Yes はい - - + + No いいえ - - + + Release Notes リリースノート - - + + Do you want to download version %1 now ? 今すぐバージョン %1 をダウンロードしますか? - + A new version of %1 firmware is available: - current is %2 - newer is %3 @@ -6463,29 +6489,29 @@ We recommend you view the release notes using the button below to learn about an 重要な変更については、下のボタンをクリックしてリリースノートを参照することをお勧めします。 - + Ignore this version %1? このバージョン %1 を無視しますか? - + The new theme will be loaded the next time you start Companion. 次回Companionを起動したときに、新しいテーマがロードされます。 - - + + Open Models and Settings file 機体モデルと設定ファイルを開く - - + + File saved ファイル 保存 - + There are unsaved file changes which you may lose when switching radio types. Do you wish to continue? @@ -6494,780 +6520,760 @@ Do you wish to continue? そのまま続けますか? - - + + Synchronize SD SDカードを同期する - + No local SD structure path configured! SDカード保存先パスが設定されていません! - + No Companion release candidates are currently being served for this version, please switch release channel 現在このバージョンのCompanion RC版は提供されていません。リリース状態を切り替えてください - + No nightly Companion builds are currently being served for this version, please switch release channel 現在、このバージョンのCompanion ナイトリービルド版は提供されていません。リリース状態を切り替えてください - + No Companion release builds are currently being served for this version, please switch release channel このバージョンのCompanion リリース版は現在提供されていません。リリース状態を切り替えてください - + Companion update check failed, new version information not found. Companionアップデートの確認に失敗しました。新しいバージョン情報が見つかりません。 - + No firmware release candidates are currently being served for this version, please switch release channel 現在、このバージョンのファームウェア RC版は提供されていません。リリース状態を切り替えてください - + No firmware nightly builds are currently being served for this version, please switch release channel 現在、このバージョンのファームウェア ナイトリービルド版は提供されていません。リリース状態を切り替えてください - + No firmware release builds are currently being served for this version, please switch release channel 現在、このバージョンのファームウェア リリース版は提供されていません。リリース状態を切り替えてください - + Release candidate builds are now available for this version, would you like to switch to using them? RC版はこのバージョンで利用可能になりました。それらに切り替えますか? - + Channel changed to RC, please restart the download process リリース状態をRC版に変更しました。ダウンロードプロセスを再起動してください - + Official release builds are now available for this version, would you like to switch to using them? このバージョンの公式リリース版が利用可能になりました。それらに切り替えますか? - + Channel changed to Release, please restart the download process リリース状態をリリース版に変更しました。ダウンロードプロセスを再起動してください - + This radio (%1) is not currently available in this firmware release channel この送信機 (%1) は、現在このファームウェアリリース状態では利用できません - + No Radio or SD card detected! 送信機またはSDカードが検出されませんでした! - + Local Folder ローカルフォルダ - + Radio Folder 送信機フォルダ - - + + Read Firmware from Radio 送信機からファームウェアを読み込み - - + + Read Models and Settings from Radio 送信機から機体モデルや設定を読み込み - + Models and Settings read 機体モデルと設定の読み込み - - + + This function is not yet implemented この機能はまだ実装されていません - + Save Radio Backup to File 送信機のバックアップをファイルに保存 - + Read Radio Firmware to File 送信機ファームウェアからファイルへの読み込み - + OpenTX Home Page: <a href='%1'>%1</a> OpenTX ホームページ: <a href='%1'>%1</a> - + The OpenTX Companion project was originally forked from <a href='%1'>eePe</a> OpenTX Companionプロジェクトは元々<a href='%1'>eePe</a>から派生しました - + If you've found this program useful, please support by <a href='%1'>donating</a> このプログラムが役に立つと感じた場合は、<a href='%1'>寄付</a>でのサポートをお願いします - + Copyright OpenTX Team Copyright OpenTX Team - + About Companion Companionについて - + OpenTX Companion %1 - Radio: %2 - Profile: %3 OpenTX Companion %1 - 送信機: %2 - プロファイル: %3 - + New 新規 - + Create a new Models and Settings file 新規モデルと設定ファイルを作成します - + Open... 開く... - + Save 保存 - - + + Save Models and Settings file 機体モデルと設定ファイルを保存します - + Save As... 名前を付けて保存... - + Close 閉じる - + Close Models and Settings file 機体モデルと設定ファイルを閉じます - + Exit 終了 - + Exit the application アプリケーションを終了します - + About... バージョン情報... - + Show the application's About box アプリケーションのバージョン情報を表示します - + Recent Files 最近使用したファイル - + List of recently used files 最近使用したファイルを一覧表示 - + Radio Profiles 送信機プロファイル - + Create or Select Radio Profiles 送信機プロファイルを作成または選択します - + View Log File... ログファイルを表示... - + Open and view log file ログファイルを開いて表示します - + Settings... 設定... - + Edit Settings 設定を編集します - + Download... ダウンロード... - + Download firmware and voice files ファームウェアと音声ファイルをダウンロードします - + Check for Updates... アップデートのチェック... - + Check OpenTX and Companion updates OpenTXとCompanionのアップデートを確認します - + Release notes... リリースノート... - + Show release notes リリースノートを表示します - + Compare Models... 機体モデルを比較... - + Compare models 機体モデルを比較します - + Edit Radio Splash Image... 送信機の起動イメージを編集... - + Edit the splash image of your Radio 送信機の起動イメージを編集します - - List programmers... - プログラムを一覧表示... - - - - List available programmers - 利用可能なプログラムを一覧表示します - - - - Fuses... - ヒューズ... - - - - Show fuses dialog - ヒューズダイアログを表示します - - - + Read firmware from Radio 送信機からファームウェアを読み込み - + Write Firmware to Radio 送信機にファームウェアを書き込み - + Write firmware to Radio 送信機にファームウェアを書き込み - + SD card synchronization SDカードの同期 - + Manuals and other Documents マニュアルと他の文書 - + Open the OpenTX document page in a web browser WebブラウザでOpenTXドキュメントページを開く - + Write Models and Settings To Radio 機体モデルと設定を送信機に書き込み - + Write Models and Settings to Radio 機体モデルと設定を送信機に書き込み - + Read Models and Settings From Radio 送信機から機体モデルや設定を読み込み - + Configure Communications... 送信機疎通を設定... - + Configure software for communicating with the Radio 送信機と疎通するためのソフトウェアを設定します - + Write Backup to Radio 送信機からバックアップを書き出す - + Write Backup from file to Radio 送信機ファイルからバックアップを書き出します - + Backup Radio to File ファイルを送信機にバックアップ - + Save a complete backup file of all settings and model data in the Radio すべての設定とモデルデータの完全なバックアップファイルを送信機に保存します - + Contributors... 貢献者... - + A tribute to those who have contributed to OpenTX and Companion OpenTXとCompanionに貢献した人々への賛辞 - + Add Radio Profile 送信機プロファイルの追加 - + Create a new Radio Settings Profile 新しい送信機設定プロファイルを作成します - + Copy Current Radio Profile 現在の送信機プロファイルをコピー - + Duplicate current Radio Settings Profile 現在の送信機設定プロファイルを複製します - + Delete Current Radio Profile... 現在の送信機プロファイルを削除... - + Delete the current Radio Settings Profile 現在の送信機設定プロファイルを削除します - + Export Application Settings.. アプリケーション設定のエクスポート.. - + Save all the current %1 and Simulator settings (including radio profiles) to a file. 現在のすべての%1およびシミュレータ設定(送信機プロファイル含)をファイルに保存します。 - + Import Application Settings.. アプリケーション設定をインポート.. - + Load %1 and Simulator settings from a prevously exported settings file. 以前にエクスポートした設定ファイルから%1とシミュレーション設定を読み込みます。 - + Tabbed Windows タブ付きウィンドウ - + Use tabs to arrange open windows. 開いているウィンドウを並べ替えるのにタブを使用します。 - + Tile Windows ウィンドウのタイトル - + Arrange open windows across all the available space. 利用可能なすべてのスペースに開いているウィンドウを配置します。 - + Cascade Windows ウィンドウを重ねる - + Arrange all open windows in a stack. 開いているウィンドウをすべて重ねて配置します。 - + Close All Windows すべてのウィンドウを閉じる - + Closes all open files (prompts to save if necessary. 開いているファイルをすべて閉じます (必要に応じ保存を求められます)。 - - + + Edit 編集 - - + + File ファイル - + Settings 設定 - + Set Icon Theme アイコンテーマ設定 - + Set Icon Size アイコンサイズ設定 - + Read/Write 読み込み/書き込み - + Window ウィンドウ - - + + Help ヘルプ - + Write 書き込み - + Some text will not be translated until the next time you start Companion. Please note that some translations may not be complete. 次にCompanionを起動するまで一部のテキストは翻訳されません。いくつかの翻訳は完全ではないかもしれませんのでご注意ください。 - + Ctrl+Shift+S - + Ctrl+Alt+L - + Ctrl+Alt+D - + Ctrl+Alt+R - + Classical クラシック - + The classic companion9x icon theme クラシック Companion9x アイコンテーマ - + Yerico イェリコ - + Yellow round honey sweet icon theme Yellow round honey sweet アイコンテーマ - + Monochrome モノクローム - + A monochrome black icon theme A monochrome black アイコンテーマ - + MonoBlue モノブルー - + A monochrome blue icon theme A monochrome blue アイコンテーマ - + MonoWhite モノホワイト - + A monochrome white icon theme A monochrome white アイコンテーマ - + Small 小サイズ - + Use small toolbar icons 小サイズのツールバーアイコンを使用 - + Normal 標準サイズ - + Use normal size toolbar icons 標準サイズのツールバーアイコンを使用 - + Big 大サイズ - + Use big toolbar icons 大サイズのツールバーアイコンを使用 - + Huge 特大サイズ - + Use huge toolbar icons 特大サイズのツールバーアイコンを使用 - + Set Menu Language メニュー言語を設定 - + System language システム言語 - + Use default system language. デフォルトのシステム言語を使用します。 - + Use %1 language (some translations may not be complete). %1言語を使用します (一部の翻訳が不完全な場合あり)。 - + Ready 準備完了 - + %2 %2 - + Alt+%1 - + New Radio 新規 送信機 - + - Copy - コピー - + Companion :: Open files warning Companion :: ファイルを開くときの警告 - + Please save or close modified file(s) before deleting the active profile. 有効なプロファイルを削除する前に、変更したファイルを保存するか閉じてください。 - + Not possible to remove profile プロファイルを削除できません - + The default profile can not be removed. デフォルトプロファイルは削除できません。 - + Confirm Delete Profile プロファイル削除の確認 - + Are you sure you wish to delete the "%1" radio profile? There is no way to undo this action! 『%1』送信機プロファイルを削除してもよろしいですか?この操作を元に戻すことはできません! - + Please save or close all modified files before importing settings 設定をインポートする前に、変更したファイルをすべて保存するか閉じてください - + <html><p>%1 and Simulator settings can be imported (restored) from a previosly saved export (backup) file. This will replace current settings with any settings found in the file.</p><p>An automatic backup of the current settings will be attempted. But if the current settings are useful then it is recommended that you make a manual backup first.</p><p>For best results when importing settings, <b>close any other %1 windows you may have open, and make sure the standalone Simulator application is not running.</p><p>Do you wish to continue?</p></html> <html><p>%1とシミュレータの設定は、以前に保存したエクスポート(バックアップ)ファイルからインポート(復元)できます。これにより、現在の設定がファイル内の設定に置き換えられます。</p><p>現在の設定の自動バックアップが実行されます。ただし、現在の設定が便利な場合は、まず手動バックアップを作成することをお勧めします。</p><p>設定をインポートし最良の結果を得るには、<b>開いている%1ウィンドウをすべて閉じます。スタンドアロンのシミュレーターアプリケーションが実行されていません。</p><p>続行しますか?</p></html> - + Confirm Settings Import 設定のインポートの確認 - + Select %1: %1を選択: - + backup バックアップ - + Press the 'Ignore' button to continue anyway. とにかく続行するには『無視』ボタンを押してください。 - + The settings could not be imported. 設定をインポートできませんでした。 - + <html><p>New settings have been imported from:<br> %1.</p><p>%2 will now re-initialize.</p><p>Note that you may need to close and restart %2 before some settings like language and icon theme take effect.</p> <html><p>新しい設定は次の場所からインポートされました。<br>%1.</p><p>%2は再初期化されます。</p><p>場合によっては閉じて再起動する必要があります。言語やアイコンテーマなどの設定が有効になる前に%2が発生しました。</p> - + <p>The previous settings were backed up to:<br> %1</p> <p>以前の設定は次の場所にバックアップされました:<br> %1</p> @@ -7918,25 +7924,25 @@ If blank then the mix is considered to be "ON" all the time. MixesPanel - + Move Up 上へ移動 - + Ctrl+Up - + Move Down 下へ移動 - + Ctrl+Down @@ -7951,97 +7957,102 @@ If blank then the mix is considered to be "ON" all the time. ミキサー項目が足りません! - - Delete Selected Mixes? - 選択したミキサーを削除しますか? + + Delete selected Mix lines. Are you sure? + 選択したMix行を削除します。よろしいですか? - + + Cut selected Mix lines. Are you sure? + 選択したMix行を切り取ります。よろしいですか? + + + &Add &追加 - + Ctrl+A - + &Edit &編集 - + Enter Enter - + &Toggle highlight &ハイライト切替 - + Ctrl+T - + &Delete &削除 - + Delete 削除 - + &Copy &コピー - + Ctrl+C - + C&ut &切り取り - + Ctrl+X - + &Paste &貼り付け - + Ctrl+V - + Du&plicate &複製 - + Ctrl+U - + Clear Mixes? ミキサーを消去しますか? - + Really clear all the mixes? すべてのミキサーを本当に消去しますか? @@ -8049,12 +8060,12 @@ If blank then the mix is considered to be "ON" all the time. ModelData - + Model: 機体モデル: - + Throttle Source スロットル値 @@ -8171,9 +8182,9 @@ If blank then the mix is considered to be "ON" all the time. - - - + + + OFF OFF @@ -8214,7 +8225,7 @@ If blank then the mix is considered to be "ON" all the time. - + Mode モード @@ -8248,14 +8259,14 @@ If blank then the mix is considered to be "ON" all the time. - - + + Delay 遅延 - + Receiver 受信機 @@ -8281,628 +8292,639 @@ If blank then the mix is considered to be "ON" all the time. + RF Output Power 送信出力 - + + Output Type + 出力タイプ + + + + RX Output Frequency + 受信出力周波数 + + + Master/Jack マスター/Jack - + Slave/Jack スレーブ/Jack - + Master/SBUS Module マスター/SBUSモジュール - + Master/CPPM Module マスター/CPPMモジュール - + Master/SBUS in battery compartment マスター/バッテリーカバー内SBUB - + 90 90 - + 120 120 - + 120X 120X - + 140 140 - + Off OFF - - - - - - + + + + + + None なし - + Name 名称 - + Countdown カウントダウン - + Minute call 音声時報 - + Persistent 持続 - - - + + + FM%1 - + FM%1%2 - + FM%1+%2 - - + + Weight ウェイト - - + + Switch スイッチ - - + + NoTrim トリムなし - + Offset(%1) オフセット(%1) - + MULT! 複数! - + No DR/Expo DR/Expoなし - - + + Offset オフセット - + Slow ゆっくり - + Warn 警告 - + Disabled in all flight modes すべてのフライトモードを無効 - + Flight modes フライトモード - + Flight mode フライトモード - + All すべて - + Edge Edge:端 - + instant 簡易 - + Sticky Sticky:追尾 - + Timer タイマー - + missing 間違い - + Duration 期間 - - - + + + Custom カスタム - + Standard 標準 - + Extended Limits 拡張制限 - + Display Checklist ディスプレイ チェックリスト - + Global Functions グローバルファンクション - + Manual 手動 - + Auto 自動 - + Failsafe Mode フェイルセーフモード - - + + Hold ホールド - + No Pulse パルスなし - + Not set セットなし - + No pulses パルスなし - + Silent 消音 - + Beeps ビープ - + Voice 音声 - + Haptic タッチパネル - + Flight フライト - + Manual reset 手動リセット - + Step ステップ - + Display ディスプレイ - + Extended 拡張 - + Never なし - + On Change 変更 - + Always 常に - - - + + + Source 選択元 - + Trim idle only トリムアイドルのみ - + Warning 警告 - + Reversed リバース - + Tmr Tmr - + FrSky S.PORT - + FrSky D - + FrSky D (cable) - + Alti - + Alti+ - + VSpeed - - - + + + A1 - - - + + + A2 - - + + A3 - - + + A4 - - + + FAS - + Cells セル - + Calculated 計算値 - + Add 追加 - + Average 平均 - - + + Min 最小 - - + + Max 最大 - + Multiply 乗算 - + Totalise 合計 - + Cell セル - + Consumption 消費 - + Distance 距離 - + Lowest より低く - + Cell %1 セル %1 - + Highest より高く - + Delta 差分 - + Formula 定式 - - + + Id - + Instance インスタンス - - - - + + + + Sensor センサー - - + + Sources 選択元 - - + + GPS GPS - + Alt. Alt. - - + + Blades ブレード - + Multi. マルチ. - + F - + Inst - + Alt - + Unit - + Prec 精度 - + Ratio レシオ - + Multi マルチ - + A/Offset A/オフセット - + Filter フィルタ - + Persist 持続 - + Positive ノーマル - + Log ログ - + Numbers ナンバー - + Bars バー - + Script スクリプト - + Filename ファイル名 - + Error: Unable to open or read file! エラー: ファイルを開けないか、読み取れません! @@ -8943,245 +8965,255 @@ If blank then the mix is considered to be "ON" all the time. スタート - + CH - + Receiver No. 受信機 No. - + Polarity 極性 - + Negative リバース - + Positive ノーマル - + RF Output Power 送信出力 - + Receiver 1 受信機 1 - - - + + + X X - + Receiver 2 受信機 2 - + Receiver 3 受信機 3 - + Low Power 低パワー - + WARNING: changing RF Output Power needs RE-BIND 警告: 送信出力を変更するには再バインドが必要です - + Channels チャンネル - + PPM delay PPM 遅延 - + us - + PPM Frame Length PPM フレーム長 - + ms ms - + Antenna アンテナ - + Output type 出力タイプ - + Open Drain オープン ドレン - + Push Pull プッシュ プル - + Option value オプション値 - + + RX Frequency + 受信周波数 + + + + Hz + Hz + + + Protocol プロトコル - + Registration ID 登録ID - + Multi Radio Protocol マルチプロトコル - + Sub Type サブタイプ - + Failsafe Mode フェイルセーフモード - + Not set 設定なし - + Hold ホールド - + Custom カスタム - + No Pulses パルスなし - + Receiver 受信機 - + Trainer Mode トレーナーモード - + Master/Jack マスター/Jack - + Slave/Jack スレーブ/Jack - + Master/SBUS Module マスター/SBUSモジュール - + Master/CPPM Module マスター/CPPMモジュール - + Master/SBUS in battery compartment マスター/バッテリーカバー内SBUB - + WARNING: Requires non-certified firmware! 警告: 未認定のR9Mファームウェアが必要です! - + Master/Bluetooth マスター/Bluetooth - + Slave/Bluetooth スレーブ/Bluetooth - + Master/Multi マスター/Multi - + Disable Telemetry テレメトリー無効 - + Disable Ch. Map チャンネルマップ無効 - + Failsafe Positions フェイルセーフポジション - + Show values in: 値の表示: - + % abbreviation for percent - + μs abbreviation for microseconds @@ -9190,85 +9222,110 @@ If blank then the mix is considered to be "ON" all the time. ModuleData - + Trainer Port トレーナーポート - + Internal Radio System 内部送信システム - + External Radio Module 外部送信モジュール - + Extra Radio System 追加送信システム - + Radio System 送信システム - + 10mW - 16CH - - + + 100mW - 16CH - + 500mW - 16CH - + Auto <= 1W - 16CH - - + + 25mW - 8CH - - + + 25mW - 16CH - + 200mW - 16CH (no telemetry) 200mW - 16CH (テレメトリーなし) - + 500mW - 16CH (no telemetry) 500mW - 16CH (テレメトリーなし) - + 100mW - 16CH (no telemetry) 100mW - 16CH (テレメトリーなし) - + + 25 mW + 25 mW + + + + 100 mW + 100 mW + + + + 500 mW + 500 mW + + + + 1 W + 1 W + + + + 2 W + 2 W + + + Positive ノーマル - + Negative リバース @@ -9276,47 +9333,42 @@ If blank then the mix is considered to be "ON" all the time. ModulePanel - + Value - + Hold ホールド - + No Pulse パルスなし - + Ask 確認 - + Internal 内部 - + Internal + External 内部 + 外部 - + External 外部 - - Autodetect Format - フォーマット自動検出 - - - + Bind on channel チャンネルへバインド @@ -9330,442 +9382,390 @@ If blank then the mix is considered to be "ON" all the time. - - + + Name 名称 - + EEprom Size EEPROMサイズ - + Model Image モデルイメージ - + Throttle スロットル - + Trims トリム - + Center Beep センター ビープ - + Switch Warnings スイッチ警告 - + Pot Warnings ダイヤル警告 - + Other その他 - + Timers タイマー - + Time 時間 - - + + Switch スイッチ - + Countdown カウントダウン - + Min.call 音声時報 - + Persist 持続 - + Modules モジュール - + Trainer port トレーナーポート - + Helicopter ヘリコプター - + Swash Swash - - + + Type タイプ - + Ring リング - + Input 入力 - + Weight ウェイト - + Long. cyc 長周期 - + Lateral cyc 側面周期 - + Collective コレクティブ - + Flight modes フライトモード - - + + Flight mode フライトモード - + F.In F.In - + F.Out F.Out - + Global vars グローバル変数 - - + + GV%1 GV%1 - + RE%1 RE%1 - - + Unit ユニット - + Prec 精度 - - + + Min 最小 - - + + Max 最大 - + Popup ポップアップ - + Outputs 出力 - + Channel チャンネル - + Subtrim サブトリム - + Direct ダイレクト - + Curve カーブ - + PPM PPM - + Linear 線形 - + Global Variables グローバル変数 - + Inputs 入力 - + Mixers ミキサー - + Curves カーブ - + L%1 L%1 - + Logical Switches 論理スイッチ - + SF%1 SF%1 - + Special Functions スペシャルファンクション - + Telemetry テレメトリー - - Analogs - アナログ - - - - Scale - スケール - - - - Offset - オフセット - - - + Protocol プロトコル - + RSSI Alarms RSSIアラーム - + Low - + Critical クリティカル - + Telemetry audio テレメトリー音源 - + Altimetry 高度計 - - + + Vario source バリオ 元値 - + Vario limits > バリオ リミット値 > - + Sink max Sink 最大 - + Sink min Sink 最小 - + Climb min クライム 最小 - + Climb max クライム 最大 - + Center silent センター サイレント - + Top Bar トップバー - - + Volts source ボルト 元値 - + Altitude source 高度 元値 - - Various - その他の設定 - - - - Serial protocol - シリアル プロトコル - - - - FAS offset - FAS オフセット - - - - mAh count - mAh カウント - - - - Persistent mAh - 持続 mAh - - - - Current source - 現在の元値 - - - - Blades - ブレード - - - + Parameters パラメータ - + Telemetry Sensors テレメトリーセンサー - + Telemetry Screens テレメトリースクリーン - + GF%1 GF%1 - + Global Functions グローバルファンクション - + Checklist チェックリスト @@ -9789,13 +9789,13 @@ If blank then the mix is considered to be "ON" all the time. - Telemetry - テレメトリー + RF power + 送信出力 - Radio output power - 送信機 送信出力 + Telemetry + テレメトリー @@ -9844,22 +9844,22 @@ If blank then the mix is considered to be "ON" all the time. OpenTxEepromInterface - + Unknown error 不明のエラー - + ... plus %1 errors ...追加 %1 エラー - + Cannot write radio settings 送信機設定を書き込めません - + Cannot write model %1 機体モデル %1 を書き込めません @@ -10126,25 +10126,20 @@ If blank then the mix is considered to be "ON" all the time. RadioInterface - + Cannot write file %1: %2. ファイルを書き込めません %1: %2. - - <b><u>WARNING!</u></b><br>This will reset the fuses of %1 to the factory settings.<br>Writing fuses can mess up your radio.<br>Do this only if you are sure they are wrong!<br>Are you sure you want to continue? - <b><u>WARNING!</u></b><br>これにより %1 のヒューズが工場出荷時の設定にリセットされます。<br>ヒューズを作成すると送信機が故障する可能性があります。<br>操作が間違っているかと思います!<br>本当に続行しても宜しいですか? - - - - + + Could not delete temporary file: %1 一時ファイルを削除できませんでした: %1 - + Unable to find radio SD card! 送信機のSDカードが見つかりません! @@ -10287,439 +10282,131 @@ X RawSource - - - - + V V - - - - + + s s - - ft - - - - - - m - - - - - °C - - - - - ° - - - - - % - - - - - - mph - - - - - - km/h - - - - - m/s - - - - - A - - - - - mAh - - - - - W - - - - - g - - - - + TrmR トリムR - + TrmE トリムE - + TrmT トリムT - + TrmA トリムA - + Trm5 トリム5 - + Trm6 トリム6 - + TrmH トリム横 - + TrmV トリム縦 - - + Batt - - + Time 時間 - - + Timer1 タイマー1 - - + Timer2 タイマー2 - - + Timer3 タイマー3 - - RAS - - - - - RSSI Tx - RSSI送信 - - - - RSSI Rx - RSSI受信 - - - - A1 - - - - - A2 - - - - - A3 - - - - - A4 - - - - - Alt - - - - - Rpm - RPM - - - - Fuel - 燃料 - - - - T1 - - - - - T2 - - - - - Speed - 速度 - - - - Dist - - - - - GPS Alt - - - - - Cell - セル - - - - Cells - セル - - - - Vfas - - - - - Curr - - - - - Cnsp - - - - - Powr - - - - - AccX - - - - - AccY - - - - - AccZ - - - - - Hdg - - - - - VSpd - - - - - AirSpeed - エアスピード - - - - dTE - - - - - A1- - - - - - A2- - - - - - A3- - - - - - A4- - - - - - Alt- - - - - - Alt+ - - - - - Rpm+ - RPM+ - - - - T1+ - - - - - T2+ - - - - - Speed+ - 速度+ - - - - Dist+ - - - - - AirSpeed+ - エアスピード+ - - - - Cell- - セル- - - - - Cells- - セル- - - - - Vfas- - - - - - Curr+ - - - - - Powr+ - - - - - ACC - - - - - GPS Time - - - - + REa エンコーダ再生a - + REb エンコーダ再生b - - + + ??? - + ---- - + I as in Input - + LUA%1%2 - + MAX 最大 - + CYC%1 - + TR as in Trainer - + SRC @@ -11088,7 +10775,22 @@ X - + + Hertz + + + + + mS + + + + + uS + + + + TELE @@ -11101,117 +10803,117 @@ X タイマー 1 - + Top LCD Timer 液晶タイマー - + Model Image モデルイメージ - + Warnings 警告 - + Switch Warnings スイッチ警告 - + Pot Warnings ダイヤル警告 - + OFF OFF - + Manual 手動 - + Auto 自動 - + Model 機体モデル - + Center beep センター ビープ - + Display Checklist チェックリスト表示 - + Never なし - + On change 変更 - + Always 常に - + Throttle Trim Idle Only THRトリムアイドル - + Global Functions グローバルファンクション - + Throttle Warning スロットル警告 - + Exponential エクスポ - + Extra Fine 極細 - + Fine 細かめ - + Medium 中間 - + Coarse 粗め - + Reverse throttle operation. If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well. @@ -11220,47 +10922,52 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi これがチェックされている場合、スロットル操作が逆になります。アイドルは前方になり、トリムもまた逆になり、スロットル警告も逆になります。 - + Reverse Throttle スロットル リバース - + Edit Checklist... チェックリストの編集... - + + Throttle trim switch + スロットル トリムスイッチ + + + Extended Trims 拡張トリム - + Extended Limits 拡張制限 - + Throttle Source スロットル値 - + Trim Step トリム間隔 - + Trims Display トリム表示 - + Timer 2 タイマー 2 - + Timer 3 タイマー 3 @@ -11268,87 +10975,92 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi SetupPanel - + Popup menu available 利用可能なポップアップメニュー - + Timer %1 タイマー %1 - + THR - + Profile Settings プロファイル設定 - + SD structure path not specified or invalid SDカード保存先パスが指定されていないか無効です - + Copy コピー - + Cut 切り取り - + Paste 貼り付け - + Clear 消去 - + Insert 挿入 - + Delete 削除 - + Move Up 上へ移動 - + Move Down 下へ移動 - + Clear All すべて消去 - + Clear Timer. Are you sure? タイマーを消去します。よろしいですか? - + Clear all Timers. Are you sure? タイマーをすべて消去します。よろしいですか? - + + Cut Timer. Are you sure? + タイマーを切り取ります。よろしいですか? + + + Delete Timer. Are you sure? タイマーを削除します。よろしいですか? @@ -12074,62 +11786,62 @@ The default is configured in the chosen Radio Profile. 送信機シミュレータ (%1) - + Could not determine startup data source. 起動データ元を特定できませんでした。 - + Could not load data, possibly wrong format. データをロードできません、フォーマットが間違っている可能性があります。 - + Data Load Error データロード エラー - + Invalid startup data provided. Plese specify a proper file/path. 無効なスタートアップデータが提供されました。正しいファイル/パスを指定してください。 - + Simulator Startup Error シミュレータ スタートアップ エラー - + Error saving data: could open file for writing: '%1' データ保存エラー: 書き込み用にファイルを開くことができました: 「%1」 - + Error saving data: could not get data from simulator interface. データ保存エラー: シミュレータのインターフェイスからデータを取得できませんでした。 - + An unexpected error occurred while attempting to save radio data to file '%1'. 送信機データをファイル「%1」に保存しようとしたときに予期せぬエラーが発生しました。 - + Data Save Error データ保存 エラー - + Cannot open joystick, joystick disabled スティックが接続不可、もしくはスティックが無効です - + Radio firmware error: %1 送信機 ファームウェア エラー: %1 - + - Flight Mode %1 (#%2) - フライトモード %1 (#%2) @@ -12773,11 +12485,6 @@ Too many errors, giving up. mAmps (mA) ミリアンペア (mA) - - - Range - レンジ - TelemetryCustomScreen @@ -12807,22 +12514,22 @@ Too many errors, giving up. 最大 - + None なし - + Numbers ナンバー - + Bars バー - + Script スクリプト @@ -12830,107 +12537,112 @@ Too many errors, giving up. TelemetryPanel - + Telemetry screen %1 テレメトリースクリーン %1 - + FrSky S.PORT - + FrSky D - + FrSky D (cable) - + Source 信号元 - + Low Alarm 低アラーム - + Critical Alarm クリティカルアラーム - + Winged Shadow How High Winged Shadow How High - + Winged Shadow How High (not supported) Winged Shadow How High (サポートなし) - + Alti - + Alti+ - + VSpeed - - - + + + A1 - - - + + + A2 - - + + A3 - - + + A4 - - + + FAS - + Cells セル - + --- --- + + + Delete Sensor. Are you sure? + テレメトリーセンサーを削除します。よろしいですか? + TelemetrySensor @@ -13225,67 +12937,92 @@ Too many errors, giving up. TelemetrySensorPanel - + TELE%1 - + Popup menu available 利用可能なポップアップメニュー - + Lowest より低く - + Cell %1 セル %1 - + Highest より高く - + Delta 差分 - + Copy コピー - + Cut 切り取り - + Paste 貼り付け - + Clear 消去 - + + Insert + 挿入 + + + + Delete + 削除 + + + + Move Up + 上へ移動 + + + + Move Down + 下へ移動 + + + Clear All すべて消去 - + + Cut Telemetry Sensor. Are you sure? + テレメトリーセンサーを切り取ります。よろしいですか? + + + Clear Telemetry Sensor. Are you sure? テレメトリーセンサーを消去します。よろしいですか? - + Clear all Telemetry Sensors. Are you sure? テレメトリーセンサーのすべてを消去します。よろしいですか? @@ -13669,13 +13406,19 @@ hh:mm:ss TMR - + TMR Timer %1 タイマー %1 + + + TMR + as in Timer + TMR + TimerEdit @@ -13705,37 +13448,37 @@ CTRL+スクロールまたはPAGE UP/DOWNキーを押すと、大きなステ TimerPanel - + Silent 消音 - + Beeps ビープ - + Voice 音声 - + Haptic タッチパネル - + Not persistent 持続なし - + Persistent (flight) 持続 (フライト) - + Persistent (manual reset) 持続 (手動リセット) @@ -14297,74 +14040,42 @@ CTRL+スクロールまたはPAGE UP/DOWNキーを押すと、大きなステ プログラムの設定 - - + + Location of sam-ba executable sam-ba実行ファイル場所 - - - - + + + The location of the AVRDUDE executable. AVRDUDE実行ファイル場所. - + DFU-Util Location DFU-Utiltyの場所 - - Location of AVRDUDE executable - AVRDUDE実行ファイル場所 - - - - - + + Use this button to browse and look for the AVRDUDE executable file. AVRDUDE実行ファイルを参照・検索するには、このボタンを押してください。 - - - + + Browse... 参照... - - Programmer - プログラム - - - - Programmer used for communicating with the controller. -Please consult the programmer's documentation and the AVRDUDE documentation to select the appropriate programmer. - コントローラとの通信に使用されるプログラムです。 -適切なプログラムを選択するには、プログラム側の資料とAVRDUDEの資料を参照してください。 - - - - List all available programmers. - 利用可能なプログラムを一覧表示します。 - - - - List Available - 一覧表示 - - - - + Extra arguments that will be passed to AVRDUDE on every call すべての呼び出しでAVRDUDEに渡される追加引数 - - + Extra arguments used in AVRDUDE. This can be used for providing extra information to AVRDUDE. @@ -14375,51 +14086,17 @@ Please only use this if you know what you are doing. There are no error checks こちらは自己責任においてご利用ください。エラーチェックは行われません。不具合がある場合コントローラが制御不能となる可能性があります。 - - Extra Arguments - 追加引数 - - - - Show AVRDUDE help - AVRDUDEのヘルプを表示します - - - - Show Help - ヘルプを表示 - - - - Communication port to the programmer. - - プログラムへの通信ポートです。 - - - - + Port ポート - - AVRDUDE Location - AVRDUDEの場所 - - - - MCU - MCU - - - - + CPU of your TX 送信機のCPU - - + CPU present on your 9x radio Should be m64 for stock radios m2560 for v4.1 boards @@ -14428,72 +14105,51 @@ m2560 for v4.1 boards v4.1ボード用m2560 - + at91sam3s8-9xr at91sam3s8-9xr - + SAM-BA Location SAM-BAの場所 - + ARM MCU ARM MCU - + sam-ba serial port sam-ba シリアルポート - + Alternate device 代替デバイス - + Use advanced controls 詳細設定を使用 - + DFU-UTIL Configuration DFU-Utility 設定 - + SAM-BA Configuration SAM-BA 設定 - - AVRDUDE Configuration - AVRDUDE 設定 - - - - - + + Select Location 場所の選択 - - - List available programmers - 利用可能なプログラムを一覧表示します - - - - Avrdude help - Avrdude ヘルプ - - - - <b><u>WARNING!</u></b><br>Normally CPU type is automatically selected according to the chosen firmware.<br>If you change the CPU type the resulting eeprom could be inconsistent. - <b><u>警告!</u></b><br>通常CPUタイプは、選択されたファームウェアによって自動的に選択されます。<br>CPUタイプを変更すると、その結果EEPROMに矛盾が生じる可能性があります。 - joystickDialog From a82ed914c9e431a1f45772d587655d8858b2f64a Mon Sep 17 00:00:00 2001 From: 3djc Date: Sat, 10 Oct 2020 09:46:07 +0200 Subject: [PATCH 025/231] Allow backlight function to turn off backlight entirely (#8005) --- radio/src/functions.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/radio/src/functions.cpp b/radio/src/functions.cpp index 6b41254c4..4806d3584 100644 --- a/radio/src/functions.cpp +++ b/radio/src/functions.cpp @@ -358,7 +358,10 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext { getvalue_t raw = getValue(CFN_PARAM(cfn)); #if defined(COLORLCD) - requiredBacklightBright = (1024 - raw) * (BACKLIGHT_LEVEL_MAX - BACKLIGHT_LEVEL_MIN) / 2048; + if (raw == -1024) + requiredBacklightBright = 100; + else + requiredBacklightBright = (1024 - raw) * (BACKLIGHT_LEVEL_MAX - BACKLIGHT_LEVEL_MIN) / 2048; #else requiredBacklightBright = (1024 - raw) * 100 / 2048; #endif From f02bf874fd09dee1f28270792ba4e96d5eb9a574 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sat, 10 Oct 2020 17:26:10 +0200 Subject: [PATCH 026/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index 96973332d..2603cc08a 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1950,3 +1950,4 @@ Michael Florey Gerhard Weixelbaumer Peter K Lehotsky Elisha Jones +Joerg Sattler From 15bd01062c3c99dc96d627954e5cb8653ad1e49d Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 11 Oct 2020 10:37:28 +0200 Subject: [PATCH 027/231] Update CREDITS.txt --- CREDITS.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CREDITS.txt b/CREDITS.txt index 2603cc08a..5925343ac 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1951,3 +1951,7 @@ Gerhard Weixelbaumer Peter K Lehotsky Elisha Jones Joerg Sattler +paul42 +Pascal Heg +Bjorn Sorenssen +Chris Payne From dfda43c6cefb3d991ee2a073d4ae6ac257f55323 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 11 Oct 2020 11:27:05 +0200 Subject: [PATCH 028/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index 5925343ac..ce62699f5 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1955,3 +1955,4 @@ paul42 Pascal Heg Bjorn Sorenssen Chris Payne +Pascal Afflard From e1778cde065e58fe236c3b7c00c6153cabfff5f3 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 11 Oct 2020 16:57:31 +0200 Subject: [PATCH 029/231] Update CREDITS.txt --- CREDITS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CREDITS.txt b/CREDITS.txt index ce62699f5..c81b56dec 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1956,3 +1956,5 @@ Pascal Heg Bjorn Sorenssen Chris Payne Pascal Afflard +Robert Boboryko +Chris Whitehead From 364e49d0a7f1d9363abe0498d20195c3517446cb Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 11 Oct 2020 21:20:46 +0200 Subject: [PATCH 030/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index c81b56dec..00c1a6d1f 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1958,3 +1958,4 @@ Chris Payne Pascal Afflard Robert Boboryko Chris Whitehead +David Bradley From a5697000ae0992fc2a7e2abd5aefa9094b50bac2 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 11 Oct 2020 23:05:47 +0200 Subject: [PATCH 031/231] Update CREDITS.txt --- CREDITS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS.txt b/CREDITS.txt index 00c1a6d1f..9daf8d522 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1959,3 +1959,4 @@ Pascal Afflard Robert Boboryko Chris Whitehead David Bradley +Ian Lever From a920f0cbe3d6e6bccbe4264f9acf02ee6f0d8a2e Mon Sep 17 00:00:00 2001 From: 3djc Date: Mon, 12 Oct 2020 17:58:08 +0200 Subject: [PATCH 032/231] Correct stylesheet --- .idea/codeStyles/Project.xml | 1 + .idea/codeStyles/codeStyleConfig.xml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 777209761..efad3ce27 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -7,6 +7,7 @@