diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index d213f68f9..d7f113447 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -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 diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp new file mode 100644 index 000000000..0a8a137f6 --- /dev/null +++ b/apps/opencs/editor.cpp @@ -0,0 +1,21 @@ + +#include "editor.hpp" + +#include + +CS::Editor::Editor() +{ +} + +void CS::Editor::createDocument() +{ + CSMDoc::Document *document = mDocumentManager.addDocument(); + mViewManager.addView (document); +} + +int CS::Editor::run() +{ + createDocument(); + + return QApplication::exec(); +} \ No newline at end of file diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp new file mode 100644 index 000000000..6e183b843 --- /dev/null +++ b/apps/opencs/editor.hpp @@ -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 \ No newline at end of file diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index cd443603b..15772eba0 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -1,5 +1,13 @@ +#include "editor.hpp" + +#include + int main(int argc, char *argv[]) { + QApplication mApplication (argc, argv); + + CS::Editor editor; + return editor.run(); } \ No newline at end of file diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 7badf8fd7..e44085962 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -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&); diff --git a/apps/opencs/model/doc/documentmanager.hpp b/apps/opencs/model/doc/documentmanager.hpp index 7f0d388bc..f20f3101d 100644 --- a/apps/opencs/model/doc/documentmanager.hpp +++ b/apps/opencs/model/doc/documentmanager.hpp @@ -1,5 +1,5 @@ -#ifndef CSM_DOCUMENTMGR_H -#define CSM_DOCUMENTMGR_H +#ifndef CSM_DOC_DOCUMENTMGR_H +#define CSM_DOC_DOCUMENTMGR_H #include diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp new file mode 100644 index 000000000..2bad69bad --- /dev/null +++ b/apps/opencs/view/doc/view.cpp @@ -0,0 +1,8 @@ + +#include "view.hpp" + +CSVDoc::View::View (CSMDoc::Document *document) : mDocument (document) +{ + resize (200, 200); + setWindowTitle ("New Document"); +} \ No newline at end of file diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp new file mode 100644 index 000000000..797eef083 --- /dev/null +++ b/apps/opencs/view/doc/view.hpp @@ -0,0 +1,30 @@ +#ifndef CSV_DOC_VIEW_H +#define CSV_DOC_VIEW_H + +#include + +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 \ No newline at end of file diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp new file mode 100644 index 000000000..59b79be47 --- /dev/null +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -0,0 +1,26 @@ + +#include "viewmanager.hpp" + +#include "view.hpp" + +CSVDoc::ViewManager::ViewManager() +{ + +} + +CSVDoc::ViewManager::~ViewManager() +{ + for (std::vector::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; +} \ No newline at end of file diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp new file mode 100644 index 000000000..dc6a07bce --- /dev/null +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -0,0 +1,38 @@ +#ifndef CSV_DOC_VIEWMANAGER_H +#define CSV_DOC_VIEWMANAGER_H + +#include + +namespace CSMDoc +{ + class Document; +} + +namespace CSVDoc +{ + class View; + + class ViewManager + { + std::vector 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 \ No newline at end of file