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"
CSMDoc::Document::Document() {}
CSMDoc::Document::Document() {}
QUndoStack& CSMDoc::Document::getUndoStack()
{
return mUndoStack;
}

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

@ -6,6 +6,8 @@
#include <QCloseEvent>
#include <QMenuBar>
#include "../../model/doc/document.hpp"
#include "viewmanager.hpp"
void CSVDoc::View::closeEvent (QCloseEvent *event)
@ -14,17 +16,34 @@ void CSVDoc::View::closeEvent (QCloseEvent *event)
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"));
QAction *newWindow = new QAction (tr ("&New View"), this);
connect (newWindow, SIGNAL (triggered()), this, SLOT (newView()));
view->addAction (newWindow);
}
void CSVDoc::View::setupUi()
{
setupEditMenu();
setupViewMenu();
}
void CSVDoc::View::updateTitle()
{
std::ostringstream stream;

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

Loading…
Cancel
Save