mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-26 01:35:16 +03:00
Add data models to setup timers
This commit is contained in:
parent
b4478ea48f
commit
c40136d08a
12 changed files with 179 additions and 137 deletions
|
@ -717,6 +717,16 @@ AbstractItemModel * CompoundItemModelFactory::getItemModel(const int id) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractItemModel * CompoundItemModelFactory::getItemModel(const QString name) const
|
||||||
|
{
|
||||||
|
foreach (AbstractItemModel * itemModel, registeredItemModels) {
|
||||||
|
if (itemModel->getName() == name)
|
||||||
|
return itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool CompoundItemModelFactory::isItemModelRegistered(const int id) const
|
bool CompoundItemModelFactory::isItemModelRegistered(const int id) const
|
||||||
{
|
{
|
||||||
foreach (AbstractItemModel * itemModel, registeredItemModels) {
|
foreach (AbstractItemModel * itemModel, registeredItemModels) {
|
||||||
|
|
|
@ -363,6 +363,7 @@ class CompoundItemModelFactory
|
||||||
void unregisterItemModel(const int id);
|
void unregisterItemModel(const int id);
|
||||||
bool isItemModelRegistered(const int id) const;
|
bool isItemModelRegistered(const int id) const;
|
||||||
AbstractItemModel * getItemModel(const int id) const;
|
AbstractItemModel * getItemModel(const int id) const;
|
||||||
|
AbstractItemModel * getItemModel(const QString name) const;
|
||||||
void update(const int event = AbstractItemModel::IMUE_SystemRefresh);
|
void update(const int event = AbstractItemModel::IMUE_SystemRefresh);
|
||||||
void dumpAllItemModelContents() const;
|
void dumpAllItemModelContents() const;
|
||||||
|
|
||||||
|
|
|
@ -47,3 +47,24 @@ QString DataHelpers::getElementName(const QString & prefix, const unsigned int i
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DataHelpers::timeToString(const int value, const unsigned int mask)
|
||||||
|
{
|
||||||
|
bool negative = value < 0 ? true : false;
|
||||||
|
int val = abs(value);
|
||||||
|
|
||||||
|
QString result = QString("%1").arg(negative ? "-" : ((mask & TIMESTR_MASK_PADSIGN) ? " " : ""));
|
||||||
|
|
||||||
|
if (mask & TIMESTR_MASK_HRSMINS) {
|
||||||
|
int hours = val / 3600;
|
||||||
|
if (hours > 0 || (mask & TIMESTR_MASK_ZEROHRS)) {
|
||||||
|
val -= hours * 3600;
|
||||||
|
result.append(QString("%1:").arg(hours, 2, 10, QLatin1Char('0')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int minutes = val / 60;
|
||||||
|
int seconds = val % 60;
|
||||||
|
result.append(QString("%1:%2").arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,11 @@ class FieldRange
|
||||||
QString unit;
|
QString unit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
constexpr unsigned int TIMESTR_MASK_HRSMINS { 1 << 1 };
|
||||||
|
constexpr unsigned int TIMESTR_MASK_ZEROHRS { 1 << 2 };
|
||||||
|
constexpr unsigned int TIMESTR_MASK_PADSIGN { 1 << 3 };
|
||||||
|
|
||||||
namespace DataHelpers
|
namespace DataHelpers
|
||||||
{
|
{
|
||||||
enum BoolFormat {
|
enum BoolFormat {
|
||||||
|
@ -59,5 +64,6 @@ namespace DataHelpers
|
||||||
|
|
||||||
QString boolToString(const bool value, const BoolFormat format);
|
QString boolToString(const bool value, const BoolFormat format);
|
||||||
QString getElementName(const QString & prefix, const unsigned int index, const char * name = 0, const bool padding = false);
|
QString getElementName(const QString & prefix, const unsigned int index, const char * name = 0, const bool padding = false);
|
||||||
|
QString timeToString(const int value, const unsigned int mask);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "timerdata.h"
|
#include "timerdata.h"
|
||||||
#include "radiodataconversionstate.h"
|
#include "radiodataconversionstate.h"
|
||||||
|
#include "compounditemmodels.h"
|
||||||
|
|
||||||
void TimerData::convert(RadioDataConversionState & cstate)
|
void TimerData::convert(RadioDataConversionState & cstate)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +37,7 @@ void TimerData::clear()
|
||||||
|
|
||||||
bool TimerData::isEmpty()
|
bool TimerData::isEmpty()
|
||||||
{
|
{
|
||||||
return (mode == RawSwitch(SWITCH_TYPE_TIMER_MODE, 0) && name[0] == '\0' && minuteBeep == 0 && countdownBeep == COUNTDOWN_SILENT && val == 0 && persistent == 0 /*&& pvalue == 0*/);
|
return (mode == RawSwitch(SWITCH_TYPE_TIMER_MODE, 0) && name[0] == '\0' && minuteBeep == 0 && countdownBeep == COUNTDOWNBEEP_SILENT && val == 0 && persistent == 0 /*&& pvalue == 0*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimerData::isModeOff()
|
bool TimerData::isModeOff()
|
||||||
|
@ -59,9 +60,14 @@ QString TimerData::countdownStartToString() const
|
||||||
return countdownStartToString(countdownStart);
|
return countdownStartToString(countdownStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TimerData::persistentToString() const
|
QString TimerData::persistentToString(const bool verbose) const
|
||||||
{
|
{
|
||||||
return persistentToString(persistent);
|
return persistentToString(persistent, verbose);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TimerData::pvalueToString() const
|
||||||
|
{
|
||||||
|
return pvalueToString(pvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -99,25 +105,31 @@ QString TimerData::countdownStartToString(const int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
QString TimerData::persistentToString(const int value)
|
QString TimerData::persistentToString(const int value, const bool verbose)
|
||||||
{
|
{
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case PERSISTENT_NOT:
|
case PERSISTENT_NOT:
|
||||||
return tr("Not persistent");
|
return verbose ? tr("Not persistent") : tr("NOT");
|
||||||
case PERSISTENT_FLIGHT:
|
case PERSISTENT_FLIGHT:
|
||||||
return tr("Persistent (flight)");
|
return verbose ? tr("Persistent (flight)") : tr("Flight");
|
||||||
case PERSISTENT_MANUALRESET:
|
case PERSISTENT_MANUALRESET:
|
||||||
return tr("Persistent (manual reset)");
|
return verbose ? tr("Persistent (manual reset)") : tr("Manual reset");
|
||||||
default:
|
default:
|
||||||
return CPN_STR_UNKNOWN_ITEM;
|
return CPN_STR_UNKNOWN_ITEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QString TimerData::pvalueToString(const int value)
|
||||||
|
{
|
||||||
|
return DataHelpers::timeToString(value, TIMESTR_MASK_HRSMINS);
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
AbstractStaticItemModel * TimerData::countdownBeepItemModel()
|
AbstractStaticItemModel * TimerData::countdownBeepItemModel()
|
||||||
{
|
{
|
||||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||||
mdl->setName("timerdata.countdownBeep");
|
mdl->setName(AIM_TIMER_COUNTDOWNBEEP);
|
||||||
|
|
||||||
for (int i = 0; i < COUNTDOWNBEEP_COUNT; i++) {
|
for (int i = 0; i < COUNTDOWNBEEP_COUNT; i++) {
|
||||||
QString str = countdownBeepToString(i);
|
QString str = countdownBeepToString(i);
|
||||||
|
@ -131,7 +143,7 @@ AbstractStaticItemModel * TimerData::countdownBeepItemModel()
|
||||||
AbstractStaticItemModel * TimerData::countdownStartItemModel()
|
AbstractStaticItemModel * TimerData::countdownStartItemModel()
|
||||||
{
|
{
|
||||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||||
mdl->setName("timerdata.countdownStart");
|
mdl->setName(AIM_TIMER_COUNTDOWNSTART);
|
||||||
|
|
||||||
for (int i = COUNTDOWNSTART_LAST - 1; i >= COUNTDOWNSTART_FIRST; i--) {
|
for (int i = COUNTDOWNSTART_LAST - 1; i >= COUNTDOWNSTART_FIRST; i--) {
|
||||||
QString str = countdownStartToString(i);
|
QString str = countdownStartToString(i);
|
||||||
|
@ -145,7 +157,7 @@ AbstractStaticItemModel * TimerData::countdownStartItemModel()
|
||||||
AbstractStaticItemModel * TimerData::persistentItemModel()
|
AbstractStaticItemModel * TimerData::persistentItemModel()
|
||||||
{
|
{
|
||||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||||
mdl->setName("timerdata.persistent");
|
mdl->setName(AIM_TIMER_PERSISTENT);
|
||||||
|
|
||||||
for (int i = 0; i < PERSISTENT_COUNT; i++) {
|
for (int i = 0; i < PERSISTENT_COUNT; i++) {
|
||||||
QString str = persistentToString(i);
|
QString str = persistentToString(i);
|
||||||
|
|
|
@ -26,8 +26,13 @@
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
class RadioDataConversionState;
|
class RadioDataConversionState;
|
||||||
|
class AbstractStaticItemModel;
|
||||||
|
|
||||||
#define TIMER_NAME_LEN 8
|
constexpr char AIM_TIMER_COUNTDOWNBEEP[] {"timerdata.countdownBeep"};
|
||||||
|
constexpr char AIM_TIMER_COUNTDOWNSTART[] {"timerdata.countdownStart"};
|
||||||
|
constexpr char AIM_TIMER_PERSISTENT[] {"timerdata.persistent"};
|
||||||
|
|
||||||
|
constexpr int TIMER_NAME_LEN {8};
|
||||||
|
|
||||||
class TimerData {
|
class TimerData {
|
||||||
Q_DECLARE_TR_FUNCTIONS(TimerData)
|
Q_DECLARE_TR_FUNCTIONS(TimerData)
|
||||||
|
@ -74,13 +79,15 @@ class TimerData {
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
bool isModeOff();
|
bool isModeOff();
|
||||||
QString nameToString(int index) const;
|
QString nameToString(int index) const;
|
||||||
QString countdownBeepToString();
|
QString countdownBeepToString() const;
|
||||||
QString countdownStartToString();
|
QString countdownStartToString() const;
|
||||||
QString persistentToString();
|
QString persistentToString(const bool verbose = true) const;
|
||||||
|
QString pvalueToString() const;
|
||||||
|
|
||||||
static QString countdownBeepToString(const int value);
|
static QString countdownBeepToString(const int value);
|
||||||
static QString countdownStartToString(const int value);
|
static QString countdownStartToString(const int value);
|
||||||
static QString persistentToString(const int value);
|
static QString persistentToString(const int value, const bool verbose = true);
|
||||||
|
static QString pvalueToString(const int value);
|
||||||
static AbstractStaticItemModel * countdownBeepItemModel();
|
static AbstractStaticItemModel * countdownBeepItemModel();
|
||||||
static AbstractStaticItemModel * countdownStartItemModel();
|
static AbstractStaticItemModel * countdownStartItemModel();
|
||||||
static AbstractStaticItemModel * persistentItemModel();
|
static AbstractStaticItemModel * persistentItemModel();
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "ui_setup.h"
|
#include "ui_setup.h"
|
||||||
#include "ui_setup_timer.h"
|
#include "ui_setup_timer.h"
|
||||||
#include "ui_setup_module.h"
|
#include "ui_setup_module.h"
|
||||||
#include "filtereditemmodels.h"
|
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "modelprinter.h"
|
#include "modelprinter.h"
|
||||||
#include "multiprotocols.h"
|
#include "multiprotocols.h"
|
||||||
|
@ -31,54 +30,51 @@
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
constexpr char FIM_TIMERSWITCH[] {"Timer Switch"};
|
||||||
|
constexpr char FIM_THRSOURCE[] {"Throttle Source"};
|
||||||
|
|
||||||
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware,
|
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware,
|
||||||
QWidget * prevFocus, FilteredItemModel * rawSwitchFilteredModel):
|
QWidget * prevFocus, FilteredItemModelFactory * panelFilteredModels, CompoundItemModelFactory * panelItemModels):
|
||||||
ModelPanel(parent, model, generalSettings, firmware),
|
ModelPanel(parent, model, generalSettings, firmware),
|
||||||
timer(timer),
|
timer(timer),
|
||||||
ui(new Ui::Timer)
|
ui(new Ui::Timer)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connectItemModelEvents(rawSwitchFilteredModel);
|
connectItemModelEvents(panelFilteredModels->getItemModel(FIM_TIMERSWITCH));
|
||||||
|
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
int length = firmware->getCapability(TimersName);
|
int length = firmware->getCapability(TimersName);
|
||||||
if (length == 0) {
|
if (length == 0)
|
||||||
ui->name->hide();
|
ui->name->hide();
|
||||||
}
|
else
|
||||||
else {
|
ui->name->setField(timer.name, length, this);
|
||||||
ui->name->setMaxLength(length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mode
|
// Mode
|
||||||
ui->mode->setModel(rawSwitchFilteredModel);
|
ui->mode->setModel(panelFilteredModels->getItemModel(FIM_TIMERSWITCH));
|
||||||
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
|
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
|
||||||
connect(ui->mode, SIGNAL(activated(int)), this, SLOT(onModeChanged(int)));
|
connect(ui->mode, SIGNAL(activated(int)), this, SLOT(onModeChanged(int)));
|
||||||
|
|
||||||
|
ui->countdownBeep->setModel(panelItemModels->getItemModel(AIM_TIMER_COUNTDOWNBEEP));
|
||||||
|
ui->countdownBeep->setField(timer.countdownBeep, this);
|
||||||
|
|
||||||
|
ui->value->setMaximumTime(firmware->getMaxTimerStart());
|
||||||
|
|
||||||
|
ui->minuteBeep->setField(timer.minuteBeep, this);
|
||||||
|
|
||||||
if (!firmware->getCapability(PermTimers)) {
|
if (!firmware->getCapability(PermTimers)) {
|
||||||
ui->persistent->hide();
|
ui->persistent->hide();
|
||||||
ui->persistentValue->hide();
|
ui->persistentValue->hide();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
ui->countdownBeep->setField(timer.countdownBeep, this);
|
ui->persistent->setModel(panelItemModels->getItemModel(AIM_TIMER_PERSISTENT));
|
||||||
ui->countdownBeep->addItem(tr("Silent"), TimerData::COUNTDOWN_SILENT);
|
|
||||||
ui->countdownBeep->addItem(tr("Beeps"), TimerData::COUNTDOWN_BEEPS);
|
|
||||||
ui->countdownBeep->addItem(tr("Voice"), TimerData::COUNTDOWN_VOICE);
|
|
||||||
ui->countdownBeep->addItem(tr("Haptic"), TimerData::COUNTDOWN_HAPTIC);
|
|
||||||
|
|
||||||
ui->value->setMaximumTime(firmware->getMaxTimerStart());
|
|
||||||
|
|
||||||
ui->persistent->setField(timer.persistent, this);
|
ui->persistent->setField(timer.persistent, this);
|
||||||
ui->persistent->addItem(tr("Not persistent"), 0);
|
ui->persistentValue->setText(timer.pvalueToString());
|
||||||
ui->persistent->addItem(tr("Persistent (flight)"), 1);
|
}
|
||||||
ui->persistent->addItem(tr("Persistent (manual reset)"), 2);
|
|
||||||
|
|
||||||
|
ui->countdownStart->setModel(panelItemModels->getItemModel(AIM_TIMER_COUNTDOWNSTART));
|
||||||
ui->countdownStart->setField(timer.countdownStart, this);
|
ui->countdownStart->setField(timer.countdownStart, this);
|
||||||
ui->countdownStart->addItem("5s", 1);
|
|
||||||
ui->countdownStart->addItem("10s", 0);
|
|
||||||
ui->countdownStart->addItem("20s", -1);
|
|
||||||
ui->countdownStart->addItem("30s", -2);
|
|
||||||
|
|
||||||
disableMouseScrolling();
|
disableMouseScrolling();
|
||||||
QWidget::setTabOrder(prevFocus, ui->name);
|
QWidget::setTabOrder(prevFocus, ui->name);
|
||||||
|
@ -102,31 +98,17 @@ void TimerPanel::update()
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
ui->name->setText(timer.name);
|
ui->name->updateValue();
|
||||||
|
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
|
||||||
|
|
||||||
int hour = timer.val / 3600;
|
int hour = timer.val / 3600;
|
||||||
int min = (timer.val - (hour * 3600)) / 60;
|
int min = (timer.val - (hour * 3600)) / 60;
|
||||||
int sec = (timer.val - (hour * 3600)) % 60;
|
int sec = (timer.val - (hour * 3600)) % 60;
|
||||||
|
|
||||||
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
|
|
||||||
ui->value->setTime(QTime(hour, min, sec));
|
ui->value->setTime(QTime(hour, min, sec));
|
||||||
|
|
||||||
if (firmware->getCapability(PermTimers)) {
|
|
||||||
int sign = 1;
|
|
||||||
int pvalue = timer.pvalue;
|
|
||||||
if (pvalue < 0) {
|
|
||||||
pvalue = -pvalue;
|
|
||||||
sign = -1;
|
|
||||||
}
|
|
||||||
int hours = pvalue / 3600;
|
|
||||||
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->countdownBeep->updateValue();
|
ui->countdownBeep->updateValue();
|
||||||
ui->minuteBeep->setChecked(timer.minuteBeep);
|
ui->minuteBeep->updateValue();
|
||||||
|
if (firmware->getCapability(PermTimers))
|
||||||
ui->persistent->updateValue();
|
ui->persistent->updateValue();
|
||||||
ui->countdownStart->updateValue();
|
ui->countdownStart->updateValue();
|
||||||
lock = false;
|
lock = false;
|
||||||
|
@ -139,10 +121,17 @@ QWidget * TimerPanel::getLastFocus()
|
||||||
|
|
||||||
void TimerPanel::on_countdownBeep_currentIndexChanged(int index)
|
void TimerPanel::on_countdownBeep_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if(index == TimerData::COUNTDOWN_SILENT)
|
if (!lock) {
|
||||||
ui->countdownStart->hide();
|
const int start = ui->countdownStart->itemData(index).toInt();
|
||||||
|
if (start != timer.countdownStart) {
|
||||||
|
timer.countdownStart = start;
|
||||||
|
emit modified();
|
||||||
|
if(index == TimerData::COUNTDOWNBEEP_SILENT)
|
||||||
|
ui->countdownStart->setEnabled(false);
|
||||||
else
|
else
|
||||||
ui->countdownStart->show();
|
ui->countdownStart->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerPanel::on_value_editingFinished()
|
void TimerPanel::on_value_editingFinished()
|
||||||
|
@ -197,13 +186,28 @@ void TimerPanel::connectItemModelEvents(const FilteredItemModel * itemModel)
|
||||||
void TimerPanel::onItemModelAboutToBeUpdated()
|
void TimerPanel::onItemModelAboutToBeUpdated()
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
|
modelsUpdateCnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerPanel::onItemModelUpdateComplete()
|
void TimerPanel::onItemModelUpdateComplete()
|
||||||
{
|
{
|
||||||
|
modelsUpdateCnt--;
|
||||||
|
if (modelsUpdateCnt < 1) {
|
||||||
update();
|
update();
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimerPanel::on_countdownStart_currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
const int start = ui->countdownStart->itemData(index).toInt();
|
||||||
|
if (start != timer.countdownStart) {
|
||||||
|
timer.countdownStart = start;
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -1023,16 +1027,26 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
rawSwitchFilteredModel = new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_RawSwitch), RawSwitch::TimersContext);
|
lock = true;
|
||||||
connectItemModelEvents(rawSwitchFilteredModel);
|
|
||||||
|
|
||||||
thrSourceFilteredModel = new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_ThrSource));
|
panelFilteredModels = new FilteredItemModelFactory();
|
||||||
connectItemModelEvents(thrSourceFilteredModel);
|
|
||||||
|
panelFilteredModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_RawSwitch),
|
||||||
|
RawSwitch::TimersContext),
|
||||||
|
FIM_TIMERSWITCH);
|
||||||
|
connectItemModelEvents(panelFilteredModels->getItemModel(FIM_TIMERSWITCH));
|
||||||
|
|
||||||
|
panelFilteredModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_ThrSource)),
|
||||||
|
FIM_THRSOURCE);
|
||||||
|
connectItemModelEvents(panelFilteredModels->getItemModel(FIM_THRSOURCE));
|
||||||
|
|
||||||
|
panelItemModels = new CompoundItemModelFactory(&generalSettings, &model);
|
||||||
|
panelItemModels->registerItemModel(TimerData::countdownBeepItemModel());
|
||||||
|
panelItemModels->registerItemModel(TimerData::countdownStartItemModel());
|
||||||
|
panelItemModels->registerItemModel(TimerData::persistentItemModel());
|
||||||
|
|
||||||
Board::Type board = firmware->getBoard();
|
Board::Type board = firmware->getBoard();
|
||||||
|
|
||||||
lock = true;
|
|
||||||
|
|
||||||
memset(modules, 0, sizeof(modules));
|
memset(modules, 0, sizeof(modules));
|
||||||
|
|
||||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||||
|
@ -1112,7 +1126,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||||
|
|
||||||
for (int i = 0; i < CPN_MAX_TIMERS; i++) {
|
for (int i = 0; i < CPN_MAX_TIMERS; i++) {
|
||||||
if (i < timersCount) {
|
if (i < timersCount) {
|
||||||
timers[i] = new TimerPanel(this, model, model.timers[i], generalSettings, firmware, prevFocus, rawSwitchFilteredModel);
|
timers[i] = new TimerPanel(this, model, model.timers[i], generalSettings, firmware, prevFocus, panelFilteredModels, panelItemModels);
|
||||||
ui->gridLayout->addWidget(timers[i], 1+i, 1);
|
ui->gridLayout->addWidget(timers[i], 1+i, 1);
|
||||||
connect(timers[i], &TimerPanel::modified, this, &SetupPanel::modified);
|
connect(timers[i], &TimerPanel::modified, this, &SetupPanel::modified);
|
||||||
connect(timers[i], &TimerPanel::nameChanged, this, &SetupPanel::onTimerNameChanged);
|
connect(timers[i], &TimerPanel::nameChanged, this, &SetupPanel::onTimerNameChanged);
|
||||||
|
@ -1279,8 +1293,8 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||||
SetupPanel::~SetupPanel()
|
SetupPanel::~SetupPanel()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
delete rawSwitchFilteredModel;
|
delete panelFilteredModels;
|
||||||
delete thrSourceFilteredModel;
|
delete panelItemModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_extendedLimits_toggled(bool checked)
|
void SetupPanel::on_extendedLimits_toggled(bool checked)
|
||||||
|
|
|
@ -18,17 +18,15 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SETUP_H_
|
#pragma once
|
||||||
#define _SETUP_H_
|
|
||||||
|
|
||||||
#include "modeledit.h"
|
#include "modeledit.h"
|
||||||
#include "eeprominterface.h"
|
#include "eeprominterface.h"
|
||||||
|
#include "compounditemmodels.h"
|
||||||
|
#include "filtereditemmodels.h"
|
||||||
|
|
||||||
constexpr char MIMETYPE_TIMER[] = "application/x-companion-timer";
|
constexpr char MIMETYPE_TIMER[] = "application/x-companion-timer";
|
||||||
|
|
||||||
class CompoundItemModelFactory;
|
|
||||||
class FilteredItemModel;
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Setup;
|
class Setup;
|
||||||
class Timer;
|
class Timer;
|
||||||
|
@ -41,7 +39,7 @@ class TimerPanel : public ModelPanel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware,
|
TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware,
|
||||||
QWidget *prevFocus, FilteredItemModel * switchModel);
|
QWidget *prevFocus, FilteredItemModelFactory * panelFilteredModels, CompoundItemModelFactory * panelItemModels);
|
||||||
virtual ~TimerPanel();
|
virtual ~TimerPanel();
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
@ -55,6 +53,7 @@ class TimerPanel : public ModelPanel
|
||||||
void on_name_editingFinished();
|
void on_name_editingFinished();
|
||||||
void onItemModelAboutToBeUpdated();
|
void onItemModelAboutToBeUpdated();
|
||||||
void onItemModelUpdateComplete();
|
void onItemModelUpdateComplete();
|
||||||
|
void on_countdownStart_currentIndexChanged(int index);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
|
@ -63,6 +62,7 @@ class TimerPanel : public ModelPanel
|
||||||
TimerData & timer;
|
TimerData & timer;
|
||||||
Ui::Timer * ui;
|
Ui::Timer * ui;
|
||||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||||
|
int modelsUpdateCnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModulePanel : public ModelPanel
|
class ModulePanel : public ModelPanel
|
||||||
|
@ -199,10 +199,8 @@ class SetupPanel : public ModelPanel
|
||||||
bool moveTimerUpAllowed() const;
|
bool moveTimerUpAllowed() const;
|
||||||
void swapTimerData(int idx1, int idx2);
|
void swapTimerData(int idx1, int idx2);
|
||||||
CompoundItemModelFactory * sharedItemModels;
|
CompoundItemModelFactory * sharedItemModels;
|
||||||
FilteredItemModel * rawSwitchFilteredModel;
|
|
||||||
FilteredItemModel * thrSourceFilteredModel;
|
|
||||||
void updateItemModels();
|
void updateItemModels();
|
||||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||||
|
CompoundItemModelFactory * panelItemModels;
|
||||||
|
FilteredItemModelFactory * panelFilteredModels;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SETUP_H_
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>675</width>
|
<width>874</width>
|
||||||
<height>33</height>
|
<height>33</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="name">
|
<widget class="AutoLineEdit" name="name">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>80</width>
|
<width>80</width>
|
||||||
|
@ -68,11 +68,18 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="AutoComboBox" name="countdownBeep"/>
|
<widget class="AutoComboBox" name="countdownBeep"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="countdownStartLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="AutoComboBox" name="countdownStart"/>
|
<widget class="AutoComboBox" name="countdownStart"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="minuteBeep">
|
<widget class="AutoCheckBox" name="minuteBeep">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Minute Call</string>
|
<string>Minute Call</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -109,6 +116,16 @@
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header>autocombobox.h</header>
|
<header>autocombobox.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AutoLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>autolineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AutoCheckBox</class>
|
||||||
|
<extends>QCheckBox</extends>
|
||||||
|
<header>autocheckbox.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -938,36 +938,6 @@ QString ModelPrinter::printFailsafeMode(unsigned int fsmode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModelPrinter::printTimerCountdownBeep(unsigned int countdownBeep)
|
|
||||||
{
|
|
||||||
switch (countdownBeep) {
|
|
||||||
case TimerData::COUNTDOWN_SILENT:
|
|
||||||
return tr("Silent");
|
|
||||||
case TimerData::COUNTDOWN_BEEPS:
|
|
||||||
return tr("Beeps");
|
|
||||||
case TimerData::COUNTDOWN_VOICE:
|
|
||||||
return tr("Voice");
|
|
||||||
case TimerData::COUNTDOWN_HAPTIC:
|
|
||||||
return tr("Haptic");
|
|
||||||
default:
|
|
||||||
return CPN_STR_UNKNOWN_ITEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ModelPrinter::printTimerPersistent(unsigned int persistent)
|
|
||||||
{
|
|
||||||
switch (persistent) {
|
|
||||||
case 0:
|
|
||||||
return tr("OFF");
|
|
||||||
case 1:
|
|
||||||
return tr("Flight");
|
|
||||||
case 2:
|
|
||||||
return tr("Manual reset");
|
|
||||||
default:
|
|
||||||
return CPN_STR_UNKNOWN_ITEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ModelPrinter::printSettingsTrim()
|
QString ModelPrinter::printSettingsTrim()
|
||||||
{
|
{
|
||||||
QStringList str;
|
QStringList str;
|
||||||
|
@ -1042,16 +1012,6 @@ QString ModelPrinter::printTimerName(int idx)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ModelPrinter::printTimerTimeValue(unsigned int val)
|
|
||||||
{
|
|
||||||
return printTimeValue(val, MASK_TIMEVALUE_HRSMINS | MASK_TIMEVALUE_ZEROHRS);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ModelPrinter::printTimerMinuteBeep(bool mb)
|
|
||||||
{
|
|
||||||
return printBoolean(mb, BOOLEAN_YESNO);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ModelPrinter::printTelemetryProtocol(unsigned int val)
|
QString ModelPrinter::printTelemetryProtocol(unsigned int val)
|
||||||
{
|
{
|
||||||
switch (val) {
|
switch (val) {
|
||||||
|
|
|
@ -104,13 +104,9 @@ class ModelPrinter: public QObject
|
||||||
QString printFailsafe(int idx);
|
QString printFailsafe(int idx);
|
||||||
QString printFailsafeMode(unsigned int fsmode);
|
QString printFailsafeMode(unsigned int fsmode);
|
||||||
QString printFailsafeValue(int val);
|
QString printFailsafeValue(int val);
|
||||||
QString printTimerCountdownBeep(unsigned int countdownBeep);
|
|
||||||
QString printTimerPersistent(unsigned int persistent);
|
|
||||||
QString printPPMFrameLength(int ppmFL);
|
QString printPPMFrameLength(int ppmFL);
|
||||||
QString printTimerName(int idx);
|
QString printTimerName(int idx);
|
||||||
QString printTimeValue(const int value, const unsigned int mask);
|
QString printTimeValue(const int value, const unsigned int mask);
|
||||||
QString printTimerMinuteBeep(bool mb);
|
|
||||||
QString printTimerTimeValue(unsigned int val);
|
|
||||||
QString printTelemetryProtocol(unsigned int val);
|
QString printTelemetryProtocol(unsigned int val);
|
||||||
QString printLabelValue(const QString & lbl, const QString & val, const bool sep = false);
|
QString printLabelValue(const QString & lbl, const QString & val, const bool sep = false);
|
||||||
QString printLabelValues(const QString & lbl, const QStringList & vals, const bool sep = false);
|
QString printLabelValues(const QString & lbl, const QStringList & vals, const bool sep = false);
|
||||||
|
|
|
@ -341,11 +341,11 @@ QString MultiModelPrinter::printTimers()
|
||||||
columns.appendCellStart(20, true);
|
columns.appendCellStart(20, true);
|
||||||
COMPARE(modelPrinter->printTimerName(i));
|
COMPARE(modelPrinter->printTimerName(i));
|
||||||
columns.appendCellEnd(true);
|
columns.appendCellEnd(true);
|
||||||
COMPARECELLWIDTH(modelPrinter->printTimerTimeValue(model->timers[i].val), 15);
|
COMPARECELLWIDTH(DataHelpers::timeToString(model->timers[i].val, TIMESTR_MASK_HRSMINS), 15);
|
||||||
COMPARECELLWIDTH(model->timers[i].mode.toString(), 15);
|
COMPARECELLWIDTH(model->timers[i].mode.toString(), 15);
|
||||||
COMPARECELLWIDTH(modelPrinter->printTimerCountdownBeep(model->timers[i].countdownBeep), 15);
|
COMPARECELLWIDTH(model->timers[i].countdownBeepToString(), 15);
|
||||||
COMPARECELLWIDTH(modelPrinter->printTimerMinuteBeep(model->timers[i].minuteBeep), 15);
|
COMPARECELLWIDTH(DataHelpers::boolToString(model->timers[i].minuteBeep, DataHelpers::BOOL_FMT_YESNO), 15);
|
||||||
COMPARECELLWIDTH(modelPrinter->printTimerPersistent(model->timers[i].persistent), 20);
|
COMPARECELLWIDTH(model->timers[i].persistentToString(false), 20);
|
||||||
columns.appendRowEnd();
|
columns.appendRowEnd();
|
||||||
}
|
}
|
||||||
columns.appendTableEnd();
|
columns.appendTableEnd();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue