QtNovelUI/WordsIDE/appcore.cpp

140 lines
3.2 KiB
C++
Raw Normal View History

2022-11-18 23:47:32 +00:00
#include "appcore.h"
#include "xmlconfig.h"
#include "srcedit_storychain.h"
#include "srcedit_storyunit.h"
#include "srcedit_storyboard.h"
#include "srcedit_storyvolume.h"
2022-12-31 13:05:58 +00:00
#include "DocsManager.h"
#include "mainwindow.h"
#include "srcedit_storyconcept.h"
#include <QApplication>
#include <QMessageBox>
#include <QTextStream>
#include <StoryTool.h>
2022-11-18 23:47:32 +00:00
using namespace Core;
using namespace Components;
using namespace Parse::Result;
using namespace MakeTools;
2023-03-11 05:55:16 +00:00
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"));
auto ins0 = new StorychainSourceEdit();
auto ins1 = new StoryunitSourceEdit();
auto ins2 = new StoryboardSourceEdit();
auto ins3 = new StoryvolumeSourceEdit();
auto ins4 = new StoryconceptSourceEdit();
registerHighlightType(ins0);
registerHighlightType(ins1);
registerHighlightType(ins2);
registerHighlightType(ins3);
registerHighlightType(ins4);
present_types << ins0 << ins1 << ins2 << ins3 << ins4
2023-02-26 14:44:00 +00:00
<< new DefaultTextPresent();
}
2023-03-01 14:19:13 +00:00
void AppCore::registerHighlightType(Enhancement::HighlightFeature *base_type)
{
render_types << base_type;
}
bool AppCore::isHighlightDemand(void *ins) const
{
2023-03-01 14:19:13 +00:00
return render_types.contains((Enhancement::HighlightFeature*)ins);
}
QList<ContentPresent *> AppCore::allViews() const
{
return present_types;
}
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;
}
2022-11-18 23:47:32 +00:00
QList<Config::Configration *> AppCore::getConfigs(QList<Scale> types) const
2022-11-18 23:47:32 +00:00
{
QList<Config::Configration*> rets;
2022-11-18 23:47:32 +00:00
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
{
2022-12-31 13:05:58 +00:00
return makes_core->getCore();
}
2023-02-26 14:44:00 +00:00
QList<ContentPresent *> AppCore::extensions(const QString &suffix) const
{
if(suffix.isEmpty())
return this->present_types;
2023-02-26 14:44:00 +00:00
QList<ContentPresent*> rets;
for(auto &ext : present_types)
2023-02-26 14:44:00 +00:00
if(ext->suffixes().contains(suffix))
rets << ext;
for(auto &ext : present_types)
2023-02-26 14:44:00 +00:00
if(ext->suffixes().contains("*"))
rets << ext;
return rets;
}
2022-12-31 13:05:58 +00:00
MakeTools::StoryTool *AppCore::getMakeCore() const
{
2022-12-31 13:05:58 +00:00
return makes_core;
}
2023-03-10 13:01:19 +00:00
QString AppCore::name() const
{
2023-03-10 13:01:19 +00:00
return NAME(AppCore);
}
2023-03-10 13:01:19 +00:00
//MakeTools::DocsManager *AppCore::getDocsManager() const
//{
// return docs_manager;
//}
2023-02-26 16:22:44 +00:00
SimpleException::SimpleException(const QString &msg)
: msg_store(msg) {}
const char *SimpleException::what() const{
return msg_store.toLocal8Bit();
}