global: made every user action set a project "modified" state that will prevent
the main window from closing instantly
This commit is contained in:
@@ -490,7 +490,7 @@ ProjectViewModel::MoveItemCommand::MoveItemCommand(ProjectViewModel *model,
|
||||
Item *item,
|
||||
Folder *destination,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
model_(model),
|
||||
item_(item),
|
||||
destination_(destination)
|
||||
@@ -500,18 +500,18 @@ ProjectViewModel::MoveItemCommand::MoveItemCommand(ProjectViewModel *model,
|
||||
setText(tr("Move Item"));
|
||||
}
|
||||
|
||||
void ProjectViewModel::MoveItemCommand::redo()
|
||||
void ProjectViewModel::MoveItemCommand::redo_internal()
|
||||
{
|
||||
model_->MoveItemInternal(item_, destination_);
|
||||
}
|
||||
|
||||
void ProjectViewModel::MoveItemCommand::undo()
|
||||
void ProjectViewModel::MoveItemCommand::undo_internal()
|
||||
{
|
||||
model_->MoveItemInternal(item_, source_);
|
||||
}
|
||||
|
||||
ProjectViewModel::RenameItemCommand::RenameItemCommand(ProjectViewModel* model, Item *item, const QString &name, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
model_(model),
|
||||
item_(item),
|
||||
new_name_(name)
|
||||
@@ -521,18 +521,18 @@ ProjectViewModel::RenameItemCommand::RenameItemCommand(ProjectViewModel* model,
|
||||
setText(tr("Rename Item"));
|
||||
}
|
||||
|
||||
void ProjectViewModel::RenameItemCommand::redo()
|
||||
void ProjectViewModel::RenameItemCommand::redo_internal()
|
||||
{
|
||||
model_->RenameChild(item_, new_name_);
|
||||
}
|
||||
|
||||
void ProjectViewModel::RenameItemCommand::undo()
|
||||
void ProjectViewModel::RenameItemCommand::undo_internal()
|
||||
{
|
||||
model_->RenameChild(item_, old_name_);
|
||||
}
|
||||
|
||||
ProjectViewModel::AddItemCommand::AddItemCommand(ProjectViewModel* model, Item* folder, ItemPtr child, QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
model_(model),
|
||||
parent_(folder),
|
||||
child_(child),
|
||||
@@ -544,14 +544,14 @@ ProjectViewModel::AddItemCommand::~AddItemCommand()
|
||||
{
|
||||
}
|
||||
|
||||
void ProjectViewModel::AddItemCommand::redo()
|
||||
void ProjectViewModel::AddItemCommand::redo_internal()
|
||||
{
|
||||
model_->AddChild(parent_, child_);
|
||||
|
||||
done_ = true;
|
||||
}
|
||||
|
||||
void ProjectViewModel::AddItemCommand::undo()
|
||||
void ProjectViewModel::AddItemCommand::undo_internal()
|
||||
{
|
||||
model_->RemoveChild(parent_, child_.get());
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#define VIEWMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "project.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
/**
|
||||
* @brief An adapter that interprets the data in a Project into a Qt item model for usage in ViewModel Views.
|
||||
@@ -108,13 +108,14 @@ public:
|
||||
/**
|
||||
* @brief A QUndoCommand for moving an item from one folder to another folder
|
||||
*/
|
||||
class MoveItemCommand : public QUndoCommand {
|
||||
class MoveItemCommand : public UndoCommand {
|
||||
public:
|
||||
MoveItemCommand(ProjectViewModel* model, Item* item, Folder* destination, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ProjectViewModel* model_;
|
||||
@@ -127,13 +128,14 @@ public:
|
||||
/**
|
||||
* @brief A QUndoCommand for renaming an item
|
||||
*/
|
||||
class RenameItemCommand : public QUndoCommand {
|
||||
class RenameItemCommand : public UndoCommand {
|
||||
public:
|
||||
RenameItemCommand(ProjectViewModel* model, Item* item, const QString& name, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ProjectViewModel* model_;
|
||||
@@ -145,15 +147,16 @@ public:
|
||||
/**
|
||||
* @brief A QUndoCommand for adding an item
|
||||
*/
|
||||
class AddItemCommand : public QUndoCommand {
|
||||
class AddItemCommand : public UndoCommand {
|
||||
public:
|
||||
AddItemCommand(ProjectViewModel* model, Item* folder, ItemPtr child, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual ~AddItemCommand() override;
|
||||
|
||||
virtual void redo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ProjectViewModel* model_;
|
||||
|
||||
Reference in New Issue
Block a user