Skip to content

Commit

Permalink
Clazy fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Dec 26, 2024
1 parent 523fa5b commit a5370b4
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 29 deletions.
6 changes: 3 additions & 3 deletions examples/Examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Examples::Examples()
startStopButtonInfinite_{QStringLiteral("start")},
startStopButtonCounter_{QStringLiteral("start")}
{
setWindowTitle("Wble library examples");
setWindowTitle(QString::fromLatin1("Wble library examples"));
QHBoxLayout* widgetLayout{new QHBoxLayout()};
QVBoxLayout* leftWidgetColumn = createLeftWidgetColumn();
widgetLayout->addLayout(leftWidgetColumn);
Expand Down Expand Up @@ -161,9 +161,9 @@ void Examples::filterDatesValuesChanged(QDate from, QDate to,
" | "};

if (filterEmptyDates)
msg.append("yes");
msg.append(QString::fromLatin1("yes"));
else
msg.append("no");
msg.append(QString::fromLatin1("no"));

info_.setText(msg);
}
Expand Down
1 change: 1 addition & 0 deletions examples/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class QPushButton;

class Examples : public QWidget
{
Q_OBJECT
public:
Examples();

Expand Down
6 changes: 3 additions & 3 deletions tests/DoubleSliderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void DoubleSliderTest::testPaintingDefaultState()
{
DoubleSlider slider(MIN, MAX);
auto actual{slider.grab().toImage()};
QImage expected(":/res/sliderDefault.png");
QImage expected(QString::fromLatin1(":/res/sliderDefault.png"));
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}
Expand All @@ -163,7 +163,7 @@ void DoubleSliderTest::testPaintingMovedHandles()
slider.setCurrentMax(MAX - step);
slider.setCurrentMin(MIN + step);
auto actual{slider.grab().toImage()};
QImage expected(":/res/sliderMovedHandles.png");
QImage expected(QString::fromLatin1(":/res/sliderMovedHandles.png"));
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}
Expand All @@ -175,7 +175,7 @@ void DoubleSliderTest::testPaintingBothHandlesTogether()
slider.setCurrentMax(MAX - step);
slider.setCurrentMin(slider.getCurrentMax());
auto actual{slider.grab().toImage()};
QImage expected(":/res/sliderBothHandlesTogether.png");
QImage expected(QString::fromLatin1(":/res/sliderBothHandlesTogether.png"));
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/FilterDatesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void FilterDatesTest::initTestCase()

void FilterDatesTest::testFilterEmptyDatesToggle()
{
const FilterDates filter(QLatin1String(""), fromDate_, toDate_, true);
const FilterDates filter(QString::fromLatin1(""), fromDate_, toDate_, true);
QSignalSpy spy(&filter, &FilterDates::newDateFilter);

auto* ignoreEmptyDates{filter.findChild<QCheckBox*>()};
Expand All @@ -31,7 +31,7 @@ void FilterDatesTest::testFilterEmptyDatesToggle()

void FilterDatesTest::testToggling()
{
FilterDates filter(QLatin1String(""), fromDate_, toDate_, true);
FilterDates filter(QString::fromLatin1(""), fromDate_, toDate_, true);
auto lineEdits{filter.findChildren<QDateEdit*>()};
auto checkBoxes{filter.findChildren<QCheckBox*>()};
for (const auto* widget : lineEdits)
Expand All @@ -49,20 +49,20 @@ void FilterDatesTest::testToggling()

void FilterDatesTest::testProperInitOfEmptyDatesCheckbox()
{
const FilterDates filterWithEmptyDates(QLatin1String(""), fromDate_,
const FilterDates filterWithEmptyDates(QString::fromLatin1(""), fromDate_,
toDate_, true);
auto* ignoreEmptyDates{filterWithEmptyDates.findChild<QCheckBox*>()};
QCOMPARE(ignoreEmptyDates->isEnabled(), true);

const FilterDates filterWithoutEmptyDates(QLatin1String(""), fromDate_,
const FilterDates filterWithoutEmptyDates(QString::fromLatin1(""), fromDate_,
toDate_, false);
ignoreEmptyDates = filterWithoutEmptyDates.findChild<QCheckBox*>();
QCOMPARE(ignoreEmptyDates->isEnabled(), false);
}

void FilterDatesTest::testChangingDates()
{
const FilterDates filter(QLatin1String(""), fromDate_, toDate_, true);
const FilterDates filter(QString::fromLatin1(""), fromDate_, toDate_, true);
auto lineEdits{filter.findChildren<QDateEdit*>()};
Q_ASSERT(lineEdits.count() == 2);
QDateEdit* fromEdit{(lineEdits.first()->date() == fromDate_
Expand Down
10 changes: 5 additions & 5 deletions tests/FilterStringsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

void FilterStringsTest::initTestCase()
{
testEntriesList_ = QStringList{QLatin1String("a"), QLatin1String("b"),
QLatin1String("c"), QLatin1String("d")};
testEntriesList_ = QStringList{QString::fromLatin1("a"), QString::fromLatin1("b"),
QString::fromLatin1("c"), QString::fromLatin1("d")};
}

void FilterStringsTest::testToggling()
{
FilterStrings filter(QLatin1String(""), testEntriesList_);
FilterStrings filter(QString::fromLatin1(""), testEntriesList_);
auto* listWidget{filter.findChild<QListWidget*>()};
auto* selectAll{filter.findChild<QCheckBox*>()};
QCOMPARE(listWidget->isEnabled(), true);
Expand All @@ -28,7 +28,7 @@ void FilterStringsTest::testToggling()

void FilterStringsTest::testSelectAllToggling()
{
const FilterStrings filter(QLatin1String(""), testEntriesList_);
const FilterStrings filter(QString::fromLatin1(""), testEntriesList_);
QSignalSpy spy(&filter, &FilterStrings::newStringFilter);

auto* selectAll{filter.findChild<QCheckBox*>()};
Expand All @@ -43,7 +43,7 @@ void FilterStringsTest::testSelectAllToggling()

void FilterStringsTest::testListItemChecking()
{
const FilterStrings filter(QLatin1String(""), testEntriesList_);
const FilterStrings filter(QString::fromLatin1(""), testEntriesList_);
QSignalSpy spy(&filter, &FilterStrings::newStringFilter);
const auto* listWidget{filter.findChild<QListWidget*>()};
const int itemPos{
Expand Down
10 changes: 5 additions & 5 deletions tests/ProgressBarCounterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@

void ProgressBarCounterTest::testStarting()
{
ProgressBarCounter progressBar(QLatin1String(""), max_);
ProgressBarCounter progressBar(QString::fromLatin1(""), max_);
ProgressBarCommon::checkStarting(progressBar);
}

void ProgressBarCounterTest::testFirstUpdatingProgress()
{
ProgressBarCounter progressBar(QLatin1String(""), max_);
ProgressBarCounter progressBar(QString::fromLatin1(""), max_);
progressBar.updateProgress(max_ / 2);
QCOMPARE(progressBar.isRunning(), true);
}

void ProgressBarCounterTest::testSecondUpdatingProgress()
{
ProgressBarCounter progressBar(QLatin1String(""), max_);
ProgressBarCounter progressBar(QString::fromLatin1(""), max_);
progressBar.updateProgress(max_ / 4);
progressBar.updateProgress(max_ / 2);
QCOMPARE(progressBar.isRunning(), true);
}

void ProgressBarCounterTest::testStopping()
{
ProgressBarCounter progressBar(QLatin1String(""), max_);
ProgressBarCounter progressBar(QString::fromLatin1(""), max_);
ProgressBarCommon::checkStopping(progressBar);
}

void ProgressBarCounterTest::testReseting()
{
ProgressBarCounter progressBar(QLatin1String(""), max_);
ProgressBarCounter progressBar(QString::fromLatin1(""), max_);
ProgressBarCommon::checkReseting(progressBar);
}

Expand Down
14 changes: 7 additions & 7 deletions tests/ProgressBarInfiniteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@

void ProgressBarInfiniteTest::testStarting()
{
ProgressBarInfinite progressBar(QLatin1String(""));
ProgressBarInfinite progressBar(QString::fromLatin1(""));
ProgressBarCommon::checkStarting(progressBar);
}

void ProgressBarInfiniteTest::testStopping()
{
ProgressBarInfinite progressBar(QLatin1String(""));
ProgressBarInfinite progressBar(QString::fromLatin1(""));
ProgressBarCommon::checkStopping(progressBar);
}

void ProgressBarInfiniteTest::testReseting()
{
ProgressBarInfinite progressBar(QLatin1String(""));
ProgressBarInfinite progressBar(QString::fromLatin1(""));
ProgressBarCommon::checkReseting(progressBar);
}

void ProgressBarInfiniteTest::checkInitialPaintNoTitle()
{
ProgressBarInfinite progressBar(QLatin1String(""));
ProgressBarInfinite progressBar(QString::fromLatin1(""));
auto actual{progressBar.grab().toImage()};
QImage expected(":/res/infinityInitial.png");
QImage expected(QString::fromLatin1(":/res/infinityInitial.png"));
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}

void ProgressBarInfiniteTest::checkPaintAfterUpdateNoTitle()
{
ProgressBarInfinite progressBar(QLatin1String(""));
ProgressBarInfinite progressBar(QString::fromLatin1(""));
QTimerEvent event{0};
for (int i{0}; i < 10; ++i)
QApplication::sendEvent(&progressBar, &event);

auto actual{progressBar.grab().toImage()};
QImage expected(":/res/infinityUpdated.png");
QImage expected(QString::fromLatin1(":/res/infinityUpdated.png"));
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}
2 changes: 1 addition & 1 deletion tests/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(int argc, char* argv[])
{
const QApplication a(argc, argv);

QStyle* style = QStyleFactory::create("Fusion");
QStyle* style = QStyleFactory::create(QStringLiteral("Fusion"));
QApplication::setStyle(style);
setLightPalette();

Expand Down

0 comments on commit a5370b4

Please sign in to comment.