This repository has been archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements ConnectionTracker for future notification systems.
- Loading branch information
Showing
8 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <QDebug> | ||
|
||
#include "connectiontracker.h" | ||
|
||
#include "models/vialistmodel.h" | ||
#include "api.h" | ||
#include "os.h" | ||
|
||
ConnectionTracker::ConnectionTracker(QObject *parent) | ||
: QObject(parent), m_connections() | ||
{ | ||
|
||
} | ||
|
||
|
||
void ConnectionTracker::toggleTracked(int i) { | ||
auto connection = m_api->connections()->connectionList()[i]; | ||
|
||
auto uuid = connection->uuid(); | ||
qDebug() << "toggle tracking of" << connection->from()->station()->name() << " to " << connection->to()->station()->name() | ||
<< "with uuid" << uuid; | ||
|
||
if(m_connections.contains(uuid)) { | ||
m_connections.remove(uuid); | ||
emit connectionUntracked(uuid); | ||
} else { | ||
m_connections.insert(uuid, connection); | ||
emit connectionTracked(uuid, connection); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef CONNECTIONTRACKER_H | ||
#define CONNECTIONTRACKER_H | ||
|
||
#include <QObject> | ||
#include <QUuid> | ||
#include <QMap> | ||
|
||
#include "models/connection.h" | ||
#include "models/vialistmodel.h" | ||
|
||
#include "os.h" | ||
#include "api.h" | ||
|
||
class ConnectionTracker: public QObject { | ||
Q_OBJECT | ||
Q_PROPERTY(API *api MEMBER m_api) | ||
public: | ||
ConnectionTracker(QObject *parent = nullptr); | ||
Q_INVOKABLE void toggleTracked(int i); | ||
|
||
void setApi(API *api) { this->m_api = api; } | ||
API *api() { return this->m_api; } | ||
|
||
signals: | ||
void connectionTracked(QUuid, QSharedPointer<Connection>); | ||
void connectionUntracked(QUuid); | ||
|
||
private: | ||
QMap<QUuid, QSharedPointer<Connection>> m_connections; | ||
API *m_api; | ||
OS sfos; | ||
}; | ||
|
||
#endif // CONNECTIONTRACKER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters