mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
OP-1122 OP-1123 fixed OSX specific GCS compilation errors
This commit is contained in:
parent
ee1584d639
commit
339e69f25d
@ -28,8 +28,10 @@
|
|||||||
#include "flightdatamodel.h"
|
#include "flightdatamodel.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
|
|
||||||
flightDataModel::flightDataModel(QObject *parent) : QAbstractTableModel(parent)
|
flightDataModel::flightDataModel(QObject *parent) : QAbstractTableModel(parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int flightDataModel::rowCount(const QModelIndex & /*parent*/) const
|
int flightDataModel::rowCount(const QModelIndex & /*parent*/) const
|
||||||
{
|
{
|
||||||
@ -72,332 +74,270 @@ QVariant flightDataModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
bool flightDataModel::setColumnByIndex(pathPlanData *row, const int index, const QVariant value)
|
bool flightDataModel::setColumnByIndex(pathPlanData *row, const int index, const QVariant value)
|
||||||
{
|
{
|
||||||
|
bool b;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case WPDESCRITPTION:
|
case WPDESCRITPTION:
|
||||||
row->wpDescritption = value.toString();
|
row->wpDescritption = value.toString();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LATPOSITION:
|
case LATPOSITION:
|
||||||
row->latPosition = value.toDouble();
|
row->latPosition = value.toDouble();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LNGPOSITION:
|
case LNGPOSITION:
|
||||||
row->lngPosition = value.toDouble();
|
row->lngPosition = value.toDouble();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DISRELATIVE:
|
case DISRELATIVE:
|
||||||
row->disRelative = value.toDouble();
|
row->disRelative = value.toDouble();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case BEARELATIVE:
|
case BEARELATIVE:
|
||||||
row->beaRelative = value.toDouble();
|
row->beaRelative = value.toDouble();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ALTITUDERELATIVE:
|
case ALTITUDERELATIVE:
|
||||||
row->altitudeRelative = value.toFloat();
|
row->altitudeRelative = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ISRELATIVE:
|
case ISRELATIVE:
|
||||||
row->isRelative = value.toBool();
|
row->isRelative = value.toBool();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ALTITUDE:
|
case ALTITUDE:
|
||||||
row->altitude = value.toDouble();
|
row->altitude = value.toDouble();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case VELOCITY:
|
case VELOCITY:
|
||||||
row->velocity = value.toFloat();
|
row->velocity = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE:
|
case MODE:
|
||||||
row->mode = value.toInt();
|
row->mode = value.toInt();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS0:
|
case MODE_PARAMS0:
|
||||||
row->mode_params[0] = value.toFloat();
|
row->mode_params[0] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS1:
|
case MODE_PARAMS1:
|
||||||
row->mode_params[1] = value.toFloat();
|
row->mode_params[1] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS2:
|
case MODE_PARAMS2:
|
||||||
row->mode_params[2] = value.toFloat();
|
row->mode_params[2] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS3:
|
case MODE_PARAMS3:
|
||||||
row->mode_params[3] = value.toFloat();
|
row->mode_params[3] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION:
|
case CONDITION:
|
||||||
row->condition = value.toInt();
|
row->condition = value.toInt();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS0:
|
case CONDITION_PARAMS0:
|
||||||
row->condition_params[0] = value.toFloat();
|
row->condition_params[0] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS1:
|
case CONDITION_PARAMS1:
|
||||||
row->condition_params[1] = value.toFloat();
|
row->condition_params[1] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS2:
|
case CONDITION_PARAMS2:
|
||||||
row->condition_params[2] = value.toFloat();
|
row->condition_params[2] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS3:
|
case CONDITION_PARAMS3:
|
||||||
row->condition_params[3] = value.toFloat();
|
row->condition_params[3] = value.toFloat();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case COMMAND:
|
case COMMAND:
|
||||||
row->command = value.toInt();
|
row->command = value.toInt();
|
||||||
|
b = true;
|
||||||
break;
|
break;
|
||||||
case JUMPDESTINATION:
|
case JUMPDESTINATION:
|
||||||
row->jumpdestination = value.toInt();
|
row->jumpdestination = value.toInt();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ERRORDESTINATION:
|
case ERRORDESTINATION:
|
||||||
row->errordestination = value.toInt();
|
row->errordestination = value.toInt();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LOCKED:
|
case LOCKED:
|
||||||
row->locked = value.toBool();
|
row->locked = value.toBool();
|
||||||
return true;
|
b = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
b = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant flightDataModel::getColumnByIndex(const pathPlanData *row, const int index) const
|
QVariant flightDataModel::getColumnByIndex(const pathPlanData *row, const int index) const
|
||||||
{
|
{
|
||||||
|
QVariant value;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case WPDESCRITPTION:
|
case WPDESCRITPTION:
|
||||||
return row->wpDescritption;
|
value = row->wpDescritption;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LATPOSITION:
|
case LATPOSITION:
|
||||||
return row->latPosition;
|
value = row->latPosition;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LNGPOSITION:
|
case LNGPOSITION:
|
||||||
return row->lngPosition;
|
value = row->lngPosition;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DISRELATIVE:
|
case DISRELATIVE:
|
||||||
return row->disRelative;
|
value = row->disRelative;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case BEARELATIVE:
|
case BEARELATIVE:
|
||||||
return row->beaRelative;
|
value = row->beaRelative;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ALTITUDERELATIVE:
|
case ALTITUDERELATIVE:
|
||||||
return row->altitudeRelative;
|
value = row->altitudeRelative;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ISRELATIVE:
|
case ISRELATIVE:
|
||||||
return row->isRelative;
|
value = row->isRelative;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ALTITUDE:
|
case ALTITUDE:
|
||||||
return row->altitude;
|
value = row->altitude;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case VELOCITY:
|
case VELOCITY:
|
||||||
return row->velocity;
|
value = row->velocity;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE:
|
case MODE:
|
||||||
return row->mode;
|
value = row->mode;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS0:
|
case MODE_PARAMS0:
|
||||||
return row->mode_params[0];
|
value = row->mode_params[0];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS1:
|
case MODE_PARAMS1:
|
||||||
return row->mode_params[1];
|
value = row->mode_params[1];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS2:
|
case MODE_PARAMS2:
|
||||||
return row->mode_params[2];
|
value = row->mode_params[2];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS3:
|
case MODE_PARAMS3:
|
||||||
return row->mode_params[3];
|
value = row->mode_params[3];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION:
|
case CONDITION:
|
||||||
return row->condition;
|
value = row->condition;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS0:
|
case CONDITION_PARAMS0:
|
||||||
return row->condition_params[0];
|
value = row->condition_params[0];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS1:
|
case CONDITION_PARAMS1:
|
||||||
return row->condition_params[1];
|
value = row->condition_params[1];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS2:
|
case CONDITION_PARAMS2:
|
||||||
return row->condition_params[2];
|
value = row->condition_params[2];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS3:
|
case CONDITION_PARAMS3:
|
||||||
return row->condition_params[3];
|
value = row->condition_params[3];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case COMMAND:
|
case COMMAND:
|
||||||
return row->command;
|
value = row->command;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case JUMPDESTINATION:
|
case JUMPDESTINATION:
|
||||||
return row->jumpdestination;
|
value = row->jumpdestination;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ERRORDESTINATION:
|
case ERRORDESTINATION:
|
||||||
return row->errordestination;
|
value = row->errordestination;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LOCKED:
|
case LOCKED:
|
||||||
return row->locked;
|
value = row->locked;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return NULL;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant flightDataModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant flightDataModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
|
QVariant value;
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if (orientation == Qt::Vertical) {
|
if (orientation == Qt::Vertical) {
|
||||||
return QString::number(section + 1);
|
value = QString::number(section + 1);
|
||||||
} else if (orientation == Qt::Horizontal) {
|
} else if (orientation == Qt::Horizontal) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case WPDESCRITPTION:
|
case WPDESCRITPTION:
|
||||||
return QString("Description");
|
value = QString("Description");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LATPOSITION:
|
case LATPOSITION:
|
||||||
return QString("Latitude");
|
value = QString("Latitude");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LNGPOSITION:
|
case LNGPOSITION:
|
||||||
return QString("Longitude");
|
value = QString("Longitude");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DISRELATIVE:
|
case DISRELATIVE:
|
||||||
return QString("Distance to home");
|
value = QString("Distance to home");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case BEARELATIVE:
|
case BEARELATIVE:
|
||||||
return QString("Bearing from home");
|
value = QString("Bearing from home");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ALTITUDERELATIVE:
|
case ALTITUDERELATIVE:
|
||||||
return QString("Altitude above home");
|
value = QString("Altitude above home");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ISRELATIVE:
|
case ISRELATIVE:
|
||||||
return QString("Relative to home");
|
value = QString("Relative to home");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ALTITUDE:
|
case ALTITUDE:
|
||||||
return QString("Altitude");
|
value = QString("Altitude");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case VELOCITY:
|
case VELOCITY:
|
||||||
return QString("Velocity");
|
value = QString("Velocity");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE:
|
case MODE:
|
||||||
return QString("Mode");
|
value = QString("Mode");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS0:
|
case MODE_PARAMS0:
|
||||||
return QString("Mode parameter 0");
|
value = QString("Mode parameter 0");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS1:
|
case MODE_PARAMS1:
|
||||||
return QString("Mode parameter 1");
|
value = QString("Mode parameter 1");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS2:
|
case MODE_PARAMS2:
|
||||||
return QString("Mode parameter 2");
|
value = QString("Mode parameter 2");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MODE_PARAMS3:
|
case MODE_PARAMS3:
|
||||||
return QString("Mode parameter 3");
|
value = QString("Mode parameter 3");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION:
|
case CONDITION:
|
||||||
return QString("Condition");
|
value = QString("Condition");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS0:
|
case CONDITION_PARAMS0:
|
||||||
return QString("Condition parameter 0");
|
value = QString("Condition parameter 0");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS1:
|
case CONDITION_PARAMS1:
|
||||||
return QString("Condition parameter 1");
|
value = QString("Condition parameter 1");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS2:
|
case CONDITION_PARAMS2:
|
||||||
return QString("Condition parameter 2");
|
value = QString("Condition parameter 2");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CONDITION_PARAMS3:
|
case CONDITION_PARAMS3:
|
||||||
return QString("Condition parameter 3");
|
value = QString("Condition parameter 3");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case COMMAND:
|
case COMMAND:
|
||||||
return QString("Command");
|
value = QString("Command");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case JUMPDESTINATION:
|
case JUMPDESTINATION:
|
||||||
return QString("Jump Destination");
|
value = QString("Jump Destination");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ERRORDESTINATION:
|
case ERRORDESTINATION:
|
||||||
return QString("Error Destination");
|
value = QString("Error Destination");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case LOCKED:
|
case LOCKED:
|
||||||
return QString("Locked");
|
value = QString("Locked");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return QString();
|
value = QString();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return QAbstractTableModel::headerData(section, orientation, role);
|
value = QAbstractTableModel::headerData(section, orientation, role);
|
||||||
}
|
}
|
||||||
return NULL;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool flightDataModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool flightDataModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
@ -665,54 +605,56 @@ void flightDataModel::readFromFile(QString fileName)
|
|||||||
while (!fieldNode.isNull()) {
|
while (!fieldNode.isNull()) {
|
||||||
QDomElement field = fieldNode.toElement();
|
QDomElement field = fieldNode.toElement();
|
||||||
if (field.tagName() == "field") {
|
if (field.tagName() == "field") {
|
||||||
if (field.attribute("name") == "altitude") {
|
QString name = field.attribute("name");
|
||||||
data->altitude = field.attribute("value").toDouble();
|
QString value = field.attribute("value");
|
||||||
} else if (field.attribute("name") == "description") {
|
if (name == "altitude") {
|
||||||
data->wpDescritption = field.attribute("value");
|
data->altitude = value.toDouble();
|
||||||
} else if (field.attribute("name") == "latitude") {
|
} else if (name == "description") {
|
||||||
data->latPosition = field.attribute("value").toDouble();
|
data->wpDescritption = value;
|
||||||
} else if (field.attribute("name") == "longitude") {
|
} else if (name == "latitude") {
|
||||||
data->lngPosition = field.attribute("value").toDouble();
|
data->latPosition = value.toDouble();
|
||||||
} else if (field.attribute("name") == "distance_to_home") {
|
} else if (name == "longitude") {
|
||||||
data->disRelative = field.attribute("value").toDouble();
|
data->lngPosition = value.toDouble();
|
||||||
} else if (field.attribute("name") == "bearing_from_home") {
|
} else if (name == "distance_to_home") {
|
||||||
data->beaRelative = field.attribute("value").toDouble();
|
data->disRelative = value.toDouble();
|
||||||
} else if (field.attribute("name") == "altitude_above_home") {
|
} else if (name == "bearing_from_home") {
|
||||||
data->altitudeRelative = field.attribute("value").toFloat();
|
data->beaRelative = value.toDouble();
|
||||||
} else if (field.attribute("name") == "is_relative_to_home") {
|
} else if (name == "altitude_above_home") {
|
||||||
data->isRelative = field.attribute("value").toInt();
|
data->altitudeRelative = value.toFloat();
|
||||||
} else if (field.attribute("name") == "altitude") {
|
} else if (name == "is_relative_to_home") {
|
||||||
data->altitude = field.attribute("value").toDouble();
|
data->isRelative = value.toInt();
|
||||||
} else if (field.attribute("name") == "velocity") {
|
} else if (name == "altitude") {
|
||||||
data->velocity = field.attribute("value").toFloat();
|
data->altitude = value.toDouble();
|
||||||
} else if (field.attribute("name") == "mode") {
|
} else if (name == "velocity") {
|
||||||
data->mode = field.attribute("value").toInt();
|
data->velocity = value.toFloat();
|
||||||
} else if (field.attribute("name") == "mode_param0") {
|
} else if (name == "mode") {
|
||||||
data->mode_params[0] = field.attribute("value").toFloat();
|
data->mode = value.toInt();
|
||||||
} else if (field.attribute("name") == "mode_param1") {
|
} else if (name == "mode_param0") {
|
||||||
data->mode_params[1] = field.attribute("value").toFloat();
|
data->mode_params[0] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "mode_param2") {
|
} else if (name == "mode_param1") {
|
||||||
data->mode_params[2] = field.attribute("value").toFloat();
|
data->mode_params[1] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "mode_param3") {
|
} else if (name == "mode_param2") {
|
||||||
data->mode_params[3] = field.attribute("value").toFloat();
|
data->mode_params[2] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "condition") {
|
} else if (name == "mode_param3") {
|
||||||
data->condition = field.attribute("value").toDouble();
|
data->mode_params[3] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "condition_param0") {
|
} else if (name == "condition") {
|
||||||
data->condition_params[0] = field.attribute("value").toFloat();
|
data->condition = value.toDouble();
|
||||||
} else if (field.attribute("name") == "condition_param1") {
|
} else if (name == "condition_param0") {
|
||||||
data->condition_params[1] = field.attribute("value").toFloat();
|
data->condition_params[0] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "condition_param2") {
|
} else if (name == "condition_param1") {
|
||||||
data->condition_params[2] = field.attribute("value").toFloat();
|
data->condition_params[1] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "condition_param3") {
|
} else if (name == "condition_param2") {
|
||||||
data->condition_params[3] = field.attribute("value").toFloat();
|
data->condition_params[2] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "command") {
|
} else if (name == "condition_param3") {
|
||||||
data->command = field.attribute("value").toInt();
|
data->condition_params[3] = value.toFloat();
|
||||||
} else if (field.attribute("name") == "jumpdestination") {
|
} else if (name == "command") {
|
||||||
data->jumpdestination = field.attribute("value").toInt();
|
data->command = value.toInt();
|
||||||
} else if (field.attribute("name") == "errordestination") {
|
} else if (name == "jumpdestination") {
|
||||||
data->errordestination = field.attribute("value").toInt();
|
data->jumpdestination = value.toInt();
|
||||||
} else if (field.attribute("name") == "is_locked") {
|
} else if (name == "errordestination") {
|
||||||
data->locked = field.attribute("value").toInt();
|
data->errordestination = value.toInt();
|
||||||
|
} else if (name == "is_locked") {
|
||||||
|
data->locked = value.toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fieldNode = fieldNode.nextSibling();
|
fieldNode = fieldNode.nextSibling();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user