Minor code cleanup

presentation
Ulrich Huber 7 years ago
parent 312789b486
commit cd0830d4fa
  1. 28
      src/undo/DeleteUndoAction.cpp
  2. 12
      src/undo/DeleteUndoAction.h

@ -8,7 +8,7 @@
#include <i18n.h>
DeleteUndoAction::DeleteUndoAction(PageRef page, bool eraser)
DeleteUndoAction::DeleteUndoAction(const PageRef& page, bool eraser)
: UndoAction("DeleteUndoAction")
{
XOJ_INIT_TYPE(DeleteUndoAction);
@ -21,9 +21,9 @@ DeleteUndoAction::~DeleteUndoAction()
{
XOJ_CHECK_TYPE(DeleteUndoAction);
for (GList* l = this->elements; l != NULL; l = l->next)
for (GList* l = this->elements; l != nullptr; l = l->next)
{
PageLayerPosEntry<Element>* e = (PageLayerPosEntry<Element>*) l->data;
auto e = (PageLayerPosEntry<Element>*) l->data;
if (!undone)
{
delete e->element;
@ -43,11 +43,11 @@ void DeleteUndoAction::addElement(Layer* layer, Element* e, int pos)
(GCompareFunc) PageLayerPosEntry<Element>::cmp);
}
bool DeleteUndoAction::undo(Control* control)
bool DeleteUndoAction::undo(Control*)
{
XOJ_CHECK_TYPE(DeleteUndoAction);
if (this->elements == NULL)
if (this->elements == nullptr)
{
g_warning("Could not undo DeleteUndoAction, there is nothing to undo");
@ -55,9 +55,9 @@ bool DeleteUndoAction::undo(Control* control)
return false;
}
for (GList* l = this->elements; l != NULL; l = l->next)
for (GList* l = this->elements; l != nullptr; l = l->next)
{
PageLayerPosEntry<Element>* e = (PageLayerPosEntry<Element>*) l->data;
auto e = (PageLayerPosEntry<Element>*) l->data;
e->layer->insertElement(e->element, e->pos);
this->page->fireElementChanged(e->element);
}
@ -66,11 +66,11 @@ bool DeleteUndoAction::undo(Control* control)
return true;
}
bool DeleteUndoAction::redo(Control* control)
bool DeleteUndoAction::redo(Control*)
{
XOJ_CHECK_TYPE(DeleteUndoAction);
if (this->elements == NULL)
if (this->elements == nullptr)
{
g_warning("Could not redo DeleteUndoAction, there is nothing to redo");
@ -78,9 +78,9 @@ bool DeleteUndoAction::redo(Control* control)
return false;
}
for (GList* l = this->elements; l != NULL; l = l->next)
for (GList* l = this->elements; l != nullptr; l = l->next)
{
PageLayerPosEntry<Element>* e = (PageLayerPosEntry<Element>*) l->data;
auto e = (PageLayerPosEntry<Element>*) l->data;
e->layer->removeElement(e->element, false);
this->page->fireElementChanged(e->element);
}
@ -101,13 +101,13 @@ string DeleteUndoAction::getText()
string text = _("Delete");
if (this->elements != NULL)
if (this->elements != nullptr)
{
ElementType type = ((PageLayerPosEntry<Element>*) this->elements->data)->element->getType();
for (GList* l = this->elements->next; l != NULL; l = l->next)
for (GList* l = this->elements->next; l != nullptr; l = l->next)
{
PageLayerPosEntry<Element>* e = (PageLayerPosEntry<Element>*) l->data;
auto e = (PageLayerPosEntry<Element>*) l->data;
if (type != e->element->getType())
{
text += " ";

@ -21,20 +21,20 @@ class Redrawable;
class DeleteUndoAction : public UndoAction
{
public:
DeleteUndoAction(PageRef page, bool eraser);
virtual ~DeleteUndoAction();
DeleteUndoAction(const PageRef& page, bool eraser);
~DeleteUndoAction() override;
public:
virtual bool undo(Control* control);
virtual bool redo(Control* control);
bool undo(Control*) override;
bool redo(Control*) override;
void addElement(Layer* layer, Element* e, int pos);
virtual string getText();
string getText() override;
private:
XOJ_TYPE_ATTRIB;
GList* elements = NULL;
GList* elements = nullptr;
bool eraser = true;
};

Loading…
Cancel
Save