[Companion] Show custom control names throughout the UI (& internal refactoring) (#4693)
* [Companion] Introduce new Boards class to further consolidate hardware metadata and remove some globals.
* [Companion] * RawSource::toString() and RawSwitch::toString() can now return custom hardware names (if given a GeneralSettings object) for the following types (respectively):
SOURCE_TYPE_STICK, SOURCE_TYPE_SWITCH, SWITCH_TYPE_SWITCH, & SWITCH_TYPE_MULTIPOS_POT;
* RawSource::isPot() and isSlider() can now return their own index position in potConfig[]/sliderConfig[];
* Switch indicator strings can be localized if necessary.
* [Companion] Refactor model printers to use new RawSource/RawSwitch capabilities; Simplify model-to-printer mapping scheme in multimodelprinter; Use const ModelData pointer.
* [Companion] Refactor how RawSource and RawSwitch selection combo boxes are populated, using cache-able data models instead of direct manipulation; Refactor some other Helpers function into their own namespace.
* Cosmetics & forgotten qualifier.
This commit is contained in:
committed by
Bertrand Songis
parent
627347a48c
commit
f5ab145d2f
+38
-28
@@ -29,6 +29,7 @@
|
||||
#include <QDebug>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
extern const QColor colors[CPN_MAX_CURVES];
|
||||
|
||||
@@ -51,11 +52,6 @@ extern const QColor colors[CPN_MAX_CURVES];
|
||||
|
||||
#define TRIM_MODE_NONE 0x1F // 0b11111
|
||||
|
||||
void populateGvSourceCB(QComboBox *b, int value);
|
||||
void populateFileComboBox(QComboBox * b, const QSet<QString> & set, const QString & current);
|
||||
void getFileComboBoxValue(QComboBox * b, char * dest, int length);
|
||||
void populateRotEncCB(QComboBox *b, int value, int renumber);
|
||||
|
||||
QString getTheme();
|
||||
|
||||
class CompanionIcon: public QIcon {
|
||||
@@ -117,19 +113,6 @@ class CurveGroup : public QObject {
|
||||
int lastType;
|
||||
};
|
||||
|
||||
enum SwitchContext
|
||||
{
|
||||
LogicalSwitchesContext,
|
||||
SpecialFunctionsContext,
|
||||
GlobalFunctionsContext,
|
||||
TimersContext,
|
||||
MixesContext
|
||||
};
|
||||
|
||||
void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, SwitchContext context);
|
||||
|
||||
void populatePhasesCB(QComboBox *b, int value);
|
||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||
|
||||
#define POPULATE_NONE (1<<0)
|
||||
#define POPULATE_SOURCES (1<<1)
|
||||
@@ -144,8 +127,35 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||
#define GVARS_VARIANT 0x0001
|
||||
#define FRSKY_VARIANT 0x0002
|
||||
|
||||
void populateGVCB(QComboBox & b, int value, const ModelData & model);
|
||||
void populateSourceCB(QComboBox *b, const RawSource &source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags);
|
||||
namespace Helpers
|
||||
{
|
||||
enum SwitchContext
|
||||
{
|
||||
LogicalSwitchesContext,
|
||||
SpecialFunctionsContext,
|
||||
GlobalFunctionsContext,
|
||||
TimersContext,
|
||||
MixesContext
|
||||
};
|
||||
|
||||
void addRawSwitchItems(QStandardItemModel * itemModel, const RawSwitchType & type, int count, const GeneralSettings * const generalSettings = NULL);
|
||||
QStandardItemModel * getRawSwitchItemModel(const GeneralSettings * const generalSettings = NULL, SwitchContext context = LogicalSwitchesContext);
|
||||
|
||||
void addRawSourceItems(QStandardItemModel * itemModel, const RawSourceType & type, int count, const GeneralSettings * const generalSettings = NULL,
|
||||
const ModelData * const model = NULL, const int start = 0, const QList<int> exclude = QList<int>());
|
||||
QStandardItemModel * getRawSourceItemModel(const GeneralSettings * const generalSettings = NULL, const ModelData * const model = NULL, unsigned int flags = 0);
|
||||
|
||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||
void populateGvSourceCB(QComboBox *b, int value);
|
||||
void populatePhasesCB(QComboBox *b, int value);
|
||||
void populateGVCB(QComboBox & b, int value, const ModelData & model);
|
||||
|
||||
void populateFileComboBox(QComboBox * b, const QSet<QString> & set, const QString & current);
|
||||
void getFileComboBoxValue(QComboBox * b, char * dest, int length);
|
||||
} // namespace Helpers
|
||||
|
||||
// TODO : move to Helpers namespace
|
||||
|
||||
QString image2qstring(QImage image);
|
||||
int findmult(float value, float base);
|
||||
|
||||
@@ -162,14 +172,14 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx);
|
||||
QPixmap makePixMap(const QImage & image);
|
||||
|
||||
int version2index(const QString & version);
|
||||
QString index2version(int index);
|
||||
const QString index2version(int index);
|
||||
|
||||
class QTimeS : public QTime
|
||||
{
|
||||
public:
|
||||
QTimeS(int s) { int h = s/3600; s %= 3600; int m = s/60; s %=60; setHMS(h, m, s); };
|
||||
QTimeS(const QTime & q) : QTime(q) {};
|
||||
int seconds() const { return hour()*3600 + minute()*60 + second(); };
|
||||
QTimeS(int s) { int h = s/3600; s %= 3600; int m = s/60; s %=60; setHMS(h, m, s); }
|
||||
QTimeS(const QTime & q) : QTime(q) {}
|
||||
int seconds() const { return hour()*3600 + minute()*60 + second(); }
|
||||
};
|
||||
|
||||
bool qunlink(const QString & fileName);
|
||||
@@ -186,7 +196,7 @@ bool caseInsensitiveLessThan(const QString &s1, const QString &s2);
|
||||
class GpsCoord
|
||||
{
|
||||
public:
|
||||
GpsCoord(): latitude(0), longitude(0) {};
|
||||
GpsCoord(): latitude(0), longitude(0) {}
|
||||
double latitude; // Precede South latitudes and West longitudes with a minus sign. Latitudes range from -90 to 90.
|
||||
double longitude; // Longitudes range from -180 to 180.
|
||||
};
|
||||
@@ -194,7 +204,7 @@ public:
|
||||
class GpsGlitchFilter
|
||||
{
|
||||
public:
|
||||
GpsGlitchFilter() : lastValid(false), glitchCount(0) {};
|
||||
GpsGlitchFilter() : lastValid(false), glitchCount(0) {}
|
||||
bool isGlitch(GpsCoord coord);
|
||||
|
||||
private:
|
||||
@@ -207,7 +217,7 @@ private:
|
||||
class GpsLatLonFilter
|
||||
{
|
||||
public:
|
||||
GpsLatLonFilter() {};
|
||||
GpsLatLonFilter() {}
|
||||
bool isValid(GpsCoord coord);
|
||||
|
||||
private:
|
||||
@@ -248,7 +258,7 @@ public:
|
||||
name(name), total(0) {
|
||||
timer.start();
|
||||
};
|
||||
~Stopwatch() {};
|
||||
~Stopwatch() {}
|
||||
|
||||
void restart() {
|
||||
total = 0;
|
||||
|
||||
Reference in New Issue
Block a user