| 1 |
/* This file is part of the KDE project |
| 2 |
* SPDX-FileCopyrightText: 2019 Dag Andersen <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef KPTNAMEDCOMMAND_H |
| 8 |
#define KPTNAMEDCOMMAND_H |
| 9 |
|
| 10 |
#include "plankernel_export.h" |
| 11 |
|
| 12 |
#include <kundo2command.h> |
| 13 |
|
| 14 |
#include <QHash> |
| 15 |
|
| 16 |
|
| 17 |
/// The main namespace |
| 18 |
namespace KPlato |
| 19 |
{ |
| 20 |
|
| 21 |
class Schedule; |
| 22 |
|
| 23 |
class PLANKERNEL_EXPORT NamedCommand : public KUndo2Command |
| 24 |
{ |
| 25 |
public: |
| 26 |
explicit NamedCommand(const KUndo2MagicString& name) |
| 27 |
: KUndo2Command(name) |
| 28 |
{} |
| 29 |
void redo() override { execute(); } |
| 30 |
void undo() override { unexecute(); } |
| 31 |
|
| 32 |
virtual void execute() = 0; |
| 33 |
virtual void unexecute() = 0; |
| 34 |
|
| 35 |
protected: |
| 36 |
/// Set all scheduled in the m_schedules map to their original scheduled state |
| 37 |
void setSchScheduled(); |
| 38 |
/// Set all schedules in the m_schedules map to scheduled state @p state |
| 39 |
void setSchScheduled(bool state); |
| 40 |
/// Add a schedule to the m_schedules map along with its current scheduled state |
| 41 |
void addSchScheduled(Schedule *sch); |
| 42 |
|
| 43 |
QHash<Schedule*, bool> m_schedules; |
| 44 |
|
| 45 |
}; |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
#endif |