Skip to content

Commit a5ed832

Browse files
committed
Introduce Core namespace
1 parent 0eff4ab commit a5ed832

Some content is hidden

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

46 files changed

+213
-132
lines changed

src/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,34 @@ set(HEIMER_LIB_SRC
2828
editor_scene.cpp
2929
editor_view.cpp
3030
grid.cpp
31-
hash_seed.cpp
3231
image.cpp
3332
image_manager.cpp
3433
item_filter.cpp
3534
layout_optimizer.cpp
3635
magic_zoom.cpp
3736
main_window.cpp
3837
mediator.cpp
39-
mind_map_data.cpp
40-
mind_map_data_base.cpp
4138
mouse_action.cpp
4239
node_action.hpp
4340
recent_files_manager.cpp
4441
selection_group.cpp
4542
state_machine.cpp
46-
test_mode.cpp
4743
types.hpp
4844
undo_stack.cpp
49-
user_exception.hpp
5045
utils.cpp
51-
version.hpp
52-
version_checker.cpp
5346

5447
core/graph.cpp
48+
core/hash_seed.cpp
49+
core/mind_map_data.cpp
50+
core/mind_map_data_base.cpp
5551
core/settings.cpp
5652
core/settings_proxy.cpp
5753
core/shadow_effect_params.hpp
5854
core/single_instance_container.cpp
55+
core/test_mode.cpp
56+
core/user_exception.hpp
57+
core/version.hpp
58+
core/version_checker.cpp
5959

6060
dialogs/about_dialog.cpp
6161
dialogs/color_dialog.cpp

src/application.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
#include "node_action.hpp"
2626
#include "recent_files_manager.hpp"
2727
#include "state_machine.hpp"
28-
#include "user_exception.hpp"
29-
#include "version_checker.hpp"
3028

3129
#include "core/settings.hpp"
3230
#include "core/settings_proxy.hpp"
3331
#include "core/single_instance_container.hpp"
32+
#include "core/user_exception.hpp"
33+
#include "core/version_checker.hpp"
3434

3535
#include "dialogs/layout_optimization_dialog.hpp"
3636
#include "dialogs/png_export_dialog.hpp"
@@ -144,7 +144,7 @@ void Application::parseArgs(int argc, char ** argv)
144144
Application::Application(int & argc, char ** argv)
145145
: m_app(argc, argv)
146146
, m_stateMachine(std::make_unique<StateMachine>())
147-
, m_versionChecker(std::make_unique<VersionChecker>())
147+
, m_versionChecker(std::make_unique<Core::VersionChecker>())
148148
{
149149
parseArgs(argc, argv);
150150

@@ -211,7 +211,7 @@ Application::Application(int & argc, char ** argv)
211211
}
212212
}
213213

214-
connect(m_versionChecker.get(), &VersionChecker::newVersionFound, this, [this](Version version, QString downloadUrl) {
214+
connect(m_versionChecker.get(), &Core::VersionChecker::newVersionFound, this, [this](Core::Version version, QString downloadUrl) {
215215
m_mainWindow->showStatusText(QString(tr("A new version %1 available at <a href='%2'>%2</a>")).arg(version.toString(), downloadUrl));
216216
});
217217
m_versionChecker->checkForNewReleases();

src/application.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ class EditorView;
3030
class ImageManager;
3131
class MainWindow;
3232
class Mediator;
33-
class Node;
33+
34+
namespace Core {
3435
class VersionChecker;
36+
}
3537

3638
namespace Dialogs {
3739
class PngExportDialog;
@@ -120,7 +122,7 @@ public slots:
120122

121123
std::unique_ptr<Dialogs::SvgExportDialog> m_svgExportDialog;
122124

123-
std::unique_ptr<VersionChecker> m_versionChecker;
125+
std::unique_ptr<Core::VersionChecker> m_versionChecker;
124126
};
125127

126128
#endif // APPLICATION_HPP

src/core/graph.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "graph.hpp"
1717

18-
#include "../test_mode.hpp"
18+
#include "test_mode.hpp"
1919

2020
#include "simple_logger.hpp"
2121

@@ -27,6 +27,8 @@
2727
#include <stdexcept>
2828
#include <string>
2929

30+
namespace Core {
31+
3032
namespace rv = ranges::views;
3133

3234
namespace {
@@ -180,3 +182,5 @@ Graph::~Graph()
180182

181183
juzzlin::L().debug() << "Graph deleted";
182184
}
185+
186+
} // namespace Core

src/core/graph.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <unordered_map>
2626
#include <vector>
2727

28+
namespace Core {
29+
2830
class Graph
2931
{
3032
public:
@@ -95,4 +97,6 @@ class Graph
9597
int m_count = 0;
9698
};
9799

100+
} // namespace Core
101+
98102
#endif // GRAPH_HPP

src/hash_seed.cpp renamed to src/core/hash_seed.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "hash_seed.hpp"
1717

18+
namespace Core {
19+
1820
void HashSeed::init()
1921
{
2022
#if QT_VERSION >= 0x50600
@@ -23,3 +25,5 @@ void HashSeed::init()
2325
qt_qhash_seed.store(0);
2426
#endif
2527
}
28+
29+
} // namespace Core

src/hash_seed.hpp renamed to src/core/hash_seed.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed;
2323
#endif
2424

25-
namespace HashSeed {
25+
namespace Core::HashSeed {
2626

2727
void init();
2828

29-
}
29+
} // namespace Core::HashSeed
3030

3131
#endif // HASH_SEED_HPP

src/mind_map_data.cpp renamed to src/core/mind_map_data.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515

1616
#include "mind_map_data.hpp"
1717

18-
#include "grid.hpp"
19-
#include "image_manager.hpp"
18+
#include "graph.hpp"
19+
#include "settings_proxy.hpp"
20+
#include "shadow_effect_params.hpp"
21+
#include "single_instance_container.hpp"
2022

21-
#include "core/settings_proxy.hpp"
22-
#include "core/shadow_effect_params.hpp"
23-
#include "core/single_instance_container.hpp"
23+
#include "../grid.hpp"
24+
#include "../image_manager.hpp"
2425

25-
#include "core/graph.hpp"
26-
#include "scene_items/node.hpp"
26+
#include "../scene_items/node.hpp"
27+
28+
namespace Core {
2729

2830
struct MindMapData::Style
2931
{
@@ -307,3 +309,5 @@ void MindMapData::setVersion(const QString & version)
307309
}
308310

309311
MindMapData::~MindMapData() = default;
312+
313+
} // namespace Core

src/mind_map_data.hpp renamed to src/core/mind_map_data.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
#include "constants.hpp"
2525
#include "mind_map_data_base.hpp"
2626

27-
class Graph;
2827
class Grid;
2928
class ImageManager;
3029
class ObjectModelLoader;
3130
struct ShadowEffectParams;
3231

32+
namespace Core {
33+
34+
class Graph;
35+
3336
class MindMapData : public MindMapDataBase
3437
{
3538
public:
@@ -125,6 +128,6 @@ class MindMapData : public MindMapDataBase
125128
LayoutOptimizerParameters m_layoutOptimizerParameters;
126129
};
127130

128-
typedef std::shared_ptr<MindMapData> MindMapDataPtr;
131+
} // namespace Core
129132

130133
#endif // MIND_MAP_DATA_HPP
File renamed without changes.
File renamed without changes.

src/test_mode.cpp renamed to src/core/test_mode.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
// along with Heimer. If not, see <http://www.gnu.org/licenses/>.
1515

1616
#include "test_mode.hpp"
17+
1718
#include "simple_logger.hpp"
1819

20+
namespace Core {
21+
1922
bool TestMode::m_enabled = false;
2023

2124
bool TestMode::enabled()
@@ -32,3 +35,5 @@ void TestMode::logDisabledCode(const std::string & message)
3235
{
3336
juzzlin::L().debug() << "TestMode: '" << message << "' disabled";
3437
}
38+
39+
} // namespace Core

src/test_mode.hpp renamed to src/core/test_mode.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <string>
2020

21+
namespace Core {
22+
2123
class TestMode
2224
{
2325
public:
@@ -31,4 +33,6 @@ class TestMode
3133
static bool m_enabled;
3234
};
3335

36+
} // namespace Core
37+
3438
#endif // TEST_MODE_HPP

src/user_exception.hpp renamed to src/core/user_exception.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <stdexcept>
2020
#include <string>
2121

22+
namespace Core {
23+
2224
class UserException : public std::runtime_error
2325
{
2426
public:
@@ -28,4 +30,6 @@ class UserException : public std::runtime_error
2830
}
2931
};
3032

33+
} // namespace Core
34+
3135
#endif // USER_EXCEPTION_HPP

src/version.hpp renamed to src/core/version.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#undef minor
2727
#undef patch
2828

29+
namespace Core {
30+
2931
struct Version
3032
{
3133
Version()
@@ -120,4 +122,6 @@ inline std::ostream & operator<<(std::ostream & os, const Version & version)
120122
return os;
121123
}
122124

125+
} // namespace Core
126+
123127
#endif // VERSION_HPP

src/version_checker.cpp renamed to src/core/version_checker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
using juzzlin::L;
2525

26+
namespace Core {
27+
2628
VersionChecker::VersionChecker(QObject * parent)
2729
: QObject(parent)
2830
{
@@ -64,3 +66,5 @@ void VersionChecker::checkForNewReleases()
6466
});
6567
manager->get(QNetworkRequest({ Constants::Application::RELEASES_URL }));
6668
}
69+
70+
} // namespace Core

src/version_checker.hpp renamed to src/core/version_checker.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#include "version.hpp"
2222

23+
namespace Core {
24+
2325
class VersionChecker : public QObject
2426
{
2527
Q_OBJECT
@@ -33,4 +35,6 @@ class VersionChecker : public QObject
3335
void newVersionFound(Version version, QString downloadUrl);
3436
};
3537

38+
} // namespace Core
39+
3640
#endif // VERSION_CHECKER_HPP

src/dialogs/layout_optimization_dialog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
#include "../constants.hpp"
1919
#include "../layout_optimizer.hpp"
20-
#include "../mind_map_data.hpp"
20+
21+
#include "../core/mind_map_data.hpp"
2122

2223
#include "widget_factory.hpp"
2324

@@ -35,7 +36,7 @@
3536

3637
namespace Dialogs {
3738

38-
LayoutOptimizationDialog::LayoutOptimizationDialog(QWidget & parent, MindMapData & mindMapData, LayoutOptimizer & layoutOptimizer)
39+
LayoutOptimizationDialog::LayoutOptimizationDialog(QWidget & parent, MindMapDataR mindMapData, LayoutOptimizer & layoutOptimizer)
3940
: QDialog(&parent)
4041
, m_mindMapData(mindMapData)
4142
, m_layoutOptimizer(layoutOptimizer)
@@ -68,7 +69,7 @@ void LayoutOptimizationDialog::finishOptimization()
6869
QTimer::singleShot(500, this, &QDialog::accept);
6970
}
7071

71-
void LayoutOptimizationDialog::initWidgets(const MindMapData & mindMapData)
72+
void LayoutOptimizationDialog::initWidgets(MindMapDataCR mindMapData)
7273
{
7374
const auto mainLayout = new QVBoxLayout(this);
7475

src/dialogs/layout_optimization_dialog.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818

1919
#include <QDialog>
2020

21+
#include "../types.hpp"
22+
2123
class LayoutOptimizer;
22-
class MindMapData;
2324
class QDoubleSpinBox;
2425
class QProgressBar;
2526

@@ -31,7 +32,7 @@ class LayoutOptimizationDialog : public QDialog
3132

3233
public:
3334
//! Constructor.
34-
explicit LayoutOptimizationDialog(QWidget & parent, MindMapData & mindMapData, LayoutOptimizer & layoutOptimizer);
35+
explicit LayoutOptimizationDialog(QWidget & parent, MindMapDataR mindMapData, LayoutOptimizer & layoutOptimizer);
3536

3637
int exec() override;
3738

@@ -44,9 +45,9 @@ private slots:
4445
void finishOptimization();
4546

4647
private:
47-
void initWidgets(const MindMapData & mindMapData);
48+
void initWidgets(MindMapDataCR mindMapData);
4849

49-
MindMapData & m_mindMapData;
50+
MindMapDataR m_mindMapData;
5051

5152
LayoutOptimizer & m_layoutOptimizer;
5253

0 commit comments

Comments
 (0)