From c3cd6e8a8aaccf74a8e62d6460a938584be4fc4c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 21 Nov 2012 17:31:18 +0100 Subject: [PATCH] new attempt at the editor --- CMakeLists.txt | 7 +++- apps/opencs/CMakeLists.txt | 44 +++++++++++++++++++++++ apps/opencs/main.cpp | 5 +++ apps/opencs/model/doc/document.cpp | 4 +++ apps/opencs/model/doc/document.hpp | 17 +++++++++ apps/opencs/model/doc/documentmanager.cpp | 37 +++++++++++++++++++ apps/opencs/model/doc/documentmanager.hpp | 31 ++++++++++++++++ 7 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/CMakeLists.txt create mode 100644 apps/opencs/main.cpp create mode 100644 apps/opencs/model/doc/document.cpp create mode 100644 apps/opencs/model/doc/document.hpp create mode 100644 apps/opencs/model/doc/documentmanager.cpp create mode 100644 apps/opencs/model/doc/documentmanager.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 78388e20f..d657de6ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries option(BUILD_ESMTOOL "build ESM inspector" ON) option(BUILD_LAUNCHER "build Launcher" ON) option(BUILD_MWINIIMPORTER "build MWiniImporter" ON) +option(BUILD_OPENCS "build OpenMW Construction Set" ON) option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF) option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest ang GMock frameworks" OFF) @@ -244,7 +245,7 @@ if (APPLE) else () set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) endif () - + #set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/") configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist @@ -462,6 +463,10 @@ if (BUILD_MWINIIMPORTER) add_subdirectory( apps/mwiniimporter ) endif() +if (BUILD_OPENCS) + add_subdirectory (apps/opencs) +endif() + # UnitTests if (BUILD_UNITTESTS) add_subdirectory( apps/openmw_test_suite ) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt new file mode 100644 index 000000000..d213f68f9 --- /dev/null +++ b/apps/opencs/CMakeLists.txt @@ -0,0 +1,44 @@ + +set (OPENCS_SRC + main.cpp + + model/doc/documentmanager.cpp model/doc/document.cpp + ) + +set (OPENCS_HDR + model/doc/documentmanager.hpp model/doc/document.hpp + ) + +set (OPENCS_US + ) + +set (OPENCS_RES + ) + +source_group (opencs FILES ${OPENCS_SRC} ${OPENCS_HDR}) + +if(WIN32) + set(QT_USE_QTMAIN TRUE) +endif(WIN32) + +find_package(Qt4 COMPONENTS QtCore QtGui QtXml QtXmlPatterns REQUIRED) +include(${QT_USE_FILE}) + +qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) +qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR}) +qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +add_executable(opencs + ${OPENCS_SRC} + ${OPENCS_UI_HDR} + ${OPENCS_MOC_SRC} + ${OPENCS_RES_SRC} +) + +target_link_libraries(opencs + ${Boost_LIBRARIES} + ${QT_LIBRARIES} + components +) \ No newline at end of file diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp new file mode 100644 index 000000000..cd443603b --- /dev/null +++ b/apps/opencs/main.cpp @@ -0,0 +1,5 @@ + +int main(int argc, char *argv[]) +{ + +} \ No newline at end of file diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp new file mode 100644 index 000000000..7154c484b --- /dev/null +++ b/apps/opencs/model/doc/document.cpp @@ -0,0 +1,4 @@ + +#include "document.hpp" + +CSMDoc::Document::Document() {} \ No newline at end of file diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp new file mode 100644 index 000000000..7badf8fd7 --- /dev/null +++ b/apps/opencs/model/doc/document.hpp @@ -0,0 +1,17 @@ +#ifndef CSM_DOCUMENT_H +#define CSM_DOCUMENT_H + +namespace CSMDoc +{ + class Document + { + Document (const Document&); + Document& operator= (const Document&); + + public: + + Document(); + }; +} + +#endif \ No newline at end of file diff --git a/apps/opencs/model/doc/documentmanager.cpp b/apps/opencs/model/doc/documentmanager.cpp new file mode 100644 index 000000000..68595f2d4 --- /dev/null +++ b/apps/opencs/model/doc/documentmanager.cpp @@ -0,0 +1,37 @@ + +#include "documentmanager.hpp" + +#include +#include + +#include "document.hpp" + +CSMDoc::DocumentManager::DocumentManager() {} + +CSMDoc::DocumentManager::~DocumentManager() +{ + for (std::vector::iterator iter (mDocuments.begin()); iter!=mDocuments.end(); ++iter) + delete *iter; +} + +CSMDoc::Document *CSMDoc::DocumentManager::addDocument() +{ + Document *document = new Document; + + mDocuments.push_back (document); + + return document; +} + +bool CSMDoc::DocumentManager::removeDocument (Document *document) +{ + std::vector::iterator iter = std::find (mDocuments.begin(), mDocuments.end(), document); + + if (iter==mDocuments.end()) + throw std::runtime_error ("removing invalid document"); + + mDocuments.erase (iter); + delete document; + + return mDocuments.empty(); +} \ No newline at end of file diff --git a/apps/opencs/model/doc/documentmanager.hpp b/apps/opencs/model/doc/documentmanager.hpp new file mode 100644 index 000000000..7f0d388bc --- /dev/null +++ b/apps/opencs/model/doc/documentmanager.hpp @@ -0,0 +1,31 @@ +#ifndef CSM_DOCUMENTMGR_H +#define CSM_DOCUMENTMGR_H + +#include + +namespace CSMDoc +{ + class Document; + + class DocumentManager + { + std::vector mDocuments; + + DocumentManager (const DocumentManager&); + DocumentManager& operator= (const DocumentManager&); + + public: + + DocumentManager(); + + ~DocumentManager(); + + Document *addDocument(); + ///< The ownership of the returned document is not transferred to the caller. + + bool removeDocument (Document *document); + ///< \return last document removed? + }; +} + +#endif \ No newline at end of file