修改SplitView之前

This commit is contained in:
玉宇清音 2023-12-24 12:49:58 +08:00
parent 44d05e4032
commit 24a1bfa51a
23 changed files with 331 additions and 334 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.15.0, 2023-09-08T22:11:48. -->
<!-- Written by QtCreator 4.15.0, 2023-12-22T22:09:13. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -94,16 +94,16 @@
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.11 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.11 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51211.win64_msvc2017_64_kit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.11 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.11 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51211.win64_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Projects\Cpp\build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Projects\Cpp\build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -140,8 +140,8 @@
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Projects\Cpp\build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Projects\Cpp\build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -180,8 +180,8 @@
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Projects\Cpp\build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Projects\Cpp\build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -304,7 +304,7 @@
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug/u_test</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Debug/u_test</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
@ -377,7 +377,7 @@
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug/WordsIDE</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MinGW_64_bit-Debug/WordsIDE</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
</valuemap>

View File

@ -1,7 +1,6 @@
#ifndef DOCSMANAGER_H
#define DOCSMANAGER_H
#include "appcore.h"
#include "route.h"
#include <QHash>
#include <QObject>

View File

@ -19,7 +19,6 @@ msvc {
SOURCES += \
DocsManager.cpp \
appcore.cpp \
command_list.cpp \
# contentpresenttest.cpp \
# keywordshighlighter.cpp \
@ -33,7 +32,6 @@ SOURCES += \
route.cpp \
srcedit_defaulttext.cpp \
srcedit_storyboard.cpp \
tools.cpp \
viewsession.cpp \
viewstackedbar.cpp \
welcomepanel.cpp \
@ -41,7 +39,6 @@ SOURCES += \
HEADERS += \
DocsManager.h \
appcore.h \
command_list.h \
# contentpresenttest.h \
# keywordshighlighter.h \
@ -54,7 +51,6 @@ HEADERS += \
route.h \
srcedit_defaulttext.h \
srcedit_storyboard.h \
tools.h \
viewsession.h \
viewstackedbar.h \
welcomepanel.h \

View File

@ -1,13 +0,0 @@
#include "appcore.h"
#include "DocsManager.h"
#include "mainwindow.h"
#include "manager_docs.h"
#include "srcedit_storyboard.h"
#include "xapp.h"
#include "xmlconfig.h"
#include <QMessageBox>
#include <QTextStream>
using namespace Core;
using namespace Components;

View File

@ -1,21 +0,0 @@
#ifndef APPCORE_H
#define APPCORE_H
#include <QMenu>
#include <QObject>
#include <commandsdispatcher.h>
#include <libConfig.h>
#include <libProjectManager.h>
namespace Core {
enum class Scale
{
Global,
Project,
File,
};
}
#endif // APPCORE_H

View File

@ -24,7 +24,6 @@
using namespace Project;
using namespace Components;
using namespace Core;
using namespace Tools;
using namespace CommandList;
using namespace bridge;
@ -32,7 +31,6 @@ MainWindow::MainWindow(XApp *core, const QString &layout, QWidget *parent)
: QMainWindow(parent),
layout_name_store(layout),
core_bind(core),
sync_kernel(new StatusSyncCore(this)),
present_host(new SplitFrame::ViewPresent(this)),
session_service(new ViewSession(XApp::gconfig, this)),
actions_stack(new QToolBar(this)),
@ -69,46 +67,48 @@ void MainWindow::resetLayoutName(const QString &name) { layout_name_store = name
void MainWindow::initial_menubar(QMenuBar *mbar) {
// 项目菜单树
auto project = mbar->addMenu("项目");
project = mbar->addMenu("项目");
this->build_project_menu(project);
// 编辑菜单
auto edit = mbar->addMenu("编辑");
edit = mbar->addMenu("编辑");
this->build_edit_menu(edit);
// 视图菜单
auto view = mbar->addMenu("视图");
view = mbar->addMenu("视图");
build_view_menu(view);
// 版本管理
// 工具菜单
auto tool = mbar->addMenu("工具");
tool = mbar->addMenu("工具");
build_tools_menu(tool);
// 窗口菜单
auto window = mbar->addMenu("窗口");
window = mbar->addMenu("窗口");
build_window_menu(window);
// 系统
auto sys = mbar->addMenu("系统");
sys->addAction("软件激活");
sys->addAction("系统信息");
sys->addSeparator();
sys->addAction("关于……");
system = mbar->addMenu("系统");
system_active = system->addAction("软件激活");
system_info = system->addAction("系统信息");
system->addSeparator();
system_about = system->addAction("关于……");
}
auto action_sync = [](bool enable, const QList<QAction*> &same_state){
for(auto &a : same_state)
a->setEnabled(enable);
};
void MainWindow::build_project_menu(QMenu *project) {
auto opnp = project->addAction("打开项目", [this]() {
project_open = project->addAction("打开项目", [this]() {
auto file = QFileDialog::getOpenFileName(this, "打开项目", QString(), "小说项目(*.nsf)");
if (file == "")
return;
XApp::disp_core->postCommand(OpenProject(file));
});
sync_kernel->actionEnableSync(opnp, [this]() -> bool { return !core_bind->pjtManager()->isOpenning(); });
auto newp = project->addAction("新建项目", [this]() {
project_new = project->addAction("新建项目", [this]() {
auto name = QInputDialog::getText(this, "输入项目名称", "项目名称");
if (name == "")
return;
@ -118,25 +118,21 @@ void MainWindow::build_project_menu(QMenu *project) {
XApp::disp_core->postCommand(NewProject(QDir(dir_path), name));
});
sync_kernel->actionEnableSync(newp, [this]() -> bool { return !core_bind->pjtManager()->isOpenning(); });
auto clsp = project->addAction("关闭项目", [this]() { XApp::disp_core->postCommand(CloseProject()); });
sync_kernel->actionEnableSync(clsp, [this]() -> bool { return core_bind->pjtManager()->isOpenning(); });
project_close = project->addAction("关闭项目", []() { XApp::disp_core->postCommand(CloseProject()); });
project->addSeparator();
auto pnew = project->addAction("新建路径", [this]() {
project_newpath = project->addAction("新建路径", [this]() {
auto packages = QInputDialog::getText(this, "输入包路径名称/PackA/PackB/PackC", "包路径:");
if (packages != "")
XApp::disp_core->postCommand(NewPackage(packages));
});
sync_kernel->actionEnableSync(pnew, [this]() -> bool { return core_bind->pjtManager()->isOpenning(); });
auto _xnew = project->addMenu("新建文件");
_xnew->setEnabled(core_bind->pjtManager()->isOpenning());
project_newfile = project->addMenu("新建文件");
auto types = core_bind->docsManager()->fileTypes();
for (auto &t : types) {
_xnew->addAction(t, [this, &t]() {
project_newfile->addAction(t, [this, &t]() {
auto name = QInputDialog::getText(this, "输入名称", "名称:");
if (name == "")
return;
@ -149,55 +145,48 @@ void MainWindow::build_project_menu(QMenu *project) {
XApp::disp_core->postCommand(NewFile(group_path, name, t));
});
}
sync_kernel->widgetEnableSync(_xnew, [this]() -> bool { return core_bind->pjtManager()->isOpenning(); });
project->addSeparator();
auto sav = project->addAction("保存全部", []() { XApp::disp_core->postCommand(SaveAll()); });
sav->setShortcut(QKeySequence::StandardKey::Save);
sync_kernel->actionEnableSync(sav, [this]() -> bool { return core_bind->pjtManager()->isOpenning(); });
project->addSeparator();
project->addAction("退出", []() {
project_save = project->addAction("保存全部", []() { XApp::disp_core->postCommand(SaveAll()); });
project_save->setShortcut(QKeySequence::StandardKey::Save);
project->addSeparator();
software_exit = project->addAction("退出", []() {
XApp::disp_core->postCommand(SaveAll());
QApplication::exit(0);
});
this->hasBeenCLOSE();
}
void MainWindow::build_edit_menu(QMenu *edit) {
edit->addAction("撤销一步");
edit->addAction("重做一步");
edit_undo = edit->addAction("撤销一步");
edit_redo = edit->addAction("重做一步");
edit->addSeparator();
edit->addAction("查找关键词");
edit->addAction("替换关键词");
edit_find = edit->addAction("查找关键词");
edit_replace = edit->addAction("替换关键词");
}
void MainWindow::build_view_menu(QMenu *view) {
auto area = view->addMenu("区域管理");
view_area = view->addMenu("区域管理");
actions_stack->setMovable(false);
addToolBar(Qt::ToolBarArea::TopToolBarArea, actions_stack);
auto act_tool = area->addAction("工具栏");
sync_kernel->actionCheckSync(act_tool, [this]() -> bool { return actions_stack->isVisible(); });
connect(act_tool, &QAction::triggered, [this](bool v) { actions_stack->setVisible(v); });
view_area_toolbar = view_area->addAction("工具栏");
connect(view_area_toolbar, &QAction::triggered, [this](bool v) { actions_stack->setVisible(v); });
auto xstatus = statusBar();
xstatus->setVisible(false);
xstatus->addWidget(new QLabel("文本消息", this));
auto act_status = area->addAction("状态栏");
sync_kernel->actionCheckSync(act_status, [xstatus]() -> bool { return xstatus->isVisible(); });
connect(act_status, &QAction::triggered, [xstatus](bool v) { xstatus->setVisible(v); });
view_area_statusbar = view_area->addAction("状态栏");
view->addSeparator();
auto change = view->addMenu("内容切换");
change->addAction("序列视图");
change->addAction("编辑视图");
view->addSeparator();
auto func = view->addMenu("功能视图");
sync_kernel->widgetEnableSync(func, [this]() { return this->core_bind->pjtManager()->isOpenning(); });
connect(view_area_statusbar, &QAction::triggered, [xstatus](bool v) { xstatus->setVisible(v); });
auto fconfig = view->addAction("视图配置", [this]() {
view_config = view->addAction("视图配置", [this]() {
auto dialog = new QDialog();
auto tabs = new QTabWidget(dialog);
auto layout = new QVBoxLayout(dialog);
@ -205,54 +194,61 @@ void MainWindow::build_view_menu(QMenu *view) {
core_bind->docsManager()->loadViewConfigWidgets(tabs);
dialog->exec();
});
sync_kernel->actionEnableSync(fconfig, [this]() { return this->core_bind->pjtManager()->isOpenning(); });
}
void MainWindow::build_tools_menu(QMenu *tool) {
auto word = tool->addMenu("敏感词检测");
word->addAction("工具配置");
word->addAction("敏感词编辑");
auto vcs = tool->addMenu("版本管理");
vcs->addAction("工具配置");
vcs->addAction("启用");
auto exp = tool->addMenu("导入导出");
exp->addAction("导入WsOutlines");
exp->addSeparator();
exp->addAction("导出TXT大纲");
exp->addAction("导出Web大纲");
exp->addAction("导出WsOutlines");
exp->addSeparator();
exp->addAction("导出TXT内容");
tool_console = tool->addAction("控制台");
tool->addSeparator();
tool_wcheck = tool->addMenu("敏感词检测");
tool_wcheck_setting = tool_wcheck->addAction("工具配置");
tool_wcheck_wordslist = tool_wcheck->addAction("敏感词编辑");
tool_version = tool->addMenu("版本管理");
tool_version_setting = tool_version->addAction("工具配置");
tool_version_enable = tool_version->addAction("启用");
tool_version_commit = tool_version->addAction("提交版本");
tool_version_rollback = tool_version->addAction("版本回滚");
tool_inout = tool->addMenu("导入导出");
tool_inout_outline_in = tool_inout->addAction("导入WsOutlines");
tool_inout->addSeparator();
tool_inout_outline_out = tool_inout->addAction("导出WsOutlines");
tool_inout_outline_webout = tool_inout->addAction("导出Web大纲");
tool_inout->addSeparator();
tool_inout_storytxt_out = tool_inout->addAction("导出TXT故事");
tool_inout_storyepub_out = tool_inout->addAction("导出EQUP故事");
}
QList<QString> layout_peak_path = {"sys-configs", "foreground", "view-layouts"};
void MainWindow::build_window_menu(QMenu *window) {
auto new_window = window->addMenu("新建窗口");
connect(new_window, &QMenu::aboutToShow, [new_window]() {
window_winnew = window->addMenu("新建窗口");
connect(window_winnew, &QMenu::aboutToShow, [this]() {
auto names = XApp::gconfig->getList(layout_peak_path);
if (!names.size()) {
names << "default";
XApp::gconfig->setList(layout_peak_path, names);
}
new_window->clear();
window_winnew->clear();
for (auto &n : names)
new_window->addAction(n);
window_winnew->addAction(n);
});
connect(new_window, &QMenu::triggered, [this](QAction *s) {
connect(window_winnew, &QMenu::triggered, [this](QAction *s) {
auto layout = s->text();
auto newone = new MainWindow(this->core_bind, layout);
newone->show();
});
window->addAction("关闭窗口", [this]() {
window_winclose = window->addAction("关闭窗口", [this]() {
XApp::disp_core->postCommand(SaveAll());
this->close();
});
window->addSeparator();
window->addAction("保存当前布局", [this]() {
window_layout_store = window->addAction("保存当前布局", [this]() {
auto new_name = QInputDialog::getText(this, "输入新布局名称", "名称:");
if (new_name.isEmpty())
return;
@ -269,8 +265,8 @@ void MainWindow::build_window_menu(QMenu *window) {
session_service->viewStatesSave(this, this->present_host);
});
window->addMenu("布局切换");
window->addMenu("布局删除");
window_layout_load = window->addMenu("布局切换");
window_layout_del = window->addMenu("布局删除");
}
void MainWindow::closeEvent(QCloseEvent *event) {
@ -293,10 +289,43 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) {
case QEvent::Type::MouseMove:
case QEvent::Type::KeyPress:
case QEvent::Type::KeyRelease:
sync_kernel->sync();
break;
default:
break;
}
return QMainWindow::eventFilter(watched, event);
}
void MainWindow::ProjectNEW(const QString &) {}
void MainWindow::ProjectOPEN(const QString &project_file) {
action_sync(false, {project_new, project_open});
action_sync(true, {project_close, project_newpath, project_save});
project_newfile->setEnabled(true);
this->setWindowTitle(QString("WordIDE::%1 - %2").arg(this->core_bind->pjtManager()->name()).arg(project_file));
}
void MainWindow::hasBeenSAVE() {}
void MainWindow::hasBeenCLOSE() {
action_sync(true, {project_open, project_new});
action_sync(false, {project_close, project_newpath, project_save});
project_newfile->setEnabled(false);
this->setWindowTitle("WordIDE");
}
void MainWindow::hasBeenRENAME(const QModelIndex &path, const QString &new_name) {}
void MainWindow::hasBeenAPPEND(const QModelIndex &new_path) {}
void MainWindow::hasBeenMOVE(const QModelIndex &new_path) {}
void MainWindow::aboutToBeSAVE() {}
void MainWindow::aboutToBeCLOSE() {}
void MainWindow::aboutToBeDELETE(const QModelIndex &path) {}
void MainWindow::aboutToBeMOVE(const QModelIndex &old_path) {}

View File

@ -7,7 +7,6 @@
#include "parsebridge.h"
#include "presentcontainerview.h"
#include "projectview.h"
#include "tools.h"
#include "viewsession.h"
#include "viewstackedbar.h"
#include "welcomepanel.h"
@ -20,7 +19,7 @@
#include <libProjectManager.h>
#include <splitpanel.h>
class MainWindow : public QMainWindow {
class MainWindow : public QMainWindow , public Project::ManagerListener{
Q_OBJECT
public:
@ -35,7 +34,6 @@ private:
QString layout_name_store;
// model ============================================
XApp *const core_bind;
Tools::StatusSyncCore *const sync_kernel;
SplitFrame::ViewPresent *const present_host;
Core::ViewSession *const session_service;
@ -45,6 +43,57 @@ private:
Components::PresentContainerView *const center_frame;
Components::ProjectView *const project_present;
// menu =============================================
QMenu *project;
QAction *project_open;
QAction *project_new;
QAction *project_close;
QAction *project_newpath;
QMenu *project_newfile;
QAction *project_save;
QAction *software_exit;
QMenu *edit;
QAction *edit_undo;
QAction *edit_redo;
QAction *edit_find;
QAction *edit_replace;
QMenu *view;
QMenu *view_area;
QAction *view_area_toolbar;
QAction *view_area_statusbar;
QAction *view_config;
QMenu *tool;
QAction *tool_console;
QMenu *tool_wcheck;
QAction *tool_wcheck_setting;
QAction *tool_wcheck_wordslist;
QMenu *tool_version;
QAction *tool_version_enable;
QAction *tool_version_setting;
QAction *tool_version_commit;
QAction *tool_version_rollback;
QMenu *tool_inout;
QAction *tool_inout_outline_in;
QAction *tool_inout_outline_out;
QAction *tool_inout_outline_webout;
QAction *tool_inout_storytxt_out;
QAction *tool_inout_storyepub_out;
QMenu *window;
QMenu *window_winnew;
QAction *window_winclose;
QAction *window_layout_store;
QMenu *window_layout_load;
QMenu *window_layout_del;
QMenu *system;
QAction *system_active;
QAction *system_info;
QAction *system_about;
// 内部逻辑 ===========================================
void initial_menubar(QMenuBar *mbar);
@ -61,5 +110,19 @@ protected:
// QObject interface
public:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
// Project::ManagerListener interface
public:
virtual void ProjectNEW(const QString &project_file) override;
virtual void ProjectOPEN(const QString &project_file) override;
virtual void hasBeenSAVE() override;
virtual void hasBeenCLOSE() override;
virtual void hasBeenRENAME(const QModelIndex &path, const QString &new_name) override;
virtual void hasBeenAPPEND(const QModelIndex &new_path) override;
virtual void hasBeenMOVE(const QModelIndex &new_path) override;
virtual void aboutToBeSAVE() override;
virtual void aboutToBeCLOSE() override;
virtual void aboutToBeDELETE(const QModelIndex &path) override;
virtual void aboutToBeMOVE(const QModelIndex &old_path) override;
};
#endif // MAINWINDOW_H

View File

@ -2,6 +2,7 @@
#define PRESENTCONTAINERVIEW_H
#include "manager_docs.h"
#include <QComboBox>
#include <QPushButton>
#include <QStackedLayout>
#include <QStackedWidget>

View File

@ -10,6 +10,20 @@
#include <QTextStream>
#include <libConfig.h>
class GenException : public std::exception{
private:
QString exception_reason;
public:
GenException(const QString &msg):exception_reason(msg){}
// exception interface
public:
virtual const char *what() const noexcept override{
return exception_reason.toLocal8Bit();
}
};
using namespace Presents;
using namespace Enhancement;
using namespace Core;
@ -62,7 +76,7 @@ void DefaultTextEdit::saveAs(const QString &path)
QFile bout(target_file_path);
if(!bout.open(QIODevice::WriteOnly|QIODevice::Text))
throw new std::exception(QString("指定文件无法打开:%1").arg(target_file_path).toLocal8Bit());
throw new GenException(QString("指定文件无法打开:%1").arg(target_file_path).toLocal8Bit());
QTextStream tout(&bout);
tout.setCodec("UTF-8");

View File

@ -1,63 +0,0 @@
#include "tools.h"
#include <QWidget>
#include <QAction>
using namespace Tools;
Run::Run(bool manual_flag, std::function<bool ()> judge, std::function<void (bool)> execution)
: manual(manual_flag), judgement(judge), execution(execution){}
void Run::exec()
{
if(!manual)
execution(judgement());
}
StatusSyncCore::StatusSyncCore(QObject *p)
: QObject(p){}
void StatusSyncCore::widgetEnableSync(QWidget *tar, std::function<bool()> proc) { widget_trigger_map[tar] = proc; }
void StatusSyncCore::actionEnableSync(QAction *tar, std::function<bool()> proc) { action_trigger_map[tar] = proc; }
void StatusSyncCore::actionCheckSync(QAction *tar, std::function<bool()> proc) {
tar->setCheckable(true);
registerTrigger(proc, [tar](bool state) {
if (tar->isChecked() != state)
tar->setChecked(state);
});
}
void StatusSyncCore::registerTrigger(std::function<bool()> judge, std::function<void(bool)> exec) {
auto run = new Run(false, judge, exec);
alltriggers << run;
}
Run *StatusSyncCore::registerManualRun(std::function<bool ()> judge, std::function<void (bool)> exec)
{
auto run = new Run(true, judge, exec);
alltriggers << run;
return run;
}
void StatusSyncCore::sync()
{
for(auto &it : widget_trigger_map.keys()){
auto status = widget_trigger_map[it]();
if(it->isEnabled() != status)
it->setEnabled(status);
}
for(auto &it : action_trigger_map.keys()){
auto status = action_trigger_map[it]();
if(it->isEnabled() != status)
it->setEnabled(status);
}
for(auto &act : alltriggers){
act->exec();
}
}

View File

@ -1,45 +0,0 @@
#ifndef COMNTOOLS_H
#define COMNTOOLS_H
#include <QAction>
#include <QStandardItemModel>
#include <functional>
namespace Tools {
class Run {
public:
Run(bool manual_flag, std::function<bool()> judge,
std::function<void(bool)> execution);
void exec();
private:
bool manual;
std::function<bool()> judgement;
std::function<void(bool)> execution;
};
class StatusSyncCore : public QObject {
public:
explicit StatusSyncCore(QObject *p = nullptr);
virtual ~StatusSyncCore() = default;
void widgetEnableSync(QWidget *tar, std::function<bool()> proc);
void actionEnableSync(QAction *tar, std::function<bool()> proc);
void actionCheckSync(QAction *tar, std::function<bool()> proc);
void registerTrigger(std::function<bool()> judge,
std::function<void(bool)> exec);
Run *registerManualRun(std::function<bool()> judge,
std::function<void(bool)> exec);
void sync();
private:
QHash<QWidget *, std::function<bool()>> widget_trigger_map;
QHash<QAction *, std::function<bool()>> action_trigger_map;
QList<Run *> alltriggers;
};
} // namespace Tools
#endif // COMNTOOLS_H

View File

@ -28,7 +28,7 @@ namespace Config {
// exception interface
public:
virtual const char *what() const override { return this->buffer; }
virtual const char *what() const noexcept override { return this->buffer; }
// ParseException interface
public:

View File

@ -16,7 +16,7 @@ public:
virtual ~Impl_ParseException() = default;
// exception interface
public:
virtual const char *what() const override{
virtual const char *what() const noexcept override {
return temp_string.toLocal8Bit();
}

View File

@ -16,7 +16,7 @@ public:
// exception interface
public:
virtual const char *what() const override;
virtual const char *what() const noexcept override;
private:
QString ex_string;
@ -39,7 +39,7 @@ QString Impl_CmdException::reason() const
return ex_string.mid(title_length+1);
}
const char *Impl_CmdException::what() const
const char *Impl_CmdException::what() const noexcept
{
return ex_string.toLocal8Bit();
}

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -1,12 +1,8 @@
<RCC>
<qresource prefix="/icons">
<file>集合.png</file>
<file>脉络.png</file>
<file>文件.png</file>
<file>单元.png</file>
<file>故事.png</file>
<file>叙述.png</file>
<file>sets.png</file>
<file>file.png</file>
<file>story.png</file>
<file>toplevel.png</file>
<file>概念.png</file>
</qresource>
</RCC>

View File

@ -98,6 +98,64 @@ namespace Project {
virtual QStringList packagePath(const QModelIndex &path) const = 0;
};
class ManagerListener{
public:
/**
* @brief
* @param project_file
*/
virtual void ProjectNEW(const QString &project_file) = 0;
/**
* @brief
* @param project_file
*/
virtual void ProjectOPEN(const QString &project_file) = 0;
/**
* @brief
*/
virtual void hasBeenSAVE() = 0;
/**
* @brief
*/
virtual void hasBeenCLOSE() = 0;
/**
* @brief
* @param path
* @param new_name
*/
virtual void hasBeenRENAME(const QModelIndex &path, const QString &new_name) = 0;
/**
* @brief
* @param new_path
*/
virtual void hasBeenAPPEND(const QModelIndex &new_path) = 0;
/**
* @brief
* @param new_path
*/
virtual void hasBeenMOVE(const QModelIndex &new_path) = 0;
/**
* @brief
*/
virtual void aboutToBeSAVE() = 0;
/**
* @brief
*/
virtual void aboutToBeCLOSE() = 0;
/**
* @brief
* @param path
*/
virtual void aboutToBeDELETE(const QModelIndex &path) = 0;
/**
* @brief
* @param old_path
*/
virtual void aboutToBeMOVE(const QModelIndex &old_path) = 0;
};
/**
* @brief
*
@ -111,6 +169,13 @@ namespace Project {
public:
virtual ~ProjectManager() = default;
/**
* @brief ManagerListener实例
* @param inst
*/
virtual void addListener(ManagerListener *inst) = 0;
virtual void removeListener(ManagerListener *inst) = 0;
/**
* @brief
* @return
@ -183,11 +248,6 @@ namespace Project {
*/
virtual bool isOpenning() const noexcept = 0;
/**
* @brief
* @return
*/
virtual bool isModified() const noexcept = 0;
};
} // namespace Project

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -26,7 +26,7 @@ private:
// exception interface
public:
virtual const char *what() const override{
virtual const char *what() const noexcept override{
return temp_string.toLocal8Bit();
}
@ -62,8 +62,6 @@ QString XMLProjectManager::suffix() const
bool XMLProjectManager::isOpenning() const noexcept { return open_status; }
bool XMLProjectManager::isModified() const noexcept { return unsaved_status; }
/*
* <?xml version='1.0'?>
* <project name="project-name" config="xml-path">
@ -108,6 +106,8 @@ void XMLProjectManager::openProject(const QString &project_file)
open_status = true;
unsaved_status = false;
pnode->setIcon(QIcon(":/icons/toplevel.png"));
notify_all([&](ManagerListener *it){it->ProjectOPEN(project_file);});
}
void XMLProjectManager::newProject(const QDir &project_dir, const QString &name) {
@ -130,17 +130,25 @@ void XMLProjectManager::newProject(const QDir &project_dir, const QString &name)
save();
open_status = true;
project_node->setIcon(QIcon(":/icons/toplevel.png"));
notify_all([&](ManagerListener *it){it->ProjectNEW(filepath_store);});
}
void XMLProjectManager::closeProject()
{
notify_all([&](ManagerListener *it){it->aboutToBeCLOSE();});
open_status = false;
unsaved_status = false;
project_structure->clear();
notify_all([&](ManagerListener *it){it->hasBeenCLOSE();});
}
void XMLProjectManager::save()
{
notify_all([&](ManagerListener *it){it->aboutToBeSAVE();});
project_config->save();
QDomDocument doc;
@ -161,11 +169,17 @@ void XMLProjectManager::save()
QTextStream txout(&records);
doc.save(txout, 4);
txout.flush();
notify_all([&](ManagerListener *it){it->hasBeenSAVE();});
}
QString XMLProjectManager::name() const { return project_structure->item(0)->text(); }
void XMLProjectManager::resetName(const QString &name) { this->project_structure->item(0)->setText(name); }
void XMLProjectManager::resetName(const QString &name) {
this->project_structure->item(0)->setText(name);
notify_all([&](ManagerListener *it){it->hasBeenRENAME(this->project_structure->item(0)->index(), name);});
}
Configration *XMLProjectManager::configraions() const
{
@ -236,6 +250,8 @@ void XMLProjectManager::rename(const QModelIndex &node, const QString &name)
unsaved_status = true;
item->setText(name);
notify_all([&](ManagerListener *it){it->hasBeenRENAME(node, name);});
}
QList<QModelIndex> XMLProjectManager::filesGather(const QModelIndex &node) const
@ -266,10 +282,23 @@ void XMLProjectManager::deleteT(const QModelIndex &node_path) {
if(xnode->nodeType() == NodeType::ROOT)
throw new Impl_ProjectException("参数错误", "不允许删除项目节点");
notify_all([&](ManagerListener *it){it->aboutToBeDELETE(node_path);});
xnode->parent()->removeRow(xnode->row());
unsaved_status = true;
}
void XMLProjectManager::addListener(ManagerListener *inst)
{
if(!this->listeners_list.contains(inst))
this->listeners_list.append(inst);
}
void XMLProjectManager::removeListener(ManagerListener *inst)
{
if(this->listeners_list.contains(inst))
this->listeners_list.removeAll(inst);
}
QList<std::tuple<QString, QFileInfo> > XMLProjectManager::filesWithEnds(const QString &suffix) const
{
auto root_project = project_structure->item(0);
@ -280,7 +309,10 @@ QModelIndex XMLProjectManager::newPackage(const QList<QString> &path)
{
unsaved_status = true;
auto pnode = project_structure->item(0);
return groups_rebuild(static_cast<ProjectNode*>(pnode), path);
auto nidx = groups_rebuild(static_cast<ProjectNode*>(pnode), path);
notify_all([&](ManagerListener *it){it->hasBeenAPPEND(nidx);});
return nidx;
}
QStringList XMLProjectManager::packagePath(const QModelIndex &path) const
@ -338,7 +370,10 @@ QModelIndex XMLProjectManager::newFile(const QModelIndex &package_path, const QS
node->appendRow(leaf);
unsaved_status = true;
return leaf->index();
auto nidx = leaf->index();
notify_all([&](ManagerListener *it){it->hasBeenAPPEND(nidx);});
return nidx;
}
QFileInfo XMLProjectManager::queryInfo(const QModelIndex &path) {
@ -449,6 +484,12 @@ QModelIndex XMLProjectManager::query_index(const QFileInfo &file, const QModelIn
return QModelIndex();
}
void XMLProjectManager::notify_all(std::function<void (ManagerListener *)> proc)
{
for(auto l : listeners_list)
proc(l);
}
void XMLProjectManager::moveTo(const QModelIndex &item_path, const QModelIndex &target_group, int index)
{
@ -458,6 +499,7 @@ void XMLProjectManager::moveTo(const QModelIndex &item_path, const QModelIndex &
if(!target_group.isValid())
throw new Impl_ProjectException("参数错误", "传入的目标包路径无效");
notify_all([&](ManagerListener *it){it->aboutToBeMOVE(item_path);});
auto node = static_cast<ProjectNode *>(project_structure->itemFromIndex(item_path));
auto group = static_cast<ProjectNode*>(project_structure->itemFromIndex(target_group));
@ -477,6 +519,8 @@ void XMLProjectManager::moveTo(const QModelIndex &item_path, const QModelIndex &
group->appendRow(node);
unsaved_status = true;
notify_all([&](ManagerListener *it){it->hasBeenMOVE(node->index());});
}
@ -491,11 +535,11 @@ ProjectNode::ProjectNode(NodeType t, const QString &name)
{
if(t == NodeType::FILE)
{
setIcon(QIcon(":/icons/文件.png"));
setIcon(QIcon(":/icons/file.png"));
}
else
{
setIcon(QIcon(":/icons/集合.png"));
setIcon(QIcon(":/icons/sets.png"));
}
setEditable(false);
@ -508,19 +552,10 @@ void ProjectNode::setFile(const QString &name)
{
this->filename = name;
// if(name.endsWith("storychain"))
// setIcon(QIcon(":/icons/脉络.png"));
// if(name.endsWith("storyunit"))
// setIcon(QIcon(":/icons/单元.png"));
// if(name.endsWith("storyvolume"))
// setIcon(QIcon(":/icons/叙述.png"));
// if(name.endsWith("storyconcept"))
// setIcon(QIcon(":/icons/概念.png"));
if(name.endsWith("storyboard"))
setIcon(QIcon(":/icons/故事.png"));
setIcon(QIcon(":/icons/story.png"));
if (name.endsWith("txt"))
setIcon(QIcon(":/icons/文件.png"));
setIcon(QIcon(":/icons/file.png"));
}
QString ProjectNode::file() const

View File

@ -56,6 +56,8 @@ namespace Project {
// ProjectManager interface
public:
virtual void addListener(ManagerListener *inst) override;
virtual void removeListener(ManagerListener *inst) override;
virtual QStandardItemModel *model() const override;
virtual Config::Configration *configraions() const override;
virtual FilesOperate *operateAccess() const override;
@ -69,9 +71,9 @@ namespace Project {
virtual void resetName(const QString &name) override;
virtual QDir directory() const override;
virtual bool isOpenning() const noexcept override;
virtual bool isModified() const noexcept override;
private:
QList<ManagerListener*> listeners_list;
Config::Configration *const project_config;
QStandardItemModel*const project_structure;
QString filepath_store;
@ -86,6 +88,8 @@ namespace Project {
QModelIndex groups_rebuild(ProjectNode *pnode, const QList<QString> &path_remains);
virtual QModelIndex query_index(const QFileInfo &file, const QModelIndex &base);
void notify_all(std::function<void(ManagerListener*inst)> proc);
};
}
#endif // XMLPROJECTMANAGER_H

View File

@ -16,68 +16,10 @@
using namespace SplitFrame;
enum class XEnum { ONE, TWO };
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
// qDebug() << QString("%1").arg((int)XEnum::ONE);
auto win = new QMainWindow();
// win->setMinimumSize(800, 600);
// win->menuBar()->addMenu("文件");
// auto tbar = new QToolBar();
// win->addToolBar(Qt::ToolBarArea::LeftToolBarArea, tbar);
// auto conv = new ViewPresent();
// auto aview = new XWidget(conv, Qt::black);
// auto bview = new XWidget(conv, Qt::green);
// auto cview = new XWidget(conv, Qt::yellow);
// auto dview = new YWidget(conv);
// auto rect0 = conv->appendView(aview, QIcon(), "hello0");
// auto rect1 = conv->appendView(bview, QIcon(), "hello1");
// auto rect2 = conv->appendView(cview, QIcon(), "hello2");
// auto rect3 = conv->appendView(dview, QIcon(), "hello3");
// conv->markFreedom(rect0);
// conv->markFreedom(rect1);
// conv->markFreedom(rect2);
// conv->markFreedom(rect3);
// conv->objsRelateRebuild();
// conv->resetEngross(static_cast<RectCom *>(rect3));
// win->setCentralWidget(conv->bind());
// auto b_left = tbar->addAction("左侧添加");
// win->connect(b_left, &QAction::triggered, [=](bool v) {
// auto items = conv->freedomViews();
// if (items.size()) {
// conv->temporaryVisible(SplitFrame::DockType::LEFT, items.last());
// }
// });
// auto b_right = tbar->addAction(" 右侧添加");
// win->connect(b_right, &QAction::triggered, [=](bool v) {
// auto items = conv->freedomViews();
// if (items.size()) {
// conv->temporaryVisible(SplitFrame::DockType::RIGHT, items.last());
// }
// });
// auto b_top = tbar->addAction("上侧添加");
// win->connect(b_top, &QAction::triggered, [=](bool v) {
// auto items = conv->freedomViews();
// if (items.size()) {
// conv->temporaryVisible(SplitFrame::DockType::TOP, items.last());
// }
// });
// auto b_bottom = tbar->addAction("下侧添加");
// win->connect(b_bottom, &QAction::triggered, [=](bool v) {
// auto items = conv->freedomViews();
// if (items.size()) {
// conv->temporaryVisible(SplitFrame::DockType::BOTTOM, items.last());
// }
// });
win->show();
QWidget *firstPageWidget = new XWidget(nullptr, Qt::GlobalColor::green);