Skip to content
This repository was archived by the owner on May 4, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Checks: >
readability-qt6-parent-child-check,
cppcoreguidelines*,
performance*,
readability-identifier-naming,
modernize-use-list-initialization,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-special-member-functions,
-performance-enum-size,
-cppcoreguidelines-non-private-member-variables-in-classes

HeaderFilterRegex: '.*'

CheckOptions:
- key: modernize-use-list-initialization.StrictMode
value: 'true'
168 changes: 100 additions & 68 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
qt6.qtbase
qtcreator

python3
llvmPackages_latest.clang-tools
cmake
bear
entr
Expand Down
4 changes: 2 additions & 2 deletions src/canvas/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <QScreen>

// PUBLIC
Canvas::Canvas(QWidget *parent) : QWidget{parent} {
Canvas::Canvas(QWidget *parent) : QWidget{parent}, m_maxSize(m_sizeHint) {
m_sizeHint = screen()->size() * m_scale;
m_maxSize = m_sizeHint;


m_canvas = new QPixmap(m_sizeHint);
m_overlay = new QPixmap(m_sizeHint);
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Canvas : public QWidget {

public:
explicit Canvas(QWidget *parent = nullptr);
~Canvas();
~Canvas() override;

QPixmap *const canvas() const;
QPixmap *const overlay() const;
Expand Down
1 change: 1 addition & 0 deletions src/command/command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ApplicationContext;

class Command {
public:
virtual ~Command() = default;
virtual void execute(ApplicationContext *context) = 0;
virtual void undo(ApplicationContext *context) = 0;
};
2 changes: 1 addition & 1 deletion src/command/commandhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CommandHistory::redo() {
m_redoStack->pop_front();
}

void CommandHistory::insert(std::shared_ptr<Command> command) {
void CommandHistory::insert(const std::shared_ptr<Command>& command) {
while (!m_redoStack->empty()) {
m_redoStack->pop_front();
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/commandhistory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CommandHistory {

void undo();
void redo();
void insert(std::shared_ptr<Command> command);
void insert(const std::shared_ptr<Command>& command);

static constexpr int maxCommands{100}; // arbitrary

Expand Down
11 changes: 5 additions & 6 deletions src/command/deselectcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@

#include "deselectcommand.hpp"

#include <utility>

#include "../context/applicationcontext.hpp"
#include "../context/coordinatetransformer.hpp"
#include "../context/selectioncontext.hpp"
#include "../context/spatialcontext.hpp"
#include "../item/item.hpp"
#include "../data-structures/cachegrid.hpp"

DeselectCommand::DeselectCommand(QVector<std::shared_ptr<Item>> items) : ItemCommand{items} {}

DeselectCommand::~DeselectCommand() {
}
DeselectCommand::DeselectCommand(QVector<std::shared_ptr<Item>> items) : ItemCommand{std::move(items)} {}

void DeselectCommand::execute(ApplicationContext *context) {
auto &selectedItems{context->selectionContext().selectedItems()};

QRectF dirtyRegion{};
for (const auto item : m_items) {
for (const auto& item : m_items) {
dirtyRegion |= item->boundingBox();
selectedItems.erase(item);
}
Expand All @@ -46,7 +45,7 @@ void DeselectCommand::undo(ApplicationContext *context) {
auto &selectedItems{context->selectionContext().selectedItems()};

QRectF dirtyRegion{};
for (const auto item : m_items) {
for (const auto& item : m_items) {
dirtyRegion |= item->boundingBox();
selectedItems.insert(item);
}
Expand Down
1 change: 0 additions & 1 deletion src/command/deselectcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class ApplicationContext;
class DeselectCommand : public ItemCommand {
public:
DeselectCommand(QVector<std::shared_ptr<Item>> items);
~DeselectCommand();

void execute(ApplicationContext *context) override;
void undo(ApplicationContext *context) override;
Expand Down
11 changes: 5 additions & 6 deletions src/command/groupcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "groupcommand.hpp"

#include <utility>

#include "commandhistory.hpp"
#include "selectcommand.hpp"
#include "deselectcommand.hpp"
Expand All @@ -29,21 +31,18 @@
#include "../data-structures/quadtree.hpp"
#include "../item/group.hpp"

GroupCommand::GroupCommand(QVector<std::shared_ptr<Item>> items) : ItemCommand{items} {
GroupCommand::GroupCommand(QVector<std::shared_ptr<Item>> items) : ItemCommand{std::move(items)} {
m_group = std::make_shared<GroupItem>();

// sort according to z order
ApplicationContext::instance()->spatialContext().quadtree().reorder(m_items);
}

GroupCommand::~GroupCommand() {
}

void GroupCommand::execute(ApplicationContext *context) {
auto &quadtree{context->spatialContext().quadtree()};
auto &selectedItems{context->selectionContext().selectedItems()};

for (const auto item : m_items) {
for (const auto& item : m_items) {
quadtree.deleteItem(item, false);
}

Expand All @@ -63,7 +62,7 @@ void GroupCommand::undo(ApplicationContext *context) {
quadtree.deleteItem(m_group);
selectedItems.clear();

for (const auto item : m_items) {
for (const auto& item : m_items) {
selectedItems.insert(item);
quadtree.insertItem(item, false);
}
Expand Down
1 change: 0 additions & 1 deletion src/command/groupcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class GroupItem;
class GroupCommand : public ItemCommand {
public:
GroupCommand(QVector<std::shared_ptr<Item>> items);
~GroupCommand();

void execute(ApplicationContext *context) override;
void undo(ApplicationContext *context) override;
Expand Down
7 changes: 3 additions & 4 deletions src/command/insertitemcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@

#include "insertitemcommand.hpp"

#include <utility>

#include "../context/applicationcontext.hpp"
#include "../context/coordinatetransformer.hpp"
#include "../context/selectioncontext.hpp"
#include "../context/spatialcontext.hpp"
#include "../data-structures/cachegrid.hpp"
#include "../data-structures/quadtree.hpp"

InsertItemCommand::InsertItemCommand(QVector<std::shared_ptr<Item>> items) : ItemCommand{items} {
}

InsertItemCommand::~InsertItemCommand() {
InsertItemCommand::InsertItemCommand(QVector<std::shared_ptr<Item>> items) : ItemCommand{std::move(items)} {
}

void InsertItemCommand::execute(ApplicationContext *context) {
Expand Down
1 change: 0 additions & 1 deletion src/command/insertitemcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ApplicationContext;
class InsertItemCommand : public ItemCommand {
public:
InsertItemCommand(QVector<std::shared_ptr<Item>> items);
~InsertItemCommand();

void execute(ApplicationContext *context) override;
void undo(ApplicationContext *context) override;
Expand Down
3 changes: 2 additions & 1 deletion src/command/itemcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#include "itemcommand.hpp"

#include <QDebug>
#include <utility>

ItemCommand::ItemCommand(QVector<std::shared_ptr<Item>> items) : m_items{items} {
ItemCommand::ItemCommand(QVector<std::shared_ptr<Item>> items) : m_items{std::move(items)} {
}

ItemCommand::~ItemCommand() {
Expand Down
2 changes: 1 addition & 1 deletion src/command/itemcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Item;
class ItemCommand : public Command {
public:
ItemCommand(QVector<std::shared_ptr<Item>> items);
~ItemCommand();
~ItemCommand() override;

protected:
QVector<std::shared_ptr<Item>> m_items;
Expand Down
Loading
Loading