basic document handling

actorid
Marc Zinnschlag 12 years ago
parent c3cd6e8a8a
commit 9834bb3ad5

@ -1,12 +1,18 @@
set (OPENCS_SRC
main.cpp
main.cpp editor.cpp
model/doc/documentmanager.cpp model/doc/document.cpp
view/doc/viewmanager.cpp view/doc/view.cpp
)
set (OPENCS_HDR
editor.hpp
model/doc/documentmanager.hpp model/doc/document.hpp
view/doc/viewmanager.hpp view/doc/view.hpp
)
set (OPENCS_US

@ -0,0 +1,21 @@
#include "editor.hpp"
#include <QtGui/QApplication>
CS::Editor::Editor()
{
}
void CS::Editor::createDocument()
{
CSMDoc::Document *document = mDocumentManager.addDocument();
mViewManager.addView (document);
}
int CS::Editor::run()
{
createDocument();
return QApplication::exec();
}

@ -0,0 +1,29 @@
#ifndef CS_EDITOR_H
#define CS_EDITOR_H
#include "model/doc/documentmanager.hpp"
#include "view/doc/viewmanager.hpp"
namespace CS
{
class Editor
{
CSMDoc::DocumentManager mDocumentManager;
CSVDoc::ViewManager mViewManager;
// not implemented
Editor (const Editor&);
Editor& operator= (const Editor&);
public:
Editor();
void createDocument();
int run();
///< \return error status
};
}
#endif

@ -1,5 +1,13 @@
#include "editor.hpp"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication mApplication (argc, argv);
CS::Editor editor;
return editor.run();
}

@ -1,10 +1,11 @@
#ifndef CSM_DOCUMENT_H
#define CSM_DOCUMENT_H
#ifndef CSM_DOC_DOCUMENT_H
#define CSM_DOC_DOCUMENT_H
namespace CSMDoc
{
class Document
{
// not implemented
Document (const Document&);
Document& operator= (const Document&);

@ -1,5 +1,5 @@
#ifndef CSM_DOCUMENTMGR_H
#define CSM_DOCUMENTMGR_H
#ifndef CSM_DOC_DOCUMENTMGR_H
#define CSM_DOC_DOCUMENTMGR_H
#include <vector>

@ -0,0 +1,8 @@
#include "view.hpp"
CSVDoc::View::View (CSMDoc::Document *document) : mDocument (document)
{
resize (200, 200);
setWindowTitle ("New Document");
}

@ -0,0 +1,30 @@
#ifndef CSV_DOC_VIEW_H
#define CSV_DOC_VIEW_H
#include <QWidget>
namespace CSMDoc
{
class Document;
}
namespace CSVDoc
{
class View : public QWidget
{
Q_OBJECT
CSMDoc::Document *mDocument;
// not implemented
View (const View&);
View& operator= (const View&);
public:
View (CSMDoc::Document *document);
///< The ownership of \a document is not transferred to *this.
};
}
#endif

@ -0,0 +1,26 @@
#include "viewmanager.hpp"
#include "view.hpp"
CSVDoc::ViewManager::ViewManager()
{
}
CSVDoc::ViewManager::~ViewManager()
{
for (std::vector<View *>::iterator iter (mViews.begin()); iter!=mViews.end(); ++iter)
delete *iter;
}
CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
{
View *view = new View (document);
mViews.push_back (view);
view->show();
return view;
}

@ -0,0 +1,38 @@
#ifndef CSV_DOC_VIEWMANAGER_H
#define CSV_DOC_VIEWMANAGER_H
#include <vector>
namespace CSMDoc
{
class Document;
}
namespace CSVDoc
{
class View;
class ViewManager
{
std::vector<View *> mViews;
// not implemented
ViewManager (const ViewManager&);
ViewManager& operator= (const ViewManager&);
public:
ViewManager();
~ViewManager();
View *addView (CSMDoc::Document *document);
///< The ownership of the returned view is not transferred.
};
}
#endif
Loading…
Cancel
Save