style: Apply clang-format to all C++ files
qt-migration-copilot-demo/pipeline/pr-main There was a failure building this commit
qt-migration-copilot-demo/pipeline/pr-main There was a failure building this commit
- 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
This commit is contained in:
5 files changed
+32
-24
No files matched your search
@@ -1,16 +1,15 @@
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include "ui_MainWindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
#include <QString>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)"))
|
||||
MainWindow::MainWindow(QWidget* parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow), m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)"))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -28,15 +27,16 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool MainWindow::validateInput(const QString &text) const
|
||||
bool MainWindow::validateInput(const QString& text) const
|
||||
{
|
||||
return m_pattern.match(text).hasMatch();
|
||||
}
|
||||
|
||||
QString MainWindow::getScreenInfo() const
|
||||
{
|
||||
const QScreen *screen = QApplication::primaryScreen();
|
||||
if (!screen) {
|
||||
const QScreen* screen = QApplication::primaryScreen();
|
||||
if (!screen)
|
||||
{
|
||||
return u"Screen: unavailable"_s;
|
||||
}
|
||||
const QRect geometry = screen->geometry();
|
||||
@@ -47,9 +47,12 @@ void MainWindow::onValidateClicked()
|
||||
{
|
||||
const QString text = ui->lineEdit->text();
|
||||
|
||||
if (validateInput(text)) {
|
||||
if (validateInput(text))
|
||||
{
|
||||
ui->resultLabel->setText(u"Match"_s);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->resultLabel->setText(u"No match"_s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,27 +4,30 @@
|
||||
#include <QRegularExpression>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit MainWindow(QWidget* parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
[[nodiscard]] bool validateInput(const QString &text) const;
|
||||
[[nodiscard]] bool validateInput(const QString& text) const;
|
||||
[[nodiscard]] QString getScreenInfo() const;
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void onValidateClicked();
|
||||
void onScreenInfoClicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
QRegularExpression m_pattern;
|
||||
};
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <QApplication>
|
||||
#include "MainWindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
||||
@@ -4,7 +4,7 @@ class TestMainWindow : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void testValidateInputValid();
|
||||
void testValidateInputInvalid();
|
||||
void testValidateInputEmpty();
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QApplication>
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class TestMainWindowWidget : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void testMainWindowCreation();
|
||||
void testWindowTitle();
|
||||
void testValidateInputMethod();
|
||||
|
||||
Reference in new issue
Block a user