diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 460b017591d1398fcf9b217e2fdd159cf649bb13..880e4cda0b097ffc21ca974bccadde12cfc320f5 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -670,7 +670,6 @@ HEADERS += \ src/QmlControls/TerrainProfile.h \ src/QmlControls/ToolStripAction.h \ src/QmlControls/ToolStripActionList.h \ - src/QmlControls/VerticalFactValueGrid.h \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \ src/Settings/ADSBVehicleManagerSettings.h \ src/Settings/AppSettings.h \ @@ -890,7 +889,6 @@ SOURCES += \ src/QmlControls/TerrainProfile.cc \ src/QmlControls/ToolStripAction.cc \ src/QmlControls/ToolStripActionList.cc \ - src/QmlControls/VerticalFactValueGrid.cc \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \ src/Settings/ADSBVehicleManagerSettings.cc \ src/Settings/AppSettings.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index d02a006c57c6afd930e5840bbb79b556605b07de..fc2c9105b69288fb3e9a6258151b17aa3cdd91b7 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -183,7 +183,6 @@ src/PlanView/TransectStyleComplexItemTerrainFollow.qml src/QmlControls/VehicleRotationCal.qml src/QmlControls/VehicleSummaryRow.qml - src/QmlControls/VerticalFactValueGrid.qml src/PlanView/VTOLLandingPatternMapVisual.qml src/FactSystem/FactControls/AltitudeFactTextField.qml src/FactSystem/FactControls/FactBitmask.qml diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index ebd11b45d34a4c41533de7f16e24f49b04f05faf..ba87770d077efaf1b4bbfc7aed4362f8c3ae6296 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -77,7 +77,6 @@ #include "MAVLinkInspectorController.h" #endif #include "HorizontalFactValueGrid.h" -#include "VerticalFactValueGrid.h" #include "InstrumentValueData.h" #include "AppMessages.h" #include "SimulatedPosition.h" @@ -553,7 +552,6 @@ void QGCApplication::_initCommon() qmlRegisterUncreatableType (kQGCTemplates, 1, 0, "FactValueGrid", kRefOnly); qmlRegisterType (kQGCTemplates, 1, 0, "HorizontalFactValueGrid"); - qmlRegisterType (kQGCTemplates, 1, 0, "VerticalFactValueGrid"); qmlRegisterType ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle"); diff --git a/src/QmlControls/FactValueGrid.cc b/src/QmlControls/FactValueGrid.cc index 09f807fb0f3bd7a10b8369bc973ddfd43e6f7976..b0c9a108cae68b36aa705ea3c51f0ca7d10152a3 100644 --- a/src/QmlControls/FactValueGrid.cc +++ b/src/QmlControls/FactValueGrid.cc @@ -15,9 +15,7 @@ #include const char* FactValueGrid::_rowsKey = "rows"; -const char* FactValueGrid::_columnsKey = "columns"; const char* FactValueGrid::_fontSizeKey = "fontSize"; -const char* FactValueGrid::_orientationKey = "orientation"; const char* FactValueGrid::_versionKey = "version"; const char* FactValueGrid::_factGroupNameKey = "groupName"; const char* FactValueGrid::_factNameKey = "factName"; @@ -44,7 +42,7 @@ const QStringList FactValueGrid::_fontSizeNames = { FactValueGrid::FactValueGrid(QQuickItem* parent) : QQuickItem(parent) - , _rows (new QmlObjectListModel(this)) + , _columns (new QmlObjectListModel(this)) { if (_iconNames.isEmpty()) { QDir iconDir(":/InstrumentValueIcons/"); @@ -57,7 +55,7 @@ FactValueGrid::FactValueGrid(QQuickItem* parent) FactValueGrid::FactValueGrid(const QString& defaultSettingsGroup) : QQuickItem (nullptr) , _defaultSettingsGroup (defaultSettingsGroup) - , _rows (new QmlObjectListModel(this)) + , _columns (new QmlObjectListModel(this)) { _init(); } @@ -189,46 +187,46 @@ void FactValueGrid::_connectSaveSignals(InstrumentValueData* value) connect(value, &InstrumentValueData::rangeIconsChanged, this, &FactValueGrid::_saveSettings); } -void FactValueGrid::appendColumn(void) +void FactValueGrid::appendRow(void) { - for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) { - QmlObjectListModel* list = _rows->value(rowIndex); + for (int colIndex=0; colIndex<_columns->count(); colIndex++) { + QmlObjectListModel* list = _columns->value(colIndex); list->append(_createNewInstrumentValueWorker(list)); } - _columnCount++; - emit columnCountChanged(_columnCount); + _rowCount++; + emit rowCountChanged(_rowCount); _saveSettings(); } -void FactValueGrid::deleteLastColumn(void) +void FactValueGrid::deleteLastRow(void) { - if (_columnCount <= 1) { + if (_rowCount <= 1) { return; } - for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) { - QmlObjectListModel* list = _rows->value(rowIndex); + for (int colIndex=0; colIndex<_columns->count(); colIndex++) { + QmlObjectListModel* list = _columns->value(colIndex); list->removeAt(list->count() - 1)->deleteLater(); } - _columnCount--; - emit columnCountChanged(_columnCount); + _rowCount--; + emit rowCountChanged(_rowCount); _saveSettings(); } -QmlObjectListModel* FactValueGrid::appendRow(void) +QmlObjectListModel* FactValueGrid::appendColumn(void) { - QmlObjectListModel* newList = new QmlObjectListModel(_rows); - _rows->append(newList); + QmlObjectListModel* newList = new QmlObjectListModel(_columns); + _columns->append(newList); // If this is the first row then we automatically add the first column as well - int cColsToAdd = qMax(_columnCount, 1); - for (int i=0; iappend(_createNewInstrumentValueWorker(newList)); } - if (cColsToAdd != _columnCount) { - _columnCount = cColsToAdd; - emit columnCountChanged(_columnCount); + if (cRowsToAdd != _rowCount) { + _rowCount = cRowsToAdd; + emit rowCountChanged(_rowCount); } _saveSettings(); @@ -236,10 +234,10 @@ QmlObjectListModel* FactValueGrid::appendRow(void) return newList; } -void FactValueGrid::deleteLastRow(void) +void FactValueGrid::deleteLastColumn(void) { - if (_rows->count() > 1) { - _rows->removeAt(_rows->count() - 1)->deleteLater(); + if (_columns->count() > 1) { + _columns->removeAt(_columns->count() - 1)->deleteLater(); } } @@ -272,17 +270,16 @@ void FactValueGrid::_saveSettings(void) settings.remove(""); // Remove any previous settings - settings.setValue(_versionKey, 1); - settings.setValue(_fontSizeKey, _fontSize); - settings.setValue(_orientationKey, _orientation); - settings.setValue(_columnsKey, _columnCount); + settings.setValue(_versionKey, 1); + settings.setValue(_fontSizeKey, _fontSize); + settings.setValue(_rowsKey, _rowCount); settings.beginWriteArray(_rowsKey); - for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) { - QmlObjectListModel* columns = _rows->value(rowIndex); + for (int colIndex=0; colIndex<_columns->count(); colIndex++) { + QmlObjectListModel* columns = _columns->value(colIndex); - settings.setArrayIndex(rowIndex); - settings.beginWriteArray(_columnsKey); + settings.setArrayIndex(colIndex); + settings.beginWriteArray(_rowsKey); for (int colIndex=0; colIndexcount(); colIndex++) { InstrumentValueData* value = columns->value(colIndex); @@ -299,10 +296,10 @@ void FactValueGrid::_loadSettings(void) { _preventSaveSettings = true; - _rows->deleteLater(); + _columns->deleteLater(); - _rows = new QmlObjectListModel(this); - _columnCount = 0; + _columns = new QmlObjectListModel(this); + _rowCount = 0; QSettings settings; QString groupNameFormat("%1-%2"); @@ -325,27 +322,26 @@ void FactValueGrid::_loadSettings(void) qgcApp()->toolbox()->corePlugin()->factValueGridCreateDefaultSettings(_defaultSettingsGroup); } _fontSize = settings.value(_fontSizeKey, DefaultFontSize).value(); - _orientation = settings.value(_orientationKey, VerticalOrientation).value(); // Initial setup of empty items - int cColumns = settings.value(_columnsKey).toInt(); + int cColumns = settings.value(_rowsKey).toInt(); int cModelLists = settings.beginReadArray(_rowsKey); if (cModelLists && cColumns) { - appendRow(); + appendColumn(); for (int itemIndex=1; itemIndexvalue(rowIndex); + QmlObjectListModel* list = _columns->value(colIndex); InstrumentValueData* value = list->value(itemIndex); settings.setArrayIndex(itemIndex); _loadValueData(settings, value); @@ -354,7 +350,7 @@ void FactValueGrid::_loadSettings(void) } settings.endArray(); - emit rowsChanged(_rows); + emit columnsChanged(_columns); _preventSaveSettings = false; } diff --git a/src/QmlControls/FactValueGrid.h b/src/QmlControls/FactValueGrid.h index e7f24ed3d8f5bea8fb16012eda281d4038b85ce6..c611bd3e29209f31b98424a2d06df66eeb24c60e 100644 --- a/src/QmlControls/FactValueGrid.h +++ b/src/QmlControls/FactValueGrid.h @@ -26,12 +26,6 @@ public: FactValueGrid(QQuickItem *parent = nullptr); FactValueGrid(const QString& defaultSettingsGroup); - enum Orientation { - HorizontalOrientation=0, // Labels will be to the left of the value - VerticalOrientation // Labels will be above the value - }; - Q_ENUMS(Orientation) - enum FontSize { DefaultFontSize=0, SmallFontSize, @@ -50,22 +44,21 @@ public: // The combination of the two valuePage*SettingsGroup values allows each FactValueGrid to have it's own persistence space. - Q_PROPERTY(QmlObjectListModel* rows MEMBER _rows NOTIFY rowsChanged) - Q_PROPERTY(int columnCount MEMBER _columnCount NOTIFY columnCountChanged) + Q_PROPERTY(QmlObjectListModel* columns MEMBER _columns NOTIFY columnsChanged) + Q_PROPERTY(int rowCount MEMBER _rowCount NOTIFY rowCountChanged) Q_PROPERTY(QString userSettingsGroup MEMBER _userSettingsGroup NOTIFY userSettingsGroupChanged) Q_PROPERTY(QString defaultSettingsGroup MEMBER _defaultSettingsGroup NOTIFY defaultSettingsGroupChanged) - Q_PROPERTY(Orientation orientation MEMBER _orientation CONSTANT) Q_PROPERTY(QStringList iconNames READ iconNames CONSTANT) Q_PROPERTY(FontSize fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) Q_PROPERTY(QStringList fontSizeNames MEMBER _fontSizeNames CONSTANT) - Q_INVOKABLE void resetToDefaults (void); - Q_INVOKABLE QmlObjectListModel* appendRow (void); - Q_INVOKABLE void deleteLastRow (void); - Q_INVOKABLE void appendColumn (void); - Q_INVOKABLE void deleteLastColumn (void); + Q_INVOKABLE void resetToDefaults (void); + Q_INVOKABLE QmlObjectListModel* appendColumn (void); + Q_INVOKABLE void deleteLastColumn(void); + Q_INVOKABLE void appendRow (void); + Q_INVOKABLE void deleteLastRow (void); - QmlObjectListModel* rows (void) const { return _rows; } + QmlObjectListModel* columns (void) const { return _columns; } FontSize fontSize (void) const { return _fontSize; } QStringList iconNames (void) const { return _iconNames; } QGCMAVLink::VehicleClass_t vehicleClass(void) const { return _vehicleClass; } @@ -79,8 +72,8 @@ signals: void userSettingsGroupChanged (const QString& userSettingsGroup); void defaultSettingsGroupChanged(const QString& defaultSettingsGroup); void fontSizeChanged (FontSize fontSize); - void rowsChanged (QmlObjectListModel* model); - void columnCountChanged (int columnCount); + void columnsChanged (QmlObjectListModel* model); + void rowCountChanged (int rowCount); protected: Q_DISABLE_COPY(FactValueGrid) @@ -88,11 +81,10 @@ protected: QGCMAVLink::VehicleClass_t _vehicleClass = QGCMAVLink::VehicleClassGeneric; QString _defaultSettingsGroup; // Settings group to read from if the user has not modified from the default settings QString _userSettingsGroup; // Settings group to read from for user modified settings - Orientation _orientation = VerticalOrientation; FontSize _fontSize = DefaultFontSize; bool _preventSaveSettings = false; - QmlObjectListModel* _rows = nullptr; - int _columnCount = 0; + QmlObjectListModel* _columns = nullptr; + int _rowCount = 0; private slots: void _offlineVehicleTypeChanged(void); @@ -113,8 +105,6 @@ private: static const char* _versionKey; static const char* _rowsKey; - static const char* _columnsKey; - static const char* _orientationKey; static const char* _fontSizeKey; static const char* _factGroupNameKey; static const char* _factNameKey; @@ -133,4 +123,3 @@ private: QML_DECLARE_TYPE(FactValueGrid) Q_DECLARE_METATYPE(FactValueGrid::FontSize) -Q_DECLARE_METATYPE(FactValueGrid::Orientation) diff --git a/src/QmlControls/HorizontalFactValueGrid.cc b/src/QmlControls/HorizontalFactValueGrid.cc index bedb044230c845396448b59f3e1430fd9776b8bc..429eabeba09ee1268a6e14ca0d35e39e4b36a7ee 100644 --- a/src/QmlControls/HorizontalFactValueGrid.cc +++ b/src/QmlControls/HorizontalFactValueGrid.cc @@ -14,17 +14,17 @@ #include -const QString HorizontalFactValueGrid::_toolbarUserSettingsGroup ("TelemetryBarUserSettingsWIP0"); -const QString HorizontalFactValueGrid::telemetryBarDefaultSettingsGroup ("TelemetryBarDefaultSettingsWIP0"); +const QString HorizontalFactValueGrid::_toolbarUserSettingsGroup ("TelemetryBarUserSettingsWIP01"); +const QString HorizontalFactValueGrid::telemetryBarDefaultSettingsGroup ("TelemetryBarDefaultSettingsWIP01"); HorizontalFactValueGrid::HorizontalFactValueGrid(QQuickItem* parent) : FactValueGrid(parent) { - _orientation = HorizontalOrientation; + } HorizontalFactValueGrid::HorizontalFactValueGrid(const QString& defaultSettingsGroup) : FactValueGrid(defaultSettingsGroup) { - _orientation = HorizontalOrientation; + } diff --git a/src/QmlControls/HorizontalFactValueGrid.qml b/src/QmlControls/HorizontalFactValueGrid.qml index 3c9d5155d7bf6fdc50ae2b89713e22227dda6b41..28ed1f551eab9a139b6db5ee73697cf797746ef7 100644 --- a/src/QmlControls/HorizontalFactValueGrid.qml +++ b/src/QmlControls/HorizontalFactValueGrid.qml @@ -71,11 +71,11 @@ T.HorizontalFactValueGrid { GridLayout { id: valueGrid - rows: _root.rows.count + rows: _root.columns.count rowSpacing: 0 Repeater { - model: _root.rows + model: _root.columns Repeater { id: labelRepeater @@ -84,8 +84,8 @@ T.HorizontalFactValueGrid { property real _index: index InstrumentValueLabel { - Layout.row: labelRepeater._index - Layout.column: index * 3 + Layout.row: index + Layout.column: labelRepeater._index * 3 Layout.fillHeight: true Layout.alignment: Qt.AlignRight instrumentValueData: object @@ -94,26 +94,55 @@ T.HorizontalFactValueGrid { } Repeater { - model: _root.rows + model: _root.columns Repeater { id: valueRepeater model: object - property real _index: index + property real _index: index + property real maxWidth: 0 + property var lastCheck: new Date().getTime() + + function recalcWidth() { + var newMaxWidth = 0 + for (var i=0; i 30 * 1000) { + lastCheck = currentTime + valueRepeater.recalcWidth() + } + } } } } Repeater { - model: _root.rows + model: _root.columns Repeater { id: spacerRepeater @@ -122,8 +151,8 @@ T.HorizontalFactValueGrid { property real _index: index Item { - Layout.row: spacerRepeater._index - Layout.column: (index * 3) + 2 + Layout.row: index + Layout.column: (spacerRepeater._index * 3) + 2 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth Layout.preferredHeight: 1 } @@ -150,7 +179,7 @@ T.HorizontalFactValueGrid { Layout.fillWidth: true Layout.preferredHeight: parent.height text: qsTr("-") - enabled: _root.rows.count > 1 + enabled: _root.rowCount > 1 onClicked: deleteLastRow() } } @@ -177,7 +206,7 @@ T.HorizontalFactValueGrid { Layout.preferredHeight: ScreenTools.minTouchPixels Layout.preferredWidth: parent.width text: qsTr("-") - enabled: _root.columnCount > 1 + enabled: _root.columns.count > 1 onClicked: deleteLastColumn() } } diff --git a/src/QmlControls/InstrumentValueValue.qml b/src/QmlControls/InstrumentValueValue.qml index dd63bb79855048d62d118054e9f7a13c3b2cfb6a..535fffe6d57adae04b6fcfce13806be0b6b5aa07 100644 --- a/src/QmlControls/InstrumentValueValue.qml +++ b/src/QmlControls/InstrumentValueValue.qml @@ -21,6 +21,7 @@ import QGroundControl.Palette 1.0 ColumnLayout { property var instrumentValueData: null property bool settingsUnlocked: false + property alias contentWidth: label.contentWidth property bool _verticalOrientation: instrumentValueData.factValueGrid.orientation === FactValueGrid.VerticalOrientation property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ] @@ -36,6 +37,7 @@ ColumnLayout { property real _height: 0 QGCLabel { + id: label Layout.alignment: _verticalOrientation ? Qt.AlignHCenter : Qt.AlignVCenter font.pointSize: _fontSize text: instrumentValueData.fact.enumOrValueString + (instrumentValueData.showUnits ? " " + instrumentValueData.fact.units : "") diff --git a/src/QmlControls/QGroundControl/Controls/qmldir b/src/QmlControls/QGroundControl/Controls/qmldir index 695b7f61ffe9ace139595cfab8eec624a47c4eea..713ef49f5b815d63b67f169c83e0cae06e64abbe 100644 --- a/src/QmlControls/QGroundControl/Controls/qmldir +++ b/src/QmlControls/QGroundControl/Controls/qmldir @@ -107,6 +107,5 @@ TransectStyleMapVisuals 1.0 TransectStyleMapVisuals.qml ToolStrip 1.0 ToolStrip.qml VehicleRotationCal 1.0 VehicleRotationCal.qml VehicleSummaryRow 1.0 VehicleSummaryRow.qml -VerticalFactValueGrid 1.0 VerticalFactValueGrid.qml QGCHoverButton 1.0 QGCHoverButton.qml MAVLinkChart 1.0 MAVLinkChart.qml diff --git a/src/QmlControls/VerticalFactValueGrid.cc b/src/QmlControls/VerticalFactValueGrid.cc deleted file mode 100644 index 55d448a52cf99ab265d8309e2b133129c96bb553..0000000000000000000000000000000000000000 --- a/src/QmlControls/VerticalFactValueGrid.cc +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2020 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#include "VerticalFactValueGrid.h" -#include "InstrumentValueData.h" -#include "QGCApplication.h" -#include "QGCCorePlugin.h" - -#include - -const QString VerticalFactValueGrid::_valuePageUserSettingsGroup ("ValuePageUserSettings2"); -const QString VerticalFactValueGrid::valuePageDefaultSettingsGroup("ValuePageDefaultSettings2"); - -VerticalFactValueGrid::VerticalFactValueGrid(QQuickItem* parent) - : FactValueGrid(parent) -{ - _orientation = VerticalOrientation; -} - -VerticalFactValueGrid::VerticalFactValueGrid(const QString& defaultSettingsGroup) - : FactValueGrid(defaultSettingsGroup) -{ - _orientation = VerticalOrientation; -} diff --git a/src/QmlControls/VerticalFactValueGrid.h b/src/QmlControls/VerticalFactValueGrid.h deleted file mode 100644 index f022be138378a73366fa9047eb5154bcccd3ebd7..0000000000000000000000000000000000000000 --- a/src/QmlControls/VerticalFactValueGrid.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2020 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#pragma once - -#include "FactSystem.h" -#include "QmlObjectListModel.h" -#include "QGCApplication.h" -#include "FactValueGrid.h" - -class InstrumentValueData; - -class VerticalFactValueGrid : public FactValueGrid -{ - Q_OBJECT - -public: - VerticalFactValueGrid(QQuickItem *parent = nullptr); - VerticalFactValueGrid(const QString& defaultSettingsGroup); - - Q_PROPERTY(QString valuePageDefaultSettingsGroup MEMBER valuePageDefaultSettingsGroup CONSTANT) - Q_PROPERTY(QString valuePageUserSettingsGroup MEMBER _valuePageUserSettingsGroup CONSTANT) - - static const QString valuePageDefaultSettingsGroup; - -private: - Q_DISABLE_COPY(VerticalFactValueGrid) - - static const QString _valuePageUserSettingsGroup; -}; - -QML_DECLARE_TYPE(VerticalFactValueGrid) diff --git a/src/QmlControls/VerticalFactValueGrid.qml b/src/QmlControls/VerticalFactValueGrid.qml deleted file mode 100644 index b34dbe54d0bf5ea7b9ce72d0b5bba5eb16c5a97e..0000000000000000000000000000000000000000 --- a/src/QmlControls/VerticalFactValueGrid.qml +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2020 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -import QtQuick 2.12 -import QtQuick.Layouts 1.2 -import QtQuick.Controls 2.5 -import QtQml 2.12 - -import QGroundControl.Templates 1.0 as T -import QGroundControl.Controls 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Controllers 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl.FlightMap 1.0 -import QGroundControl 1.0 - -// Note: This control will spit out qWarnings like this: "QGridLayoutEngine::addItem: Cell (0, 1) already taken" -// This is due to Qt bug https://bugreports.qt.io/browse/QTBUG-65121 -// If this becomes a problem I'll implement our own grid layout control - -T.VerticalFactValueGrid { - id: _root - height: childrenRect.height - - property bool settingsUnlocked: false - - QGCPalette { id: qgcPal; colorGroupEnabled: enabled } - - QGCFlickable { - width: parent.width - height: topLevelRowLayout.height - flickableDirection: QGCFlickable.HorizontalFlick - contentWidth: topLevelRowLayout.width - - RowLayout { - id: topLevelRowLayout - spacing: 0 - - ColumnLayout { - spacing: 0 - - GridLayout { - id: valueGrid - Layout.minimumWidth: _root.width - (columnButtons.visible? columnButtons.width + columnSpacing : 0) - rows: _root.rows.count * 2 - rowSpacing: 0 - columnSpacing: 5 - - Repeater { - model: _root.rows - - Repeater { - id: labelRepeater - model: object - - property real _index: index - - InstrumentValueLabel { - Layout.row: labelRepeater._index * 2 - Layout.column: index - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - instrumentValueData: object - } - } - } - - Repeater { - model: _root.rows - - Repeater { - id: valueRepeater - model: object - - property real _index: index - - InstrumentValueValue { - Layout.row: valueRepeater._index * 2 + 1 - Layout.column: index - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - instrumentValueData: object - } - } - } - } - - RowLayout { - id: rowButtons - height: ScreenTools.minTouchPixels / 2 - Layout.fillWidth: true - spacing: 1 - visible: settingsUnlocked - - QGCButton { - Layout.fillWidth: true - Layout.preferredHeight: parent.height - text: qsTr("+") - onClicked: appendRow() - } - - QGCButton { - Layout.fillWidth: true - Layout.preferredHeight: parent.height - text: qsTr("-") - enabled: _root.rows.count > 1 - onClicked: deleteLastRow() - } - } - } - - ColumnLayout { - id: columnButtons - Layout.fillHeight: true - Layout.bottomMargin: rowButtons.height - width: ScreenTools.minTouchPixels / 2 - spacing: 1 - visible: settingsUnlocked - - QGCButton { - Layout.fillHeight: true - Layout.preferredHeight: ScreenTools.minTouchPixels - Layout.preferredWidth: parent.width - text: qsTr("+") - onClicked: appendColumn() - } - - QGCButton { - Layout.fillHeight: true - Layout.preferredHeight: ScreenTools.minTouchPixels - Layout.preferredWidth: parent.width - text: qsTr("-") - enabled: _root.columnCount > 1 - onClicked: deleteLastColumn() - } - } - } - - QGCMouseArea { - x: valueGrid.x - y: valueGrid.y - width: valueGrid.width - height: valueGrid.height - visible: settingsUnlocked - onClicked: { - var item = valueGrid.childAt(mouse.x, mouse.y) - //console.log(item, item ? item.instrumentValueData : "null", item && item.parent ? item.parent.instrumentValueData : "null") - if (item && item.instrumentValueData !== undefined) { - mainWindow.showPopupDialogFromComponent(valueEditDialog, { instrumentValueData: item.instrumentValueData }) - } - } - - /*Rectangle { - anchors.fill: parent - border.color: "green" - border.width: 1 - color: "transparent" - }*/ - } - } - - Component { - id: valueEditDialog - - InstrumentValueEditDialog { } - } -} - diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index 2954d7e1d2e8d05b77e99d8b5cca85feffb88d00..ce1936c551961a9fde1330b293250e3af57c321f 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -23,7 +23,6 @@ #include "QGCLoggingCategory.h" #include "QGCCameraManager.h" #include "HorizontalFactValueGrid.h" -#include "VerticalFactValueGrid.h" #include "InstrumentValueData.h" #include @@ -298,65 +297,70 @@ void QGCCorePlugin::factValueGridCreateDefaultSettings(const QString& defaultSet factValueGrid.setFontSize(FactValueGrid::LargeFontSize); - factValueGrid.appendRow(); - factValueGrid.appendRow(); + factValueGrid.appendColumn(); factValueGrid.appendColumn(); factValueGrid.appendColumn(); if (includeFWValues) { factValueGrid.appendColumn(); } + factValueGrid.appendRow(); - int colIndex = 0; - QmlObjectListModel* row = factValueGrid.rows()->value(0); + int rowIndex = 0; + QmlObjectListModel* column = factValueGrid.columns()->value(0); - InstrumentValueData* value = row->value(colIndex++); + InstrumentValueData* value = column->value(rowIndex++); value->setFact("Vehicle", "AltitudeRelative"); value->setIcon("arrow-thick-up.svg"); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); - value = row->value(colIndex++); - value->setFact("Vehicle", "ClimbRate"); - value->setIcon("arrow-simple-up.svg"); + value = column->value(rowIndex++); + value->setFact("Vehicle", "DistanceToHome"); + value->setIcon("bookmark copy 3.svg"); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); - if (includeFWValues) { - value = row->value(colIndex++); - value->setFact("Vehicle", "AirSpeed"); - value->setText("AirSpd"); - value->setShowUnits(true); - } - - value = row->value(colIndex++); - value->setFact("Vehicle", "FlightTime"); - value->setIcon("timer.svg"); - value->setText(value->fact()->shortDescription()); - value->setShowUnits(false); + rowIndex = 0; + column = factValueGrid.columns()->value(1); - colIndex = 0; - row = factValueGrid.rows()->value(1); - - value = row->value(colIndex++); - value->setFact("Vehicle", "DistanceToHome"); - value->setIcon("bookmark copy 3.svg"); + value = column->value(rowIndex++); + value->setFact("Vehicle", "ClimbRate"); + value->setIcon("arrow-simple-up.svg"); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); - value = row->value(colIndex++); + value = column->value(rowIndex++); value->setFact("Vehicle", "GroundSpeed"); value->setIcon("arrow-simple-right.svg"); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); + if (includeFWValues) { - value = row->value(colIndex++); + rowIndex = 0; + column = factValueGrid.columns()->value(2); + + value = column->value(rowIndex++); + value->setFact("Vehicle", "AirSpeed"); + value->setText("AirSpd"); + value->setShowUnits(true); + + value = column->value(rowIndex++); value->setFact("Vehicle", "ThrottlePct"); value->setText("Thr"); value->setShowUnits(true); } - value = row->value(colIndex++); + rowIndex = 0; + column = factValueGrid.columns()->value(includeFWValues ? 3 : 2); + + value = column->value(rowIndex++); + value->setFact("Vehicle", "FlightTime"); + value->setIcon("timer.svg"); + value->setText(value->fact()->shortDescription()); + value->setShowUnits(false); + + value = column->value(rowIndex++); value->setFact("Vehicle", "FlightDistance"); value->setIcon("travel-walk.svg"); value->setText(value->fact()->shortDescription());