migrate std::string to qstring + add sysinfo via json (#412)

* std::string -> qstring part 1

* more string migration

* more string migration ...

* ...

* more qstring mogrations
add sysinfo via json

* remove unneccessary includes

* integrate sysinfo into webui
This commit is contained in:
redPanther
2017-03-04 22:17:42 +01:00
committed by GitHub
parent 19f8928869
commit bfb9a08c80
90 changed files with 539 additions and 529 deletions

View File

@@ -1,7 +1,4 @@
// Stl includes
#include <string>
#include <sstream>
#include <algorithm>
#include <exception>
#include <map>
@@ -60,13 +57,12 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
QString ss(config.toJson(QJsonDocument::Indented));
Info(log, "configuration: %s ", ss.toUtf8().constData());
std::string type = deviceConfig["type"].toString("UNSPECIFIED").toStdString();
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
QString type = deviceConfig["type"].toString("UNSPECIFIED").toLower();
// set amount of led to leddevice
LedDevice::setLedCount(ledCount);
#define REGISTER(className) LedDevice::addToDeviceMap(QString(#className).toLower().toStdString(), LedDevice##className::construct);
#define REGISTER(className) LedDevice::addToDeviceMap(QString(#className).toLower(), LedDevice##className::construct);
// rs232 devices
REGISTER(Adalight);
REGISTER(Sedu);
@@ -126,21 +122,21 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
{
device = dev.second(deviceConfig);
LedDevice::setActiveDevice(dev.first);
Info(log,"LedDevice '%s' configured.", dev.first.c_str());
Info(log,"LedDevice '%s' configured.", QSTRING_CSTR(dev.first));
break;
}
}
if (device == nullptr)
{
Error(log, "Dummy device used, because configured device '%s' is unknown", type.c_str() );
Error(log, "Dummy device used, because configured device '%s' is unknown", QSTRING_CSTR(type) );
throw std::runtime_error("unknown device");
}
}
catch(std::exception& e)
{
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", type.c_str(), e.what());
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", QSTRING_CSTR(type), e.what());
const QJsonObject dummyDeviceConfig;
device = LedDeviceFile::construct(QJsonObject());
}