new attempt at the editor
parent
c8562d8442
commit
c3cd6e8a8a
@ -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
|
||||
)
|
@ -0,0 +1,5 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
|
||||
#include "document.hpp"
|
||||
|
||||
CSMDoc::Document::Document() {}
|
@ -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
|
@ -0,0 +1,37 @@
|
||||
|
||||
#include "documentmanager.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "document.hpp"
|
||||
|
||||
CSMDoc::DocumentManager::DocumentManager() {}
|
||||
|
||||
CSMDoc::DocumentManager::~DocumentManager()
|
||||
{
|
||||
for (std::vector<Document *>::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<Document *>::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();
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
#ifndef CSM_DOCUMENTMGR_H
|
||||
#define CSM_DOCUMENTMGR_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
|
||||
class DocumentManager
|
||||
{
|
||||
std::vector<Document *> 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
|
Loading…
Reference in New Issue