mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 09:36:43 +00:00
added new document function
This commit is contained in:
parent
997386d873
commit
303506d24b
10 changed files with 57 additions and 12 deletions
|
@ -1,20 +1,28 @@
|
||||||
|
|
||||||
#include "editor.hpp"
|
#include "editor.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
|
|
||||||
CS::Editor::Editor() : mViewManager (mDocumentManager)
|
CS::Editor::Editor() : mViewManager (mDocumentManager), mNewDocumentIndex (0)
|
||||||
{
|
{
|
||||||
|
connect (&mViewManager, SIGNAL (newDocumentRequest ()), this, SLOT (createDocument ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CS::Editor::createDocument()
|
void CS::Editor::createDocument()
|
||||||
{
|
{
|
||||||
CSMDoc::Document *document = mDocumentManager.addDocument();
|
std::ostringstream stream;
|
||||||
|
|
||||||
|
stream << "NewDocument" << (++mNewDocumentIndex);
|
||||||
|
|
||||||
|
CSMDoc::Document *document = mDocumentManager.addDocument (stream.str());
|
||||||
mViewManager.addView (document);
|
mViewManager.addView (document);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CS::Editor::run()
|
int CS::Editor::run()
|
||||||
{
|
{
|
||||||
|
/// \todo Instead of creating an empty document, open a small welcome dialogue window with buttons for new/load/recent projects
|
||||||
createDocument();
|
createDocument();
|
||||||
|
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
#ifndef CS_EDITOR_H
|
#ifndef CS_EDITOR_H
|
||||||
#define CS_EDITOR_H
|
#define CS_EDITOR_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
#include "model/doc/documentmanager.hpp"
|
#include "model/doc/documentmanager.hpp"
|
||||||
#include "view/doc/viewmanager.hpp"
|
#include "view/doc/viewmanager.hpp"
|
||||||
|
|
||||||
namespace CS
|
namespace CS
|
||||||
{
|
{
|
||||||
class Editor
|
class Editor : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
int mNewDocumentIndex; ///< \todo remove when the proper new document dialogue is implemented.
|
||||||
|
|
||||||
CSMDoc::DocumentManager mDocumentManager;
|
CSMDoc::DocumentManager mDocumentManager;
|
||||||
CSVDoc::ViewManager mViewManager;
|
CSVDoc::ViewManager mViewManager;
|
||||||
|
|
||||||
|
@ -19,10 +25,12 @@ namespace CS
|
||||||
|
|
||||||
Editor();
|
Editor();
|
||||||
|
|
||||||
void createDocument();
|
|
||||||
|
|
||||||
int run();
|
int run();
|
||||||
///< \return error status
|
///< \return error status
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void createDocument();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::Document::Document()
|
CSMDoc::Document::Document (const std::string& name)
|
||||||
{
|
{
|
||||||
|
mName = name; ///< \todo replace with ESX list
|
||||||
|
|
||||||
connect (&mUndoStack, SIGNAL (cleanChanged (bool)), this, SLOT (modificationStateChanged (bool)));
|
connect (&mUndoStack, SIGNAL (cleanChanged (bool)), this, SLOT (modificationStateChanged (bool)));
|
||||||
|
|
||||||
// dummy implementation -> remove when proper save is implemented.
|
// dummy implementation -> remove when proper save is implemented.
|
||||||
|
@ -35,6 +37,11 @@ int CSMDoc::Document::getState() const
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& CSMDoc::Document::getName() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::save()
|
void CSMDoc::Document::save()
|
||||||
{
|
{
|
||||||
mSaveCount = 1;
|
mSaveCount = 1;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef CSM_DOC_DOCUMENT_H
|
#ifndef CSM_DOC_DOCUMENT_H
|
||||||
#define CSM_DOC_DOCUMENT_H
|
#define CSM_DOC_DOCUMENT_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@ -21,6 +23,7 @@ namespace CSMDoc
|
||||||
State_Verifying = 8
|
State_Verifying = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string mName; ///< \todo replace name with ESX list
|
||||||
QUndoStack mUndoStack;
|
QUndoStack mUndoStack;
|
||||||
|
|
||||||
int mSaveCount; ///< dummy implementation -> remove when proper save is implemented.
|
int mSaveCount; ///< dummy implementation -> remove when proper save is implemented.
|
||||||
|
@ -35,12 +38,16 @@ namespace CSMDoc
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document();
|
Document (const std::string& name);
|
||||||
|
///< \todo replace name with ESX list
|
||||||
|
|
||||||
QUndoStack& getUndoStack();
|
QUndoStack& getUndoStack();
|
||||||
|
|
||||||
int getState() const;
|
int getState() const;
|
||||||
|
|
||||||
|
const std::string& getName() const;
|
||||||
|
///< \todo replace with ESX list
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
void verify();
|
void verify();
|
||||||
|
|
|
@ -14,9 +14,9 @@ CSMDoc::DocumentManager::~DocumentManager()
|
||||||
delete *iter;
|
delete *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document *CSMDoc::DocumentManager::addDocument()
|
CSMDoc::Document *CSMDoc::DocumentManager::addDocument (const std::string& name)
|
||||||
{
|
{
|
||||||
Document *document = new Document;
|
Document *document = new Document (name);
|
||||||
|
|
||||||
mDocuments.push_back (document);
|
mDocuments.push_back (document);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CSM_DOC_DOCUMENTMGR_H
|
#define CSM_DOC_DOCUMENTMGR_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
|
@ -20,7 +21,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
~DocumentManager();
|
~DocumentManager();
|
||||||
|
|
||||||
Document *addDocument();
|
Document *addDocument (const std::string& name);
|
||||||
///< The ownership of the returned document is not transferred to the caller.
|
///< The ownership of the returned document is not transferred to the caller.
|
||||||
|
|
||||||
bool removeDocument (Document *document);
|
bool removeDocument (Document *document);
|
||||||
|
|
|
@ -21,6 +21,10 @@ void CSVDoc::View::setupFileMenu()
|
||||||
{
|
{
|
||||||
QMenu *file = menuBar()->addMenu (tr ("&File"));
|
QMenu *file = menuBar()->addMenu (tr ("&File"));
|
||||||
|
|
||||||
|
QAction *new_ = new QAction (tr ("New"), this);
|
||||||
|
connect (new_, SIGNAL (triggered()), this, SIGNAL (newDocumentRequest()));
|
||||||
|
file->addAction (new_);
|
||||||
|
|
||||||
mSave = new QAction (tr ("&Save"), this);
|
mSave = new QAction (tr ("&Save"), this);
|
||||||
connect (mSave, SIGNAL (triggered()), this, SLOT (save()));
|
connect (mSave, SIGNAL (triggered()), this, SLOT (save()));
|
||||||
file->addAction (mSave);
|
file->addAction (mSave);
|
||||||
|
@ -75,7 +79,7 @@ void CSVDoc::View::updateTitle()
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
||||||
stream << "New Document ";
|
stream << mDocument->getName();
|
||||||
|
|
||||||
if (mDocument->getState() & CSMDoc::Document::State_Modified)
|
if (mDocument->getState() & CSMDoc::Document::State_Modified)
|
||||||
stream << " *";
|
stream << " *";
|
||||||
|
@ -104,7 +108,7 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
|
||||||
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews)
|
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews)
|
||||||
{
|
{
|
||||||
setCentralWidget (new QWidget);
|
setCentralWidget (new QWidget);
|
||||||
resize (200, 200);
|
resize (200, 200); /// \todo get default size from settings and set reasonable minimal size
|
||||||
|
|
||||||
mOperations = new Operations;
|
mOperations = new Operations;
|
||||||
addDockWidget (Qt::BottomDockWidgetArea, mOperations);
|
addDockWidget (Qt::BottomDockWidgetArea, mOperations);
|
||||||
|
|
|
@ -69,6 +69,10 @@ namespace CSVDoc
|
||||||
|
|
||||||
void updateProgress (int current, int max, int type, int threads);
|
void updateProgress (int current, int max, int type, int threads);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void newDocumentRequest();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void newView();
|
void newView();
|
||||||
|
|
|
@ -56,6 +56,8 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
|
||||||
|
|
||||||
view->show();
|
view->show();
|
||||||
|
|
||||||
|
connect (view, SIGNAL (newDocumentRequest ()), this, SIGNAL (newDocumentRequest()));
|
||||||
|
|
||||||
updateIndices();
|
updateIndices();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -42,6 +42,10 @@ namespace CSVDoc
|
||||||
|
|
||||||
bool closeRequest (View *view);
|
bool closeRequest (View *view);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void newDocumentRequest();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void documentStateChanged (int state, CSMDoc::Document *document);
|
void documentStateChanged (int state, CSMDoc::Document *document);
|
||||||
|
|
Loading…
Reference in a new issue