Commit e2cc0f38 authored by Leander Schulten's avatar Leander Schulten
Browse files

fix compiler errors and remove warnings

parent 2ef1184f
#include "channel.h"
QString Channel::syncServiceClassName;
Channel::Channel(const QJsonObject &o):NamedObject(o,&syncServiceClassName),IDBase<Channel>(o),index(o["index"].toInt()){}
......
......@@ -21,7 +21,7 @@ private:
friend class DevicePrototype;
public:
static QString syncServiceClassName;
Channel(int index, QString name = "Unknown", QString description=""):NamedObject(name,description,&syncClassName),index(index){}
Channel(int index, QString name = "Unknown", QString description=""):NamedObject(name,description,&syncServiceClassName),index(index){}
Channel(const QJsonObject &o);
int getIndex()const{return index;}
......
#include "device.h"
QString Device::syncServiceClassName;
Device::Device(const QJsonObject &o):NamedObject(o,&syncServiceClassName),IDBase<Device>(o),
prototype(IDBase<DevicePrototype>::getIDBaseObjectByID(o["prototype"].toString().toLong())),
startDMXChannel(o["startDMXChannel"].toInt()),
......
#include "deviceprototype.h"
#include <QJsonArray>
QString DevicePrototype::syncServiceClassName;
void DevicePrototype::removeChannels(int newMaxIndex){
if (newMaxIndex<0||newMaxIndex>getNumberOfChannels()) {
return;
......
......@@ -22,7 +22,7 @@ private:
public:
static QString syncServiceClassName;
DevicePrototype(const QJsonObject &o);
DevicePrototype(QString name):NamedObject(name,&syncServiceClassName){}
DevicePrototype(QString name):NamedObject(name,"",&syncServiceClassName){}
int getNumberOfChannels()const{return channels.size();}
/**
* @brief removeChannels Entfernt Channel bis zu einem bestimmten Index
......
......@@ -158,7 +158,7 @@
virtual int rowCount(const QModelIndex &parent = QModelIndex())const override {Q_UNUSED(parent)return IDBase<IDBaseWithNamedObject>::getAllIDBases().size();}
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole)const {
if(std::is_base_of<IDBase<IDBaseWithNamedObject>,IDBaseWithNamedObject>::value && std::is_base_of<NamedObject,IDBaseWithNamedObject>::value){
if(index.row()>=0 && index.row()<IDBase<IDBaseWithNamedObject>::getAllIDBases().size()){
if(index.row()>=0 && index.row()<static_cast<decltype(index.row())>(IDBase<IDBaseWithNamedObject>::getAllIDBases().size())){
if(role==Qt::DisplayRole){
return (**std::next(IDBase<IDBaseWithNamedObject>::getAllIDBases().cbegin(),index.row())).getName();
}else if(role==Qt::ToolTipRole){
......
......@@ -2,6 +2,7 @@
#include <QJsonArray>
#include <unordered_set>
QString Programm::syncServiceClassName;
Programm::Programm(const QJsonObject &o):NamedObject(o,&syncServiceClassName),IDBase<Programm>(o)
{
......
......@@ -5,6 +5,7 @@
#include "device.h"
#include "idbase.h"
#include <map>
#include <cmath>
class DeviceProgramm : public QObject , public IDBase<DeviceProgramm>{
Q_OBJECT
......@@ -56,7 +57,7 @@ signals:
void programmPrototypeChanged();
};
class TimeDistortion : QObject{
class TimeDistortion : public QObject{
Q_OBJECT
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QEasingCurve distortionCurve READ getDistortionCurve WRITE setDistortionCurve NOTIFY distortionCurveChanged)
......@@ -74,9 +75,9 @@ public:
bool getIntervall()const{return intervall;}
public:
double distort(double time){
double diff = std::fmodf(time,interval);
double diff = std::fmodf(time,intervall);
double offset = time-diff;
diff = curve.valueForProgress(diff/interval)*interval;
diff = distortionCurve.valueForProgress(diff/intervall)*intervall;
return offset+diff;
}
signals:
......@@ -90,7 +91,7 @@ class Programm : public NamedObject, public IDBase<Programm>
Q_OBJECT
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged RESET stop)
Q_PROPERTY(double speed READ getSpeed WRITE setSpeed NOTIFY speedChanged)
Q_PROPERTY(TimeDistortion timeDistortion READ getTimeDistortion CONSTANT)
Q_PROPERTY(TimeDistortion * timeDistortion READ getTimeDistortion CONSTANT)
bool isRunning_ = false;
double speed=1.0;
std::vector<DeviceProgramm*> programms;
......@@ -110,7 +111,7 @@ public:
void writeJsonObject(QJsonObject &o)const;
const std::vector<DeviceProgramm*>& getDeviceProgramms()const{return programms;}
bool addDeviceProgramm(Device * device, ProgrammPrototype * programmPrototype, double offset = 0);
TimeDistortion * getTimeDistortion()const{return &timeDistortion;}
TimeDistortion * getTimeDistortion(){return &timeDistortion;}
private:
void addDeviceProgramm(const QJsonObject &o);
private slots:
......
......@@ -2,6 +2,8 @@
#include <cmath>
#include <QJsonArray>
QString ProgrammPrototype::syncServiceClassName;
ProgrammPrototype::ProgrammPrototype(DevicePrototype *devicePrototype, QString name, QString description):NamedObject(name,description,&syncServiceClassName),devicePrototype(devicePrototype){
setParent(devicePrototype);
connect(devicePrototype,&DevicePrototype::channelAdded,this,&ProgrammPrototype::channelAdded);
......@@ -129,7 +131,7 @@ TimePoint::TimePoint(const QJsonObject &o):time(o["time"].toDouble()),value(o["v
if(c != o.end()) easingCurveToNextPoint.setPeriod(c->toDouble());
}
ChannelProgramm::ChannelProgramm(const QJsonObject &o):channel(IDBase<Channel>::getIDBaseObjectByID(o["channel"])),repeatPolicy(RepeatPolicy(o["repeatPolicy"].toInt())){
ChannelProgramm::ChannelProgramm(const QJsonObject &o):repeatPolicy(RepeatPolicy(o["repeatPolicy"].toInt())),channel(IDBase<Channel>::getIDBaseObjectByID(o["channel"])){
setParent(getChannel());
for(const auto p : o["timeline"].toArray()){
timeline.insert(p.toObject());
......
#include "syncservice.h"
std::vector<SyncService*> SyncService::syncServices;
std::map<QString,std::tuple<SyncService::CreateMethod,SyncService::UpdateMethod,SyncService::RemoveMethod,SyncService::CreateMemberMethod,SyncService::RemoveMemberMethod>> SyncService::classes;
void SyncService::processCreateMessage(const QString &className, const QJsonObject &o){
const auto c = classes.find(className);
if(c!=classes.cend()){
if(c->second.get<CreateMethodIndex>()){
*c->second.get<CreateMethodIndex>()(o);
if(std::get<CreateMethodIndex>(c->second)){
(*std::get<CreateMethodIndex>(c->second))(o);
}
}
}
......@@ -12,8 +16,8 @@ void SyncService::processCreateMessage(const QString &className, const QJsonObje
void SyncService::processCreateMemberMessage(const QString &className, const QString &id, const QString &memberName, const QJsonObject &o){
const auto c = classes.find(className);
if(c!=classes.cend()){
if(c->second.get<CreateMemberMethodIndex>()){
*c->second.get<CreateMemberMethodIndex>()(ID(id.toLong()),memberName,o);
if(std::get<CreateMemberMethodIndex>(c->second)){
(*std::get<CreateMemberMethodIndex>(c->second))(ID(id.toLong()),memberName,o);
}
}
}
......@@ -21,8 +25,8 @@ void SyncService::processCreateMemberMessage(const QString &className, const QSt
void SyncService::processUpdateMessage(const QString &className, const QString &id, const QString &varName, const QString &varValue){
const auto c = classes.find(className);
if(c!=classes.cend()){
if(c->second.get<UpdateMethodIndex>()){
*c->second.get<UpdateMethodIndex>()(ID(id.toLong()),varName,varValue);
if(std::get<UpdateMethodIndex>(c->second)){
(*std::get<UpdateMethodIndex>(c->second))(ID(id.toLong()),varName,varValue);
}
}
}
......@@ -30,8 +34,8 @@ void SyncService::processUpdateMessage(const QString &className, const QString &
void SyncService::processRemoveMemberMessage(const QString &className, const QString &id, const QString &memberName, const QString &memid){
const auto c = classes.find(className);
if(c!=classes.cend()){
if(c->second.get<RemoveMemberMethodIndex>()){
*c->second.get<RemoveMemberMethodIndex>()(ID(id.toLong()),memberName,ID(memid.toLong()));
if(std::get<RemoveMemberMethodIndex>(c->second)){
(*std::get<RemoveMemberMethodIndex>(c->second))(ID(id.toLong()),memberName,ID(memid.toLong()));
}
}
}
......@@ -39,15 +43,15 @@ void SyncService::processRemoveMemberMessage(const QString &className, const QSt
void SyncService::processRemoveMessage(const QString &className, const QString &id){
const auto c = classes.find(className);
if(c!=classes.cend()){
if(c->second.get<RemoveMethodIndex>()){
*c->second.get<RemoveMethodIndex>()(ID(id.toLong()));
if(std::get<RemoveMethodIndex>(c->second)){
(*std::get<RemoveMethodIndex>(c->second))(ID(id.toLong()));
}
}
}
void SyncService::enableSyncService(bool b){
// wenn true, soll er in die liste, sonst raus
for(auto i = syncServices.cbegin();i!=syncServices.send();++i){
for(auto i = syncServices.cbegin();i!=syncServices.cend();++i){
if(*i==this){ // gefunden
if(b) // ist schon drin
return;
......
Supports Markdown
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