mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
added undo stack and undo/redo actions
This commit is contained in:
parent
1ddcea1f07
commit
ed3d8b8ca2
4 changed files with 38 additions and 4 deletions
|
@ -2,3 +2,8 @@
|
|||
#include "document.hpp"
|
||||
|
||||
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…
Reference in a new issue