Commit cb151242 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Start to make it compile with strict compile flags

parent 8947a292
......@@ -38,6 +38,14 @@ find_package(KF5 REQUIRED COMPONENTS
find_package(KF5 REQUIRED COMPONENTS SysGuard)
#add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
#add_definitions(-DQT_USE_QSTRINGBUILDER)
#add_definitions(-DQT_NO_CAST_FROM_ASCII)
#add_definitions(-DQT_NO_CAST_TO_ASCII)
#add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
#add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
find_package(Sensors)
set_package_properties(Sensors PROPERTIES
TYPE OPTIONAL
......
......@@ -149,13 +149,13 @@ bool DancingBars::addSensor( const QString &hostName, const QString &name,
/* To differentiate between answers from value requests and info
* requests we add 100 to the beam index for info requests. */
sendRequest( hostName, name + '?', mBars + 100 );
sendRequest( hostName, name + QLatin1Char('?'), mBars + 100 );
++mBars;
mSampleBuffer.resize( mBars );
QString tooltip;
for ( uint i = 0; i < mBars; ++i ) {
tooltip += QStringLiteral( "%1%2:%3" ).arg( i != 0 ? "\n" : "" )
tooltip += QStringLiteral( "%1%2:%3" ).arg( i != 0 ? QLatin1Literal("\n") : QString() )
.arg( sensors().at( i )->hostName() )
.arg( sensors().at( i )->name() );
}
......@@ -178,7 +178,7 @@ bool DancingBars::removeSensor( uint pos )
QString tooltip;
for ( uint i = 0; i < mBars; ++i ) {
tooltip += QStringLiteral( "%1%2:%3" ).arg( i != 0 ? "\n" : "" )
tooltip += QStringLiteral( "%1%2:%3" ).arg( i != 0 ? QStringLiteral("\n") : QString() )
.arg( sensors().at( i )->hostName() )
.arg( sensors().at( i )->name() );
}
......
......@@ -36,7 +36,7 @@
#include <QInputDialog>
#include "DancingBarsSettings.h"
DancingBarsSettings::DancingBarsSettings( QWidget* parent, const char* name )
DancingBarsSettings::DancingBarsSettings(QWidget* parent, const QString &name )
: KPageDialog( parent ), mModel( new SensorModel( this ) )
{
setFaceType( Tabbed );
......
......@@ -41,7 +41,7 @@ class DancingBarsSettings : public KPageDialog
Q_OBJECT
public:
explicit DancingBarsSettings( QWidget* parent = 0, const char* name = 0 );
explicit DancingBarsSettings( QWidget* parent = 0, const QString &name = QString() );
~DancingBarsSettings();
void setTitle( const QString& title );
......
......@@ -69,7 +69,7 @@ class FancyPlotterLabel : public QLabel {
if(fontMetrics().inFont(QChar(0x25CF)))
indicatorSymbol = QChar(0x25CF);
else
indicatorSymbol = '#';
indicatorSymbol = QLatin1Char('#');
}
changeLabel(color);
......@@ -116,14 +116,14 @@ class FancyPlotterLabel : public QLabel {
color = _color;
if ( QApplication::layoutDirection() == Qt::RightToLeft )
longHeadingText = QStringLiteral(": ") + labelName + " <font color=\"" + color.name() + "\">" + indicatorSymbol + "</font>";
longHeadingText = QStringLiteral(": ") + labelName + QStringLiteral(" <font color=\"") + color.name() + QStringLiteral("\">") + indicatorSymbol + QStringLiteral("</font>");
else
longHeadingText = QStringLiteral("<qt><font color=\"") + color.name() + "\">" + indicatorSymbol + "</font> " + labelName + " :";
shortHeadingText = QStringLiteral("<qt><font color=\"") + color.name() + "\">" + indicatorSymbol + "</font>";
noHeadingText = QStringLiteral("<qt><font color=\"") + color.name() + "\">";
longHeadingText = QStringLiteral("<qt><font color=\"") + color.name() + QStringLiteral("\">") + indicatorSymbol + QStringLiteral("</font> ") + labelName + QStringLiteral(" :");
shortHeadingText = QStringLiteral("<qt><font color=\"") + color.name() + QStringLiteral("\">") + indicatorSymbol + QStringLiteral("</font>");
noHeadingText = QStringLiteral("<qt><font color=\"") + color.name() + QStringLiteral("\">");
textMargin = fontMetrics().width('x') + margin()*2 + frameWidth()*2;
longHeadingWidth = fontMetrics().boundingRect(labelName + " :" + indicatorSymbol + " x").width() + textMargin;
textMargin = fontMetrics().width(QLatin1Char('x')) + margin()*2 + frameWidth()*2;
longHeadingWidth = fontMetrics().boundingRect(labelName + QStringLiteral(" :") + indicatorSymbol + QStringLiteral(" x")).width() + textMargin;
shortHeadingWidth = fontMetrics().boundingRect(indicatorSymbol).width() + textMargin;
setMinimumWidth(shortHeadingWidth);
update();
......@@ -131,9 +131,9 @@ class FancyPlotterLabel : public QLabel {
private:
void setBothText(const QString &heading, const QString & value) {
if(QApplication::layoutDirection() == Qt::LeftToRight)
setText(heading + ' ' + value);
setText(heading + QLatin1Char(' ') + value);
else
setText("<qt>" + value + ' ' + heading);
setText(QStringLiteral("<qt>") + value + QLatin1Char(' ') + heading);
}
int textMargin;
QString longHeadingText;
......@@ -169,7 +169,7 @@ FancyPlotter::FancyPlotter( QWidget* parent,
if(fm.inFont(QChar(0x25CF)))
mIndicatorSymbol = QChar(0x25CF);
else
mIndicatorSymbol = '#';
mIndicatorSymbol = QLatin1Char('#');
QBoxLayout *layout = new QVBoxLayout(this);
layout->setSpacing(0);
......@@ -428,7 +428,7 @@ bool FancyPlotter::addSensor( const QString &hostName, const QString &name,
/* To differentiate between answers from value requests and info
* requests we add 100 to the beam index for info requests. */
sendRequest( hostName, name + '?', sensors().size() - 1 + 100 );
sendRequest( hostName, name + QLatin1Char('?'), sensors().size() - 1 + 100 );
if((int)mBeams == beamId) {
mPlotter->addBeam( color );
......@@ -517,7 +517,7 @@ void FancyPlotter::setTooltip()
if (sensor->unit() == QLatin1String("%"))
lastValue = i18nc("units", "%1%", lastValue);
else if( !sensor->unit().isEmpty() )
lastValue = i18nc("units", QString(QString("%1 ") + sensor->unit()).toUtf8().constData(), lastValue);
lastValue = i18nc("units", QString(QStringLiteral("%1 ") + sensor->unit()).toUtf8().constData(), lastValue);
} else {
lastValue = i18n("Error");
}
......@@ -536,14 +536,14 @@ void FancyPlotter::setTooltip()
beamId = sensor->beamId;
if(sensor->isLocalhost()) {
tooltip += QStringLiteral( "%1%2 %3 (%4)" ).arg( neednewline ? "<br>" : "")
.arg("<font color=\"" + mPlotter->beamColor( beamId ).name() + "\">"+mIndicatorSymbol+"</font>")
tooltip += QStringLiteral( "%1%2 %3 (%4)" ).arg( neednewline ? QStringLiteral("<br>") : QString())
.arg(QStringLiteral("<font color=\"") + mPlotter->beamColor( beamId ).name() + QStringLiteral("\">") + mIndicatorSymbol+ QStringLiteral("</font>"))
.arg( i18n(description.toUtf8().constData()) )
.arg( lastValue );
} else {
tooltip += QStringLiteral( "%1%2 %3:%4 (%5)" ).arg( neednewline ? "<br>" : "" )
.arg("<font color=\"" + mPlotter->beamColor( beamId ).name() + "\">"+mIndicatorSymbol+"</font>")
tooltip += QStringLiteral( "%1%2 %3:%4 (%5)" ).arg( neednewline ? QStringLiteral("<br>") : QString() )
.arg(QStringLiteral("<font color=\"") + mPlotter->beamColor( beamId ).name() + QStringLiteral("\">") + mIndicatorSymbol+ QStringLiteral("</font>"))
.arg( sensor->hostName() )
.arg( i18n(description.toUtf8().constData()) )
.arg( lastValue );
......@@ -588,7 +588,7 @@ void FancyPlotter::sendDataToPlotter( )
if (sensor->unit() == QLatin1String("%"))
lastValue = i18nc("units", "%1%", lastValue);
else if( !sensor->unit().isEmpty() ) {
lastValue = i18nc("units", QString("%1 " + sensor->unit()).toUtf8().constData(), lastValue);
lastValue = i18nc("units", QString(QStringLiteral("%1 ") + sensor->unit()).toUtf8().constData(), lastValue);
}
}
......@@ -660,7 +660,7 @@ void FancyPlotter::plotterAxisScaleChanged()
#endif
mPlotter->setScaleDownBy(1);
//translate any others
unit = ki18nc("units", QString("%1 " + mUnit).toUtf8().constData());
unit = ki18nc("units", QString(QStringLiteral("%1 ") + mUnit).toUtf8().constData());
}
mPlotter->setUnit(unit);
//reconnect
......@@ -784,8 +784,8 @@ bool FancyPlotter::restoreSettings( QDomElement &element )
mPlotter->setStackGraph( element.attribute(QStringLiteral("stacked"), QStringLiteral("0")).toInt());
QString filename = element.attribute( QStringLiteral("svgBackground"));
if (!filename.isEmpty() && filename[0] == '/') {
filename = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "ksysguard/" + filename);
if (!filename.isEmpty() && filename[0] == QLatin1Char('/')) {
filename = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("ksysguard/") + filename);
}
mPlotter->setSvgBackground( filename );
if(version >= 1) {
......@@ -805,7 +805,7 @@ bool FancyPlotter::restoreSettings( QDomElement &element )
sensor->hostname = el.attribute( QStringLiteral("hostName") );
sensor->type = el.attribute( QStringLiteral("sensorType") );
sensor->summationName = el.attribute(QStringLiteral("summationName"));
QStringList colors = el.attribute(QStringLiteral("color")).split(',');
QStringList colors = el.attribute(QStringLiteral("color")).split(QLatin1Char(','));
bool ok;
foreach(const QString &color, colors) {
int c = color.toUInt( &ok, 0 );
......
......@@ -205,7 +205,7 @@ FancyPlotterSettings::FancyPlotterSettings( QWidget* parent, bool locked )
mView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
bool hideFirstColumn = true;
for(int i = 0; i < mModel->rowCount(); i++)
if(mModel->data(mModel->index(i, 0)) != "localhost") {
if(mModel->data(mModel->index(i, 0)) != QStringLiteral("localhost")) {
hideFirstColumn = false;
break;
}
......@@ -296,8 +296,8 @@ QString FancyPlotterSettings::title() const
void FancyPlotterSettings::setRangeUnits( const QString & units )
{
mMinValue->setSuffix(' ' + units);
mMaxValue->setSuffix(' ' + units);
mMinValue->setSuffix(QLatin1Char(' ') + units);
mMaxValue->setSuffix(QLatin1Char(' ') + units);
}
void FancyPlotterSettings::setUseManualRange( bool value )
......
......@@ -224,13 +224,13 @@ QColor SensorDisplay::restoreColor( QDomElement &element, const QString &attr,
void SensorDisplay::saveColor( QDomElement &element, const QString &attr,
const QColor &color )
{
element.setAttribute( attr, "0x" + QString::number(color.rgba(),16) );
element.setAttribute( attr, QStringLiteral("0x") + QString::number(color.rgba(),16) );
}
void SensorDisplay::saveColorAppend( QDomElement &element, const QString &attr,
const QColor &color )
{
element.setAttribute( attr, element.attribute(attr) + ",0x" + QString::number(color.rgba(),16) );
element.setAttribute( attr, element.attribute(attr) + QStringLiteral(",0x") + QString::number(color.rgba(),16) );
}
bool SensorDisplay::addSensor( const QString &hostName, const QString &name,
......
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