mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
OP-1119 Added QmlProperty to handle list of log events downloaded from board.
This commit is contained in:
parent
2191acd22f
commit
e42c53de74
@ -1,15 +1,53 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.0
|
||||
import QtQuick.Layouts 1.0
|
||||
|
||||
import org.openpilot 1.0
|
||||
|
||||
Rectangle {
|
||||
width: 100
|
||||
height: 62
|
||||
width: 600
|
||||
height: 400
|
||||
|
||||
Button {
|
||||
id: button1
|
||||
x: 8
|
||||
y: 18
|
||||
text: qsTr("OK")
|
||||
onClicked: dialog.close()
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Text {
|
||||
id:flights
|
||||
height: 40
|
||||
text: logStatus.Flight
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
frameVisible: true
|
||||
ListView {
|
||||
id: authorsView
|
||||
anchors.fill: parent
|
||||
|
||||
spacing: 3
|
||||
model: logManager.logEntries
|
||||
delegate: Text {
|
||||
font.pixelSize: 12
|
||||
text: Flight
|
||||
}
|
||||
clip: true
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
height: 40
|
||||
Button {
|
||||
id: button1
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 10
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 10
|
||||
text: qsTr("OK")
|
||||
onClicked: dialog.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,13 @@
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include "debuglogentry.h"
|
||||
|
||||
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
|
||||
QDialog(parent)
|
||||
{
|
||||
qmlRegisterType<DebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
|
||||
|
||||
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
||||
setWindowTitle(tr("Manage flight side logs"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
@ -45,6 +49,7 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan
|
||||
|
||||
QQuickView *view = new QQuickView();
|
||||
view->rootContext()->setContextProperty("dialog", this);
|
||||
view->rootContext()->setContextProperty("logStatus", flightLogManager->flightLogStatus());
|
||||
view->rootContext()->setContextProperty("logManager", flightLogManager);
|
||||
view->setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml"));
|
||||
|
@ -40,16 +40,67 @@ FlightLogManager::FlightLogManager(QObject *parent) :
|
||||
m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager);
|
||||
Q_ASSERT(m_flightLogStatus);
|
||||
|
||||
DebugLogEntry *entry = new DebugLogEntry();
|
||||
entry->setFlight(1);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(2);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(3);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(4);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(5);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(6);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(7);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(8);
|
||||
m_logEntries.append(entry);
|
||||
entry = new DebugLogEntry();
|
||||
entry->setFlight(9);
|
||||
m_logEntries.append(entry);
|
||||
|
||||
}
|
||||
|
||||
FlightLogManager::~FlightLogManager() {
|
||||
|
||||
}
|
||||
|
||||
void addEntries(QQmlListProperty<DebugLogEntry> *list, DebugLogEntry *entry) {
|
||||
Q_UNUSED(list);
|
||||
Q_UNUSED(entry);
|
||||
}
|
||||
|
||||
int countEntries(QQmlListProperty<DebugLogEntry> *list) {
|
||||
return static_cast< QList<DebugLogEntry *> *>(list->data)->size();
|
||||
}
|
||||
|
||||
DebugLogEntry* entryAt(QQmlListProperty<DebugLogEntry> *list, int index) {
|
||||
return static_cast< QList<DebugLogEntry *> *>(list->data)->at(index);
|
||||
}
|
||||
|
||||
void clearEntries(QQmlListProperty<DebugLogEntry> *list) {
|
||||
return static_cast< QList<DebugLogEntry *> *>(list->data)->clear();
|
||||
}
|
||||
|
||||
QQmlListProperty<DebugLogEntry> FlightLogManager::logEntries() {
|
||||
return QQmlListProperty<DebugLogEntry>(this, &m_logEntries, &addEntries, &countEntries, &entryAt, &clearEntries);
|
||||
}
|
||||
|
||||
void FlightLogManager::clearAllLogs() {
|
||||
|
||||
//Clear on flight side
|
||||
m_logEntries.clear();
|
||||
}
|
||||
|
||||
void FlightLogManager::retrieveLogs(int flight) {
|
||||
|
||||
//Get logs from flight side
|
||||
}
|
||||
|
@ -29,7 +29,8 @@
|
||||
#define FLIGHTLOGMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtDeclarative/QDeclarativeListProperty>
|
||||
#include <QList>
|
||||
#include <QQmlListProperty>
|
||||
|
||||
#include "uavobjectmanager.h"
|
||||
#include "debuglogentry.h"
|
||||
@ -37,23 +38,20 @@
|
||||
|
||||
class FlightLogManager : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(DebugLogStatus * flightLogStatus READ flightLogStatus)
|
||||
Q_PROPERTY(QDeclarativeListProperty<DebugLogEntry *> *logEntries READ logEntries)
|
||||
Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus)
|
||||
Q_PROPERTY(QQmlListProperty<DebugLogEntry> logEntries READ logEntries CONSTANT)
|
||||
|
||||
public:
|
||||
explicit FlightLogManager(QObject *parent = 0);
|
||||
~FlightLogManager();
|
||||
|
||||
QQmlListProperty<DebugLogEntry> logEntries();
|
||||
|
||||
DebugLogStatus* flightLogStatus() const
|
||||
{
|
||||
return m_flightLogStatus;
|
||||
}
|
||||
|
||||
QDeclarativeListProperty<DebugLogEntry *>* logEntries() const
|
||||
{
|
||||
return m_records;
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
@ -63,7 +61,8 @@ public slots:
|
||||
private:
|
||||
UAVObjectManager *m_objectManager;
|
||||
DebugLogStatus *m_flightLogStatus;
|
||||
QDeclarativeListProperty<DebugLogEntry *> *m_records;
|
||||
QList<DebugLogEntry *> m_logEntries;
|
||||
|
||||
};
|
||||
|
||||
#endif // FLIGHTLOGMANAGER_H
|
||||
|
@ -41,6 +41,7 @@ FlightLogPlugin::FlightLogPlugin() : m_logDialog(0)
|
||||
|
||||
FlightLogPlugin::~FlightLogPlugin()
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
|
||||
bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
|
||||
@ -81,6 +82,7 @@ void FlightLogPlugin::ShowLogManagementDialog()
|
||||
void FlightLogPlugin::LogManagementDialogClosed()
|
||||
{
|
||||
if(m_logDialog) {
|
||||
m_logDialog->deleteLater();
|
||||
m_logDialog = 0;
|
||||
}
|
||||
}
|
||||
@ -91,4 +93,8 @@ void FlightLogPlugin::extensionsInitialized()
|
||||
|
||||
void FlightLogPlugin::shutdown()
|
||||
{
|
||||
if(m_logDialog) {
|
||||
m_logDialog->close();
|
||||
LogManagementDialogClosed();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user