QtNovelUI/WordsIDE/DocsManager.cpp

152 lines
4.1 KiB
C++
Raw Normal View History

2022-12-31 13:05:58 +00:00
#include "DocsManager.h"
#include "mainwindow.h"
#include <QMessageBox>
#include <QTextStream>
#include <QDebug>
2023-02-26 14:44:00 +00:00
#include <QTextCodec>
2022-12-31 13:05:58 +00:00
using namespace MakeTools;
using namespace Core;
2023-03-10 13:01:19 +00:00
//DocsManager::DocsManager(StoryTool *tool, AppCore *host, MainWindow *views)
// : host_core(host), views_holder(views), make_core(tool)
//{
//}
//void DocsManager::saveAll() const
//{
// for(auto &it : sourcecode_map)
// it->saveAs();
// for(auto &it : plaintext_map)
// it->saveAs();
//}
//void DocsManager::closeAll()
//{
// for(auto &it : sourcecode_map.keys())
// closeTextComponent(QFileInfo(it));
// for(auto &it : plaintext_map.keys())
// closeTextComponent(QFileInfo(it));
// host_core->getMakeCore()->getCore()->clear();
//}
//bool DocsManager::activedContains(const QFileInfo &target) const
//{
// for(auto &it : sourcecode_map.keys())
// if(it == target.absoluteFilePath())
// return true;
// for(auto &it : plaintext_map.keys())
// if(it == target.absoluteFilePath())
// return true;
// return false;
//}
//MakeTools::ContentPresent *DocsManager::queryTextComponent(const QWidget *child_view) const
//{
// for(auto ins : sourcecode_map)
// if(ins->widget() == child_view)
// return ins;
// for(auto ins : plaintext_map)
// if(ins->widget() == child_view)
// return ins;
// return nullptr;
//}
//MakeTools::ContentPresent *DocsManager::queryTextComponent(const QFileInfo &target) const
//{
// for(auto &it : sourcecode_map.keys())
// if(it == target.absoluteFilePath())
// return sourcecode_map[it];
// for(auto &it : plaintext_map.keys())
// if(it == target.absoluteFilePath())
// return plaintext_map[it];
// return nullptr;
//}
//void DocsManager::closeTextComponent(const QFileInfo &target)
//{
// auto key = target.absoluteFilePath();
// if(sourcecode_map.contains(key)){
// sourcecode_map[key]->saveAs();
// delete sourcecode_map[key];
// sourcecode_map.remove(key);
// }
// else if(plaintext_map.contains(key)){
// plaintext_map[key]->saveAs();
// delete plaintext_map[key];
// plaintext_map.remove(key);
// }
//}
//void DocsManager::openTextDocument(const QString &src, const QString &name)
//{
// // 获取匹配的处理类型
// auto xfactorys = host_core->extensions(QFileInfo(src).suffix());
// // 如果已经打开
// if(activedContains(src)){
// auto ins = queryTextComponent(QFileInfo(src));
// if(ins == nullptr)
// throw new SimpleException("逻辑错误,不应出现空指针");
// views_holder->contentViewAppend(ins->widget(), name);
// return;
// }
// make_core->compile(QFileInfo(src), name);
// auto tins = xfactorys[0]->newInst();
// tins->applySetting(name, host_core);
// tins->load(QFileInfo(src));
// addPerceptionList(tins);
// views_holder->contentViewAppend(tins->widget(), name);
//}
//void DocsManager::addPerceptionList(ContentPresent *ins, SensitiveType type)
//{
// auto cins = dynamic_cast<CompileFeature*>(ins);
// if(type == SensitiveType::CompileAtChanged && cins != nullptr){
// connect(cins, &CompileFeature::dataChanged, [ins, this](const QString &path){
// this->recompile(path, ins->name());
// });
// this->sourcecode_map[ins->absoluteTargetPath()] = ins;
// }
// else{
// this->plaintext_map[ins->absoluteTargetPath()] = ins;
// }
//}
//void DocsManager::addProcTrigger(std::function<void ()> exc)
//{
// this->trigger_list << exc;
//}
//void DocsManager::recompile(const QString &file_path, const QString &doc_name)
//{
// if(!sourcecode_map.contains(file_path))
// return;
// auto view = this->sourcecode_map[file_path];
// auto cins = dynamic_cast<CompileFeature*>(view);
// make_core->compileSource(QFileInfo(file_path), cins->getText(), doc_name);
// for(auto &ex : trigger_list)
// ex();
//}
2022-12-31 13:05:58 +00:00
CompileFeature::CompileFeature(QObject *parent)
2023-02-26 14:44:00 +00:00
: QObject(parent)
2022-12-31 13:05:58 +00:00
{
}