Skip to content

Commit aa15931

Browse files
committed
refactor: Improve imports and fix SFINAE issues
Some forward declarations cause SFINAE issues, because the definition is needed to choose the correct template. This affects the classes UBGraphicsMediaItem, UBGraphicsTextItem, UBBackgroundRuling, UBToolWidget, and WebView. To eliminate these forward declarations, the imports need to be restructured. The easiest case is replacing the forward declaration with the include of the definition. This doesn't quite work for UBGraphicsMediaItem as it causes an include cycle: src/domain/UBGraphicsMediaItem.h includes src/domain/UBItem.h which includes src/domain/UBGraphicsItemDelegate.h which includes src/domain/UBGraphicsMediaItem.h The solution provided here is to turn the UBGraphicsMediaItem class into a forward declaration in src/domain/UBGraphicsItemDelegate.h In the course of this work, UBGraphicsItem has been split from UBItem into its own file; this surfaced a lot of transitive includes that weren't properly declared.
1 parent 82ea870 commit aa15931

42 files changed

Lines changed: 394 additions & 225 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/adaptors/UBExportDocumentSetAdaptor.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,9 @@
2525
*/
2626

2727

28-
#include "UBExportDocumentSetAdaptor.h"
29-
#include "UBExportDocument.h"
30-
31-
#include "adaptors/UBPageMapper.h"
32-
33-
#include "frameworks/UBPlatformUtils.h"
34-
35-
#include "core/UBDocumentManager.h"
36-
#include "core/UBApplication.h"
3728

38-
#include "document/UBDocumentProxy.h"
39-
#include "document/UBDocumentController.h"
40-
#include "document/UBDocumentToc.h"
4129

42-
#include "core/UBPersistenceManager.h"
30+
#include "UBExportDocumentSetAdaptor.h"
4331

4432
#ifdef Q_OS_OSX
4533
#include <quazip.h>
@@ -49,7 +37,21 @@
4937
#include "quazipfile.h"
5038
#endif
5139

40+
#include "adaptors/UBPageMapper.h"
41+
5242
#include "core/memcheck.h"
43+
#include "core/UBApplication.h"
44+
#include "core/UBDocumentManager.h"
45+
#include "core/UBPersistenceManager.h"
46+
#include "core/UBSettings.h"
47+
48+
#include "document/UBDocumentProxy.h"
49+
#include "document/UBDocumentController.h"
50+
#include "document/UBDocumentToc.h"
51+
52+
#include "frameworks/UBPlatformUtils.h"
53+
54+
#include "UBExportDocument.h"
5355

5456
UBExportDocumentSetAdaptor::UBExportDocumentSetAdaptor(QObject *parent)
5557
: UBExportAdaptor(parent)

src/adaptors/UBSvgSubsetAdaptor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "domain/UBGraphicsStrokesGroup.h"
5050
#include "domain/UBGraphicsGroupContainerItem.h"
5151
#include "domain/UBGraphicsGroupContainerItemDelegate.h"
52+
#include "domain/UBGraphicsItem.h"
5253
#include "domain/UBItem.h"
5354

5455
#include "gui/UBBackgroundRuling.h"

src/adaptors/UBSvgSubsetAdaptor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@
3636

3737
#include <optional>
3838

39+
#include "domain/UBGraphicsMediaItem.h"
40+
#include "domain/UBGraphicsTextItem.h"
41+
3942
#include "frameworks/UBGeometryUtils.h"
4043

4144
class UBGraphicsSvgItem;
4245
class UBGraphicsPolygonItem;
4346
class UBGraphicsPixmapItem;
4447
class UBGraphicsPDFItem;
4548
class UBGraphicsWidgetItem;
46-
class UBGraphicsMediaItem;
4749
class UBGraphicsVideoItem;
4850
class UBGraphicsAudioItem;
4951
class UBGraphicsW3CWidgetItem;
50-
class UBGraphicsTextItem;
5152
class UBGraphicsCurtainItem;
5253
class UBGraphicsRuler;
5354
class UBGraphicsAxes;

src/adaptors/UBWidgetUpgradeAdaptor.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,20 @@
2525
*/
2626

2727

28-
#include "UBWidgetUpgradeAdaptor.h"
2928

30-
#include "core/UBPersistenceManager.h"
31-
#include "document/UBDocumentProxy.h"
32-
#include "frameworks/UBPlatformUtils.h"
29+
30+
#include "UBWidgetUpgradeAdaptor.h"
3331

3432
#include <QCryptographicHash>
3533
#include <QDomDocument>
3634

3735
#include "core/memcheck.h"
36+
#include "core/UBPersistenceManager.h"
37+
#include "core/UBSettings.h"
38+
39+
#include "document/UBDocumentProxy.h"
40+
41+
#include "frameworks/UBPlatformUtils.h"
3842

3943
UBWidgetUpgradeAdaptor::UBWidgetUpgradeAdaptor()
4044
{

src/board/UBBoardController.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "document/UBDocumentProxy.h"
6060

6161
#include "domain/UBGraphicsGroupContainerItem.h"
62+
#include "domain/UBGraphicsItem.h"
6263
#include "domain/UBGraphicsItemUndoCommand.h"
6364
#include "domain/UBGraphicsMediaItem.h"
6465
#include "domain/UBGraphicsPDFItem.h"

src/board/UBBoardController.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040
#include "core/UB.h"
4141
#include "core/UBApplicationController.h"
4242
#include "document/UBDocumentContainer.h"
43+
#include "domain/UBGraphicsMediaItem.h"
44+
#include "gui/UBBackgroundRuling.h"
45+
#include "gui/UBToolWidget.h"
4346

4447
class UBMainWindow;
4548
class UBApplication;
4649
class UBBoardView;
4750

48-
class UBBackgroundRuling;
4951
class UBBackgroundManager;
5052
class UBDocument;
5153
class UBDocumentController;
@@ -54,11 +56,9 @@ class UBGraphicsScene;
5456
class UBDocumentProxy;
5557
class UBEmbedController;
5658
class UBBlackoutWidget;
57-
class UBToolWidget;
5859
class UBVersion;
5960
class UBSoftwareUpdate;
6061
class UBSoftwareUpdateDialog;
61-
class UBGraphicsMediaItem;
6262
class UBGraphicsWidgetItem;
6363
class UBBoardPaletteManager;
6464
class UBItem;

src/board/UBBoardView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#include "domain/UBGraphicsWidgetItem.h"
7070
#include "domain/UBGraphicsPDFItem.h"
7171
#include "domain/UBGraphicsPolygonItem.h"
72-
#include "domain/UBItem.h"
72+
#include "domain/UBGraphicsItem.h"
7373
#include "domain/UBGraphicsMediaItem.h"
7474
#include "domain/UBGraphicsSvgItem.h"
7575
#include "domain/UBGraphicsGroupContainerItem.h"

src/domain/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ target_sources(${PROJECT_NAME} PRIVATE
55
UBGraphicsGroupContainerItem.h
66
UBGraphicsGroupContainerItemDelegate.cpp
77
UBGraphicsGroupContainerItemDelegate.h
8+
UBGraphicsItem.cpp
9+
UBGraphicsItem.h
810
UBGraphicsItemDelegate.cpp
911
UBGraphicsItemDelegate.h
1012
UBGraphicsItemGroupUndoCommand.cpp

src/domain/UBGraphicsGroupContainerItem.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@
3030
#include "UBGraphicsGroupContainerItem.h"
3131

3232
#include <QtGui>
33+
#include <QGraphicsItem>
34+
35+
#include "core/memcheck.h"
36+
#include "core/UB.h"
3337

34-
#include "UBGraphicsMediaItem.h"
35-
#include "UBGraphicsTextItem.h"
3638
#include "domain/UBGraphicsItemDelegate.h"
3739
#include "domain/UBGraphicsGroupContainerItemDelegate.h"
3840
#include "domain/UBGraphicsScene.h"
3941

40-
#include "core/memcheck.h"
42+
#include "UBGraphicsMediaItem.h"
43+
#include "UBGraphicsTextItem.h"
4144

4245
UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent)
4346
: QGraphicsItem(parent)

src/domain/UBGraphicsGroupContainerItem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#include <QGraphicsItem>
3434

35+
#include "core/UB.h"
36+
#include "domain/UBGraphicsItem.h"
3537
#include "domain/UBItem.h"
3638
#include "frameworks/UBCoreGraphicsScene.h"
3739

0 commit comments

Comments
 (0)