style: Apply clang-format to all C++ files

- Format MainWindow.cpp, MainWindow.h, main.cpp
- Format test files (test_main.cpp, test_mainwindow.cpp)
- Fixes Jenkins clang-format policy check

Entire-Checkpoint: ea47c089bf3a
Signed-off-by: twi-devel <torsten.wierschin@life-maps.com>
This commit is contained in:
torsten committed 2026-10-22 18:42:43 +02:00
1 parent 44f52cb2db
commit fc70e757bd
5 files changed
+36 -28

No files matched your search

+14 -11
View File
@@ -1,16 +1,15 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
#include <QApplication> #include <QApplication>
#include <QScreen>
#include <QPixmap> #include <QPixmap>
#include <QString>
#include <QRect> #include <QRect>
#include <QScreen>
#include <QString>
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)"))
, ui(new Ui::MainWindow)
, m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)"))
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -28,15 +27,16 @@ MainWindow::~MainWindow()
delete ui; delete ui;
} }
bool MainWindow::validateInput(const QString &text) const bool MainWindow::validateInput(const QString& text) const
{ {
return m_pattern.match(text).hasMatch(); return m_pattern.match(text).hasMatch();
} }
QString MainWindow::getScreenInfo() const QString MainWindow::getScreenInfo() const
{ {
const QScreen *screen = QApplication::primaryScreen(); const QScreen* screen = QApplication::primaryScreen();
if (!screen) { if (!screen)
{
return u"Screen: unavailable"_s; return u"Screen: unavailable"_s;
} }
const QRect geometry = screen->geometry(); const QRect geometry = screen->geometry();
@@ -47,9 +47,12 @@ void MainWindow::onValidateClicked()
{ {
const QString text = ui->lineEdit->text(); const QString text = ui->lineEdit->text();
if (validateInput(text)) { if (validateInput(text))
{
ui->resultLabel->setText(u"Match"_s); ui->resultLabel->setText(u"Match"_s);
} else { }
else
{
ui->resultLabel->setText(u"No match"_s); ui->resultLabel->setText(u"No match"_s);
} }
} }
+10 -7
View File
@@ -4,27 +4,30 @@
#include <QRegularExpression> #include <QRegularExpression>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui {
namespace Ui
{
class MainWindow; class MainWindow;
} }
QT_END_NAMESPACE QT_END_NAMESPACE
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget* parent = nullptr);
~MainWindow(); ~MainWindow();
[[nodiscard]] bool validateInput(const QString &text) const; [[nodiscard]] bool validateInput(const QString& text) const;
[[nodiscard]] QString getScreenInfo() const; [[nodiscard]] QString getScreenInfo() const;
public slots: public slots:
void onValidateClicked(); void onValidateClicked();
void onScreenInfoClicked(); void onScreenInfoClicked();
private: private:
Ui::MainWindow *ui; Ui::MainWindow* ui;
QRegularExpression m_pattern; QRegularExpression m_pattern;
}; };
+3 -2
View File
@@ -1,7 +1,8 @@
#include <QApplication>
#include "MainWindow.h" #include "MainWindow.h"
int main(int argc, char *argv[]) #include <QApplication>
int main(int argc, char* argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
@@ -4,7 +4,7 @@ class TestMainWindow : public QObject
{ {
Q_OBJECT Q_OBJECT
private slots: private slots:
void testValidateInputValid(); void testValidateInputValid();
void testValidateInputInvalid(); void testValidateInputInvalid();
void testValidateInputEmpty(); void testValidateInputEmpty();
@@ -15,7 +15,7 @@ void TestMainWindow::testValidateInputValid()
{ {
// Test valid input patterns // Test valid input patterns
QRegularExpression pattern(R"(^[A-Za-z]+\d+$)"); QRegularExpression pattern(R"(^[A-Za-z]+\d+$)");
QVERIFY(pattern.match("Test123").hasMatch()); QVERIFY(pattern.match("Test123").hasMatch());
QVERIFY(pattern.match("abc456").hasMatch()); QVERIFY(pattern.match("abc456").hasMatch());
QVERIFY(pattern.match("ABC789").hasMatch()); QVERIFY(pattern.match("ABC789").hasMatch());
@@ -25,7 +25,7 @@ void TestMainWindow::testValidateInputInvalid()
{ {
// Test invalid input patterns // Test invalid input patterns
QRegularExpression pattern(R"(^[A-Za-z]+\d+$)"); QRegularExpression pattern(R"(^[A-Za-z]+\d+$)");
QVERIFY(!pattern.match("123Test").hasMatch()); QVERIFY(!pattern.match("123Test").hasMatch());
QVERIFY(!pattern.match("Test").hasMatch()); QVERIFY(!pattern.match("Test").hasMatch());
QVERIFY(!pattern.match("123").hasMatch()); QVERIFY(!pattern.match("123").hasMatch());
@@ -42,7 +42,7 @@ void TestMainWindow::testValidateInputEmpty()
void TestMainWindow::testValidateInputMixedCase() void TestMainWindow::testValidateInputMixedCase()
{ {
QRegularExpression pattern(R"(^[A-Za-z]+\d+$)"); QRegularExpression pattern(R"(^[A-Za-z]+\d+$)");
QVERIFY(pattern.match("TeSt123").hasMatch()); QVERIFY(pattern.match("TeSt123").hasMatch());
QVERIFY(pattern.match("aBcDeF999").hasMatch()); QVERIFY(pattern.match("aBcDeF999").hasMatch());
} }
@@ -1,12 +1,13 @@
#include <QtTest/QtTest>
#include <QApplication>
#include "MainWindow.h" #include "MainWindow.h"
#include <QApplication>
#include <QtTest/QtTest>
class TestMainWindowWidget : public QObject class TestMainWindowWidget : public QObject
{ {
Q_OBJECT Q_OBJECT
private slots: private slots:
void testMainWindowCreation(); void testMainWindowCreation();
void testWindowTitle(); void testWindowTitle();
void testValidateInputMethod(); void testValidateInputMethod();
@@ -28,7 +29,7 @@ void TestMainWindowWidget::testWindowTitle()
void TestMainWindowWidget::testValidateInputMethod() void TestMainWindowWidget::testValidateInputMethod()
{ {
MainWindow window; MainWindow window;
QVERIFY(window.validateInput(u"Test123"_s)); QVERIFY(window.validateInput(u"Test123"_s));
QVERIFY(window.validateInput(u"abc456"_s)); QVERIFY(window.validateInput(u"abc456"_s));
QVERIFY(!window.validateInput(u"123Test"_s)); QVERIFY(!window.validateInput(u"123Test"_s));