From b69942028e615c2312d015648f5090341f9f8019 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 17 Nov 2024 17:28:25 +0000 Subject: [PATCH] cleanup: Minimise direct dependencies on core.h. And transitively on tox.h. This reduces the amount of rebuild that needs to happen when we change tox.h. --- src/chatlog/chatwidget.cpp | 1 + src/core/corefile.h | 4 ++-- src/model/chatroom/friendchatroom.cpp | 1 + src/model/friend.h | 1 - src/model/ichatlog.h | 1 - src/model/imessagedispatcher.h | 1 + src/persistence/history.cpp | 3 ++- src/persistence/offlinemsgengine.h | 3 +-- src/persistence/profile.h | 11 ++++----- src/widget/categorywidget.h | 1 - src/widget/form/chatform.h | 20 ++++++++-------- src/widget/form/filesform.cpp | 1 + src/widget/form/filesform.h | 8 +++---- src/widget/friendlistlayout.h | 1 - src/widget/friendlistwidget.cpp | 1 + src/widget/friendlistwidget.h | 26 ++++++++++----------- src/widget/widget.h | 1 - test/model/friendmessagedispatcher_test.cpp | 2 ++ test/model/groupmessagedispatcher_test.cpp | 1 + test/widget/filesform_test.cpp | 2 ++ 20 files changed, 47 insertions(+), 43 deletions(-) diff --git a/src/chatlog/chatwidget.cpp b/src/chatlog/chatwidget.cpp index 88194a4162..092f824c54 100644 --- a/src/chatlog/chatwidget.cpp +++ b/src/chatlog/chatwidget.cpp @@ -10,6 +10,7 @@ #include "content/filetransferwidget.h" #include "content/text.h" #include "src/chatlog/chatlinestorage.h" +#include "src/core/core.h" #include "src/persistence/settings.h" #include "src/widget/style.h" #include "src/widget/translator.h" diff --git a/src/core/corefile.h b/src/core/corefile.h index bab450ef5c..d332535ecb 100644 --- a/src/core/corefile.h +++ b/src/core/corefile.h @@ -6,10 +6,9 @@ #pragma once -#include +#include // Tox_File_Control #include "toxfile.h" -#include "src/core/core.h" #include "src/core/toxpk.h" #include "src/model/status.h" @@ -23,6 +22,7 @@ #include struct Tox; +class Core; class CoreFile; using CoreFilePtr = std::unique_ptr; diff --git a/src/model/chatroom/friendchatroom.cpp b/src/model/chatroom/friendchatroom.cpp index 880d17fb28..378b0eeca1 100644 --- a/src/model/chatroom/friendchatroom.cpp +++ b/src/model/chatroom/friendchatroom.cpp @@ -4,6 +4,7 @@ */ #include "src/model/chatroom/friendchatroom.h" +#include "src/core/core.h" #include "src/grouplist.h" #include "src/model/dialogs/idialogsmanager.h" #include "src/model/friend.h" diff --git a/src/model/friend.h b/src/model/friend.h index 32675fe528..44c49b7bf1 100644 --- a/src/model/friend.h +++ b/src/model/friend.h @@ -7,7 +7,6 @@ #include "chat.h" #include "src/core/chatid.h" -#include "src/core/core.h" #include "src/core/extension.h" #include "src/core/toxpk.h" #include "src/model/status.h" diff --git a/src/model/ichatlog.h b/src/model/ichatlog.h index 59942991a7..015e180a6f 100644 --- a/src/model/ichatlog.h +++ b/src/model/ichatlog.h @@ -6,7 +6,6 @@ #pragma once #include "message.h" -#include "src/core/core.h" #include "src/core/toxfile.h" #include "src/core/toxpk.h" #include "src/friendlist.h" diff --git a/src/model/imessagedispatcher.h b/src/model/imessagedispatcher.h index b0739870cf..8da8b2a478 100644 --- a/src/model/imessagedispatcher.h +++ b/src/model/imessagedispatcher.h @@ -8,6 +8,7 @@ #include "src/model/brokenmessagereason.h" #include "src/model/friend.h" #include "src/model/message.h" +#include "util/strongtype.h" #include #include diff --git a/src/persistence/history.cpp b/src/persistence/history.cpp index e0af6da8cd..677e1678d9 100644 --- a/src/persistence/history.cpp +++ b/src/persistence/history.cpp @@ -6,7 +6,8 @@ #include #include -#include "history.h" +#include + #include "profile.h" #include "settings.h" #include "db/rawdatabase.h" diff --git a/src/persistence/offlinemsgengine.h b/src/persistence/offlinemsgengine.h index 9e5ea1b99d..fb6f508e82 100644 --- a/src/persistence/offlinemsgengine.h +++ b/src/persistence/offlinemsgengine.h @@ -6,7 +6,7 @@ #pragma once #include "src/chatlog/chatmessage.h" -#include "src/core/core.h" +#include "src/core/receiptnum.h" #include "src/model/message.h" #include "src/persistence/db/rawdatabase.h" @@ -17,7 +17,6 @@ #include #include - class OfflineMsgEngine : public QObject { Q_OBJECT diff --git a/src/persistence/profile.h b/src/persistence/profile.h index 43d725d407..03b3081380 100644 --- a/src/persistence/profile.h +++ b/src/persistence/profile.h @@ -6,11 +6,8 @@ #pragma once -#include "src/core/core.h" #include "src/core/toxencrypt.h" - #include "src/net/avatarbroadcaster.h" - #include "src/net/bootstrapnodeupdater.h" #include "src/persistence/history.h" @@ -21,11 +18,13 @@ #include #include -class Settings; -class QCommandLineParser; -class ToxPk; class CameraSource; +class Core; +class CoreAV; class IMessageBoxManager; +class QCommandLineParser; +class Settings; +class ToxPk; class Profile : public QObject { diff --git a/src/widget/categorywidget.h b/src/widget/categorywidget.h index eb309ee5b3..c0fe186428 100644 --- a/src/widget/categorywidget.h +++ b/src/widget/categorywidget.h @@ -6,7 +6,6 @@ #pragma once #include "genericchatitemwidget.h" -#include "src/core/core.h" #include "src/model/status.h" class FriendListLayout; diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index 39b75a32c8..e84d4de1c0 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -11,7 +11,6 @@ #include #include "genericchatform.h" -#include "src/core/core.h" #include "src/model/ichatlog.h" #include "src/model/imessagedispatcher.h" #include "src/model/status.h" @@ -20,23 +19,24 @@ #include "src/widget/tool/screenshotgrabber.h" class CallConfirmWidget; +class ContentDialogManager; +class Core; +class DocumentCache; class FileTransferInstance; class Friend; +class FriendList; +class GroupList; class History; +class ImagePreviewButton; +class IMessageBoxManager; class OfflineMsgEngine; -class QPixmap; +class Profile; class QHideEvent; class QMoveEvent; -class ImagePreviewButton; -class DocumentCache; -class SmileyPack; +class QPixmap; class Settings; +class SmileyPack; class Style; -class Profile; -class IMessageBoxManager; -class ContentDialogManager; -class FriendList; -class GroupList; class ChatForm : public GenericChatForm { diff --git a/src/widget/form/filesform.cpp b/src/widget/form/filesform.cpp index 9ad46acce2..acdeadf624 100644 --- a/src/widget/form/filesform.cpp +++ b/src/widget/form/filesform.cpp @@ -4,6 +4,7 @@ */ #include "filesform.h" +#include "src/core/corefile.h" #include "src/core/toxfile.h" #include "src/friendlist.h" #include "src/widget/contentlayout.h" diff --git a/src/widget/form/filesform.h b/src/widget/form/filesform.h index 7c8ff36a3f..a92c9489f1 100644 --- a/src/widget/form/filesform.h +++ b/src/widget/form/filesform.h @@ -5,7 +5,6 @@ #pragma once -#include "src/core/corefile.h" #include "src/core/toxfile.h" #include @@ -19,12 +18,13 @@ #include class ContentLayout; +class CoreFile; +class FriendList; +class IMessageBoxManager; +class QFileInfo; class QTableView; class Settings; class Style; -class QFileInfo; -class IMessageBoxManager; -class FriendList; namespace FileTransferList { diff --git a/src/widget/friendlistlayout.h b/src/widget/friendlistlayout.h index 81ba8a9883..749db12313 100644 --- a/src/widget/friendlistlayout.h +++ b/src/widget/friendlistlayout.h @@ -6,7 +6,6 @@ #pragma once #include "genericchatitemlayout.h" -#include "src/core/core.h" #include "src/model/status.h" #include diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp index 8b2e19aea8..08fccf73f3 100644 --- a/src/widget/friendlistwidget.cpp +++ b/src/widget/friendlistwidget.cpp @@ -8,6 +8,7 @@ #include "friendwidget.h" #include "groupwidget.h" #include "widget.h" +#include "src/core/core.h" #include "src/friendlist.h" #include "src/model/friend.h" #include "src/model/friendlist/friendlistmanager.h" diff --git a/src/widget/friendlistwidget.h b/src/widget/friendlistwidget.h index 0a4cc79f90..632afc3935 100644 --- a/src/widget/friendlistwidget.h +++ b/src/widget/friendlistwidget.h @@ -6,30 +6,30 @@ #pragma once #include "genericchatitemlayout.h" -#include "src/core/core.h" #include "src/model/status.h" #include "src/persistence/settings.h" #include -class QVBoxLayout; -class QGridLayout; -class QPixmap; -class Widget; -class FriendWidget; -class GroupWidget; +class CategoryWidget; class CircleWidget; +class Core; +class Friend; +class FriendList; class FriendListManager; +class FriendWidget; class GenericChatroomWidget; -class CategoryWidget; -class Friend; +class GroupList; +class GroupWidget; class IFriendListItem; -class Settings; -class Style; class IMessageBoxManager; -class FriendList; -class GroupList; class Profile; +class QGridLayout; +class QPixmap; +class QVBoxLayout; +class Settings; +class Style; +class Widget; class FriendListWidget : public QWidget { diff --git a/src/widget/widget.h b/src/widget/widget.h index 700c2e47bc..c6303a8d29 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -17,7 +17,6 @@ #include "audio/iaudiocontrol.h" #include "audio/iaudiosink.h" -#include "src/core/core.h" #include "src/core/groupid.h" #include "src/core/toxfile.h" #include "src/core/toxid.h" diff --git a/test/model/friendmessagedispatcher_test.cpp b/test/model/friendmessagedispatcher_test.cpp index e3fec9e680..685f578f24 100644 --- a/test/model/friendmessagedispatcher_test.cpp +++ b/test/model/friendmessagedispatcher_test.cpp @@ -14,6 +14,8 @@ #include #include +#include // tox_max_message_length + namespace { constexpr uint64_t testMaxExtendedMessageSize = 10 * 1024 * 1024; } diff --git a/test/model/groupmessagedispatcher_test.cpp b/test/model/groupmessagedispatcher_test.cpp index 35d00afa43..b1c1df796f 100644 --- a/test/model/groupmessagedispatcher_test.cpp +++ b/test/model/groupmessagedispatcher_test.cpp @@ -21,6 +21,7 @@ #include #include +#include // tox_max_message_length class MockGroupMessageSender : public ICoreGroupMessageSender { diff --git a/test/widget/filesform_test.cpp b/test/widget/filesform_test.cpp index 08fed7b565..ca90371f66 100644 --- a/test/widget/filesform_test.cpp +++ b/test/widget/filesform_test.cpp @@ -10,6 +10,8 @@ #include #include +#include // TOX_FILE_KIND_* + class TestFileTransferList : public QObject { Q_OBJECT