1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-1119 Uncrustify

This commit is contained in:
m_thread 2013-11-26 15:42:49 +01:00
parent 3f3245b749
commit a11d98aa0d
6 changed files with 70 additions and 68 deletions

View File

@ -53,15 +53,14 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml"));
QWidget * container = QWidget::createWindowContainer(view);
QWidget *container = QWidget::createWindowContainer(view);
container->setMinimumSize(600, 400);
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout *lay = new QVBoxLayout();
lay->setContentsMargins(0,0,0,0);
QVBoxLayout *lay = new QVBoxLayout();
lay->setContentsMargins(0, 0, 0, 0);
setLayout(lay);
layout()->addWidget(container);
}
FlightLogDialog::~FlightLogDialog()
{
}
{}

View File

@ -2,10 +2,9 @@
#define FLIGHTLOGDIALOG_H
#include <QDialog>
#include"flightlogmanager.h"
#include "flightlogmanager.h"
class FlightLogDialog : public QDialog
{
class FlightLogDialog : public QDialog {
Q_OBJECT
public:

View File

@ -32,101 +32,106 @@
#include "uavobjecthelper.h"
FlightLogManager::FlightLogManager(QObject *parent) :
QObject(parent) {
QObject(parent)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
m_objectManager = pm->getObject<UAVObjectManager>();
m_objectManager = pm->getObject<UAVObjectManager>();
Q_ASSERT(m_objectManager);
m_flightLogControl = DebugLogControl::GetInstance(m_objectManager);
Q_ASSERT(m_flightLogControl);
m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager);
m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager);
Q_ASSERT(m_flightLogStatus);
m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager);
m_flightLogEntry = DebugLogEntry::GetInstance(m_objectManager);
Q_ASSERT(m_flightLogEntry);
}
FlightLogManager::~FlightLogManager() {
FlightLogManager::~FlightLogManager()
{
while (!m_logEntries.isEmpty()) {
delete m_logEntries.takeFirst();
}
}
void addEntries(QQmlListProperty<ExtendedDebugLogEntry> *list, ExtendedDebugLogEntry *entry) {
void addEntries(QQmlListProperty<ExtendedDebugLogEntry> *list, ExtendedDebugLogEntry *entry)
{
Q_UNUSED(list);
Q_UNUSED(entry);
}
int countEntries(QQmlListProperty<ExtendedDebugLogEntry> *list) {
int countEntries(QQmlListProperty<ExtendedDebugLogEntry> *list)
{
return static_cast< QList<ExtendedDebugLogEntry *> *>(list->data)->size();
}
ExtendedDebugLogEntry* entryAt(QQmlListProperty<ExtendedDebugLogEntry> *list, int index) {
ExtendedDebugLogEntry *entryAt(QQmlListProperty<ExtendedDebugLogEntry> *list, int index)
{
return static_cast< QList<ExtendedDebugLogEntry *> *>(list->data)->at(index);
}
void clearEntries(QQmlListProperty<ExtendedDebugLogEntry> *list) {
void clearEntries(QQmlListProperty<ExtendedDebugLogEntry> *list)
{
return static_cast< QList<ExtendedDebugLogEntry *> *>(list->data)->clear();
}
QQmlListProperty<ExtendedDebugLogEntry> FlightLogManager::logEntries() {
QQmlListProperty<ExtendedDebugLogEntry> FlightLogManager::logEntries()
{
return QQmlListProperty<ExtendedDebugLogEntry>(this, &m_logEntries, &addEntries, &countEntries, &entryAt, &clearEntries);
}
void FlightLogManager::clearAllLogs() {
void FlightLogManager::clearAllLogs()
{
// Clear on flight side
//Clear on flight side
//Then delete locally
// Then delete locally
while (!m_logEntries.isEmpty()) {
delete m_logEntries.takeFirst();
}
}
void FlightLogManager::retrieveLogs(int flightToRetrieve) {
void FlightLogManager::retrieveLogs(int flightToRetrieve)
{
UAVObjectUpdaterHelper updateHelper;
UAVObjectRequestHelper requestHelper;
//Get logs from flight side
// Get logs from flight side
while (!m_logEntries.isEmpty()) {
delete m_logEntries.takeFirst();
}
emit logEntriesChanged();
// Set up what to retrieve
bool timedOut = false;
bool timedOut = false;
int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve;
int endFlight = (flightToRetrieve == -1 ) ? m_flightLogStatus->getFlight() : flightToRetrieve;
int endFlight = (flightToRetrieve == -1) ? m_flightLogStatus->getFlight() : flightToRetrieve;
// Prepare to send request for event retrieval
m_flightLogControl->setOperation(DebugLogControl::OPERATION_RETRIEVE);
for(int flight = startFlight; flight <= endFlight; flight++) {
for (int flight = startFlight; flight <= endFlight; flight++) {
m_flightLogControl->setFlight(flight);
bool gotLast = false;
int entry = 0;
while(!gotLast) {
int entry = 0;
while (!gotLast) {
// Send request for loading flight entry on flight side and wait for ack/nack
m_flightLogControl->setEntry(entry);
UAVObjectUpdaterHelper::Result result = updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT);
if(result == UAVObjectUpdaterHelper::SUCCESS) {
if (result == UAVObjectUpdaterHelper::SUCCESS) {
result = requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT);
if(result == UAVObjectUpdaterHelper::TIMEOUT) {
if (result == UAVObjectUpdaterHelper::TIMEOUT) {
timedOut = true;
break;
} else {
if(!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY &&
m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) {
//Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list
ExtendedDebugLogEntry* logEntry = new ExtendedDebugLogEntry();
if (!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY &&
m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) {
// Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list
ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry();
logEntry->setObjectManager(m_objectManager);
logEntry->setData(m_flightLogEntry->getData());
m_logEntries.append(logEntry);
m_logEntries << logEntry;
// Increment to get next entry from flight side
entry++;
@ -139,7 +144,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) {
break;
}
}
if(timedOut) {
if (timedOut) {
// We timed out, do something smart here to alert the user
break;
}
@ -148,17 +153,15 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve) {
}
void FlightLogManager::exportLogs()
{
}
{}
ExtendedDebugLogEntry::ExtendedDebugLogEntry() : DebugLogEntry(),
m_objectManager(0), m_object(0)
{
}
{}
ExtendedDebugLogEntry::~ExtendedDebugLogEntry()
{
if(m_object) {
if (m_object) {
delete m_object;
m_object = 0;
}
@ -166,11 +169,11 @@ ExtendedDebugLogEntry::~ExtendedDebugLogEntry()
QString ExtendedDebugLogEntry::getLogString()
{
if(getType() == DebugLogEntry::TYPE_TEXT) {
return QString((const char*)getData().Data);
if (getType() == DebugLogEntry::TYPE_TEXT) {
return QString((const char *)getData().Data);
} else if (getType() == DebugLogEntry::TYPE_UAVOBJECT) {
UAVDataObject *object = (UAVDataObject*)m_objectManager->getObject(getObjectID(), getInstanceID());
object = object->clone(getInstanceID());
UAVDataObject *object = (UAVDataObject *)m_objectManager->getObject(getObjectID(), getInstanceID());
object = object->clone(getInstanceID());
object->unpack(getData().Data);
m_object = object;
return object->toString().replace("\n", " ").replace("\t", " ");

View File

@ -39,19 +39,24 @@
#include "debuglogcontrol.h"
class ExtendedDebugLogEntry : public DebugLogEntry {
Q_OBJECT
Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated)
Q_OBJECT Q_PROPERTY(QString LogString READ getLogString WRITE setLogString NOTIFY LogStringUpdated)
public:
explicit ExtendedDebugLogEntry();
~ExtendedDebugLogEntry();
QString getLogString();
UAVDataObject* uavObject() { return m_object; }
UAVDataObject *uavObject()
{
return m_object;
}
void setObjectManager(UAVObjectManager *objectManager);
public slots:
void setLogString(QString arg){ Q_UNUSED(arg); }
void setLogString(QString arg)
{
Q_UNUSED(arg);
}
signals:
void LogStringUpdated(QString arg);
@ -62,8 +67,7 @@ private:
};
class FlightLogManager : public QObject {
Q_OBJECT
Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus)
Q_OBJECT Q_PROPERTY(DebugLogStatus *flightLogStatus READ flightLogStatus)
Q_PROPERTY(QQmlListProperty<ExtendedDebugLogEntry> logEntries READ logEntries NOTIFY logEntriesChanged)
public:
@ -72,12 +76,12 @@ public:
QQmlListProperty<ExtendedDebugLogEntry> logEntries();
DebugLogStatus* flightLogStatus() const
DebugLogStatus *flightLogStatus() const
{
return m_flightLogStatus;
}
signals:
signals:
void logEntriesChanged();
public slots:
@ -93,7 +97,6 @@ private:
QList<ExtendedDebugLogEntry *> m_logEntries;
static const int UAVTALK_TIMEOUT = 4000;
};
#endif // FLIGHTLOGMANAGER_H

View File

@ -36,8 +36,7 @@
#include "flightlogdialog.h"
FlightLogPlugin::FlightLogPlugin() : m_logDialog(0)
{
}
{}
FlightLogPlugin::~FlightLogPlugin()
{
@ -48,7 +47,7 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
{
Q_UNUSED(args);
Q_UNUSED(errMsg);
// Add Menu entry
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_TOOLS);
@ -72,7 +71,7 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
void FlightLogPlugin::ShowLogManagementDialog()
{
if(!m_logDialog) {
if (!m_logDialog) {
m_logDialog = new FlightLogDialog(0, new FlightLogManager());
connect(m_logDialog, SIGNAL(finished(int)), this, SLOT(LogManagementDialogClosed()));
m_logDialog->show();
@ -81,19 +80,18 @@ void FlightLogPlugin::ShowLogManagementDialog()
void FlightLogPlugin::LogManagementDialogClosed()
{
if(m_logDialog) {
if (m_logDialog) {
m_logDialog->deleteLater();
m_logDialog = 0;
}
}
void FlightLogPlugin::extensionsInitialized()
{
}
{}
void FlightLogPlugin::shutdown()
{
if(m_logDialog) {
if (m_logDialog) {
m_logDialog->close();
LogManagementDialogClosed();
}

View File

@ -47,7 +47,7 @@ private slots:
void LogManagementDialogClosed();
private:
FlightLogDialog* m_logDialog;
FlightLogDialog *m_logDialog;
};
#endif /* FLIGHTLOGPLUGIN_H_ */