Modules/Taskboard/public/TaskKanban.hpp
Шурупов Илья Викторович f344c644e6 Kanban: move columns by dragging their headers
KanbanBoard: pressing a column header (anywhere but its options button) and
dragging it lifts the whole column the same way a card is lifted: the column
widget itself follows the pointer sideways above the board, and the remaining
columns slide apart to open the slot it will drop into. Releasing moves the
column and it settles into its slot with the usual geometry animation; Escape
puts it back. Hidden columns are skipped when choosing the slot, so they keep
their place among their neighbours. The board scrolls sideways near its edges
while a column is lifted, as it does for cards.

Card and column dragging share one mechanism: Lift captures the widget, the
grab offset, the pointer and the focus to restore, lift()/drop() reparent the
widget onto the board and back, and the board layout places whatever is
lifted. moveColumn(from, to) is the single place that reorders the column data,
views and options menus, and it reports the move through setOnColumnMoved.

Taskboard: KanbanColumnSettings now owns the column order next to the hidden
set and persists it as "order" in kanban-columns.json; statuses missing from a
saved order (e.g. added later) are appended in their default position. The
kanban model reads statuses through that order instead of the enum, so column
index and status no longer coincide by construction. Status-name parsing moves
next to statusName(): statusNamed() matches current names only (settings),
statusFromName() also accepts the retired server names (sync).
2026-10-26 21:02:54 +03:00

53 lines
1.5 KiB
C++

#pragma once
#include "FileBrowser.hpp"
#include "KanbanBoard.hpp"
#include "TaskBoard.hpp"
#include <string>
#include <vector>
namespace tp::taskboard {
class KanbanColumnSettings {
public:
KanbanColumnSettings(ui::FileSystem& files, const std::string& storageDirectory);
[[nodiscard]] const std::vector<TaskStatus>& order() const { return mOrder; }
void moveColumn(size_t from, size_t to);
[[nodiscard]] const std::vector<TaskStatus>& hidden() const { return mHidden; }
void setVisible(TaskStatus status, bool visible);
[[nodiscard]] const std::string& storagePath() const { return mPath; }
[[nodiscard]] static std::vector<TaskStatus> orderByDefault();
[[nodiscard]] static std::vector<TaskStatus> hiddenByDefault();
private:
void load();
void store();
ui::FileSystem& mFiles;
std::string mPath;
std::vector<TaskStatus> mOrder;
std::vector<TaskStatus> mHidden;
};
class TaskKanbanModel : public ui::KanbanModel {
public:
TaskKanbanModel(const TaskBoard& board, const KanbanColumnSettings& settings) :
mBoard(board),
mSettings(settings) {}
[[nodiscard]] std::vector<ui::KanbanColumn> columns() const;
[[nodiscard]] TaskStatus statusOf(size_t column) const { return mSettings.order()[column]; }
[[nodiscard]] size_t columnOf(TaskStatus status) const;
[[nodiscard]] std::vector<ui::KanbanItemId> items(size_t column) const override;
private:
const TaskBoard& mBoard;
const KanbanColumnSettings& mSettings;
};
void placeMovedCard(TaskBoard& board, const TaskKanbanModel& model, const ui::KanbanMove& move);
}