QtNovelUI/WordsIDE/appcore.cpp

111 lines
2.6 KiB
C++

#include "appcore.h"
#include "xmlconfig.h"
#include "storychain_sourceeditor.h"
#include "storyunitsourceedit.h"
#include "storyboardsourceedit.h"
#include "storyvolumesourceedit.h"
#include "DocsManager.h"
#include "mainwindow.h"
#include "sourcecodeeditor.h"
#include <QApplication>
#include <QMessageBox>
#include <QTextStream>
#include <StoryTool.h>
using namespace Core;
using namespace Components;
using namespace Parse::Result;
using namespace MakeTools;
AppCore::AppCore(MainWindow *win, QObject *parent)
: QObject(parent), views_holder(win),
global_config(new Config::XMLConfig(this)),
makes_core(new StoryTool()),
docs_manager(new DocsManager(makes_core, this, win))
{
global_config->loadFile(QDir(QApplication::applicationDirPath()).filePath(".software.xml"));
extensions_list << new StorychainSourceEdit()
//<< new StoryUnitSourceEditFactory
//<< new StoryBoardSourceEditFactory()
//<< new StoryVolumeSourceEditFactory()
<< new DefaultTextPresent();
//<< new SourceCodeEditorFactory();
}
void AppCore::save()
{
global_config->save();
}
Config::Configration *AppCore::globalConfig() const
{
return global_config;
}
void AppCore::setCurrentProject(Project::ProjectManager *project)
{
this->current_project = project;
}
Project::ProjectManager *AppCore::currentProject() const
{
return this->current_project;
}
QList<Config::Configration *> AppCore::getConfigs(QList<Scale> types) const
{
QList<Config::Configration*> rets;
for(auto &x : types){
if(x == Scale::Global)
rets << global_config;
if(x == Scale::Project && current_project->isOpen())
rets << current_project->configraions();
}
return rets;
}
Parse::Result::ParseCore *AppCore::parseCore() const
{
return makes_core->getCore();
}
QList<ContentPresent *> AppCore::extensions(const QString &suffix) const
{
if(suffix.isEmpty())
return this->extensions_list;
QList<ContentPresent*> rets;
for(auto &ext : extensions_list)
if(ext->suffixes().contains(suffix))
rets << ext;
for(auto &ext : extensions_list)
if(ext->suffixes().contains("*"))
rets << ext;
return rets;
}
MakeTools::StoryTool *AppCore::getMakeCore() const
{
return makes_core;
}
MakeTools::DocsManager *AppCore::getDocsManager() const
{
return docs_manager;
}
SimpleException::SimpleException(const QString &msg)
: msg_store(msg) {}
const char *SimpleException::what() const{
return msg_store.toLocal8Bit();
}