Commit 4feba023 authored by Gus Grubba's avatar Gus Grubba

WIP Flight List Management

parent a39013e9
...@@ -658,7 +658,7 @@ AirMapFlightPlanManager::loadFlightList() ...@@ -658,7 +658,7 @@ AirMapFlightPlanManager::loadFlightList()
void void
AirMapFlightPlanManager::_loadFlightList() AirMapFlightPlanManager::_loadFlightList()
{ {
_flightList.clearAndDeleteContents(); _flightList.clear();
emit flightListChanged(); emit flightListChanged();
_state = State::LoadFlightList; _state = State::LoadFlightList;
std::weak_ptr<LifetimeChecker> isAlive(_instance); std::weak_ptr<LifetimeChecker> isAlive(_instance);
...@@ -667,7 +667,7 @@ AirMapFlightPlanManager::_loadFlightList() ...@@ -667,7 +667,7 @@ AirMapFlightPlanManager::_loadFlightList()
if (_state != State::LoadFlightList) return; if (_state != State::LoadFlightList) return;
Flights::Search::Parameters params; Flights::Search::Parameters params;
params.authorization = login_token.toStdString(); params.authorization = login_token.toStdString();
params.limit = 200; params.limit = 60;
params.pilot_id = _pilotID.toStdString(); params.pilot_id = _pilotID.toStdString();
_shared.client()->flights().search(params, [this, isAlive](const Flights::Search::Result& result) { _shared.client()->flights().search(params, [this, isAlive](const Flights::Search::Result& result) {
if (!isAlive.lock()) return; if (!isAlive.lock()) return;
......
...@@ -29,9 +29,9 @@ class AirMapFlightInfo : public AirspaceFlightInfo ...@@ -29,9 +29,9 @@ class AirMapFlightInfo : public AirspaceFlightInfo
public: public:
AirMapFlightInfo (const airmap::Flight& flight, QObject *parent = nullptr); AirMapFlightInfo (const airmap::Flight& flight, QObject *parent = nullptr);
virtual QString flightID () override { return QString::fromStdString(_flight.id); } virtual QString flightID () override { return QString::fromStdString(_flight.id); }
virtual QDateTime createdTime () override { return QDateTime(); } //-- TODO: Need to get rid of boost first virtual QString createdTime () override { return QDateTime::currentDateTime().toString(Qt::SystemLocaleShortDate); } //-- TODO: Need to get rid of boost first
virtual QDateTime startTime () override { return QDateTime(); } //-- TODO: Need to get rid of boost first virtual QString startTime () override { return QDateTime::currentDateTime().toString(Qt::SystemLocaleShortDate); } //-- TODO: Need to get rid of boost first
virtual QDateTime endTime () override { return QDateTime(); } //-- TODO: Need to get rid of boost first virtual QString endTime () override { return QDateTime::currentDateTime().toString(Qt::SystemLocaleShortDate); } //-- TODO: Need to get rid of boost first
virtual QGeoCoordinate takeOff () override { return QGeoCoordinate(_flight.latitude, _flight.longitude);} virtual QGeoCoordinate takeOff () override { return QGeoCoordinate(_flight.latitude, _flight.longitude);}
virtual QmlObjectListModel* boundingBox () override { return &_boundingBox; } virtual QmlObjectListModel* boundingBox () override { return &_boundingBox; }
private: private:
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
QmlObjectListModel* rulesReview () override { return &_rulesReview; } QmlObjectListModel* rulesReview () override { return &_rulesReview; }
QmlObjectListModel* rulesFollowing () override { return &_rulesFollowing; } QmlObjectListModel* rulesFollowing () override { return &_rulesFollowing; }
QmlObjectListModel* briefFeatures () override { return &_briefFeatures; } QmlObjectListModel* briefFeatures () override { return &_briefFeatures; }
QmlObjectListModel* flightList () override { return &_flightList; } AirspaceFlightModel*flightList () override { return &_flightList; }
void updateFlightPlan () override; void updateFlightPlan () override;
void submitFlightPlan () override; void submitFlightPlan () override;
...@@ -131,7 +131,7 @@ private: ...@@ -131,7 +131,7 @@ private:
QmlObjectListModel _rulesReview; QmlObjectListModel _rulesReview;
QmlObjectListModel _rulesFollowing; QmlObjectListModel _rulesFollowing;
QmlObjectListModel _briefFeatures; QmlObjectListModel _briefFeatures;
QmlObjectListModel _flightList; AirspaceFlightModel _flightList;
AirspaceAdvisoryProvider::AdvisoryColor _airspaceColor; AirspaceAdvisoryProvider::AdvisoryColor _airspaceColor;
AirspaceFlightPlanProvider::PermitStatus _flightPermitStatus = AirspaceFlightPlanProvider::PermitNone; AirspaceFlightPlanProvider::PermitStatus _flightPermitStatus = AirspaceFlightPlanProvider::PermitNone;
......
This diff is collapsed.
...@@ -8,14 +8,100 @@ ...@@ -8,14 +8,100 @@
****************************************************************************/ ****************************************************************************/
#include "AirspaceFlightPlanProvider.h" #include "AirspaceFlightPlanProvider.h"
#include <QQmlEngine>
//-----------------------------------------------------------------------------
AirspaceFlightInfo::AirspaceFlightInfo(QObject *parent) AirspaceFlightInfo::AirspaceFlightInfo(QObject *parent)
: QObject(parent) : QObject(parent)
, _selected(false) , _selected(false)
{ {
} }
//-----------------------------------------------------------------------------
AirspaceFlightPlanProvider::AirspaceFlightPlanProvider(QObject *parent) AirspaceFlightPlanProvider::AirspaceFlightPlanProvider(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
} }
//-----------------------------------------------------------------------------
AirspaceFlightModel::AirspaceFlightModel(QObject *parent)
: QAbstractListModel(parent)
{
}
//-----------------------------------------------------------------------------
AirspaceFlightInfo*
AirspaceFlightModel::get(int index)
{
if (index < 0 || index >= _flightEntries.count()) {
return NULL;
}
return _flightEntries[index];
}
//-----------------------------------------------------------------------------
int
AirspaceFlightModel::count() const
{
return _flightEntries.count();
}
//-----------------------------------------------------------------------------
void
AirspaceFlightModel::append(AirspaceFlightInfo* object)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
_flightEntries.append(object);
endInsertRows();
emit countChanged();
}
//-----------------------------------------------------------------------------
void
AirspaceFlightModel::clear(void)
{
if(!_flightEntries.isEmpty()) {
beginRemoveRows(QModelIndex(), 0, _flightEntries.count());
while (_flightEntries.count()) {
AirspaceFlightInfo* entry = _flightEntries.last();
if(entry) entry->deleteLater();
_flightEntries.removeLast();
}
endRemoveRows();
emit countChanged();
}
}
//-----------------------------------------------------------------------------
AirspaceFlightInfo*
AirspaceFlightModel::operator[](int index)
{
return get(index);
}
//-----------------------------------------------------------------------------
int
AirspaceFlightModel::rowCount(const QModelIndex& /*parent*/) const
{
return _flightEntries.count();
}
//-----------------------------------------------------------------------------
QVariant
AirspaceFlightModel::data(const QModelIndex & index, int role) const {
if (index.row() < 0 || index.row() >= _flightEntries.count())
return QVariant();
if (role == ObjectRole)
return QVariant::fromValue(_flightEntries[index.row()]);
return QVariant();
}
//-----------------------------------------------------------------------------
QHash<int, QByteArray>
AirspaceFlightModel::roleNames() const {
QHash<int, QByteArray> roles;
roles[ObjectRole] = "flightEntry";
return roles;
}
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
#include <QObject> #include <QObject>
#include <QDateTime> #include <QDateTime>
#include <QAbstractListModel>
class PlanMasterController; class PlanMasterController;
class AirspaceFlightInfo;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class AirspaceFlightInfo : public QObject class AirspaceFlightInfo : public QObject
...@@ -30,17 +32,17 @@ public: ...@@ -30,17 +32,17 @@ public:
AirspaceFlightInfo (QObject *parent = nullptr); AirspaceFlightInfo (QObject *parent = nullptr);
Q_PROPERTY(QString flightID READ flightID CONSTANT) Q_PROPERTY(QString flightID READ flightID CONSTANT)
Q_PROPERTY(QDateTime createdTime READ createdTime CONSTANT) Q_PROPERTY(QString createdTime READ createdTime CONSTANT)
Q_PROPERTY(QDateTime startTime READ startTime CONSTANT) Q_PROPERTY(QString startTime READ startTime CONSTANT)
Q_PROPERTY(QDateTime endTime READ endTime CONSTANT) Q_PROPERTY(QString endTime READ endTime CONSTANT)
Q_PROPERTY(QGeoCoordinate takeOff READ takeOff CONSTANT) Q_PROPERTY(QGeoCoordinate takeOff READ takeOff CONSTANT)
Q_PROPERTY(QmlObjectListModel* boundingBox READ boundingBox CONSTANT) Q_PROPERTY(QmlObjectListModel* boundingBox READ boundingBox CONSTANT)
Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged) Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
virtual QString flightID () = 0; virtual QString flightID () = 0;
virtual QDateTime createdTime () = 0; virtual QString createdTime () = 0;
virtual QDateTime startTime () = 0; virtual QString startTime () = 0;
virtual QDateTime endTime () = 0; virtual QString endTime () = 0;
virtual QGeoCoordinate takeOff () = 0; virtual QGeoCoordinate takeOff () = 0;
virtual QmlObjectListModel* boundingBox () = 0; virtual QmlObjectListModel* boundingBox () = 0;
...@@ -54,6 +56,40 @@ protected: ...@@ -54,6 +56,40 @@ protected:
bool _selected; bool _selected;
}; };
//-----------------------------------------------------------------------------
class AirspaceFlightModel : public QAbstractListModel
{
Q_OBJECT
public:
enum QGCLogModelRoles {
ObjectRole = Qt::UserRole + 1
};
AirspaceFlightModel(QObject *parent = 0);
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_INVOKABLE AirspaceFlightInfo* get(int index);
int count (void) const;
void append (AirspaceFlightInfo *entry);
void clear (void);
AirspaceFlightInfo*
operator[] (int i);
int rowCount (const QModelIndex & parent = QModelIndex()) const;
QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
signals:
void countChanged ();
protected:
QHash<int, QByteArray> roleNames() const;
private:
QList<AirspaceFlightInfo*> _flightEntries;
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class AirspaceFlightPlanProvider : public QObject class AirspaceFlightPlanProvider : public QObject
{ {
...@@ -85,7 +121,7 @@ public: ...@@ -85,7 +121,7 @@ public:
Q_PROPERTY(QmlObjectListModel* rulesReview READ rulesReview NOTIFY rulesChanged) Q_PROPERTY(QmlObjectListModel* rulesReview READ rulesReview NOTIFY rulesChanged)
Q_PROPERTY(QmlObjectListModel* rulesFollowing READ rulesFollowing NOTIFY rulesChanged) Q_PROPERTY(QmlObjectListModel* rulesFollowing READ rulesFollowing NOTIFY rulesChanged)
Q_PROPERTY(QmlObjectListModel* briefFeatures READ briefFeatures NOTIFY rulesChanged) Q_PROPERTY(QmlObjectListModel* briefFeatures READ briefFeatures NOTIFY rulesChanged)
Q_PROPERTY(QmlObjectListModel* flightList READ flightList NOTIFY flightListChanged) Q_PROPERTY(AirspaceFlightModel* flightList READ flightList NOTIFY flightListChanged)
//-- TODO: This will submit the current flight plan in memory. //-- TODO: This will submit the current flight plan in memory.
Q_INVOKABLE virtual void submitFlightPlan () = 0; Q_INVOKABLE virtual void submitFlightPlan () = 0;
...@@ -106,7 +142,7 @@ public: ...@@ -106,7 +142,7 @@ public:
virtual QmlObjectListModel* rulesReview () = 0; ///< List of AirspaceRule should review virtual QmlObjectListModel* rulesReview () = 0; ///< List of AirspaceRule should review
virtual QmlObjectListModel* rulesFollowing () = 0; ///< List of AirspaceRule following virtual QmlObjectListModel* rulesFollowing () = 0; ///< List of AirspaceRule following
virtual QmlObjectListModel* briefFeatures () = 0; ///< List of AirspaceRule in violation virtual QmlObjectListModel* briefFeatures () = 0; ///< List of AirspaceRule in violation
virtual QmlObjectListModel* flightList () = 0; ///< List of AirspaceFlightInfo virtual AirspaceFlightModel*flightList () = 0; ///< List of AirspaceFlightInfo
virtual void setFlightStartTime (QDateTime start) = 0; virtual void setFlightStartTime (QDateTime start) = 0;
virtual void setFlightEndTime (QDateTime end) = 0; virtual void setFlightEndTime (QDateTime end) = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment