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

@@ -58,7 +58,7 @@ ColorOrder Hyperion::createColorOrder(const QJsonObject &deviceConfig)
ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustmentConfig)
{
const std::string id = adjustmentConfig["id"].toString("default").toStdString();
const QString id = adjustmentConfig["id"].toString("default");
RgbChannelAdjustment * blackAdjustment = createRgbChannelAdjustment(adjustmentConfig, "black" , 0, 0, 0);
RgbChannelAdjustment * whiteAdjustment = createRgbChannelAdjustment(adjustmentConfig, "white" , 255,255,255);
@@ -117,13 +117,13 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
{
// Special case for indices '*' => all leds
adjustment->setAdjustmentForLed(colorAdjustment->_id, 0, ledCnt-1);
Info(CORE_LOGGER, "ColorAdjustment '%s' => [0; %d]", colorAdjustment->_id.c_str(), ledCnt-1);
Info(CORE_LOGGER, "ColorAdjustment '%s' => [0; %d]", QSTRING_CSTR(colorAdjustment->_id), ledCnt-1);
continue;
}
if (!overallExp.exactMatch(ledIndicesStr))
{
Error(CORE_LOGGER, "Given led indices %d not correct format: %s", i, ledIndicesStr.toStdString().c_str());
Error(CORE_LOGGER, "Given led indices %d not correct format: %s", i, QSTRING_CSTR(ledIndicesStr));
continue;
}
@@ -150,7 +150,7 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
ss << index;
}
}
Info(CORE_LOGGER, "ColorAdjustment '%s' => [%s]", colorAdjustment->_id.c_str(), ss.str().c_str());
Info(CORE_LOGGER, "ColorAdjustment '%s' => [%s]", QSTRING_CSTR(colorAdjustment->_id), ss.str().c_str());
}
return adjustment;
@@ -319,8 +319,7 @@ QSize Hyperion::getLedLayoutGridSize(const QJsonValue& ledsConfig)
LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice)
{
std::string type = smoothingConfig["type"].toString("linear").toStdString();
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
QString type = smoothingConfig["type"].toString("linear").toLower();
LinearColorSmoothing * device = nullptr;
type = "linear"; // TODO currently hardcoded type, delete it if we have more types
@@ -337,7 +336,7 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smooth
}
else
{
Error(CORE_LOGGER, "Smoothing disabled, because of unknown type '%s'.", type.c_str());
Error(CORE_LOGGER, "Smoothing disabled, because of unknown type '%s'.", QSTRING_CSTR(type));
}
device->setEnable(smoothingConfig["enable"].toBool(true));
@@ -358,7 +357,7 @@ MessageForwarder * Hyperion::createMessageForwarder(const QJsonObject & forwarde
for (signed i = 0; i < addr.size(); ++i)
{
Info(CORE_LOGGER, "Json forward to %s", addr.at(i).toString().toStdString().c_str());
forwarder->addJsonSlave(addr[i].toString().toStdString());
forwarder->addJsonSlave(addr[i].toString());
}
}
@@ -368,7 +367,7 @@ MessageForwarder * Hyperion::createMessageForwarder(const QJsonObject & forwarde
for (signed i = 0; i < addr.size(); ++i)
{
Info(CORE_LOGGER, "Proto forward to %s", addr.at(i).toString().toStdString().c_str());
forwarder->addProtoSlave(addr[i].toString().toStdString());
forwarder->addProtoSlave(addr[i].toString());
}
}
}
@@ -603,12 +602,12 @@ void Hyperion::setImage(int priority, const Image<ColorRgb> & image, int duratio
}
}
const std::vector<std::string> & Hyperion::getAdjustmentIds() const
const QStringList & Hyperion::getAdjustmentIds() const
{
return _raw2ledAdjustment->getAdjustmentIds();
}
ColorAdjustment * Hyperion::getAdjustment(const std::string& id)
ColorAdjustment * Hyperion::getAdjustment(const QString& id)
{
return _raw2ledAdjustment->getAdjustment(id);
}

View File

@@ -1,7 +1,6 @@
#pragma once
// STL includes
#include <string>
#include <vector>

View File

@@ -13,11 +13,11 @@ MessageForwarder::~MessageForwarder()
}
void MessageForwarder::addJsonSlave(std::string slave)
void MessageForwarder::addJsonSlave(QString slave)
{
QStringList parts = QString(slave.c_str()).split(":");
QStringList parts = slave.split(":");
if (parts.size() != 2)
throw std::runtime_error(QString("HYPERION (forwarder) ERROR: Wrong address: unable to parse address (%1)").arg(slave.c_str()).toStdString());
throw std::runtime_error(QString("HYPERION (forwarder) ERROR: Wrong address: unable to parse address (%1)").arg(slave).toStdString());
bool ok;
quint16 port = parts[1].toUShort(&ok);
@@ -30,9 +30,9 @@ void MessageForwarder::addJsonSlave(std::string slave)
_jsonSlaves << c;
}
void MessageForwarder::addProtoSlave(std::string slave)
void MessageForwarder::addProtoSlave(QString slave)
{
_protoSlaves << QString(slave.c_str());
_protoSlaves << slave;
}
QStringList MessageForwarder::getProtoSlaves()

View File

@@ -27,7 +27,7 @@ void MultiColorAdjustment::addAdjustment(ColorAdjustment * adjustment)
_adjustment.push_back(adjustment);
}
void MultiColorAdjustment::setAdjustmentForLed(const std::string& id, const unsigned startLed, const unsigned endLed)
void MultiColorAdjustment::setAdjustmentForLed(const QString& id, const unsigned startLed, const unsigned endLed)
{
assert(startLed <= endLed);
assert(endLed < _ledAdjustments.size());
@@ -61,12 +61,12 @@ bool MultiColorAdjustment::verifyAdjustments() const
return true;
}
const std::vector<std::string> & MultiColorAdjustment::getAdjustmentIds()
const QStringList & MultiColorAdjustment::getAdjustmentIds()
{
return _adjustmentIds;
}
ColorAdjustment* MultiColorAdjustment::getAdjustment(const std::string& id)
ColorAdjustment* MultiColorAdjustment::getAdjustment(const QString& id)
{
// Iterate through the unique adjustments until we find the one with the given id
for (ColorAdjustment* adjustment : _adjustment)

View File

@@ -2,11 +2,11 @@
// STL includes
#include <vector>
// Utils includes
#include <utils/ColorRgb.h>
#include <QStringList>
#include <QString>
// Hyperion includes
#include <utils/ColorRgb.h>
#include <hyperion/ColorAdjustment.h>
///
@@ -26,7 +26,7 @@ public:
*/
void addAdjustment(ColorAdjustment * adjustment);
void setAdjustmentForLed(const std::string& id, const unsigned startLed, const unsigned endLed);
void setAdjustmentForLed(const QString& id, const unsigned startLed, const unsigned endLed);
bool verifyAdjustments() const;
@@ -36,7 +36,7 @@ public:
/// Returns the identifier of all the unique ColorAdjustment
///
/// @return The list with unique id's of the ColorAdjustment
const std::vector<std::string> & getAdjustmentIds();
const QStringList & getAdjustmentIds();
///
/// Returns the pointer to the ColorAdjustment with the given id
@@ -45,7 +45,7 @@ public:
///
/// @return The ColorAdjustment with the given id (or nullptr if it does not exist)
///
ColorAdjustment* getAdjustment(const std::string& id);
ColorAdjustment* getAdjustment(const QString& id);
///
/// Performs the color adjustment from raw-color to led-color
@@ -56,7 +56,7 @@ public:
private:
/// List with transform ids
std::vector<std::string> _adjustmentIds;
QStringList _adjustmentIds;
/// List with unique ColorTransforms
std::vector<ColorAdjustment*> _adjustment;