diff --git a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml
index 4018e0e09..68f0aeb58 100644
--- a/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml
+++ b/ground/openpilotgcs/src/plugins/flightlog/FlightLogDialog.qml
@@ -34,11 +34,13 @@ Rectangle {
Layout.preferredHeight: 1000;
model: logManager.logEntries
+ rowDelegate: Rectangle {
+ height: 22
+ color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee")
+ }
+
itemDelegate: Text {
- anchors.fill: parent
- anchors.margins: 2
- anchors.leftMargin: 5
- font.pixelSize: 12
+ verticalAlignment: Text.AlignVCenter
text: styleData.value
}
@@ -46,33 +48,24 @@ Rectangle {
role: "Flight"; title: qsTr("Flight"); width: 50;
delegate:
Text {
- anchors.fill: parent
- anchors.margins: 2
- anchors.leftMargin: 5
- font.pixelSize: 12
+ verticalAlignment: Text.AlignVCenter
text: styleData.value + 1
}
}
TableViewColumn {
- role: "FlightTime"; title: qsTr("Time"); width: 80;
+ role: "FlightTime"; title: qsTr("Time"); width: 100;
delegate:
Text {
- anchors.fill: parent
- anchors.margins: 2
- anchors.leftMargin: 5
- font.pixelSize: 12
+ verticalAlignment: Text.AlignVCenter
text: Functions.millisToTime(styleData.value)
}
}
TableViewColumn {
- role: "Type"; title: "Type"; width: 50;
+ role: "Type"; title: "Type"; width: 60;
delegate:
Text {
- anchors.fill: parent
- anchors.margins: 2
- anchors.leftMargin: 5
- font.pixelSize: 12
+ verticalAlignment: Text.AlignVCenter
text: {
switch(styleData.value) {
case 0 : text: qsTr("Empty"); break;
@@ -84,7 +77,11 @@ Rectangle {
}
}
- TableViewColumn { role: "LogString"; title: qsTr("Data"); width: 280}
+ TableViewColumn {
+ role: "LogString";
+ title: qsTr("Data");
+ width: 280
+ }
}
RowLayout {
@@ -177,7 +174,7 @@ Rectangle {
anchors.fill: parent
Text {
Layout.fillWidth: true
- text: "" + qsTr("Log entries") + ""
+ text: "" + qsTr("Log settings") + ""
}
TableView {
Layout.fillWidth: true
@@ -185,29 +182,37 @@ Rectangle {
Layout.preferredHeight: 1000;
model: logManager.uavoEntries
+ rowDelegate: Rectangle {
+ height: 22
+ color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee")
+ }
+
TableViewColumn {
- role: "Name";
+ role: "name";
title: qsTr("UAVObject");
- width: 150;
+ width: 200;
delegate:
Text {
- anchors.fill: parent
- anchors.margins: 2
+ verticalAlignment: Text.AlignVCenter
anchors.leftMargin: 5
- font.pixelSize: 12
text: styleData.value
}
}
- /*
+
TableViewColumn {
- role: "Setting"; title: qsTr("Settings"); width: 150;
+ role: "setting";
+ title: qsTr("Settings");
+ width: 200;
delegate:
ComboBox {
+ anchors.leftMargin: 5
model: logManager.logSettings
+ currentIndex: styleData.value
+ //onCurrentIndexChanged:
}
}
- */
+
}
}
}
diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp
index 2397c744d..dab94c474 100644
--- a/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp
+++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.cpp
@@ -40,8 +40,10 @@
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
QDialog(parent)
{
- qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry");
+ qmlRegisterType("org.openpilot", 1, 0, "DebugLogEntry");
+ qmlRegisterType("org.openpilot", 1, 0, "UAVOLogSettingsWrapper");
qmlRegisterUncreatableType("org.openpilot", 1, 0, "UAVObject", "");
+ qRegisterMetaType("UAVOLogSettingsWrapper::UAVLogSetting");
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
setWindowTitle(tr("Manage flight side logs"));
diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp
index f34a931d5..27ced5b10 100644
--- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp
+++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.cpp
@@ -58,7 +58,9 @@ FlightLogManager::FlightLogManager(QObject *parent) :
updateFlightEntries(m_flightLogStatus->getFlight());
- updateUAVOS();
+ setupUAVOWrappers();
+
+ setupLogSettings();
}
FlightLogManager::~FlightLogManager()
@@ -94,30 +96,30 @@ QQmlListProperty FlightLogManager::logEntries()
return QQmlListProperty(this, &m_logEntries, &addLogEntries, &countLogEntries, &logEntryAt, &clearLogEntries);
}
-void addUAVOEntries(QQmlListProperty *list, UAVObject *entry)
+void addUAVOEntries(QQmlListProperty *list, UAVOLogSettingsWrapper *entry)
{
Q_UNUSED(list);
Q_UNUSED(entry);
}
-int countUAVOEntries(QQmlListProperty *list)
+int countUAVOEntries(QQmlListProperty *list)
{
- return static_cast< QList *>(list->data)->size();
+ return static_cast< QList *>(list->data)->size();
}
-UAVObject *uavoEntryAt(QQmlListProperty *list, int index)
+UAVOLogSettingsWrapper *uavoEntryAt(QQmlListProperty *list, int index)
{
- return static_cast< QList *>(list->data)->at(index);
+ return static_cast< QList *>(list->data)->at(index);
}
-void clearUAVOEntries(QQmlListProperty *list)
+void clearUAVOEntries(QQmlListProperty *list)
{
- return static_cast< QList *>(list->data)->clear();
+ return static_cast< QList *>(list->data)->clear();
}
-QQmlListProperty FlightLogManager::uavoEntries()
+QQmlListProperty FlightLogManager::uavoEntries()
{
- return QQmlListProperty(this, &m_uavoEntries, &addUAVOEntries, &countUAVOEntries, &uavoEntryAt, &clearUAVOEntries);
+ return QQmlListProperty(this, &m_uavoEntries, &addUAVOEntries, &countUAVOEntries, &uavoEntryAt, &clearUAVOEntries);
}
QStringList FlightLogManager::flightEntries()
@@ -302,18 +304,24 @@ void FlightLogManager::updateFlightEntries(quint16 currentFlight)
}
}
-void FlightLogManager::updateUAVOS()
+void FlightLogManager::setupUAVOWrappers()
{
foreach(QList objectList , m_objectManager->getObjects()) {
UAVObject* object = objectList.at(0);
if (!object->isMetaDataObject() && !object->isSettingsObject()) {
- m_uavoEntries.append(object);
+ m_uavoEntries.append(new UAVOLogSettingsWrapper(object));
qDebug() << objectList.at(0)->getName();
}
}
emit uavoEntriesChanged();
}
+void FlightLogManager::setupLogSettings()
+{
+ m_logSettings << tr("Disabled") << tr("When updated") << tr("Every 10ms") << tr("Every 50ms") << tr("Every 100ms")
+ << tr("Every 500ms") << tr("Every second") << tr("Every 5s") << tr("Every 10s") << tr("Every 30s") << tr("Every minute");
+}
+
ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(),
m_object(0)
{}
@@ -348,3 +356,14 @@ void ExtendedDebugLogEntry::setData(const DebugLogEntry::DataFields &data, UAVOb
m_object->unpack(getData().Data);
}
}
+
+
+UAVOLogSettingsWrapper::UAVOLogSettingsWrapper() : QObject()
+{}
+
+UAVOLogSettingsWrapper::UAVOLogSettingsWrapper(UAVObject *object) : QObject(),
+ m_object(object), m_setting(EVERY_5S)
+{}
+
+UAVOLogSettingsWrapper::~UAVOLogSettingsWrapper()
+{}
diff --git a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h
index 4458c4cc3..826b9b5d1 100644
--- a/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h
+++ b/ground/openpilotgcs/src/plugins/flightlog/flightlogmanager.h
@@ -38,6 +38,48 @@
#include "debuglogstatus.h"
#include "debuglogcontrol.h"
+class UAVOLogSettingsWrapper : public QObject {
+ Q_OBJECT
+ Q_ENUMS(UAVLogSetting)
+ Q_PROPERTY(QString name READ name NOTIFY nameChanged)
+ Q_PROPERTY(UAVOLogSettingsWrapper::UAVLogSetting setting READ setting WRITE setSetting NOTIFY settingChanged)
+
+public:
+ enum UAVLogSetting {DISABLED = 0, ON_CHANGE, EVERY_10MS, EVERY_50MS, EVERY_100MS,
+ EVERY_500MS, EVERY_1S, EVERY_5S, EVERY_10S, EVERY_30S, EVERY_1M};
+
+ explicit UAVOLogSettingsWrapper();
+ explicit UAVOLogSettingsWrapper(UAVObject* object);
+ ~UAVOLogSettingsWrapper();
+
+ QString name() const
+ {
+ return m_object->getName();
+ }
+
+ UAVOLogSettingsWrapper::UAVLogSetting setting() const
+ {
+ return m_setting;
+ }
+
+public slots:
+ void setSetting(UAVOLogSettingsWrapper::UAVLogSetting arg)
+ {
+ if (m_setting != arg) {
+ m_setting = arg;
+ emit settingChanged(arg);
+ }
+ }
+
+signals:
+ void settingChanged(UAVLogSetting arg);
+ void nameChanged();
+
+private:
+ UAVObject *m_object;
+ UAVLogSetting m_setting;
+};
+
class ExtendedDebugLogEntry : public DebugLogEntry {
Q_OBJECT
Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated)
@@ -76,7 +118,7 @@ class FlightLogManager : public QObject {
Q_PROPERTY(bool disableExport READ disableExport WRITE setDisableExport NOTIFY disableExportChanged)
Q_PROPERTY(bool adjustExportedTimestamps READ adjustExportedTimestamps WRITE setAdjustExportedTimestamps NOTIFY adjustExportedTimestampsChanged)
- Q_PROPERTY(QQmlListProperty uavoEntries READ uavoEntries NOTIFY uavoEntriesChanged)
+ Q_PROPERTY(QQmlListProperty uavoEntries READ uavoEntries NOTIFY uavoEntriesChanged)
Q_PROPERTY(QStringList logSettings READ logSettings NOTIFY logSettingsChanged)
@@ -85,10 +127,14 @@ public:
~FlightLogManager();
QQmlListProperty logEntries();
- QQmlListProperty uavoEntries();
+ QQmlListProperty uavoEntries();
QStringList flightEntries();
+ QStringList logSettings() {
+ return m_logSettings;
+ }
+
DebugLogStatus *flightLogStatus() const
{
return m_flightLogStatus;
@@ -111,17 +157,12 @@ public:
return m_adjustExportedTimestamps;
}
- QStringList logSettings() const
- {
- return m_logSettings;
- }
-
signals:
void logEntriesChanged();
void flightEntriesChanged();
+ void logSettingsChanged();
void uavoEntriesChanged();
- void logSettingsChanged();
void disableControlsChanged(bool arg);
void disableExportChanged(bool arg);
@@ -160,7 +201,8 @@ public slots:
private slots:
void updateFlightEntries(quint16 currentFlight);
- void updateUAVOS();
+ void setupUAVOWrappers();
+ void setupLogSettings();
private:
UAVObjectManager *m_objectManager;
@@ -170,10 +212,10 @@ private:
QList m_logEntries;
QStringList m_flightEntries;
-
- QList m_uavoEntries;
QStringList m_logSettings;
+ QList m_uavoEntries;
+
static const int UAVTALK_TIMEOUT = 4000;
bool m_disableControls;
bool m_disableExport;
@@ -181,4 +223,6 @@ private:
bool m_adjustExportedTimestamps;
};
+Q_DECLARE_METATYPE(UAVOLogSettingsWrapper::UAVLogSetting)
+
#endif // FLIGHTLOGMANAGER_H