Switched to ref handling for undo / red pages

presentation
Andreas Butti 7 years ago
parent ac89fc5388
commit 0726377044
  1. 13
      src/undo/GroupUndoAction.cpp
  2. 5
      src/undo/GroupUndoAction.h
  3. 4
      src/undo/MoveUndoAction.cpp
  4. 2
      src/undo/MoveUndoAction.h
  5. 4
      src/undo/SwapUndoAction.cpp
  6. 2
      src/undo/SwapUndoAction.h
  7. 4
      src/undo/UndoAction.cpp
  8. 2
      src/undo/UndoAction.h
  9. 9
      src/undo/UndoRedoHandler.cpp
  10. 2
      src/undo/UndoRedoHandler.h

@ -26,18 +26,23 @@ void GroupUndoAction::addAction(UndoAction* action)
actions.push_back(action);
}
vector<XojPage*> GroupUndoAction::getPages()
vector<PageRef> GroupUndoAction::getPages()
{
XOJ_CHECK_TYPE(GroupUndoAction);
vector<XojPage*> pages;
vector<PageRef> pages;
for (UndoAction* a : actions)
{
for (XojPage* addPage : a->getPages())
for (PageRef addPage : a->getPages())
{
if (!addPage.isValid())
{
continue;
}
bool pageAlreadyInTheList = false;
for (XojPage* p : pages)
for (PageRef p : pages)
{
if (addPage == p)
{

@ -14,9 +14,6 @@
#include "UndoAction.h"
#include <XournalType.h>
#include <vector>
using std::vector;
class GroupUndoAction : public UndoAction
{
public:
@ -29,7 +26,7 @@ public:
/**
* Get the affected pages
*/
virtual vector<XojPage*> getPages();
virtual vector<PageRef> getPages();
virtual bool undo(Control* control);
virtual bool redo(Control* control);

@ -117,11 +117,11 @@ void MoveUndoAction::repaint()
}
}
vector<XojPage*> MoveUndoAction::getPages()
vector<PageRef> MoveUndoAction::getPages()
{
XOJ_CHECK_TYPE(MoveUndoAction);
vector<XojPage*> pages;
vector<PageRef> pages;
pages.push_back(this->page);
pages.push_back(this->targetPage);
return pages;

@ -27,7 +27,7 @@ public:
public:
virtual bool undo(Control* control);
virtual bool redo(Control* control);
vector<XojPage*> getPages();
vector<PageRef> getPages();
virtual string getText();
private:

@ -71,11 +71,11 @@ void SwapUndoAction::swap(Control* control)
doc->lock();
}
vector<XojPage*> SwapUndoAction::getPages()
vector<PageRef> SwapUndoAction::getPages()
{
XOJ_CHECK_TYPE(SwapUndoAction);
vector<XojPage*> pages;
vector<PageRef> pages;
pages.push_back(this->swappedPage);
pages.push_back(this->otherPage);
return pages;

@ -26,7 +26,7 @@ public:
public:
virtual bool undo(Control* control);
virtual bool redo(Control* control);
vector<XojPage*> getPages();
vector<PageRef> getPages();
virtual string getText();
private:

@ -14,11 +14,11 @@ UndoAction::~UndoAction()
XOJ_RELEASE_TYPE(UndoAction);
}
vector<XojPage*> UndoAction::getPages()
vector<PageRef> UndoAction::getPages()
{
XOJ_CHECK_TYPE(UndoAction);
vector<XojPage*> pages;
vector<PageRef> pages;
pages.push_back(this->page);
return pages;
}

@ -36,7 +36,7 @@ public:
/**
* Get the affected pages
*/
virtual vector<XojPage*> getPages();
virtual vector<PageRef> getPages();
const char* getClassName() const;

@ -295,7 +295,7 @@ string UndoRedoHandler::redoDescription()
return _("Redo");
}
void UndoRedoHandler::fireUpdateUndoRedoButtons(vector<XojPage*> pages)
void UndoRedoHandler::fireUpdateUndoRedoButtons(vector<PageRef> pages)
{
XOJ_CHECK_TYPE(UndoRedoHandler);
@ -304,8 +304,13 @@ void UndoRedoHandler::fireUpdateUndoRedoButtons(vector<XojPage*> pages)
((UndoRedoListener*) l->data)->undoRedoChanged();
}
for (XojPage* page : pages)
for (PageRef page : pages)
{
if (!page.isValid())
{
continue;
}
for (GList* l = this->listener; l != NULL; l = l->next)
{
((UndoRedoListener*) l->data)->undoRedoPageChanged(page);

@ -46,7 +46,7 @@ public:
void clearContents();
void fireUpdateUndoRedoButtons(vector<XojPage*> pages);
void fireUpdateUndoRedoButtons(vector<PageRef> pages);
void addUndoRedoListener(UndoRedoListener* listener);
bool isChanged();

Loading…
Cancel
Save