project: implemented the ability to delete items from projects

This commit is contained in:
itsmattkc
2020-03-28 12:33:28 +11:00
parent a2a432a0e8
commit b54388894c
6 changed files with 69 additions and 7 deletions
+19 -5
View File
@@ -475,7 +475,7 @@ void ProjectViewModel::MoveItemInternal(Item *item, Item *destination)
beginMoveRows(item_index.parent(), item_index.row(), item_index.row(), destination_index, destination->child_count());
ItemPtr item_ptr = item->parent()->shared_ptr_from_raw(item);
ItemPtr item_ptr = item->get_shared_ptr();
destination->add_child(item_ptr);
@@ -541,10 +541,6 @@ ProjectViewModel::AddItemCommand::AddItemCommand(ProjectViewModel* model, Item*
{
}
ProjectViewModel::AddItemCommand::~AddItemCommand()
{
}
void ProjectViewModel::AddItemCommand::redo_internal()
{
model_->AddChild(parent_, child_);
@@ -558,3 +554,21 @@ void ProjectViewModel::AddItemCommand::undo_internal()
done_ = false;
}
ProjectViewModel::RemoveItemCommand::RemoveItemCommand(ProjectViewModel *model, ItemPtr item, QUndoCommand *parent) :
UndoCommand(parent),
model_(model),
item_(item)
{
}
void ProjectViewModel::RemoveItemCommand::redo_internal()
{
parent_ = item_->parent();
model_->RemoveChild(parent_, item_.get());
}
void ProjectViewModel::RemoveItemCommand::undo_internal()
{
model_->AddChild(parent_, item_);
}