added undo stack and undo/redo actions

pull/16/head
Marc Zinnschlag 12 years ago
parent 1ddcea1f07
commit ed3d8b8ca2

@ -1,4 +1,9 @@
#include "document.hpp" #include "document.hpp"
CSMDoc::Document::Document() {} CSMDoc::Document::Document() {}
QUndoStack& CSMDoc::Document::getUndoStack()
{
return mUndoStack;
}

@ -1,10 +1,14 @@
#ifndef CSM_DOC_DOCUMENT_H #ifndef CSM_DOC_DOCUMENT_H
#define CSM_DOC_DOCUMENT_H #define CSM_DOC_DOCUMENT_H
#include <QUndoStack>
namespace CSMDoc namespace CSMDoc
{ {
class Document class Document
{ {
QUndoStack mUndoStack;
// not implemented // not implemented
Document (const Document&); Document (const Document&);
Document& operator= (const Document&); Document& operator= (const Document&);
@ -12,6 +16,8 @@ namespace CSMDoc
public: public:
Document(); Document();
QUndoStack& getUndoStack();
}; };
} }

@ -6,6 +6,8 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QMenuBar> #include <QMenuBar>
#include "../../model/doc/document.hpp"
#include "viewmanager.hpp" #include "viewmanager.hpp"
void CSVDoc::View::closeEvent (QCloseEvent *event) void CSVDoc::View::closeEvent (QCloseEvent *event)
@ -14,17 +16,34 @@ void CSVDoc::View::closeEvent (QCloseEvent *event)
event->ignore(); event->ignore();
} }
void CSVDoc::View::setupUi() void CSVDoc::View::setupEditMenu()
{
QMenu *edit = menuBar()->addMenu (tr ("&Edit"));
QAction *undo = mDocument->getUndoStack().createUndoAction (this, tr("&Undo"));
undo->setShortcuts (QKeySequence::Undo);
edit->addAction (undo);
QAction *redo = mDocument->getUndoStack().createRedoAction (this, tr("&Redo"));
redo->setShortcuts (QKeySequence::Redo);
edit->addAction (redo);
}
void CSVDoc::View::setupViewMenu()
{ {
// view menu
QMenu *view = menuBar()->addMenu (tr ("&View")); QMenu *view = menuBar()->addMenu (tr ("&View"));
QAction *newWindow = new QAction (tr ("&New View"), this); QAction *newWindow = new QAction (tr ("&New View"), this);
connect (newWindow, SIGNAL (triggered()), this, SLOT (newView())); connect (newWindow, SIGNAL (triggered()), this, SLOT (newView()));
view->addAction (newWindow); view->addAction (newWindow);
} }
void CSVDoc::View::setupUi()
{
setupEditMenu();
setupViewMenu();
}
void CSVDoc::View::updateTitle() void CSVDoc::View::updateTitle()
{ {
std::ostringstream stream; std::ostringstream stream;

@ -31,6 +31,10 @@ namespace CSVDoc
void closeEvent (QCloseEvent *event); void closeEvent (QCloseEvent *event);
void setupEditMenu();
void setupViewMenu();
void setupUi(); void setupUi();
void updateTitle(); void updateTitle();

Loading…
Cancel
Save