Skip to content

Commit

Permalink
Various refactoring, retrying win build with travis
Browse files Browse the repository at this point in the history
  • Loading branch information
vranki committed Jun 12, 2018
1 parent f0982fd commit 9c59ec5
Show file tree
Hide file tree
Showing 16 changed files with 231 additions and 143 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ language: cpp
compiler:
- gcc
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq qtbase5-dev qtdeclarative5-dev qt5-default build-essential wget git unzip autoconf autopoint bison flex gperf intltool libtool ruby scons p7zip-full python3 libgdk-pixbuf2.0-dev libffi-dev
- sudo apt-get update -qq
- sudo apt-get -yq install gnupg
- sudo echo "deb http://pkg.mxe.cc/repos/apt/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mxeapt.list
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D43A795B73B16ABE9643FE1AFD8FFF16DB45C6AB
- sudo apt-get update -qq
- sudo apt-get install -yq mxe-x86-64-w64-mingw32.static-qtbase mxe-x86-64-w64-mingw32.static-qtdeclarative
- sudo apt-get install -qq qtbase5-dev qtdeclarative5-dev qt5-default build-essential
script: ./scripts/ci-build.sh
branches:
only:
Expand All @@ -17,7 +22,6 @@ notifications:
on_failure: change
cache:
directories:
- ../mxe
- ../XPlaneSDK
deploy:
provider: releases
Expand Down
105 changes: 83 additions & 22 deletions clients/extplane-client-qt/clientdataref.cpp
Original file line number Diff line number Diff line change
@@ -1,62 +1,123 @@
#include "clientdataref.h"
#include "extplaneclient.h"

ClientDataRef::ClientDataRef(QObject *parent, QString newName, double accuracy) : QObject(parent), _name(newName), _accuracy(accuracy) {
_subscribers = 0;
_values.reserve(1); // Always at least 1 size
ClientDataRef::ClientDataRef() : QObject(nullptr)
, m_accuracy(0)
, m_subscribers(0)
,m_client(nullptr)
{
m_values.reserve(1); // Always at least 1 size
}

ClientDataRef::ClientDataRef(QObject *parent, QString newName, double accuracy) : QObject(parent)
, m_name(newName)
, m_accuracy(accuracy)
, m_subscribers(0)
, m_client(nullptr) {
m_values.reserve(1); // Always at least 1 size
}

QString& ClientDataRef::name() {
return _name;
return m_name;
}

void ClientDataRef::setName(QString &name)
{
if (m_name == name)
return;

m_name = name;
emit nameChanged(m_name);
}

QString& ClientDataRef::valueString() {
return _values.first();
QString ClientDataRef::value()
{
return m_values.isEmpty() ? "" : m_values.first();
}

QStringList& ClientDataRef::valueStrings() {
return _values;
ExtPlaneClient *ClientDataRef::client() const
{
return m_client;
}

QStringList& ClientDataRef::values() {
return m_values;
}

void ClientDataRef::updateValue(QString newValue) {
if(!_values.isEmpty() && newValue == _values.first()) return;
if(!m_values.isEmpty() && newValue == m_values.first()) return;

if(_values.isEmpty()) {
_values.push_back(newValue);
if(m_values.isEmpty()) {
m_values.push_back(newValue);
} else {
_values.replace(0, newValue);
m_values.replace(0, newValue);
}
emit changed(this);
}

void ClientDataRef::updateValue(QStringList &newValues) {
if(newValues == _values) return;
_values = newValues;
if(newValues == m_values) return;
m_values = newValues;
emit changed(this);
}

double ClientDataRef::accuracy() {
return _accuracy;
return m_accuracy;
}

int ClientDataRef::subscribers() {
return _subscribers;
return m_subscribers;
}

void ClientDataRef::setSubscribers(int sub) {
_subscribers = sub;
m_subscribers = sub;
}

void ClientDataRef::setValue(double _newValue, int index) {
if(_values.size() < index + 1)
_values.reserve(index+1);
_values[index] = QString::number(_newValue);
void ClientDataRef::setValue(QString _newValue, int index) {
if(m_values.size() < index + 1)
m_values.reserve(index+1);
m_values[index] = _newValue;
emit valueSet(this);
}

void ClientDataRef::unsubscribe() {
emit unsubscribed(this);
}


void ClientDataRef::setAccuracy(double accuracy)
{
qWarning("Floating point comparison needs context sanity check");
if (qFuzzyCompare(m_accuracy, accuracy))
return;

m_accuracy = accuracy;
emit accuracyChanged(m_accuracy);
}

void ClientDataRef::setValues(QStringList values)
{
if(values == m_values) return;
m_values = values;
emit changed(this);
}

void ClientDataRef::setClient(ExtPlaneClient *client)
{
if (m_client == client)
return;

m_client = client;
emit clientChanged(m_client);
}

void ClientDataRef::subscribeIfPossible()
{
if(m_client && !m_name.isEmpty()) {
m_client->subscribeDataRef(m_name, m_accuracy);
}
}

bool ClientDataRef::isArray() {
return _values.size() > 1;
return m_values.size() > 1;
}
42 changes: 33 additions & 9 deletions clients/extplane-client-qt/clientdataref.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <QObject>
#include <QStringList>

class ExtPlaneClient;

/**
* Represents a single dataref in client side. Can contain multiple
* values, if ref is a array.
Expand All @@ -16,28 +18,50 @@
*/
class ClientDataRef : public QObject {
Q_OBJECT
Q_PROPERTY(ExtPlaneClient* client READ client WRITE setClient NOTIFY clientChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString value READ value WRITE setValue NOTIFY changed)
Q_PROPERTY(QStringList values READ values WRITE setValues NOTIFY changed)
Q_PROPERTY(double accuracy READ accuracy WRITE setAccuracy NOTIFY accuracyChanged)

public:
explicit ClientDataRef();
explicit ClientDataRef(QObject *parent, QString newName, double accuracy=0);
QString& name();
QString& valueString(); // Returns first value
QStringList& valueStrings(); // Returns all values
QStringList& values(); // Returns all values
double accuracy();
void updateValue(QString newValue); // Update single value
void updateValue(QStringList &newValues); // Update full array
void updateValue(QString newValue); // Update single value (from simulator)
void updateValue(QStringList &newValues); // Update full array (from simulator)
int subscribers();
void setSubscribers(int sub);
void setValue(double _newValue, int index=0);
bool isArray();
void unsubscribe(); // Call to unsubscribe ref.
QString value(); // Returns first value
ExtPlaneClient* client() const;

public slots:
void setName(QString &name);
void setAccuracy(double accuracy);
void setValue(QString _newValue, int index=0);
void setValues(QStringList values);
void setClient(ExtPlaneClient* client);

signals:
void changed(ClientDataRef *ref);
void valueSet(ClientDataRef *ref);
void unsubscribed(ClientDataRef *ref);
void nameChanged(QString name);
void accuracyChanged(double accuracy);
void clientChanged(ExtPlaneClient* client);

private:
QString _name;
QStringList _values;
double _accuracy;
int _subscribers;
void subscribeIfPossible();

QString m_name;
QStringList m_values;
double m_accuracy;
int m_subscribers;
ExtPlaneClient* m_client;
};

#endif // CLIENTDATAREF_H
8 changes: 0 additions & 8 deletions clients/extplane-client-qt/clientdatarefprovider.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
#include "clientdatarefprovider.h"

ClientDataRefProvider::ClientDataRefProvider()
{
}

ClientDataRefProvider::~ClientDataRefProvider()
{
}
16 changes: 7 additions & 9 deletions clients/extplane-client-qt/clientdatarefprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@
class ClientDataRefProvider
{
public:
ClientDataRefProvider();
virtual ~ClientDataRefProvider();
virtual ClientDataRef *subscribeDataRef(QString name, double accuracy=0)=0;
virtual void unsubscribeDataRef(ClientDataRef *ref)=0;
virtual ClientDataRef *subscribeDataRef(QString name, double accuracy = 0) = 0;
virtual void unsubscribeDataRef(ClientDataRef *ref) = 0;
// virtual void getDataRef(QString name)=0; // get command not supported yet
virtual void keyPress(int id)=0;
virtual void buttonPress(int id)=0;
virtual void buttonRelease(int id)=0;
virtual void keyPress(int id) = 0;
virtual void buttonPress(int id) = 0;
virtual void buttonRelease(int id) = 0;
virtual void commandOnce(QString name) = 0;
virtual void commandBegin(QString name) = 0;
virtual void commandEnd(QString name) = 0;
virtual void setValue(QString name, QString value)=0; // For single value
virtual void setValues(QString name, QStringList values)=0; // For arrays
virtual void setValue(QString name, QString value) = 0; // For single value
virtual void setValues(QString name, QStringList values) = 0; // For arrays
};

#endif // CLIENTDATAREFPROVIDER_H
Loading

0 comments on commit 9c59ec5

Please sign in to comment.