From fb87b060f861364fa260a928d8bed139d09b8f4c Mon Sep 17 00:00:00 2001 From: jared Date: Thu, 11 Jul 2024 14:53:39 +0800 Subject: [PATCH] format all --- .../Frameless/TaoFrameLessView_unix.cpp | 4 +- .../Frameless/TaoFrameLessView_win.cpp | 6 +-- .../TaoCommon/src/TaoCommon/Logger/Logger.cpp | 4 +- .../TaoCommon/src/TaoCommon/Logger/Logger.h | 16 +++---- .../QuickModel/QuickListItemBase.cpp | 7 +-- .../TaoCommon/QuickModel/QuickListModel.cpp | 5 +-- .../TaoCommon/QuickModel/QuickModelBase.hpp | 9 ++-- .../src/TaoCommon/QuickTool/QuickTool.cpp | 15 ++----- .../TaoCommon/QuickTree/Model/QuickTreeItem.h | 11 +---- .../QuickTree/Model/QuickTreeModel.cpp | 3 +- .../TaoCommon/src/TaoCommon/TaoCommonGlobal.h | 12 ++--- .../src/TaoCommon/Thread/ThreadPool.cpp | 5 +-- .../src/TaoCommon/Thread/ThreadPool.h | 2 +- .../TaoCommon/Thread/ThreadWorkerController.h | 12 +---- .../TaoCommon/src/TaoCommon/Trans/Trans.cpp | 7 +-- .../HelloTaoQuick3/HelloTaoQuick3/main.cpp | 26 +++++------ examples/TaoQuickShow/Src/AppInfo.cpp | 5 +-- .../Src/DeviceAddTable/DeviceAddItem.cpp | 5 +-- .../Src/DeviceAddTable/DeviceAddModel.cpp | 6 +-- examples/TaoQuickShow/Src/main.cpp | 6 +-- examples/TaoQuickShow/Src/stdafx.h | 44 +++++++++---------- 21 files changed, 83 insertions(+), 127 deletions(-) diff --git a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp index 716bbfe5..cc9edef2 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_unix.cpp @@ -11,9 +11,7 @@ class TaoFrameLessViewPrivate bool m_isFull = false; QQuickItem* m_titleItem = nullptr; }; -TaoFrameLessView::TaoFrameLessView(QWindow* parent) - : Super(parent) - , d(new TaoFrameLessViewPrivate) +TaoFrameLessView::TaoFrameLessView(QWindow* parent) : Super(parent), d(new TaoFrameLessViewPrivate) { setFlags(Qt::CustomizeWindowHint | Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); setResizeMode(SizeRootObjectToView); diff --git a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp index 55dbd9f3..378f1e2d 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Frameless/TaoFrameLessView_win.cpp @@ -42,7 +42,7 @@ static void setShadow(HWND handle, bool enabled) { if (isCompositionEnabled()) { - static const MARGINS shadow_state[2] { { 0, 0, 0, 0 }, { 1, 1, 1, 1 } }; + static const MARGINS shadow_state[2]{ { 0, 0, 0, 0 }, { 1, 1, 1, 1 } }; ::DwmExtendFrameIntoClientArea(handle, &shadow_state[enabled]); } } @@ -134,9 +134,7 @@ class TaoFrameLessViewPrivate } } }; -TaoFrameLessView::TaoFrameLessView(QWindow* parent) - : QQuickView(parent) - , d(new TaoFrameLessViewPrivate) +TaoFrameLessView::TaoFrameLessView(QWindow* parent) : QQuickView(parent), d(new TaoFrameLessViewPrivate) { // 此处不需要设置flags // setFlags(Qt::CustomizeWindowHint | Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowTitleHint | diff --git a/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.cpp b/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.cpp index d44033f1..7b63a4e3 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.cpp @@ -10,9 +10,9 @@ #include #ifdef Q_OS_WIN -#include +# include #else -#include +# include #endif namespace Logger diff --git a/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.h b/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.h index d153b6f1..9d7e61e1 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.h +++ b/3rdparty/TaoCommon/src/TaoCommon/Logger/Logger.h @@ -5,15 +5,15 @@ namespace Logger { #ifdef _DEBUG -#define LOG_DEBUG qDebug() << __FILE__ << __LINE__ -#define LOG_INFO qInfo() << __FILE__ << __LINE__ -#define LOG_WARN qWarning() << __FILE__ << __LINE__ -#define LOG_CRIT qCritical() << __FILE__ << __LINE__ +# define LOG_DEBUG qDebug() << __FILE__ << __LINE__ +# define LOG_INFO qInfo() << __FILE__ << __LINE__ +# define LOG_WARN qWarning() << __FILE__ << __LINE__ +# define LOG_CRIT qCritical() << __FILE__ << __LINE__ #else -#define LOG_DEBUG qDebug() -#define LOG_INFO qInfo() -#define LOG_WARN qWarning() -#define LOG_CRIT qCritical() +# define LOG_DEBUG qDebug() +# define LOG_INFO qInfo() +# define LOG_WARN qWarning() +# define LOG_CRIT qCritical() #endif // 初始化Log存储。包括创建Log文件夹、删除超过最大数的log(仅初始化时删除,运行过程中不删除)。 // logPath 存储路径 diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp index 90eee19e..47564ec6 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp @@ -1,8 +1,5 @@ #include "QuickModel/QuickListItemBase.h" -QuickListItemBase::QuickListItemBase(QObject* parent) - : QObject(parent) -{ -} +QuickListItemBase::QuickListItemBase(QObject* parent) : QObject(parent) {} -QuickListItemBase::~QuickListItemBase() { } +QuickListItemBase::~QuickListItemBase() {} diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp index aa88625e..9d8265b4 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp @@ -2,15 +2,14 @@ #include #include -QuickListModel::QuickListModel(QObject* parent) - : QuickModelBase(parent) +QuickListModel::QuickListModel(QObject* parent) : QuickModelBase(parent) { connect(&mSearchTimer, &QTimer::timeout, this, &QuickListModel::onSearch); mSearchTimer.setInterval(300); mSearchTimer.setSingleShot(true); } -QuickListModel::~QuickListModel() { } +QuickListModel::~QuickListModel() {} void QuickListModel::check(int row, bool checked) { diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickModelBase.hpp b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickModelBase.hpp index def41904..e2b6ce31 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickModelBase.hpp +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickModelBase.hpp @@ -48,7 +48,7 @@ class QuickModelBase : public QAbstractListModel //[end] update data public: - virtual void updateCalcInfo() { } + virtual void updateCalcInfo() {} bool compareDataChanged(const QList& data1, const QList& data2) { bool changed = false; @@ -86,14 +86,11 @@ class QuickModelBase : public QAbstractListModel }; template -QuickModelBase::QuickModelBase(QObject* parent) - : Super(parent) +QuickModelBase::QuickModelBase(QObject* parent) : Super(parent) { } template -QuickModelBase::QuickModelBase(const QList& datas, QObject* parent) - : Super(parent) - , mDatas(datas) +QuickModelBase::QuickModelBase(const QList& datas, QObject* parent) : Super(parent), mDatas(datas) { for (auto it = datas.begin(); it != datas.end(); it++) { diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickTool/QuickTool.cpp b/3rdparty/TaoCommon/src/TaoCommon/QuickTool/QuickTool.cpp index 12ecf70a..43b9c1c0 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickTool/QuickTool.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickTool/QuickTool.cpp @@ -1,18 +1,11 @@ #include "QuickTool.h" #include #include -QuickTool::QuickTool(QObject* parent) - : QObject(parent) -{ -} +QuickTool::QuickTool(QObject* parent) : QObject(parent) {} -QuickTool::QuickTool(QObject* rootObject, QObject* parent) - : QObject(parent) - , pRootObject(rootObject) -{ -} +QuickTool::QuickTool(QObject* rootObject, QObject* parent) : QObject(parent), pRootObject(rootObject) {} -QuickTool::~QuickTool() { } +QuickTool::~QuickTool() {} void QuickTool::findRootByNode(QObject* nodeObject) { pRootObject = nodeObject; @@ -37,7 +30,7 @@ QRect QuickTool::getItemGeometryToScene(const QString& targetObjName) const if (pItem->parentItem()) { auto pos = pItem->parentItem()->mapToScene(pItem->position()); - return QRectF { pos.x(), pos.y(), pItem->width(), pItem->height() }.toRect(); + return QRectF{ pos.x(), pos.y(), pItem->width(), pItem->height() }.toRect(); } else { diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeItem.h b/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeItem.h index 0834d29f..d411c908 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeItem.h +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeItem.h @@ -8,15 +8,8 @@ class TAO_API QuickTreeItem : public QObject { Q_OBJECT public: - explicit QuickTreeItem(QuickTreeItem* parentItem = nullptr) - : m_parentItem(parentItem) - { - } - explicit QuickTreeItem(const QVector& data, QuickTreeItem* parentItem = nullptr) - : m_itemData(data) - , m_parentItem(parentItem) - { - } + explicit QuickTreeItem(QuickTreeItem* parentItem = nullptr) : m_parentItem(parentItem) {} + explicit QuickTreeItem(const QVector& data, QuickTreeItem* parentItem = nullptr) : m_itemData(data), m_parentItem(parentItem) {} virtual ~QuickTreeItem() { diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeModel.cpp b/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeModel.cpp index b7ee039e..ef5d379e 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeModel.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickTree/Model/QuickTreeModel.cpp @@ -1,6 +1,5 @@ #include "QuickTreeModel.h" -QuickTreeModel::QuickTreeModel(QObject* parent) - : QAbstractItemModel(parent) +QuickTreeModel::QuickTreeModel(QObject* parent) : QAbstractItemModel(parent) { m_rootItem = new QuickTreeItem(nullptr); QVector datas; diff --git a/3rdparty/TaoCommon/src/TaoCommon/TaoCommonGlobal.h b/3rdparty/TaoCommon/src/TaoCommon/TaoCommonGlobal.h index c2b2ff13..940a7afe 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/TaoCommonGlobal.h +++ b/3rdparty/TaoCommon/src/TaoCommon/TaoCommonGlobal.h @@ -2,11 +2,11 @@ #include #if !defined(BUILD_STATIC) && !defined(TaoCommon_NO_LIB) -#if defined(TaoCommon_Library) -#define TAO_API Q_DECL_EXPORT +# if defined(TaoCommon_Library) +# define TAO_API Q_DECL_EXPORT +# else +# define TAO_API Q_DECL_IMPORT +# endif #else -#define TAO_API Q_DECL_IMPORT -#endif -#else -#define TAO_API +# define TAO_API #endif diff --git a/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.cpp b/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.cpp index 8fed8264..6a948d6b 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.cpp @@ -3,10 +3,7 @@ #include namespace TaoCommon { -ThreadObject::ThreadObject(const WorkCallback& work) - : m_workCall(work) -{ -} +ThreadObject::ThreadObject(const WorkCallback& work) : m_workCall(work) {} void ThreadObject::run() { bool ok = m_workCall(); diff --git a/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.h b/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.h index 39013de0..48a8aaa2 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.h +++ b/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadPool.h @@ -37,6 +37,6 @@ class TAO_API ThreadPool : public QObject void work(const WorkCallback& workCall, const WorkResultCallback& resultCall); private: - ThreadPool() { } + ThreadPool() {} }; } // namespace TaoCommon diff --git a/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadWorkerController.h b/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadWorkerController.h index 5a0341ef..0b782803 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadWorkerController.h +++ b/3rdparty/TaoCommon/src/TaoCommon/Thread/ThreadWorkerController.h @@ -14,12 +14,7 @@ class ThreadWorker : public QObject { Q_OBJECT public: - ThreadWorker(uint64_t id, const WorkCallback& workCall, QObject* parent = nullptr) - : QObject(parent) - , m_id(id) - , m_workCall(workCall) - { - } + ThreadWorker(uint64_t id, const WorkCallback& workCall, QObject* parent = nullptr) : QObject(parent), m_id(id), m_workCall(workCall) {} signals: void workFinished(bool, uint64_t); @@ -126,10 +121,7 @@ protected slots: } protected: - ThreadController(QObject* parent = nullptr) - : QObject(parent) - { - } + ThreadController(QObject* parent = nullptr) : QObject(parent) {} private: uint64_t m_rollId = 0; diff --git a/3rdparty/TaoCommon/src/TaoCommon/Trans/Trans.cpp b/3rdparty/TaoCommon/src/TaoCommon/Trans/Trans.cpp index 52be66f2..2af55cb2 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/Trans/Trans.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/Trans/Trans.cpp @@ -8,10 +8,7 @@ #include const static auto cEnglisthStr = u8"English"; const static auto cChineseStr = u8"简体中文"; -Trans::Trans(QObject* parent) - : QTranslator(parent) -{ -} +Trans::Trans(QObject* parent) : QTranslator(parent) {} void Trans::beforeUiReady(QQmlContext* ctx, const QString& folder) { @@ -28,7 +25,7 @@ void Trans::beforeUiReady(QQmlContext* ctx, const QString& folder) qApp->installTranslator(this); } -void Trans::afterUiReady() { } +void Trans::afterUiReady() {} QString Trans::translate(const char* context, const char* sourceText, const char* disambiguation, int n) const { diff --git a/examples/HelloTaoQuick3/HelloTaoQuick3/main.cpp b/examples/HelloTaoQuick3/HelloTaoQuick3/main.cpp index 8833a760..3325133d 100644 --- a/examples/HelloTaoQuick3/HelloTaoQuick3/main.cpp +++ b/examples/HelloTaoQuick3/HelloTaoQuick3/main.cpp @@ -1,24 +1,24 @@ #include #include #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { #if defined(Q_OS_WIN) - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif - QGuiApplication app(argc, argv); + QGuiApplication app(argc, argv); - QQmlApplicationEngine engine; - - QString importPath = TaoQuickImportPath; - importPath = importPath.replace("\\", "/"); - engine.addImportPath(importPath); - engine.rootContext()->setContextProperty("taoQuickImportPath", importPath); + QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - if (engine.rootObjects().isEmpty()) - return -1; + QString importPath = TaoQuickImportPath; + importPath = importPath.replace("\\", "/"); + engine.addImportPath(importPath); + engine.rootContext()->setContextProperty("taoQuickImportPath", importPath); - return app.exec(); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); } diff --git a/examples/TaoQuickShow/Src/AppInfo.cpp b/examples/TaoQuickShow/Src/AppInfo.cpp index 3aeeca3a..c18ca665 100644 --- a/examples/TaoQuickShow/Src/AppInfo.cpp +++ b/examples/TaoQuickShow/Src/AppInfo.cpp @@ -2,8 +2,7 @@ #include "Ver-u8.h" #include #include -AppInfo::AppInfo(QObject* parent) - : QObject(parent) +AppInfo::AppInfo(QObject* parent) : QObject(parent) { m_appName = VER_PRODUCTNAME_STR; m_appVersion = TaoVer; @@ -28,4 +27,4 @@ void AppInfo::afterUiReady() // qWarning() << json; } -AppInfo::~AppInfo() { } +AppInfo::~AppInfo() {} diff --git a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp index 3424eb47..9bf2e38f 100644 --- a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp +++ b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp @@ -1,12 +1,11 @@ #include "DeviceAddItem.h" #include -DeviceAddItem::DeviceAddItem(QObject* parent) - : QuickListItemBase(parent) +DeviceAddItem::DeviceAddItem(QObject* parent) : QuickListItemBase(parent) { connect(this, &DeviceAddItem::addressChanged, this, [this]() { m_ipv4Address = QHostAddress(address()).toIPv4Address(); }); } -DeviceAddItem::~DeviceAddItem() { } +DeviceAddItem::~DeviceAddItem() {} bool DeviceAddItem::match(const QString& key) { if (key.isEmpty()) diff --git a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddModel.cpp b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddModel.cpp index 2927f896..a44896b3 100644 --- a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddModel.cpp +++ b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddModel.cpp @@ -15,11 +15,9 @@ class DeviceAddModelPrivate { public: std::default_random_engine randomEngine; - std::uniform_int_distribution u65535 { 0, 0xffffffff }; + std::uniform_int_distribution u65535{ 0, 0xffffffff }; }; -DeviceAddModel::DeviceAddModel(QObject* parent) - : QuickListModel(parent) - , d(new DeviceAddModelPrivate) +DeviceAddModel::DeviceAddModel(QObject* parent) : QuickListModel(parent), d(new DeviceAddModelPrivate) { set_headerRoles(sHeaderRoles); set_sortRole("name"); diff --git a/examples/TaoQuickShow/Src/main.cpp b/examples/TaoQuickShow/Src/main.cpp index aefa81a6..bc5193d2 100644 --- a/examples/TaoQuickShow/Src/main.cpp +++ b/examples/TaoQuickShow/Src/main.cpp @@ -3,7 +3,7 @@ #include "Frameless/TaoFrameLessView.h" #ifndef TAODEBUG -#include "Logger/Logger.h" +# include "Logger/Logger.h" #endif #include "QuickTool/QuickTool.h" @@ -20,9 +20,9 @@ static void prepareApp() #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) +# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); -#endif +# endif #endif QCoreApplication::setOrganizationName("JaredTao"); QCoreApplication::setOrganizationDomain("https://jaredtao.github.io"); diff --git a/examples/TaoQuickShow/Src/stdafx.h b/examples/TaoQuickShow/Src/stdafx.h index ab2e84bb..62bd4b17 100644 --- a/examples/TaoQuickShow/Src/stdafx.h +++ b/examples/TaoQuickShow/Src/stdafx.h @@ -3,28 +3,28 @@ /* Add C++ includes here */ #if defined __cplusplus -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include #endif