From d2ac84894d421c6fc0e58dbe34371a99caaf529d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=89=E5=AE=87=E6=B8=85=E9=9F=B3?= <2422523675@qq.com> Date: Wed, 16 Aug 2023 21:48:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E9=99=A4=E4=BA=86=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=8C=E5=B0=9A=E4=B8=94=E6=AC=A0=E7=BC=BA?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=9C=BA=E5=88=B6=E5=92=8C=E5=85=B3=E8=81=94?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WordsIDE/WordsIDE.pro | 6 - WordsIDE/command_list.cpp | 236 ++------------------------------------ WordsIDE/command_list.h | 137 ---------------------- WordsIDE/mainwindow.cpp | 231 ++++--------------------------------- WordsIDE/mainwindow.h | 18 +-- WordsIDE/parsebridge.cpp | 8 ++ WordsIDE/parsebridge.h | 1 + WordsIDE/tools.h | 88 -------------- 8 files changed, 44 insertions(+), 681 deletions(-) diff --git a/WordsIDE/WordsIDE.pro b/WordsIDE/WordsIDE.pro index 835c7eb..14ffabe 100644 --- a/WordsIDE/WordsIDE.pro +++ b/WordsIDE/WordsIDE.pro @@ -81,12 +81,6 @@ else:unix: LIBS += -L$$OUT_PWD/../libProjectManager/ -llibProjectManager INCLUDEPATH += $$PWD/../libProjectManager DEPENDPATH += $$PWD/../libProjectManager -win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libParse/release/ -llibParse -else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libParse/debug/ -llibParse -else:unix: LIBS += -L$$OUT_PWD/../libParse/ -llibParse - -INCLUDEPATH += $$PWD/../libParse -DEPENDPATH += $$PWD/../libParse DISTFILES += \ design.md diff --git a/WordsIDE/command_list.cpp b/WordsIDE/command_list.cpp index 793de23..32ac94f 100644 --- a/WordsIDE/command_list.cpp +++ b/WordsIDE/command_list.cpp @@ -130,7 +130,7 @@ void CloseProject::run(Schedule::CommandsDispatcher *core) const { auto vmgr = core->get(NAME(DocumentsManager)); vmgr->save(); - vmgr->close(); + vmgr->closeFile(vmgr->actives()); vmgr->projectManager()->save(); vmgr->projectManager()->closeProject(); } @@ -168,33 +168,6 @@ void NewProject::fromText(const QString &line) name_val = list[1]; } -Build::Build(bool fromdisk) - :all_from_disk(fromdisk) -{ - -} - -QString Build::name() const -{ - return NAME(Build); -} - -void Build::run(Schedule::CommandsDispatcher *core) const -{ - auto vmgr = core->get(NAME(DocumentsManager)); - vmgr->build(all_from_disk); -} - -QString Build::toText() const -{ - return QString("%1").arg(all_from_disk); -} - -void Build::fromText(const QString &line) -{ - all_from_disk = line.toUInt(); -} - OpenFile::OpenFile(const Core::Route &path_node) { path_store = path_node.links(); @@ -214,13 +187,13 @@ void OpenFile::run(Schedule::CommandsDispatcher *core) const { auto mgr = core->get(NAME(DocumentsManager)); if(path_store.size()){ - mgr->openFile(Route::collect(path_store)); + mgr->openFile(QList() << Route::collect(path_store)); } else{ - auto index = mgr->projectManager()->queryIndex(final_file); - auto route = mgr->pathOf(index); + auto index = mgr->projectManager()->queryAccess()->queryIndex(final_file); + auto route = mgr->convertPath(index); - mgr->openFile(route); + mgr->openFile(QList() << route); } } @@ -234,204 +207,9 @@ void OpenFile::fromText(const QString &line) path_store = line.split("/"); } - -StorychainJumpTo::StorychainJumpTo(const QList &node_path) -{ - jump_path.append(node_path); -} - -QString StorychainJumpTo::name() const -{ - return NAME(StorychainJumpTo); -} - -void StorychainJumpTo::run(Schedule::CommandsDispatcher *core) const -{ - auto core_ins = core->get(NAME(AppCore)); - auto chain_ins = core_ins->parseCore()->queryStoryChain(jump_path[0]).first(); - - auto vmgr = core->get(NAME(DocumentsManager)); - auto index = vmgr->projectManager()->queryIndex(chain_ins->doc()->filePath()); - auto route = vmgr->pathOf(index); - - vmgr->openFile(route); - vmgr->activePresentOf(route)->jumpTo(jump_path); -} - -QString StorychainJumpTo::toText() const -{ - return jump_path.join("/"); -} - -void StorychainJumpTo::fromText(const QString &line) -{ - jump_path=line.split("/"); -} - -#include "storyboardspresent.h" -#include "storychainspresent.h" -#include "storyunitspresent.h" using namespace Components; using namespace DataModel; -StorychainDetailShow::StorychainDetailShow(const QList &chain_path) - : chain_path(chain_path) -{ - -} - -QString StorychainDetailShow::name() const -{ - return NAME(StorychainDetailShow); -} - -void StorychainDetailShow::run(Schedule::CommandsDispatcher *core) const -{ - auto backend = core->get(NAME(StorychainsPresentModel)); - backend->showDetails(chain_path); -} - -QString StorychainDetailShow::toText() const -{ - return chain_path.join("/"); -} - -void StorychainDetailShow::fromText(const QString &line) -{ - chain_path = line.split("/"); -} - -StoryunitDetailShow::StoryunitDetailShow(const QList &path) { - unit_nav.append(path); -} - -QString StoryunitDetailShow::name() const { return NAME(StoryunitDetailShow); } - -void StoryunitDetailShow::run(Schedule::CommandsDispatcher *core) const { - auto backend = - core->get(NAME(StoryunitsPresentModel)); - backend->details_show(unit_nav); -} - -QString StoryunitDetailShow::toText() const { return unit_nav.join("/"); } - -void StoryunitDetailShow::fromText(const QString &line) { - unit_nav = line.split("/"); -} - -StoryunitJumpTo::StoryunitJumpTo(const QList &path) { - unit_nav = path; -} - -QString StoryunitJumpTo::name() const { return NAME(StoryunitJumpTo); } - -void StoryunitJumpTo::run(Schedule::CommandsDispatcher *core) const { - auto core_ins = core->get(NAME(AppCore)); - auto vmgr = core->get(NAME(DocumentsManager)); - - auto unit_ins = core_ins->parseCore()->queryStoryUnit(unit_nav[0]).first(); - auto index = - vmgr->projectManager()->queryIndex(unit_ins->doc()->filePath()); - auto pjt_path = vmgr->converter(index); - vmgr->openFile(pjt_path); - vmgr->activePresentOf(pjt_path)->jumpTo(unit_nav); -} - -QString StoryunitJumpTo::toText() const { return unit_nav.join("/"); } - -void StoryunitJumpTo::fromText(const QString &line) { - unit_nav = line.split("/"); -} - -#include "storyconceptspresent.h" -StoryconceptDetailShow::StoryconceptDetailShow(const QList &path) { - navi_path.append(path); -} - -QString StoryconceptDetailShow::name() const { - return NAME(StoryconceptDetailShow); -} - -void StoryconceptDetailShow::run(Schedule::CommandsDispatcher *core) const { - auto vmgr = - core->get(NAME(StoryconceptsPresentModel)); - vmgr->detailsShow(navi_path); -} - -QString StoryconceptDetailShow::toText() const { return navi_path.join("/"); } - -void StoryconceptDetailShow::fromText(const QString &line) { - navi_path = line.split("/"); -} - -StoryconceptJumpTo::StoryconceptJumpTo(const QList &path) { - navi_path.append(path); -} - -QString StoryconceptJumpTo::name() const { return NAME(StoryconceptJumpTo); } - -void StoryconceptJumpTo::run(Schedule::CommandsDispatcher *core) const { - auto core_ins = core->get(NAME(AppCore)); - auto vmgr = core->get(NAME(DocumentsManager)); - - auto cept_ins = - core_ins->parseCore()->queryStoryConcept(navi_path[0]).first(); - auto cept_doc = cept_ins->doc(); - auto idx = vmgr->projectManager()->queryIndex(cept_doc->filePath()); - auto route = vmgr->converter(idx); - vmgr->openFile(route); - vmgr->activePresentOf(route)->jumpTo(navi_path); -} - -QString StoryconceptJumpTo::toText() const { return navi_path.join("/"); } - -void StoryconceptJumpTo::fromText(const QString &line) { - navi_path = line.split("/"); -} - -StoryboardJumpTo::StoryboardJumpTo(const QList &path) { - navi_path.append(path); -} - -QString StoryboardJumpTo::name() const { return NAME(StoryboardJumpTo); } - -void StoryboardJumpTo::run(Schedule::CommandsDispatcher *core) const { - auto core_ins = core->get(NAME(AppCore)); - - auto unit_ins = core_ins->parseCore()->queryStoryUnit(navi_path[0]).first(); - auto unit_doc = unit_ins->doc(); - - auto vmgr = core->get(NAME(DocumentsManager)); - - auto index = vmgr->projectManager()->queryIndex(unit_doc->filePath()); - auto route = vmgr->converter(index); - vmgr->openFile(route); - vmgr->activePresentOf(route)->jumpTo(navi_path); -} - -QString StoryboardJumpTo::toText() const { return navi_path.join("/"); } - -void StoryboardJumpTo::fromText(const QString &line) { navi_path.append(line.split("/")); } - -StoryboardDetailShow::StoryboardDetailShow(const QList &path) { - navi_path.append(path); -} - -QString StoryboardDetailShow::name() const { - return NAME(StoryboardDetailShow); -} - -void StoryboardDetailShow::run(Schedule::CommandsDispatcher *core) const { - auto vm = core->get(NAME(StoryboardsPresentModel)); - vm->detailShow(navi_path); -} - -QString StoryboardDetailShow::toText() const { return navi_path.join("/"); } - -void StoryboardDetailShow::fromText(const QString &line) { - navi_path = line.split("/"); -} - CompVisible::CompVisible(Components::PresentHost *host, PresentBase *target, bool state) : host_ins(host), target_ins(target), state_val(state) { path = Route::collect(QList() << target->name()); } @@ -441,9 +219,9 @@ QString CompVisible::name() const { return QString("/%1[%2]").arg(NAME(CompVisib void CompVisible::run(Schedule::CommandsDispatcher *core) const { target_ins->widget()->setVisible(state_val); if (state_val) { - host_ins->append(target_ins, path); + host_ins->append(target_ins); } else { - host_ins->remove(path); + host_ins->remove(target_ins); } } diff --git a/WordsIDE/command_list.h b/WordsIDE/command_list.h index 8d3c883..3ebe059 100644 --- a/WordsIDE/command_list.h +++ b/WordsIDE/command_list.h @@ -113,143 +113,6 @@ namespace CommandList { virtual void fromText(const QString &line) override; }; - class Build : public Schedule::GeCommand { - public: - Build(bool fromdisk); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - bool all_from_disk; - }; - - // 故事脉络相关命令 ======================================================== - class StorychainDetailShow : public Schedule::GeCommand { - public: - StorychainDetailShow(const QList &chain_path); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - QList chain_path; - }; - class StorychainJumpTo : public Schedule::GeCommand { - public: - StorychainJumpTo(const QList &node_path); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - QList jump_path; - }; - - // 故事单元相关命令 ====================================================== - class StoryunitDetailShow : public Schedule::GeCommand { - public: - StoryunitDetailShow(const QList &path); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - QList unit_nav; - }; - - class StoryunitJumpTo : public Schedule::GeCommand { - public: - StoryunitJumpTo(const QList &path); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - QList unit_nav; - }; - - // 故事概念相关命令=================================================== - class StoryconceptDetailShow : public Schedule::GeCommand { - public: - StoryconceptDetailShow(const QList &path); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - QList navi_path; - }; - - class StoryconceptJumpTo : public Schedule::GeCommand { - public: - StoryconceptJumpTo(const QList &path); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - QList navi_path; - }; - - class StoryboardDetailShow : public Schedule::GeCommand { - public: - StoryboardDetailShow(const QList &path); - - private: - QList navi_path; - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - }; - - class StoryboardJumpTo : public Schedule::GeCommand { - public: - StoryboardJumpTo(const QList &path); - - // GeCommand interface - public: - virtual QString name() const override; - virtual void run(Schedule::CommandsDispatcher *core) const override; - virtual QString toText() const override; - virtual void fromText(const QString &line) override; - - private: - QList navi_path; - }; - // 切换视图组件 ================================================================ class CompVisible : public Schedule::GeCommand { public: diff --git a/WordsIDE/mainwindow.cpp b/WordsIDE/mainwindow.cpp index ba3e4a7..4258d75 100644 --- a/WordsIDE/mainwindow.cpp +++ b/WordsIDE/mainwindow.cpp @@ -28,59 +28,49 @@ using namespace Core; using namespace Tools; using namespace CommandList; using namespace DataModel; +using namespace bridge; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), - app_core(new AppCore(this)), sync_kernel(new StatusSyncCore(this)), + parse_service(new ParseBridge()), split_first(new QSplitter(Qt::Horizontal, this)), split_second(new QSplitter(Qt::Vertical, this)), split_third(new QSplitter(Qt::Horizontal, this)), project_manager(new XMLProjectManager(this)), + center_frame(new PresentContainer(QTabWidget::North, this)), + messages_frame(new QTabWidget(this)), + active_docscollect(new DocumentsManager(project_manager)), welcome_list(new WelcomePanel()), - errors_present(new MessagesPresent(app_core->getMakeCore(), this)), - project_present(new ProjectPresent(XApp::disp_core, docs_container, this)) { + errors_present(new MessagesPresent(parse_service->errorsPresentModel(), this)), + project_present(new ProjectPresent(XApp::disp_core, active_docscollect, this)) { QApplication::instance()->installEventFilter(this); initial_commandlist(XApp::disp_core); - XApp::disp_core->registerMember(this->app_core); - this->app_core->setCurrentProject(project_manager); - XApp::disp_core->registerMember(docs_container); - XApp::disp_core->registerMember(fragments_model); - XApp::disp_core->registerMember(boards_model); - XApp::disp_core->registerMember(chains_model); - XApp::disp_core->registerMember(concepts_model); - XApp::disp_core->registerMember(units_model); + XApp::disp_core->registerMember(active_docscollect); setMinimumSize(1000, 600); setWindowTitle("提线木偶"); project_present->widget()->setVisible(false); - chains_view->setVisible(false); - units_view->setVisible(false); errors_present->setVisible(false); - boards_view->setVisible(false); - concept_view->setVisible(false); - fragments_order->setVisible(false); auto mbar = menuBar(); initial_menubar(mbar); setCentralWidget(this->split_first); - this->split_first->addWidget(left_funcs->hostWidget()); + this->split_first->addWidget(project_present); this->split_first->addWidget(this->split_second); this->split_second->addWidget(this->split_third); - this->split_second->addWidget(this->bottom_funcs->hostWidget()); + this->split_second->addWidget(this->errors_present); - this->split_third->addWidget(this->center_funcs->hostWidget()); - this->split_third->addWidget(this->right_funcs->hostWidget()); + this->split_third->addWidget(this->center_frame->hostWidget()); + this->split_third->addWidget(this->messages_frame); + this->messages_frame->setTabPosition(QTabWidget::TabPosition::South); - connect(static_cast(left_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport); - connect(static_cast(right_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport); - connect(static_cast(bottom_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport); - connect(static_cast(center_funcs), &PresentContainer::presentTransTo, this, &MainWindow::accept_view_transport); + this->active_docscollect->setPresent(this); } MainWindow::~MainWindow() {} @@ -95,7 +85,6 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { return; XApp::disp_core->postCommand(OpenProject(file)); - build_internal(true); }); sync_kernel->actionEnableSync(opnp, [this]() -> bool { return !project_manager->isOpenning(); }); @@ -111,11 +100,9 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { }); sync_kernel->actionEnableSync(newp, [this]() -> bool { return !project_manager->isOpenning(); }); - auto clsp = project->addAction("关闭项目", [this]() { - XApp::disp_core->postCommand(CloseProject()); - this->refresh_views(); - }); + auto clsp = project->addAction("关闭项目", [this]() { XApp::disp_core->postCommand(CloseProject()); }); sync_kernel->actionEnableSync(clsp, [this]() -> bool { return project_manager->isOpenning(); }); + project->addSeparator(); auto pnew = project->addAction("新建路径", [this]() { @@ -127,7 +114,7 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { auto _xnew = project->addMenu("新建文件"); _xnew->setEnabled(project_manager->isOpenning()); - auto types = docs_container->fileTypes(); + auto types = active_docscollect->fileTypes(); for (auto &t : types) { _xnew->addAction(t, [this, &t]() { auto name = QInputDialog::getText(this, "输入名称", "名称:"); @@ -138,7 +125,7 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { if (!idx.isValid()) idx = project_manager->model()->item(0)->index(); - auto group_path = docs_container->converter(idx); + auto group_path = active_docscollect->convertPath(idx); XApp::disp_core->postCommand(NewFile(group_path, name, t)); }); } @@ -148,6 +135,7 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { auto sav = project->addAction("保存全部", [this]() { XApp::disp_core->postCommand(SaveAll()); }); sav->setShortcut(QKeySequence::StandardKey::Save); sync_kernel->actionEnableSync(sav, [this]() -> bool { return project_manager->isOpenning(); }); + project->addSeparator(); project->addAction("退出", [this]() { @@ -181,18 +169,6 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { sync_kernel->actionCheckSync(act_status, [xstatus]() -> bool { return xstatus->isVisible(); }); connect(act_status, &QAction::triggered, [xstatus](bool v) { xstatus->setVisible(v); }); - auto act_left = area->addAction("左侧功能区"); - sync_kernel->actionCheckSync(act_left, [this]() -> bool { return this->left_funcs->visibleState(); }); - connect(act_left, &QAction::triggered, [this](bool v) { this->left_funcs->setVisibleState(v); }); - - auto act_right = area->addAction("右侧功能区"); - sync_kernel->actionCheckSync(act_right, [this]() -> bool { return this->right_funcs->visibleState(); }); - connect(act_right, &QAction::triggered, [this](bool v) { this->right_funcs->setVisibleState(v); }); - - auto act_bottom = area->addAction("底部功能区"); - sync_kernel->actionCheckSync(act_bottom, [this]() -> bool { return this->bottom_funcs->visibleState(); }); - connect(act_bottom, &QAction::triggered, [this](bool v) { this->bottom_funcs->setVisibleState(v); }); - view->addSeparator(); auto change = view->addMenu("内容切换"); change->addAction("序列视图"); @@ -207,64 +183,6 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { } func->addAction("引用统计"); func->addAction("脉络分蘖"); - // 编译信息 - { - auto msgs = func->addAction("编译输出", [this](bool v) { - XApp::disp_core->postCommand(CompVisible(this, this->errors_present, true)); - XApp::disp_core->postCommand(Build(false)); - }); - sync_kernel->actionCheckSync(msgs, [this]() -> bool { return bottom_funcs->contains(errors_present); }); - } - // 脉络统计 - { - auto chain_v = func->addAction("脉络统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, this->chains_view, v)); }); - chain_v->setCheckable(true); - sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(chains_view); }, - [chain_v](bool v) { - if (v != chain_v->isChecked()) - chain_v->setChecked(v); - }); - } - // 单元统计 - { - auto unit_v = func->addAction("单元统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, this->units_view, v)); }); - unit_v->setCheckable(true); - sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(units_view); }, - [unit_v](bool v) { - if (v != unit_v->isChecked()) - unit_v->setChecked(v); - }); - } - // 故事统计 - { - auto board_v = func->addAction("故事统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, boards_view, v)); }); - board_v->setCheckable(true); - sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(boards_view); }, - [board_v](bool v) { - if (v != board_v->isChecked()) - board_v->setChecked(v); - }); - } - // 概念统计 - { - auto concept_v = func->addAction("概念统计", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, concept_view, v)); }); - concept_v->setCheckable(true); - sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(concept_view); }, - [concept_v](bool v) { - if (v != concept_v->isChecked()) - concept_v->setChecked(v); - }); - } - // 情节序列 - { - auto fragments_v = func->addAction("情节序列", [this](bool v) { XApp::disp_core->postCommand(CompVisible(this, fragments_order, v)); }); - fragments_v->setCheckable(true); - sync_kernel->registerTrigger([this]() -> bool { return right_funcs->contains(fragments_order); }, - [fragments_v](bool v) { - if (v != fragments_v->isChecked()) - fragments_v->setChecked(v); - }); - } // 工具菜单 auto tool = mbar->addMenu("工具"); @@ -282,8 +200,6 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { exp->addAction("导出WsOutlines"); exp->addSeparator(); exp->addAction("导出TXT内容"); - auto build = tool->addAction("编译", [this]() { this->build_internal(); }); - sync_kernel->actionEnableSync(build, [this]() -> bool { return project_manager->isOpenning(); }); // 窗口菜单 auto window = mbar->addMenu("窗口"); @@ -303,17 +219,11 @@ void MainWindow::initial_menubar(QMenuBar *mbar) { } void MainWindow::initial_commandlist(Schedule::CommandsDispatcher *host) { - host->registerCommand(new Build(true)); host->registerCommand(new CloseProject()); host->registerCommand(new CompVisible(this, welcome_list, true)); host->registerCommand(new CompVisible(this, errors_present, true)); host->registerCommand(new CompVisible(this, project_present, true)); - host->registerCommand(new CompVisible(this, fragments_order, true)); - host->registerCommand(new CompVisible(this, boards_view, true)); - host->registerCommand(new CompVisible(this, chains_view, true)); - host->registerCommand(new CompVisible(this, concept_view, true)); - host->registerCommand(new CompVisible(this, units_view, true)); host->registerCommand(new NewFile(Route(), "", "")); host->registerCommand(new NewPackage("")); @@ -321,113 +231,18 @@ void MainWindow::initial_commandlist(Schedule::CommandsDispatcher *host) { host->registerCommand(new OpenFile(Route())); host->registerCommand(new OpenProject("")); host->registerCommand(new SaveAll()); - host->registerCommand(new StoryboardDetailShow(QList())); - host->registerCommand(new StoryboardJumpTo(QList())); - host->registerCommand(new StorychainDetailShow(QList())); - host->registerCommand(new StorychainJumpTo(QList())); - host->registerCommand(new StoryconceptDetailShow(QList())); - host->registerCommand(new StoryconceptJumpTo(QList())); - host->registerCommand(new StoryunitDetailShow(QList())); - host->registerCommand(new StoryunitJumpTo(QList())); } -void MainWindow::refresh_views() { - errors_present->refresh(); - chains_model->refreshTree(); - units_model->refreshTree(); - boards_model->refresh(); - concepts_model->refreshTree(); - fragments_model->refreshTable(); -} - -void MainWindow::build_internal(bool all_from_disk) { - XApp::disp_core->postCommand(Build(all_from_disk)); - refresh_views(); -} - -void MainWindow::splitter_layout_save(const QList &path_type, const QList &size) { - auto convert = [](QList sizes) -> QStringList { - QStringList size_strs; - for (auto i : sizes) - size_strs << QString("%1").arg(i); - return size_strs; - }; - app_core->globalConfig()->setList(path_type, convert(size)); -} - -#define LEFT_SIDE "left" -#define RIGHT_SIDE "right" -#define BOTTOM_SIDE "bottom" -#define CENTER_SIDE "center" -void MainWindow::append(PresentBase *ins) { - auto cfg = project_manager->configraions(); - auto pos_query = QList() << "unique-record" - << "split-area" - << "index-hash" - << "store-point"; - - auto hash_pos = cfg->getMap(pos_query); - auto unique_key = unique.links().join("/"); - auto pos = hash_pos[unique_key]; - - if (pos == "") { - pos = CENTER_SIDE; - hash_pos[unique_key] = pos; - cfg->setMap(pos_query, hash_pos); - } - - if (pos == LEFT_SIDE) { - left_funcs->append(ins, unique); - } else if (pos == RIGHT_SIDE) { - right_funcs->append(ins, unique); - } else if (pos == BOTTOM_SIDE) { - bottom_funcs->append(ins, unique); - } else if (pos == CENTER_SIDE) { - center_funcs->append(ins, unique); - } -} -void MainWindow::accept_view_transport(const Core::Route &key, Components::GroupType type) { - auto cfg = project_manager->configraions(); - auto pos_query = QList() << "unique-record" - << "split-area" - << "index-hash" - << "store-point"; - - auto hash_pos = cfg->getMap(pos_query); - auto unique_key = key.links().join("/"); - - if (type == GroupType::LEFT) - hash_pos[unique_key] = LEFT_SIDE; - else if (type == GroupType::RIGHT) - hash_pos[unique_key] = RIGHT_SIDE; - else if (type == GroupType::BOTTOM) - hash_pos[unique_key] = BOTTOM_SIDE; - else - hash_pos[unique_key] = CENTER_SIDE; - cfg->setMap(pos_query, hash_pos); - - auto xins = remove(key); - append(xins, key); -} +void MainWindow::append(PresentBase *ins) { this->center_frame->append(ins); } bool MainWindow::active(const PresentBase *ins) { - PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs}; - for (auto &it : array) - it->active(ins); - + center_frame->active(ins); return true; } -void MainWindow::remove(const PresentBase *ins) { - PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs}; - for (auto &it : array) { - auto ins = it->remove(unique); - if (ins) - return ins; - } -} +void MainWindow::remove(const PresentBase *ins) { this->center_frame->remove(ins); } -bool MainWindow::contains(const PresentBase *ins) const { return false; } +bool MainWindow::contains(const PresentBase *ins) const { return this->center_frame->contains(ins); } QWidget *MainWindow::hostWidget() const { return (QWidget *)this; } diff --git a/WordsIDE/mainwindow.h b/WordsIDE/mainwindow.h index 99a4133..256c757 100644 --- a/WordsIDE/mainwindow.h +++ b/WordsIDE/mainwindow.h @@ -4,6 +4,7 @@ #include "DocsManager.h" #include "manager_docs.h" #include "messagespresent.h" +#include "parsebridge.h" #include "presentcontainer.h" #include "projectpresent.h" #include "tools.h" @@ -24,6 +25,7 @@ class MainWindow : public QMainWindow, public Components::PresentHost { private: Tools::StatusSyncCore *const sync_kernel; + bridge::ParseBridge *const parse_service; QSplitter *const split_first; QSplitter *const split_second; QSplitter *const split_third; @@ -31,13 +33,11 @@ private: Project::ProjectManager *const project_manager; // containers ======================================= - Components::PresentHost *const left_funcs; - Components::PresentHost *const right_funcs; - Components::PresentHost *const center_funcs; - Components::PresentHost *const bottom_funcs; + Components::PresentHost *const center_frame; + QTabWidget *const messages_frame; // model ============================================ - DataModel::DocumentsManager *const docs_container; + DataModel::DocumentsManager *const active_docscollect; // view ============================================= Components::WelcomePanel *const welcome_list; @@ -48,14 +48,6 @@ private: void initial_menubar(QMenuBar *mbar); void initial_commandlist(Schedule::CommandsDispatcher *host); - void accept_view_transport(const Core::Route &key, Components::GroupType type); - - void refresh_views(); - - void build_internal(bool all_from_disk = false); - - void splitter_layout_save(const QList &path_type, const QList &size); - // PresentContainer interface public: virtual QWidget *hostWidget() const override; diff --git a/WordsIDE/parsebridge.cpp b/WordsIDE/parsebridge.cpp index 05f6e81..e1c65b6 100644 --- a/WordsIDE/parsebridge.cpp +++ b/WordsIDE/parsebridge.cpp @@ -36,8 +36,12 @@ ParseBridge::~ParseBridge() { QString ParseBridge::novelName() const { return name_store; } +QStandardItemModel *ParseBridge::chainsPresentModel() const { return chains_model; } + QStandardItemModel *ParseBridge::volumesPresentModel() const { return volumes_model; } +QStandardItemModel *ParseBridge::errorsPresentModel() const { return errors_model; } + void bridge::ParseBridge::load(const QString &data_path) { // clear cache this->doc_ins.clear(); @@ -368,6 +372,10 @@ QString StoryfragmentInst::operator[](int index) { } } +StoryfragmentRefer::StoryfragmentRefer(StoryfragmentInst *inst) : ContentNode(""), inst(inst) { + setText(QString("@%1/%2").arg(inst->parent()->text(), inst->text())); +} + QString StoryfragmentRefer::storyRef() const { return this->story; } void StoryfragmentRefer::appointStory(const QString &ref) { this->story = ref; } diff --git a/WordsIDE/parsebridge.h b/WordsIDE/parsebridge.h index d52c6da..072dc5e 100644 --- a/WordsIDE/parsebridge.h +++ b/WordsIDE/parsebridge.h @@ -102,6 +102,7 @@ namespace bridge { QString operator[](int index); private: + StoryfragmentInst *const inst; QString story, fragment; }; diff --git a/WordsIDE/tools.h b/WordsIDE/tools.h index 3bc55a7..0c1d62f 100644 --- a/WordsIDE/tools.h +++ b/WordsIDE/tools.h @@ -40,94 +40,6 @@ namespace Tools { QList alltriggers; }; - template class TreeSyncs { - public: - TreeSyncs( - QStandardItemModel *model_base, - std::function _equal, - std::function sync_proc) - : model_present(model_base), sync_process(sync_proc), - compare_process(_equal) {} - - void presentSync( - std::function(const BaseType &pnode)> items_peak) { - auto default_pdata = BaseType(); - auto datas = items_peak(default_pdata); - - Operate::OpStream( - [this](int &cnt, int idx) -> QStandardItem * { - cnt = model_present->rowCount(); - if (cnt <= 0) - return nullptr; - - return model_present->item(idx); - }) - .filter([&datas, this](QStandardItem *const &it) -> bool { - for (auto &d : datas) - if (compare_process(d, it)) - return false; - return true; - }) - .forEach([this](QStandardItem *const &it) { - model_present->removeRow(it->row()); - }); - - for (auto idx = 0; idx < datas.size(); ++idx) { - if (idx >= model_present->rowCount()) { - auto ins = new QStandardItem(); - ins->setEditable(false); - model_present->appendRow(ins); - } - - auto &data = datas[idx]; - auto item = model_present->item(idx); - sync_process(data, item); - - layer_items_sync(data, item, items_peak); - } - } - - private: - QStandardItemModel *model_present; - std::function sync_process; - std::function - compare_process; - - void layer_items_sync( - const BaseType &data, QStandardItem *pnode, - std::function(const BaseType &pnode)> items_peak) { - auto datas = items_peak(data); - - Operate::OpStream( - [pnode](int &cnt, int idx) -> QStandardItem * { - cnt = pnode->rowCount(); - return pnode->child(idx); - }) - .filter([&datas, this](QStandardItem *const &it) -> bool { - for (auto &d : datas) - if (compare_process(d, it)) - return false; - return true; - }) - .forEach([pnode](QStandardItem *const &it) { - pnode->removeRow(it->row()); - }); - - for (auto idx = 0; idx < datas.size(); ++idx) { - if (idx >= pnode->rowCount()) { - auto ins = new QStandardItem(); - ins->setEditable(false); - pnode->appendRow(ins); - } - - auto &data = datas[idx]; - auto item = pnode->child(idx); - sync_process(data, item); - - layer_items_sync(data, item, items_peak); - } - } - }; } // namespace Tools #endif // COMNTOOLS_H