Compare commits

...

10 Commits

Author SHA1 Message Date
玉宇清音 24a1bfa51a 修改SplitView之前 2023-12-24 12:49:58 +08:00
玉宇清音 44d05e4032 zuixin 2023-09-10 13:28:52 +08:00
玉宇清音 165d7f85f1 从项目操作(创建、打开、关闭、保存)到文件操作(新建、打开、删除、显示编辑)机制完成 2023-09-04 22:35:14 +08:00
玉宇清音 fc86521d1e 修复了setmap的bug 2023-09-02 06:35:46 +08:00
玉宇清音 1576a3c0b0 决定添加了自定义的文本编辑控件
1. 修复了xmlconfig的setList的bug
2023-09-02 06:34:06 +08:00
玉宇清音 ff7cae77d6 删除了冗余代码 2023-08-31 23:40:25 +08:00
玉宇清音 e5e299ad94 鼠标光标设置问题解决,重构软件代码结构 2023-08-31 23:33:45 +08:00
玉宇清音 2867cce510 整理类型命名空间分类 2023-08-29 12:31:29 +08:00
玉宇清音 7c631975b2 重新整理了类型的命名空间排布 2023-08-29 12:18:41 +08:00
玉宇清音 748dbd2f0a 移除了废弃的PresentBase类型
今后的界面视图只有两种:1,窗口绑定功能视图继承SplitRectCom;2,全局唯一文件视图继承FilePresent
2023-08-29 11:52:56 +08:00
64 changed files with 1531 additions and 1013 deletions

View File

@ -6,4 +6,5 @@ SUBDIRS += \
WordsIDE \
libConfig \
libProjectManager \
# libTextEdit \
u_test

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.15.0, 2023-08-29T08:41:33. -->
<!-- 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

@ -8,5 +8,6 @@
using namespace Components;
using namespace Core;
using namespace Presents;
FilePresent::FilePresent(QObject *parent) : QObject(parent) {}

View File

@ -1,7 +1,6 @@
#ifndef DOCSMANAGER_H
#define DOCSMANAGER_H
#include "appcore.h"
#include "route.h"
#include <QHash>
#include <QObject>
@ -11,46 +10,42 @@ namespace Core {
class DocumentsManager;
}
namespace Components {
class PresentBase {
namespace Presents {
/**
* @brief
*/
class FilePresent : public QObject {
Q_OBJECT
public:
/**
* @brief widget
* @return
*/
virtual QWidget *widget() const = 0;
explicit FilePresent(QObject *parent = nullptr);
virtual ~FilePresent() = default;
/**
* @brief
* @return
*/
virtual QString name() const = 0;
virtual Core::Route accessPath() const = 0;
/**
* @brief widget
* @return
*/
virtual QWidget *widget() const = 0;
virtual Core::DocumentsManager *docsManager() const = 0;
/**
* @brief
*/
virtual void beforeClose() = 0;
virtual Core::DocumentsManager *docsManager() const = 0;
};
/**
* @brief
*/
class FilePresent : public QObject, public PresentBase {
Q_OBJECT
public:
explicit FilePresent(QObject *parent = nullptr);
virtual ~FilePresent() = default;
virtual Core::Route accessPath() const = 0;
/**
* @brief
* @param core
* @param name
*/
virtual void applySetting(const QString &name) = 0;
virtual void applySetting(const QString &name, const Config::Configration *cfg) = 0;
/**
* @brief 使
* @param target_file info
@ -102,11 +97,18 @@ namespace Components {
*/
virtual void create(const QFileInfo &target) = 0;
/**
* @brief
* @param cfg_port
* @return
*/
virtual QDialog *createTempConfigPanel(Config::Configration *cfg_port) = 0;
/**
* @brief Present实例
* @return
*/
virtual FilePresent *newInst(Core::DocumentsManager *mgr, const Core::Route &path, QObject *parent) const = 0;
virtual FilePresent *newInst(Core::DocumentsManager *mgr, const Core::Route &path, QObject *parent = nullptr) const = 0;
};
template <class PresentType> class TypedPresentFactory : public PresentFactory {
@ -117,7 +119,7 @@ namespace Components {
* @return
*/
static QString suffix() { return PresentType::file_suffix; }
virtual FilePresent *newInst(Core::DocumentsManager *mgr, const Core::Route &path, QObject *parent) const {
virtual FilePresent *newInst(Core::DocumentsManager *mgr, const Core::Route &path, QObject *parent = nullptr) const {
return new PresentType(mgr, path, parent);
}
};
@ -125,8 +127,8 @@ namespace Components {
#define DECL_PRESENT(type) \
private: \
static QString file_suffix; \
friend class Components::TypedPresentFactory<type>;
friend class Presents::TypedPresentFactory<type>;
} // namespace Components
} // namespace Presents
#endif // DOCSMANAGER_H

View File

@ -19,21 +19,19 @@ msvc {
SOURCES += \
DocsManager.cpp \
appcore.cpp \
command_list.cpp \
# contentpresenttest.cpp \
# keywordshighlighter.cpp \
main.cpp \
mainwindow.cpp \
manager_docs.cpp \
messagespresent.cpp \
messageview.cpp \
parsebridge.cpp \
presentcontainer.cpp \
projectpresent.cpp \
presentcontainerview.cpp \
projectview.cpp \
route.cpp \
srcedit_defaulttext.cpp \
srcedit_storyboard.cpp \
tools.cpp \
viewsession.cpp \
viewstackedbar.cpp \
welcomepanel.cpp \
@ -41,21 +39,18 @@ SOURCES += \
HEADERS += \
DocsManager.h \
appcore.h \
command_list.h \
# contentpresenttest.h \
# keywordshighlighter.h \
mainwindow.h \
manager_docs.h \
messagespresent.h \
opstream.h \
messageview.h \
parsebridge.h \
presentcontainer.h \
projectpresent.h \
presentcontainerview.h \
projectview.h \
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

@ -4,8 +4,8 @@
#include "DocsManager.h"
using namespace CommandList;
using namespace Components;
using namespace Core;
using namespace Presents;
NewProject::NewProject(const QDir &dir, const QString &name) : dir_symbo(dir), name_val(name) {}
@ -24,10 +24,7 @@ void NewProject::fromText(const QString &line) {
name_val = list[1];
}
NewPackage::NewPackage(const QString &path_string)
{
sequence = path_string.split("/");
}
NewPackage::NewPackage(const QString &path_string) { sequence = path_string.split("/", QString::SplitBehavior::SkipEmptyParts); }
QString NewPackage::name() const
{
@ -89,9 +86,12 @@ QString SaveAll::name() const
void SaveAll::run(Schedule::CommandsDispatcher *core) const
{
auto vmgr = core->get<DocumentsManager>(NAME(SaveAll));
vmgr->save();
vmgr->projectManager()->save();
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
if (vmgr->projectManager()->isOpenning()) {
vmgr->save();
vmgr->projectManager()->save();
}
}
QString SaveAll::toText() const
@ -99,60 +99,7 @@ QString SaveAll::toText() const
return "";
}
void SaveAll::fromText(const QString &line)
{
}
OpenProject::OpenProject(const QString &path)
: project_path(path)
{
}
QString OpenProject::name() const
{
return NAME(OpenProject);
}
void OpenProject::run(Schedule::CommandsDispatcher *core) const
{
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
vmgr->projectManager()->openProject(project_path);
}
QString OpenProject::toText() const
{
return project_path;
}
void OpenProject::fromText(const QString &line)
{
project_path = line;
}
CloseProject::CloseProject()
{
}
QString CloseProject::name() const
{
return NAME(CloseProject);
}
void CloseProject::run(Schedule::CommandsDispatcher *core) const
{
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
vmgr->save();
vmgr->closeFile(vmgr->actives());
vmgr->projectManager()->save();
vmgr->projectManager()->closeProject();
}
QString CloseProject::toText() const { return ""; }
void CloseProject::fromText(const QString &line) {}
void SaveAll::fromText(const QString &line) {}
OpenFile::OpenFile(const Core::Route &path_node) { path_store = path_node.links(); }
@ -185,14 +132,9 @@ QString OpenFile::toText() const
return path_store.join("/");
}
void OpenFile::fromText(const QString &line)
{
path_store = line.split("/");
}
void OpenFile::fromText(const QString &line) { path_store = line.split("/"); }
using namespace Components;
CompVisible::CompVisible(PresentHost *host, PresentBase *target, bool state) : host_ins(host), target_ins(target), state_val(state) {
CompVisible::CompVisible(PresentHost *host, FilePresent *target, bool state) : host_ins(host), target_ins(target), state_val(state) {
path = Route::collect(QList<QString>() << target->name());
}
@ -214,3 +156,52 @@ void CompVisible::fromText(const QString &line) {
state_val = list[0].toUInt();
path = Route::collect(list[1].split(":"));
}
OpenProject::OpenProject(const QString &path) : project_path(path) {}
QString OpenProject::name() const { return NAME(OpenProject); }
void OpenProject::run(Schedule::CommandsDispatcher *core) const {
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
vmgr->projectManager()->openProject(project_path);
}
QString OpenProject::toText() const { return project_path; }
void OpenProject::fromText(const QString &line) { project_path = line; }
CloseProject::CloseProject() {}
QString CloseProject::name() const { return NAME(CloseProject); }
void CloseProject::run(Schedule::CommandsDispatcher *core) const {
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
vmgr->save();
vmgr->closeFile(vmgr->actives());
vmgr->projectManager()->save();
vmgr->projectManager()->closeProject();
}
QString CloseProject::toText() const { return ""; }
void CloseProject::fromText(const QString &line) {}
DeleteTarget::DeleteTarget(const Core::Route &target) : node_path(target) {}
DeleteTarget::DeleteTarget(const QModelIndex &target) : node_index(target) {}
QString DeleteTarget::name() const { return NAME(DeleteTarget); }
void DeleteTarget::run(Schedule::CommandsDispatcher *core) const {
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
if (!node_index.isValid())
vmgr->deleteNode(node_path);
else {
auto node_path = vmgr->convertPath(node_index);
vmgr->deleteNode(node_path);
}
}
QString DeleteTarget::toText() const { return node_path.links().join("/"); }
void DeleteTarget::fromText(const QString &line) { Route::collect(line.split("/", QString::SplitBehavior::SkipEmptyParts)); }

View File

@ -3,11 +3,12 @@
#include "route.h"
#include <QModelIndex>
#include <commandsdispatcher.h>
namespace Components {
namespace Presents {
class PresentHost;
class PresentBase;
class FilePresent;
}
namespace CommandList {
@ -29,25 +30,26 @@ namespace CommandList {
};
class OpenProject : public Schedule::GeCommand {
public:
public:
OpenProject(const QString &path);
// GeCommand interface
public:
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:
private:
QString project_path;
};
class CloseProject : public Schedule::GeCommand {
public:
public:
CloseProject();
// GeCommand interface
public:
public:
virtual QString name() const override;
virtual void run(Schedule::CommandsDispatcher *core) const override;
virtual QString toText() const override;
@ -84,8 +86,26 @@ namespace CommandList {
virtual QString toText() const override;
virtual void fromText(const QString &line) override;
};
class DeleteTarget : public Schedule::GeCommand {
public:
DeleteTarget(const Core::Route &target);
DeleteTarget(const QModelIndex &target);
// 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:
QModelIndex node_index = QModelIndex();
Core::Route node_path;
};
class OpenFile : public Schedule::GeCommand {
public:
public:
OpenFile(const Core::Route &path_node);
OpenFile(const QFileInfo &f);
@ -115,7 +135,7 @@ namespace CommandList {
// 切换视图组件 ================================================================
class CompVisible : public Schedule::GeCommand {
public:
CompVisible(Components::PresentHost *host, Components::PresentBase *target, bool state);
CompVisible(Presents::PresentHost *host, Presents::FilePresent *target, bool state);
// GeCommand interface
public:
@ -124,9 +144,9 @@ namespace CommandList {
virtual QString toText() const override;
virtual void fromText(const QString &line) override;
private:
Components::PresentHost *host_ins;
Components::PresentBase *target_ins;
private:
Presents::PresentHost *host_ins;
Presents::FilePresent *target_ins;
Core::Route path;
bool state_val;
};

View File

@ -9,10 +9,10 @@ namespace TestCase {
{
Q_OBJECT
public:
ContentPresentTest(Components::FilePresent *view);
ContentPresentTest(Presents::FilePresent *view);
private:
Components::FilePresent *inst;
Presents::FilePresent *inst;
private slots:
void test_Suffixes();

View File

@ -15,23 +15,6 @@ int main(int argc, char *argv[])
{
XApp a(argc, argv);
#ifdef UNIT_TEST
MakeTools::ContentPresent *array[] = {
new Components::DefaultTextPresent(),
new Components::StorychainSourceEdit(),
new Components::StoryunitSourceEdit(),
new Components::StoryboardSourceEdit(),
new Components::StoryvolumeSourceEdit(),
new Components::StoryconceptSourceEdit()
};
for(auto &it : array){
TestCase::ContentPresentTest tx0(it);
QTest::qExec(&tx0, argc, argv);
}
#else
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
@ -42,9 +25,8 @@ int main(int argc, char *argv[])
}
}
MainWindow w;
MainWindow w(&a, "default");
w.show();
#endif
return a.exec();
}

View File

@ -24,60 +24,91 @@
using namespace Project;
using namespace Components;
using namespace Core;
using namespace Tools;
using namespace CommandList;
using namespace bridge;
MainWindow::MainWindow(QWidget *parent)
MainWindow::MainWindow(XApp *core, const QString &layout, QWidget *parent)
: QMainWindow(parent),
sync_kernel(new StatusSyncCore(this)),
parse_service(new ParseBridge()),
project_manager(new XMLProjectManager(this)),
active_docscollect(new DocumentsManager(project_manager)),
layout_name_store(layout),
core_bind(core),
present_host(new SplitFrame::ViewPresent(this)),
session_service(new ViewSession(XApp::global_configration, present_host)),
session_service(new ViewSession(XApp::gconfig, this)),
actions_stack(new QToolBar(this)),
views_bar(new ViewStackedBar(present_host, this)),
center_frame(new PresentContainer(present_host, this)),
project_present(new ProjectPresent(present_host, XApp::disp_core, active_docscollect, this)) {
QApplication::instance()->installEventFilter(this);
initial_commandlist(XApp::disp_core);
XApp::disp_core->registerMember(active_docscollect);
center_frame(new PresentContainerView(present_host)),
project_present(new ProjectView(present_host, XApp::disp_core, core->docsManager())) {
setMinimumSize(1000, 600);
setWindowTitle(tr("提线木偶"));
QApplication::instance()->installEventFilter(this);
auto mbar = menuBar();
initial_menubar(mbar);
setCentralWidget(present_host->bind());
addToolBar(Qt::LeftToolBarArea, views_bar);
present_host->addListener(views_bar);
session_service->initPresentView(center_frame, project_present, parse_service->errorsPresentModel());
auto mbar = menuBar();
initial_menubar(mbar);
session_service->initPresentView(center_frame, project_present, core->parseService()->errorsPresentModel());
project_present->setVisible(true);
this->active_docscollect->setPresent(center_frame);
core->docsManager()->appendPresent(center_frame);
session_service->viewStatesRestore(this, present_host);
}
MainWindow::~MainWindow() {}
MainWindow::~MainWindow() { core_bind->docsManager()->removePresent(center_frame); }
SplitFrame::ViewPresent *MainWindow::bindPresent() const { return present_host; }
QString MainWindow::layoutName() const { return layout_name_store; }
void MainWindow::resetLayoutName(const QString &name) { layout_name_store = name; }
void MainWindow::initial_menubar(QMenuBar *mbar) {
// 项目菜单树
auto project = mbar->addMenu("项目");
auto opnp = project->addAction("打开项目", [this]() {
project = mbar->addMenu("项目");
this->build_project_menu(project);
// 编辑菜单
edit = mbar->addMenu("编辑");
this->build_edit_menu(edit);
// 视图菜单
view = mbar->addMenu("视图");
build_view_menu(view);
// 工具菜单
tool = mbar->addMenu("工具");
build_tools_menu(tool);
// 窗口菜单
window = mbar->addMenu("窗口");
build_window_menu(window);
// 系统
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) {
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 !project_manager->isOpenning(); });
auto newp = project->addAction("新建项目", [this]() {
project_new = project->addAction("新建项目", [this]() {
auto name = QInputDialog::getText(this, "输入项目名称", "项目名称");
if (name == "")
return;
@ -87,139 +118,165 @@ void MainWindow::initial_menubar(QMenuBar *mbar) {
XApp::disp_core->postCommand(NewProject(QDir(dir_path), name));
});
sync_kernel->actionEnableSync(newp, [this]() -> bool { return !project_manager->isOpenning(); });
auto clsp = project->addAction("关闭项目", [this]() { XApp::disp_core->postCommand(CloseProject()); });
sync_kernel->actionEnableSync(clsp, [this]() -> bool { return project_manager->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 project_manager->isOpenning(); });
auto _xnew = project->addMenu("新建文件");
_xnew->setEnabled(project_manager->isOpenning());
auto types = active_docscollect->fileTypes();
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;
auto idx = project_present->currentIndex();
if (!idx.isValid())
idx = project_manager->model()->item(0)->index();
idx = core_bind->pjtManager()->model()->item(0)->index();
auto group_path = active_docscollect->convertPath(idx);
auto group_path = core_bind->docsManager()->convertPath(idx);
XApp::disp_core->postCommand(NewFile(group_path, name, t));
});
}
sync_kernel->widgetEnableSync(_xnew, [this]() -> bool { return project_manager->isOpenning(); });
project->addSeparator();
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]() {
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);
});
// 编辑菜单
auto edit = mbar->addMenu("编辑");
edit->addAction("撤销一步");
edit->addAction("重做一步");
this->hasBeenCLOSE();
}
void MainWindow::build_edit_menu(QMenu *edit) {
edit_undo = edit->addAction("撤销一步");
edit_redo = edit->addAction("重做一步");
edit->addSeparator();
edit->addAction("查找关键词");
edit->addAction("替换关键词");
edit_find = edit->addAction("查找关键词");
edit_replace = edit->addAction("替换关键词");
}
// 视图菜单
auto view = mbar->addMenu("视图");
auto area = view->addMenu("区域管理");
void MainWindow::build_view_menu(QMenu *view) {
view_area = view->addMenu("区域管理");
auto xtool = new QToolBar(this);
xtool->setVisible(false);
addToolBar(Qt::ToolBarArea::TopToolBarArea, xtool);
auto act_tool = area->addAction("工具栏");
sync_kernel->actionCheckSync(act_tool, [xtool]() -> bool { return xtool->isVisible(); });
connect(act_tool, &QAction::triggered, [xtool](bool v) { xtool->setVisible(v); });
actions_stack->setMovable(false);
addToolBar(Qt::ToolBarArea::TopToolBarArea, actions_stack);
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->project_manager->isOpenning(); });
// 项目管理
connect(view_area_statusbar, &QAction::triggered, [xstatus](bool v) { xstatus->setVisible(v); });
// 工具菜单
auto tool = mbar->addMenu("工具");
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内容");
// 窗口菜单
auto window = mbar->addMenu("窗口");
window->addAction("新建窗口");
window->addAction("关闭窗口");
window->addSeparator();
window->addAction("布局管理");
window->addMenu("布局切换");
window->addMenu("窗口切换");
// 系统
auto sys = mbar->addMenu("系统");
sys->addAction("软件激活");
sys->addAction("系统信息");
sys->addSeparator();
sys->addAction("关于……");
view_config = view->addAction("视图配置", [this]() {
auto dialog = new QDialog();
auto tabs = new QTabWidget(dialog);
auto layout = new QVBoxLayout(dialog);
layout->addWidget(tabs);
core_bind->docsManager()->loadViewConfigWidgets(tabs);
dialog->exec();
});
}
void MainWindow::initial_commandlist(Schedule::CommandsDispatcher *host) {
host->registerCommand(new CloseProject());
void MainWindow::build_tools_menu(QMenu *tool) {
tool_console = tool->addAction("控制台");
host->registerCommand(new NewFile(Route(), "", "txt"));
host->registerCommand(new NewPackage(""));
host->registerCommand(new NewProject(QDir(), ""));
host->registerCommand(new OpenFile(Route()));
host->registerCommand(new OpenProject(""));
host->registerCommand(new SaveAll());
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) {
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);
}
window_winnew->clear();
for (auto &n : names)
window_winnew->addAction(n);
});
connect(window_winnew, &QMenu::triggered, [this](QAction *s) {
auto layout = s->text();
auto newone = new MainWindow(this->core_bind, layout);
newone->show();
});
window_winclose = window->addAction("关闭窗口", [this]() {
XApp::disp_core->postCommand(SaveAll());
this->close();
});
window->addSeparator();
window_layout_store = window->addAction("保存当前布局", [this]() {
auto new_name = QInputDialog::getText(this, "输入新布局名称", "名称:");
if (new_name.isEmpty())
return;
auto names = XApp::gconfig->getList(layout_peak_path);
if (names.contains(new_name)) {
QMessageBox::critical(this, "数据校验", "输入错误,输入了重复的布局名称!");
return;
}
names << new_name;
XApp::gconfig->setList(layout_peak_path, names);
this->resetLayoutName(new_name);
session_service->viewStatesSave(this, this->present_host);
});
window_layout_load = window->addMenu("布局切换");
window_layout_del = window->addMenu("布局删除");
}
void MainWindow::closeEvent(QCloseEvent *event) {
// 关闭事件
if (project_manager->isOpenning()) {
if (core_bind->pjtManager()->isOpenning()) {
XApp::disp_core->postCommand(CloseProject());
}
session_service->viewStatesSave(this, present_host);
XApp::global_configration->save();
XApp::gconfig->save();
QMainWindow::closeEvent(event);
}
@ -232,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

@ -3,14 +3,14 @@
#include "DocsManager.h"
#include "manager_docs.h"
#include "messagespresent.h"
#include "messageview.h"
#include "parsebridge.h"
#include "presentcontainer.h"
#include "projectpresent.h"
#include "tools.h"
#include "viewstackedbar.h"
#include "presentcontainerview.h"
#include "projectview.h"
#include "viewsession.h"
#include "viewstackedbar.h"
#include "welcomepanel.h"
#include "xapp.h"
#include <QListView>
#include <QMainWindow>
#include <QSplitter>
@ -19,37 +19,110 @@
#include <libProjectManager.h>
#include <splitpanel.h>
class MainWindow : public QMainWindow {
class MainWindow : public QMainWindow , public Project::ManagerListener{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
public:
MainWindow(XApp *core, const QString &layout, QWidget *parent = nullptr);
virtual ~MainWindow();
SplitFrame::ViewPresent *bindPresent() const;
QString layoutName() const;
void resetLayoutName(const QString &name);
private:
QString layout_name_store;
// model ============================================
Tools::StatusSyncCore *const sync_kernel;
bridge::ParseBridge *const parse_service;
Project::ProjectManager *const project_manager;
Core::DocumentsManager *const active_docscollect;
XApp *const core_bind;
SplitFrame::ViewPresent *const present_host;
Core::ViewSession *const session_service;
// view =============================================
QToolBar *const actions_stack;
Components::ViewStackedBar *const views_bar;
Components::PresentContainer *const center_frame;
Components::ProjectPresent *const project_present;
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);
void initial_commandlist(Schedule::CommandsDispatcher *host);
void build_project_menu(QMenu *pmenu);
void build_edit_menu(QMenu *pmenu);
void build_view_menu(QMenu *pmenu);
void build_tools_menu(QMenu *pmenu);
void build_window_menu(QMenu *pmenu);
// QWidget interface
protected:
protected:
virtual void closeEvent(QCloseEvent *event) override;
// 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

@ -1,24 +1,44 @@
#include "manager_docs.h"
#include "DocsManager.h"
#include "keywordshighlighter.h"
#include "xapp.h"
using namespace Components;
using namespace Core;
using namespace Config;
using namespace Presents;
DocumentsManager::DocumentsManager(Project::ProjectManager *project) : pjtins(project), present_ui(nullptr) { initViewPlugins(); }
DocumentsManager::DocumentsManager(XApp *host) : core_inst(host) { initContentViewPlugins(); }
void DocumentsManager::setPresent(Components::PresentHost *container) { present_ui = container; }
void DocumentsManager::appendPresent(PresentHost *container) {
if (present_ui.contains(container))
return;
Project::ProjectManager *DocumentsManager::projectManager() const { return pjtins; }
present_ui << container;
}
void DocumentsManager::removePresent(PresentHost *container) {}
Project::ProjectManager *DocumentsManager::projectManager() const { return core_inst->pjtManager(); }
#include "srcedit_defaulttext.h"
#include "srcedit_storyboard.h"
void DocumentsManager::initViewPlugins() {
void DocumentsManager::initContentViewPlugins() {
registPresentType(new DefaultTextEditFactory);
registPresentType(new StorySourceEditFactory);
}
void DocumentsManager::loadViewConfigWidgets(QTabWidget *stacked) {
if (!projectManager()->isOpenning())
return;
auto keys = factory_map.keys();
for (auto &it : keys) {
auto panel = factory_map[it]->createTempConfigPanel(projectManager()->configraions());
if (panel)
stacked->addTab(panel, it + "配置");
}
}
QList<QString> DocumentsManager::fileTypes() const {
QList<QString> all_types;
for (auto &it : factory_map.keys())
@ -26,7 +46,7 @@ QList<QString> DocumentsManager::fileTypes() const {
return all_types;
}
void DocumentsManager::createPackage(const Core::Route &link) { pjtins->operateAccess()->newPackage(link.links()); }
void DocumentsManager::createPackage(const Core::Route &link) { core_inst->pjtManager()->operateAccess()->newPackage(link.links()); }
void DocumentsManager::createFile(const Core::Route &group_path, const QString &name, const QString &suffix) {
auto all_types = fileTypes();
@ -40,12 +60,12 @@ void DocumentsManager::createFile(const Core::Route &group_path, const QString &
}
void DocumentsManager::renameNode(const Core::Route &node_path, const QString &name) {
pjtins->operateAccess()->rename(convertPath(node_path), name);
core_inst->pjtManager()->operateAccess()->rename(convertPath(node_path), name);
auto activie_file_nodes = actives();
if (activie_file_nodes.contains(node_path)) {
auto inst = convertPresent(node_path);
inst->applySetting(name);
inst->applySetting(name, core_inst->pjtManager()->configraions());
doc_openning.remove(node_path);
auto old_link = node_path.links();
@ -58,7 +78,7 @@ void DocumentsManager::renameNode(const Core::Route &node_path, const QString &n
void DocumentsManager::deleteNode(const Core::Route &node_path) {
auto node_mindex = convertPath(node_path);
auto file_nodes = pjtins->queryAccess()->filesGather(node_mindex);
auto file_nodes = core_inst->pjtManager()->queryAccess()->filesGather(node_mindex);
auto activie_file_nodes = actives();
QList<Core::Route> path_buff;
@ -69,27 +89,35 @@ void DocumentsManager::deleteNode(const Core::Route &node_path) {
}
closeFile(path_buff);
pjtins->operateAccess()->deleteT(node_mindex);
core_inst->pjtManager()->operateAccess()->deleteT(node_mindex);
}
void DocumentsManager::openFile(const QList<Route> &doc_paths) {
for (auto &it : doc_paths) {
auto openning = actives();
if (openning.contains(it)) {
doc_openning[it]->applySetting(it.links().last());
doc_openning[it]->applySetting(it.links().last(), core_inst->pjtManager()->configraions());
active(it);
continue;
}
auto info = pjtins->queryAccess()->queryInfo(convertPath(it));
auto info = core_inst->pjtManager()->queryAccess()->queryInfo(convertPath(it));
if (!info.isFile())
throw new SimpleException<QString>("打开文件错误", "指向的节点不是文件节点");
auto view = factory_map[info.suffix()]->newInst(this, it, present_ui->hostWidget());
auto view = factory_map[info.suffix()]->newInst(this, it);
doc_openning[it] = view;
view->load(info);
view->applySetting(it.links().last());
present_ui->append(view);
view->applySetting(it.links().last(), core_inst->pjtManager()->configraions());
for (auto &con : present_ui)
if (con->avaliable(view)) {
con->append(view);
return;
}
// 默认第一个打开
present_ui.first()->append(view);
}
}
@ -100,7 +128,10 @@ void DocumentsManager::closeFile(const QList<Core::Route> &doc_paths) {
auto inst = convertPresent(idx);
inst->saveAs();
present_ui->remove(inst);
for (auto vit : present_ui)
if (present_ui.contains(vit))
vit->remove(inst);
delete inst;
doc_openning.remove(idx);
}
@ -108,7 +139,7 @@ void DocumentsManager::closeFile(const QList<Core::Route> &doc_paths) {
QModelIndex DocumentsManager::convertPath(const Core::Route &path) {
auto path_list = path.links();
auto itor_node = pjtins->model()->item(0);
auto itor_node = core_inst->pjtManager()->model()->item(0);
while (path_list.size() > 1) {
auto item = path_list.takeAt(1);
int idx = 0;
@ -127,7 +158,7 @@ QModelIndex DocumentsManager::convertPath(const Core::Route &path) {
Route DocumentsManager::convertPath(const QModelIndex &index) {
Core::Route path;
auto item = pjtins->model()->itemFromIndex(index);
auto item = core_inst->pjtManager()->model()->itemFromIndex(index);
while (item != nullptr) {
path.prepend(item->text().trimmed());
item = item->parent();
@ -145,7 +176,9 @@ QList<Route> DocumentsManager::actives() const { return doc_openning.keys(); }
void DocumentsManager::active(const Core::Route &node_path) {
if (doc_openning.contains(node_path)) {
auto inst = convertPresent(node_path);
present_ui->active(inst);
for (auto &vit : present_ui)
if (vit->contains(inst))
vit->active(inst);
}
}
@ -153,6 +186,10 @@ void DocumentsManager::save() {
auto actives_paths = this->actives();
for (auto &p : actives_paths)
convertPresent(p)->saveAs();
// files
auto pjt = core_inst->pjtManager();
auto list = pjt->queryAccess()->filesWithEnds("storyboard");
}
QString DocumentsManager::name() const { return NAME(DocumentsManager); }

View File

@ -10,7 +10,7 @@
#include <commandsdispatcher.h>
#include <libProjectManager.h>
namespace Components {
namespace Presents {
class PresentHost {
public:
@ -22,31 +22,38 @@ namespace Components {
*/
virtual QWidget *hostWidget() const = 0;
/**
* @brief
* @param vins
* @return
*/
virtual bool avaliable(Presents::FilePresent *vins) = 0;
/**
* @brief
* @param ins
*/
virtual void append(Components::PresentBase *ins) = 0;
virtual void append(Presents::FilePresent *ins) = 0;
/**
* @brief
* @param ins
*/
virtual bool active(const Components::PresentBase *ins) = 0;
virtual bool active(const Presents::FilePresent *ins) = 0;
/**
* @brief
* @param ins
*/
virtual void remove(const Components::PresentBase *ins) = 0;
virtual void remove(const Presents::FilePresent *ins) = 0;
/**
* @brief
* @param ins
* @return
*/
virtual bool contains(const Components::PresentBase *ins) const = 0;
virtual bool contains(const Presents::FilePresent *ins) const = 0;
};
} // namespace Components
} // namespace Presents
class XApp;
namespace Core {
/**
@ -54,14 +61,15 @@ namespace Core {
*/
class DocumentsManager : public Schedule::AccessibleObject {
public:
DocumentsManager(Project::ProjectManager *project);
DocumentsManager(XApp *host);
virtual ~DocumentsManager() = default;
/**
* @brief
* @param container
*/
void setPresent(Components::PresentHost *container);
void appendPresent(Presents::PresentHost *container);
void removePresent(Presents::PresentHost *container);
/**
* @brief
@ -69,15 +77,19 @@ namespace Core {
*/
Project::ProjectManager *projectManager() const;
void initViewPlugins();
/**
* @brief
*/
void initContentViewPlugins();
void loadViewConfigWidgets(QTabWidget *stacked);
// ==========================================================
/**
* @brief
* @param ins
*/
template <class PresentType> void registPresentType(Components::TypedPresentFactory<PresentType> *ins) {
auto suffix = Components::TypedPresentFactory<PresentType>::suffix();
template <class PresentType> void registPresentType(Presents::TypedPresentFactory<PresentType> *ins) {
auto suffix = Presents::TypedPresentFactory<PresentType>::suffix();
factory_map[suffix] = ins;
}
@ -150,13 +162,13 @@ namespace Core {
* @param ins
* @return
*/
Core::Route convertPresent(Components::FilePresent *ins) const;
Core::Route convertPresent(Presents::FilePresent *ins) const;
/**
* @brief null
* @param node_path
* @return null或打开的展示实例
*/
Components::FilePresent *convertPresent(const Core::Route &node_path);
Presents::FilePresent *convertPresent(const Core::Route &node_path);
/**
* @brief
@ -177,11 +189,11 @@ namespace Core {
virtual QString name() const override;
private:
Project::ProjectManager *pjtins;
Components::PresentHost *present_ui;
XApp *const core_inst;
QList<Presents::PresentHost *> present_ui;
QHash<QString, Components::PresentFactory *> factory_map;
QHash<Core::Route, Components::FilePresent *> doc_openning;
QHash<QString, Presents::PresentFactory *> factory_map;
QHash<Core::Route, Presents::FilePresent *> doc_openning;
};
} // namespace Core

View File

@ -1,27 +0,0 @@
#include "messagespresent.h"
#include <QVBoxLayout>
using namespace Components;
using namespace SplitFrame;
QHash<SplitFrame::ViewPresent *, MessagesPresent *> MessagesPresent::panel_map;
MessagesPresent::MessagesPresent(SplitFrame::ViewPresent *ins, QStandardItemModel *base, QWidget *parent)
: FnWrap<MessagesPresent, false>(ins, parent), ui_present(new QTableView(this)), items_present(base) {
auto layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(ui_present);
ui_present->setModel(items_present);
}
MessagesPresent *MessagesPresent::gen(SplitFrame::ViewPresent *host, QStandardItemModel *base, QWidget *parent) {
if (panel_map.contains(host))
return panel_map[host];
auto vins = new MessagesPresent(host, base, parent);
panel_map[host] = vins;
return vins;
}

View File

@ -1,29 +0,0 @@
#ifndef MESSAGEPRESENT_H
#define MESSAGEPRESENT_H
#include "DocsManager.h"
#include <QHash>
#include <QStandardItemModel>
#include <QTableView>
#include <splitpanel.h>
namespace Components {
/**
* @brief
*/
class MessagesPresent : public SplitFrame::FnWrap<MessagesPresent, false> {
public:
virtual ~MessagesPresent() = default;
static MessagesPresent *gen(SplitFrame::ViewPresent *host, QStandardItemModel *base, QWidget *parent = nullptr);
private:
MessagesPresent(SplitFrame::ViewPresent *ins, QStandardItemModel *base, QWidget *parent = nullptr);
QTableView *const ui_present;
QStandardItemModel *const items_present;
static QHash<SplitFrame::ViewPresent *, MessagesPresent *> panel_map;
};
} // namespace Components
#endif // MESSAGEPRESENT_H

28
WordsIDE/messageview.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "messageview.h"
#include <QVBoxLayout>
using namespace Components;
using namespace SplitFrame;
QHash<SplitFrame::ViewPresent *, MessageView *> MessageView::panel_map;
MessageView::MessageView(SplitFrame::ViewPresent *ins, QStandardItemModel *base)
: FnWrap<MessageView, false>(ins), ui_present(new QTableView(this)), items_present(base) {
auto layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(ui_present);
ui_present->setModel(items_present);
ui_present->setMouseTracking(true);
}
MessageView *MessageView::gen(SplitFrame::ViewPresent *host, QStandardItemModel *base) {
if (panel_map.contains(host))
return panel_map[host];
auto vins = new MessageView(host, base);
panel_map[host] = vins;
return vins;
}

29
WordsIDE/messageview.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef MESSAGEVIEW_H
#define MESSAGEVIEW_H
#include "DocsManager.h"
#include <QHash>
#include <QStandardItemModel>
#include <QTableView>
#include <splitpanel.h>
namespace Components {
/**
* @brief
*/
class MessageView : public SplitFrame::FnWrap<MessageView, false> {
public:
virtual ~MessageView() = default;
static MessageView *gen(SplitFrame::ViewPresent *host, QStandardItemModel *base);
private:
MessageView(SplitFrame::ViewPresent *ins, QStandardItemModel *base);
QTableView *const ui_present;
QStandardItemModel *const items_present;
static QHash<SplitFrame::ViewPresent *, MessageView *> panel_map;
};
} // namespace Components
#endif // MESSAGEVIEW_H

View File

@ -1,113 +0,0 @@
#ifndef OPSTREAM_H
#define OPSTREAM_H
#include <QList>
#include <functional>
namespace Operate {
template<class ValueType, class TargetType>
class Result
{
public:
Result(QList<ValueType> source, std::function<bool(const ValueType&)> list_filter, std::function<TargetType(const ValueType&)> list_peaks)
: source_store(source), peak_store(list_peaks), filter_store(list_filter){}
virtual ~Result() = default;
virtual QList<TargetType> toList()
{
QList<TargetType> rets_list;
for(auto &it : source_store)
if(filter_store(it))
rets_list << peak_store(it);
return rets_list;
}
template<class Key>
QHash<Key, TargetType> toMap(std::function<Key(ValueType)> key_selector)
{
QHash<Key, TargetType> map;
for(auto &it : source_store)
if(filter_store(it))
map[key_selector(it)] = peak_store(it);
return map;
}
virtual void forEach(std::function<void(TargetType)> ex_proc)
{
auto items = toList();
for(auto &it : items)
ex_proc(it);
}
Result<ValueType, TargetType> filter(std::function<bool(const ValueType&)> filter){
auto filter_combine = [filter, this](const ValueType& it){ return filter(it) && filter_store(it); };
return Result<ValueType, TargetType>(source_store, filter_combine, peak_store);
}
template<class TargetTypeOut>
Result<TargetType, TargetTypeOut> select(std::function<TargetTypeOut(const TargetType&)> peak){
auto peak_combine = [peak, this](const TargetType &it){
auto temp = this->peak_store(it);
return peak(temp);
};
return Result<TargetType, TargetTypeOut>(source_store, filter_store, peak_combine);
}
private:
QList<ValueType> source_store;
std::function<TargetType(const ValueType&)> peak_store;
std::function<bool(const ValueType&)> filter_store;
};
template<class ValueType>
class OpStream
{
public:
/**
* @brief
* @param peak_proc function<V(count, idx)>
*/
OpStream(std::function<ValueType(int &cnt, int idx)> peak_proc)
{
int count = 0;
peak_proc(count, 0);
for (int index = 0; index < count; ++index)
source_store << peak_proc(count, index);
}
/**
* @brief
* @param source
*/
OpStream(QList<ValueType> source)
: source_store(source){}
template<class TargetType>
Result<ValueType, TargetType> select(std::function<TargetType(const ValueType&)> value_selector)
{
return Result<ValueType, TargetType>(source_store, [](const ValueType& it){return true;}, value_selector);
}
Result<ValueType, ValueType> select()
{
return Result<ValueType, ValueType>(source_store, [](const ValueType& it){return true;}, [](const ValueType& it){return it;});
}
Result<ValueType, ValueType> filter(std::function<bool(const ValueType&)> filter)
{
return Result<ValueType, ValueType>(source_store, filter, [](const ValueType& it){ return it; });
}
private:
QList<ValueType> source_store;
};
}
#endif // OPSTREAM_H

View File

@ -1,43 +0,0 @@
#ifndef PRESENTHOSTX_H
#define PRESENTHOSTX_H
#include "manager_docs.h"
#include <QPushButton>
#include <QStackedWidget>
#include <splitpanel.h>
namespace Components {
class WelcomePanel;
/**
* @brief
*/
class PresentContainer : public SplitFrame::FnWrap<PresentContainer, true>, public PresentHost {
Q_OBJECT
public:
PresentContainer(SplitFrame::ViewPresent *host, QWidget *parent = nullptr);
// PresentContainer interface
public:
virtual QWidget *hostWidget() const override;
virtual void append(PresentBase *ins) override;
virtual bool active(const PresentBase *ins) override;
virtual void remove(const PresentBase *ins) override;
virtual bool contains(const PresentBase *ins) const override;
private:
QList<const PresentBase *> items_store;
QComboBox *const title_store;
QStackedWidget *const stack_container;
Components::WelcomePanel *const welcome_list;
QPushButton *const close_btn;
void change_view(int view_index);
void close_current_view();
};
} // namespace Components
#endif // PRESENTHOSTX_H

View File

@ -1,7 +1,8 @@
#include "presentcontainer.h"
#include "presentcontainerview.h"
#include "DocsManager.h"
#include "welcomepanel.h"
#include <QApplication>
#include <QComboBox>
#include <QGridLayout>
#include <QMenu>
@ -10,9 +11,10 @@
using namespace Components;
using namespace Core;
using namespace SplitFrame;
using namespace Presents;
PresentContainer::PresentContainer(ViewPresent *host, QWidget *parent)
: FnWrap<PresentContainer, true>(host, parent),
PresentContainerView::PresentContainerView(ViewPresent *host)
: FnWrap<PresentContainerView, true>(host),
title_store(new QComboBox(this)),
stack_container(new QStackedWidget(this)),
welcome_list(new WelcomePanel(this)),
@ -24,9 +26,11 @@ PresentContainer::PresentContainer(ViewPresent *host, QWidget *parent)
layout->addWidget(title_store, 0, 0, 1, 3);
layout->addWidget(close_btn, 0, 3);
close_btn->setMaximumSize(QSize(30, 30));
close_btn->setEnabled(false);
items_store << welcome_list;
stack_container->addWidget(welcome_list->widget());
layout->addWidget(stack_container, 1, 0, 1, 4);
title_store->addItem(welcome_list->name());
layout->setRowStretch(0, 0);
@ -36,26 +40,29 @@ PresentContainer::PresentContainer(ViewPresent *host, QWidget *parent)
layout->setColumnStretch(2, 1);
layout->setColumnStretch(3, 0);
connect(title_store, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PresentContainer::change_view);
connect(close_btn, &QPushButton::toggled, this, &PresentContainer::close_current_view);
connect(title_store, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PresentContainerView::change_view);
connect(close_btn, &QPushButton::toggled, this, &PresentContainerView::close_current_view);
}
QWidget *PresentContainer::hostWidget() const { return (QWidget *)this; }
QWidget *PresentContainerView::hostWidget() const { return (QWidget *)this; }
#include <libConfig.h>
using namespace Config;
void PresentContainer::append(PresentBase *ins) {
void PresentContainerView::append(FilePresent *ins) {
if (!items_store.contains(ins)) {
items_store.append(ins);
title_store->addItem(ins->name());
ins->widget()->setParent(nullptr);
stack_container->addWidget(ins->widget());
}
throw new SimpleException<bool>("非法操作", "重复添加视图:" + ins->name());
active(ins);
} else
throw new SimpleException<bool>("非法操作", "重复添加视图:" + ins->name());
}
bool PresentContainer::active(const PresentBase *ins) {
#include <QDebug>
bool PresentContainerView::active(const FilePresent *ins) {
if (!items_store.contains(ins))
return false;
@ -66,7 +73,7 @@ bool PresentContainer::active(const PresentBase *ins) {
return true;
}
void PresentContainer::remove(const PresentBase *ins) {
void PresentContainerView::remove(const FilePresent *ins) {
if (!items_store.contains(ins))
return;
@ -76,7 +83,7 @@ void PresentContainer::remove(const PresentBase *ins) {
stack_container->removeWidget(ins->widget());
}
bool PresentContainer::contains(const PresentBase *ins) const {
bool PresentContainerView::contains(const FilePresent *ins) const {
for (auto &insit : items_store) {
if (insit == ins)
return true;
@ -84,7 +91,14 @@ bool PresentContainer::contains(const PresentBase *ins) const {
return false;
}
void PresentContainer::change_view(int view_index) {
bool PresentContainerView::avaliable(FilePresent *vins) {
auto global_test = QApplication::activeWindow();
if (!global_test)
return true;
return this->isActiveWindow();
}
void PresentContainerView::change_view(int view_index) {
auto view_inst = items_store[view_index];
active(view_inst);
@ -92,7 +106,7 @@ void PresentContainer::change_view(int view_index) {
}
#include <QMessageBox>
void PresentContainer::close_current_view() {
void PresentContainerView::close_current_view() {
auto index = title_store->currentIndex();
const_cast<PresentBase *>(items_store[index])->beforeClose();
const_cast<FilePresent *>(items_store[index])->beforeClose();
}

View File

@ -0,0 +1,49 @@
#ifndef PRESENTCONTAINERVIEW_H
#define PRESENTCONTAINERVIEW_H
#include "manager_docs.h"
#include <QComboBox>
#include <QPushButton>
#include <QStackedLayout>
#include <QStackedWidget>
#include <splitpanel.h>
namespace Presents {
class WelcomePanel;
}
namespace Components {
/**
* @brief
*/
class PresentContainerView : public SplitFrame::FnWrap<PresentContainerView, true>, public Presents::PresentHost {
Q_OBJECT
public:
PresentContainerView(SplitFrame::ViewPresent *host);
// PresentContainer interface
public:
virtual QWidget *hostWidget() const override;
virtual void append(Presents::FilePresent *ins) override;
virtual bool active(const Presents::FilePresent *ins) override;
virtual void remove(const Presents::FilePresent *ins) override;
virtual bool contains(const Presents::FilePresent *ins) const override;
virtual bool avaliable(Presents::FilePresent *vins) override;
private:
QList<const Presents::FilePresent *> items_store;
QComboBox *const title_store;
QStackedWidget *const stack_container;
Presents::WelcomePanel *const welcome_list;
QPushButton *const close_btn;
void change_view(int view_index);
void close_current_view();
};
} // namespace Components
#endif // PRESENTCONTAINERVIEW_H

View File

@ -1,4 +1,4 @@
#include "projectpresent.h"
#include "projectview.h"
#include "command_list.h"
#include <QInputDialog>
@ -11,25 +11,26 @@ using namespace Schedule;
using namespace SplitFrame;
using namespace Core;
ProjectPresent::ProjectPresent(ViewPresent *host, CommandsDispatcher *core, Core::DocumentsManager *mgr, QWidget *parent)
: FnWrap<ProjectPresent, false>(host, parent), project_manager(mgr), source(core), view_present(new QTreeView(this)) {
ProjectView::ProjectView(ViewPresent *host, CommandsDispatcher *core, Core::DocumentsManager *mgr)
: FnWrap<ProjectView, false>(host), project_manager(mgr), source(core), view_present(new QTreeView(this)) {
auto layout = new QVBoxLayout(this);
layout->addWidget(view_present);
layout->setMargin(1);
view_present->setModel(mgr->projectManager()->model());
view_present->setHeaderHidden(true);
view_present->setMouseTracking(true);
view_present->setContextMenuPolicy(Qt::CustomContextMenu);
connect(view_present, &QTreeView::customContextMenuRequested,
this, &ProjectPresent::menu_popup);
this, &ProjectView::menu_popup);
connect(view_present, &QTreeView::doubleClicked,
this, &ProjectPresent::open_target);
this, &ProjectView::open_target);
}
QModelIndex ProjectPresent::currentIndex() const { return view_present->currentIndex(); }
QModelIndex ProjectView::currentIndex() const { return view_present->currentIndex(); }
void ProjectPresent::menu_popup(const QPoint &p)
void ProjectView::menu_popup(const QPoint &p)
{
QMenu m;
m.addAction("新建路径", [this](){
@ -54,18 +55,18 @@ void ProjectPresent::menu_popup(const QPoint &p)
}
m.addSeparator();
m.addAction("移除节点");
m.addAction("移除节点", [&index, this]() { source->postCommand(DeleteTarget(index)); });
}
m.exec(mapToGlobal(p));
}
void ProjectPresent::open_target(const QModelIndex &t)
void ProjectView::open_target(const QModelIndex &t)
{
auto mgr = source->get<DocumentsManager>(NAME(DocumentsManager));
auto path = mgr->convertPath(t);
source->postCommand(OpenFile(path));
}
void ProjectPresent::closeProcess() { project_manager->save(); }
void ProjectView::closeProcess() { project_manager->save(); }

View File

@ -1,5 +1,5 @@
#ifndef PROJECTPRESENT_H
#define PROJECTPRESENT_H
#ifndef PROJECTVIEW_H
#define PROJECTVIEW_H
#include "DocsManager.h"
#include "manager_docs.h"
@ -14,11 +14,10 @@ namespace Components {
/**
* @brief
*/
class ProjectPresent : public SplitFrame::FnWrap<ProjectPresent, false> {
class ProjectView : public SplitFrame::FnWrap<ProjectView, false> {
Q_OBJECT
public:
explicit ProjectPresent(SplitFrame::ViewPresent *host, Schedule::CommandsDispatcher *core, Core::DocumentsManager *mgr,
QWidget *parent = nullptr);
explicit ProjectView(SplitFrame::ViewPresent *host, Schedule::CommandsDispatcher *core, Core::DocumentsManager *mgr);
QModelIndex currentIndex() const;
@ -36,5 +35,4 @@ namespace Components {
};
}
#endif // PROJECTPRESENT_H
#endif // PROJECTVIEW_H

View File

@ -3,12 +3,28 @@
#include <QComboBox>
#include <QFont>
#include <QGridLayout>
#include <QLabel>
#include <QMenu>
#include <QPushButton>
#include <QSpinBox>
#include <QTextStream>
#include <libConfig.h>
using namespace Components;
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;
using namespace Config;
@ -30,7 +46,7 @@ void DefaultTextEdit::beforeClose() { mgr_inst->save(); }
DocumentsManager *DefaultTextEdit::docsManager() const { return mgr_inst; }
void DefaultTextEdit::applySetting(const QString &name) { name_store = name; }
void DefaultTextEdit::applySetting(const QString &name, const Configration *cfg) { name_store = name; }
QString DefaultTextEdit::name() const
{
@ -60,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");
@ -95,3 +111,13 @@ void DefaultTextEditFactory::create(const QFileInfo &target) {
base_f.flush();
base_f.close();
}
QDialog *DefaultTextEditFactory::createTempConfigPanel(Config::Configration *cfg_port) {
auto panel = new QDialog();
panel->setWindowTitle("文本编辑器配置");
auto layout = new QGridLayout(panel);
layout->addWidget(new QLabel("选择字体", panel));
layout->addWidget(new QPushButton("选择字体", panel));
return panel;
}

View File

@ -4,15 +4,16 @@
#include "DocsManager.h"
#include <QSyntaxHighlighter>
#include <QDialog>
#include <QFileInfo>
#include <QTextEdit>
namespace Components {
namespace Presents {
/**
* @brief Text默认文本编辑视图
*/
class DefaultTextEdit : public Components::FilePresent {
class DefaultTextEdit : public Presents::FilePresent {
DECL_PRESENT(DefaultTextEdit);
public:
@ -30,7 +31,7 @@ namespace Components {
// FilePresent interface
public:
virtual QWidget *widget() const override;
virtual void applySetting(const QString &name) override;
virtual void applySetting(const QString &name, const Config::Configration *cfg) override;
virtual QString name() const override;
virtual void load(const QFileInfo &target_file) override;
virtual void saveAs(const QString &path) override;
@ -46,14 +47,18 @@ namespace Components {
virtual Core::DocumentsManager *docsManager() const override;
};
class DefaultTextEditFactory : public Components::TypedPresentFactory<DefaultTextEdit> {
class DefaultTextEditFactory : public Presents::TypedPresentFactory<DefaultTextEdit> {
public:
virtual ~DefaultTextEditFactory() = default;
void setPresentFont(Config::Configration *ptr, const QFont &appoint);
QFont getPresentFont(Config::Configration *ptr) const;
// PresentFactory interface
public:
virtual void create(const QFileInfo &target) override;
virtual QDialog *createTempConfigPanel(Config::Configration *cfg_port) override;
};
} // namespace Components
} // namespace Presents
#endif // SRCEDIT_DEFAULTTEXT_H

View File

@ -6,16 +6,15 @@
#include <QTextStream>
#include <QVBoxLayout>
using namespace Components;
using namespace Enhancement;
using namespace Core;
using namespace Config;
using namespace Presents;
QString StorySourceEdit::file_suffix = "storyboard";
StorySourceEdit::StorySourceEdit(DocumentsManager *mgr, const Route &p, QObject *parent)
: FilePresent(parent), mgr_inst(mgr), path_store(p), edit_square(new QTextEdit) {
// words_highlighter->setDocument(this->edit_square->document());
connect(edit_square, &QTextEdit::textChanged, [this](){
emit this->dataChanged(filepath_store);
});
@ -84,7 +83,7 @@ bool StorySourceEdit::isModified() const
return true;
}
void StorySourceEdit::applySetting(const QString &name) { this->name_store = name; }
void StorySourceEdit::applySetting(const QString &name, const Configration *cfg) { this->name_store = name; }
void StorySourceEdit::jumpTo(const QList<QString> &path) {
// auto fpath = this->absoluteTargetPath();
@ -120,3 +119,5 @@ void StorySourceEditFactory::create(const QFileInfo &target) {
base_f.flush();
base_f.close();
}
QDialog *StorySourceEditFactory::createTempConfigPanel(Config::Configration *cfg_port) { return nullptr; }

View File

@ -5,9 +5,8 @@
#include "keywordshighlighter.h"
#include <QTextEdit>
#include <docsManager.h>
namespace Components {
namespace Presents {
class StorySourceEdit : public FilePresent, public Enhancement::HighlightFeature {
DECL_PRESENT(StorySourceEdit);
@ -38,20 +37,21 @@ namespace Components {
virtual QString relativeTargetPath(const QDir &base) const override;
virtual QString absoluteTargetPath() const override;
virtual bool isModified() const override;
virtual void applySetting(const QString &name) override;
virtual void applySetting(const QString &name, const Config::Configration *cfg) override;
virtual void jumpTo(const QList<QString> &path) override;
virtual void beforeClose() override;
virtual Core::DocumentsManager *docsManager() const override;
virtual Core::Route accessPath() const override;
};
class StorySourceEditFactory : public TypedPresentFactory<StorySourceEdit> {
class StorySourceEditFactory : public Presents::TypedPresentFactory<StorySourceEdit> {
// PresentFactory interface
public:
virtual void create(const QFileInfo &target) override;
virtual QDialog *createTempConfigPanel(Config::Configration *cfg_port) override;
};
} // namespace Components
} // namespace Presents
#endif // SRCEDIT_STORYBOARD_H

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 "opstream.h"
#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

@ -1,16 +1,19 @@
#include "viewsession.h"
#include "messagespresent.h"
#include "presentcontainer.h"
#include "projectpresent.h"
#include "mainwindow.h"
#include "messageview.h"
#include "presentcontainerview.h"
#include "projectview.h"
using namespace Config;
using namespace Core;
using namespace SplitFrame;
using namespace Components;
ViewSession::ViewSession(Config::Configration *port, ViewPresent *host) : host(host), recover_port(port) {}
ViewSession::ViewSession(Config::Configration *port, MainWindow *host) : host(host->bindPresent()), recover_port(port) {
base_path = {"sys-config", "front-end", host->layoutName(), "view-state"};
}
void ViewSession::initPresentView(PresentContainer *center_frame, ProjectPresent *project_present, QStandardItemModel *error_model) {
void ViewSession::initPresentView(PresentContainerView *center_frame, ProjectView *project_present, QStandardItemModel *error_model) {
split_infos.clear();
auto project_panel = host->appendView(project_present, QIcon(":/ui/icons/dir_icon.jpg"), tr("项目管理"));
@ -20,13 +23,12 @@ void ViewSession::initPresentView(PresentContainer *center_frame, ProjectPresent
edit_panel = host->appendView(center_frame, QIcon(":/ui/icons/file_icon.jpg"), tr("编辑窗口"));
view_store[edit_panel->title()] = edit_panel;
auto msg_view = MessagesPresent::gen(host, error_model, host->bind());
auto msg_view = MessageView::gen(host, error_model);
auto msg_panel = host->appendView(msg_view, QIcon(":/ui/icons/file_icon.jpg"), "信息提示");
host->markFreedom(msg_panel);
view_store[msg_panel->title()] = msg_panel;
}
const QList<QString> base_path = {"sys-config", "front-end", "view-state"};
void views_state_store(Config::Configration *port, const QList<QString> &base_path, const QList<RectCom *> &child) {
for (auto &it : child) {
if (!it)

View File

@ -1,27 +1,30 @@
#ifndef VIEWSESSION_H
#define VIEWSESSION_H
#include "projectpresent.h"
#include "projectview.h"
#include <QList>
#include <QMainWindow>
#include <QStandardItemModel>
#include <libConfig.h>
#include <presentcontainer.h>
#include <presentcontainerview.h>
#include <splitpanel.h>
class MainWindow;
namespace Core {
class ViewSession : public QObject {
Q_OBJECT
public:
ViewSession(Config::Configration *port, SplitFrame::ViewPresent *host);
ViewSession(Config::Configration *port, MainWindow *host);
void initPresentView(Components::PresentContainer *center_frame, Components::ProjectPresent *project_present, QStandardItemModel *model);
void initPresentView(Components::PresentContainerView *center_frame, Components::ProjectView *project_present, QStandardItemModel *model);
void viewStatesSave(QMainWindow *win, SplitFrame::ViewPresent *root);
void viewStatesRestore(QMainWindow *win, SplitFrame::ViewPresent *root);
private:
QList<QString> base_path;
SplitFrame::ViewPresent *host;
SplitFrame::RectCom *edit_panel = nullptr;
Config::Configration *const recover_port;

View File

@ -1,10 +1,17 @@
#include "welcomepanel.h"
using namespace Components;
#include <QPainter>
using namespace Core;
using namespace Presents;
WelcomePanel::WelcomePanel(QWidget *parent) : QWidget(parent) {}
void WelcomePanel::paintEvent(QPaintEvent *event) {
QPainter p(this);
p.fillRect(this->rect(), Qt::green);
}
QWidget *WelcomePanel::widget() const { return (QWidget *)this; }
QString WelcomePanel::name() const { return "WelcomePanel"; }
@ -12,3 +19,19 @@ QString WelcomePanel::name() const { return "WelcomePanel"; }
void WelcomePanel::beforeClose() {}
DocumentsManager *WelcomePanel::docsManager() const { return nullptr; }
Route WelcomePanel::accessPath() const { return Route(); }
void WelcomePanel::applySetting(const QString &name, const Config::Configration *cfg) {}
void WelcomePanel::load(const QFileInfo &target_file) {}
void WelcomePanel::saveAs(const QString &path) {}
QString WelcomePanel::relativeTargetPath(const QDir &base) const { return ""; }
QString WelcomePanel::absoluteTargetPath() const { return ""; }
bool WelcomePanel::isModified() const { return false; }
void WelcomePanel::jumpTo(const QList<QString> &path) {}

View File

@ -5,20 +5,32 @@
#include <QWidget>
namespace Components {
namespace Presents {
class WelcomePanel : public QWidget, public Components::PresentBase {
class WelcomePanel : public QWidget, public FilePresent {
public:
WelcomePanel(QWidget *parent = nullptr);
// PresentBase interface
protected:
virtual void paintEvent(QPaintEvent *event) override;
// FilePresent interface
public:
virtual QWidget *widget() const override;
virtual QString name() const override;
virtual void beforeClose() override;
virtual Core::DocumentsManager *docsManager() const override;
virtual Core::Route accessPath() const override;
virtual void applySetting(const QString &name, const Config::Configration *cfg) override;
virtual void load(const QFileInfo &target_file) override;
virtual void saveAs(const QString &path) override;
virtual QString relativeTargetPath(const QDir &base) const override;
virtual QString absoluteTargetPath() const override;
virtual bool isModified() const override;
virtual void jumpTo(const QList<QString> &path) override;
};
} // namespace Components
} // namespace Presents
#endif // WELCOMEPANEL_H

View File

@ -1,12 +1,27 @@
#include "xapp.h"
#include "command_list.h"
#include <QDebug>
#include <iostream>
#include <xmlconfig.h>
#include <xmlprojectmanager.h>
using namespace Schedule;
using namespace Config;
using namespace bridge;
using namespace Core;
using namespace Project;
XApp::XApp(int argc, char **argv) : QApplication(argc, argv) { global_configration->loadFile("./software.config"); }
XApp::XApp(int argc, char **argv)
: QApplication(argc, argv),
parse_service(new ParseBridge()),
project_manager(new XMLProjectManager(this)),
active_docscollect(new DocumentsManager(this)) {
gconfig->loadFile("./software.config");
init_commands(disp_core);
XApp::disp_core->registerMember(active_docscollect);
}
bool XApp::notify(QObject *receiver, QEvent *event) {
try {
@ -19,5 +34,24 @@ bool XApp::notify(QObject *receiver, QEvent *event) {
return false;
}
CommandsDispatcher *const XApp::disp_core = new CommandsDispatcher(QDir::home(), true);
Configration *const XApp::global_configration = new XMLConfig();
ParseBridge *XApp::parseService() const { return parse_service; }
ProjectManager *XApp::pjtManager() const { return project_manager; }
DocumentsManager *XApp::docsManager() const { return active_docscollect; }
using namespace CommandList;
void XApp::init_commands(Schedule::CommandsDispatcher *host) {
host->registerCommand(new CloseProject());
host->registerCommand(new NewFile(Route(), "", "txt"));
host->registerCommand(new NewPackage(""));
host->registerCommand(new NewProject(QDir(), ""));
host->registerCommand(new OpenFile(Route()));
host->registerCommand(new OpenProject(""));
host->registerCommand(new SaveAll());
host->registerCommand(new DeleteTarget(Route()));
}
CommandsDispatcher *const XApp::disp_core = new CommandsDispatcher(QDir("./"), true);
Configration *const XApp::gconfig = new XMLConfig();

View File

@ -1,9 +1,13 @@
#ifndef XAPPLICATION_H
#define XAPPLICATION_H
#include "manager_docs.h"
#include "parsebridge.h"
#include <QApplication>
#include <commandsdispatcher.h>
#include <libConfig.h>
#include <libProjectManager.h>
class XApp : public QApplication {
public:
@ -11,9 +15,20 @@ class XApp : public QApplication {
virtual bool notify(QObject *receiver, QEvent *event);
public:
bridge::ParseBridge *parseService() const;
Project::ProjectManager *pjtManager() const;
Core::DocumentsManager *docsManager() const;
public:
static Schedule::CommandsDispatcher *const disp_core;
static Config::Configration *const global_configration;
static Config::Configration *const gconfig;
private:
bridge::ParseBridge *const parse_service;
Project::ProjectManager *const project_manager;
Core::DocumentsManager *const active_docscollect;
void init_commands(Schedule::CommandsDispatcher *core);
};
#endif // XAPPLICATION_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();
}
@ -113,13 +113,11 @@ void XMLConfig::setList(const QList<QString> &path, const QList<QString> &list)
{
auto root = doc_ins.documentElement();
auto telm = rebuild_exists_elms(root, path);
auto childs = telm.childNodes();
auto childs = telm.elementsByTagName("list");
for(auto idx= 0; idx<childs.count(); ++idx){
for (auto idx = childs.count() - 1; idx >= 0; --idx) {
auto node = childs.at(idx);
if(node.isElement() && node.toElement().tagName() == "list")
telm.removeChild(node);
telm.removeChild(node);
}
for(auto &it : list){
@ -150,13 +148,11 @@ void XMLConfig::setMap(const QList<QString> &path, const QHash<QString, QString>
{
auto root = doc_ins.documentElement();
auto telm = rebuild_exists_elms(root, path);
auto childs = telm.childNodes();
auto childs = telm.elementsByTagName("list");
QList<QDomNode> nodes;
for(auto idx=0; idx<childs.count(); ++idx){
auto child = childs.at(idx);
if(child.isElement() && child.toElement().tagName() == "map")
telm.removeChild(child);
for (auto idx = childs.count() - 1; idx >= 0; --idx) {
auto node = childs.at(idx);
telm.removeChild(node);
}
for(auto &key : map.keys()){

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

@ -75,12 +75,14 @@ void DragHeader::mouseMoveEvent(QMouseEvent *event) {
}
}
BaseView::BaseView(const QString &title, QWidget *view, bool empty, QWidget *parent) : QWidget(parent), title_header(nullptr), parent_store(nullptr) {
BaseView::BaseView(const QString &title, QWidget *view, bool empty, bool replaceable, QWidget *parent)
: QWidget(parent), replace_able(replaceable), title_header(nullptr), parent_store(nullptr) {
auto layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
registElement(this);
setCursor(Qt::CursorShape::ArrowCursor);
if (!empty) {
title_header = new DragHeader(this);
@ -115,14 +117,18 @@ void BaseView::setIcon(const QIcon &icon) {
QIcon BaseView::viewIcon() const { return this->icon_store; }
bool BaseView::canReplace() const { return replace_able; }
void BaseView::registElement(QWidget *child) {
if (this->comps_list.contains(child))
return;
comps_list << child;
if (child != this)
child->setMouseTracking(true);
if (child != this) {
child->setParent(this);
}
}
ViewPresent *BaseView::viewPanel() const {

View File

@ -42,7 +42,7 @@ namespace SplitFrame {
friend class ViewPresent;
public:
BaseView(const QString &title, QWidget *view, bool empty = false, QWidget *parent = nullptr);
BaseView(const QString &title, QWidget *view, bool empty = false, bool replaceable = false, QWidget *parent = nullptr);
virtual ~BaseView();
virtual void setTitle(const QString &title);
@ -51,6 +51,7 @@ namespace SplitFrame {
virtual void setIcon(const QIcon &icon);
virtual QIcon viewIcon() const;
virtual bool canReplace() const override;
virtual bool contains(QWidget *inst) const override;
// ViewRes interface
@ -70,6 +71,7 @@ namespace SplitFrame {
virtual void paintEvent(QPaintEvent *ev) override;
private:
bool replace_able;
QIcon icon_store;
QString title_store;
DragHeader *title_header;

View File

@ -77,7 +77,8 @@ void AttachPanel::paintEvent(QPaintEvent *event) {
p.fillRect(QRectF(rect.center() - QPointF(rect.width() / 2, 0), QSizeF(rect.width(), rect.height() / 2)), Qt::gray);
break;
case ActiveArea::CENTER:
p.fillRect(rect, Qt::gray);
if (attachmentTarget()->canReplace())
p.fillRect(rect, Qt::gray);
break;
default:
break;
@ -92,7 +93,8 @@ void AttachPanel::paintEvent(QPaintEvent *event) {
rects << std::get<1>(x_views);
rects << std::get<2>(x_views);
rects << std::get<3>(x_views);
rects << std::get<4>(x_views);
if (attachmentTarget()->canReplace())
rects << std::get<4>(x_views);
p.drawRects(rects);
}
@ -135,41 +137,44 @@ void AttachPanel::dropEvent(QDropEvent *event) {
auto target = this->attachmentTarget();
if (target != xfrom && active_comp != ActiveArea::NONE) {
static_cast<SplitRect *>(xfrom->parentRes())->removeComp(xfrom);
adjust_host->objsRelateRebuild();
if (active_comp == ActiveArea::CENTER && !target->canReplace()) {
} else {
static_cast<SplitRect *>(xfrom->parentRes())->removeComp(xfrom);
adjust_host->objsRelateRebuild();
auto ptarget = static_cast<SplitRect *>(target->parentRes());
auto target_rect = target->outline();
auto ptarget = static_cast<SplitRect *>(target->parentRes());
auto target_rect = target->outline();
RectCom *new_split = nullptr;
switch (this->active_comp) {
case ActiveArea::LEFT: {
new_split = new SplitView(xfrom, target, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::RIGHT: {
new_split = new SplitView(target, xfrom, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::TOP: {
new_split = new SplitView(xfrom, target, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::BOTTOM: {
new_split = new SplitView(target, xfrom, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::CENTER: {
new_split = xfrom;
adjust_host->markFreedom(target);
} break;
default:
return;
RectCom *new_split = nullptr;
switch (this->active_comp) {
case ActiveArea::LEFT: {
new_split = new SplitView(xfrom, target, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::RIGHT: {
new_split = new SplitView(target, xfrom, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::TOP: {
new_split = new SplitView(xfrom, target, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::BOTTOM: {
new_split = new SplitView(target, xfrom, adjust_host->bind());
static_cast<SplitView *>(new_split)->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, adjust_host->splitterWidth(), false);
} break;
case ActiveArea::CENTER: {
new_split = xfrom;
adjust_host->markFreedom(target);
} break;
default:
return;
}
ptarget->replaceComp(new_split, target);
new_split->relayout(target_rect);
adjust_host->objsRelateRebuild();
}
ptarget->replaceComp(new_split, target);
new_split->relayout(target_rect);
adjust_host->objsRelateRebuild();
}
adjust_host->setAdjustView();
@ -414,6 +419,8 @@ void ViewPresent::relayout(const QRectF &outline) {
QString ViewPresent::title() const { return ""; }
bool ViewPresent::canReplace() const { return true; }
void ViewPresent::pRelease() { throw new SimpleException<bool>("非法操作", "不允许对ViewPanel调用pRelease"); }
void ViewPresent::pClose() { throw new SimpleException<bool>("非法操作", "不允许对ViewPanel调用pClose"); }
@ -479,46 +486,9 @@ void ViewPresent::resizeEvent(QResizeEvent *ev) {
QWidget::resizeEvent(ev);
relayout();
}
void ViewPresent::mousePressEvent(QMouseEvent *event) {
QWidget::mousePressEvent(event);
if (event->button() == Qt::MouseButton::LeftButton) {
if (handle_rect().contains(event->pos()))
this->press_flags = true;
}
}
void ViewPresent::mouseReleaseEvent(QMouseEvent *event) {
QWidget::mouseReleaseEvent(event);
if (event->button() == Qt::MouseButton::LeftButton) {
this->press_flags = false;
}
}
void ViewPresent::mouseMoveEvent(QMouseEvent *event) {
QWidget::mouseMoveEvent(event);
auto drag_rect = handle_rect();
if (drag_rect.contains(event->pos())) {
if (splitType() == SplitType::SPLIT_H)
setCursor(QCursor(Qt::CursorShape::SplitHCursor));
else
setCursor(QCursor(Qt::CursorShape::SplitVCursor));
} else {
setCursor(QCursor(Qt::CursorShape::ArrowCursor));
}
if (this->press_flags) {
auto pos = this->mapFromGlobal(event->globalPos());
auto split_margin = splitterWidth();
if (std::get<0>(split_info_store) == SplitType::SPLIT_H) {
setSplitInfo(splitType(), pos.x() - split_margin / 2, split_margin, true);
} else {
setSplitInfo(splitType(), pos.y() - split_margin / 2, split_margin, true);
}
update();
}
}
void ViewPresent::mousePressEvent(QMouseEvent *event) { QWidget::mousePressEvent(event); }
void ViewPresent::mouseReleaseEvent(QMouseEvent *event) { QWidget::mouseReleaseEvent(event); }
void ViewPresent::mouseMoveEvent(QMouseEvent *event) { QWidget::mouseMoveEvent(event); }
void ViewPresent::relayout() {
if (display_members) {
@ -549,53 +519,12 @@ void ViewPresent::relayout() {
update();
}
std::pair<QRectF, QRectF> ViewPresent::view_rects() {
auto xrect = this->rect();
auto type = (int)splitType();
if (!type) {
auto width0 = splitterPos();
if (width0 + splitterWidth() > xrect.width())
width0 = xrect.width() - splitterWidth();
if (width0 < 0)
width0 = 0;
RectCom *ViewPresent::create_base_panel(QWidget *bview, const QIcon &icon, const QString &title, bool empty_flag, bool replace_flag) {
auto vinst = new BaseView(title, bview, empty_flag, replace_flag);
bview->setParent(vinst);
setSplitInfo(splitType(), width0, splitterWidth(), false);
auto rect0 = QRectF(xrect.topLeft(), QSizeF(width0, xrect.height()));
auto rect1 = QRectF(xrect.topLeft() + QPointF(rect0.width() + splitterWidth(), 0),
QSizeF(xrect.width() - rect0.width() - splitterWidth(), xrect.height()));
return std::make_pair(rect0, rect1);
} else {
auto height0 = splitterPos();
if (height0 + splitterWidth() > xrect.height())
height0 = xrect.height() - splitterWidth();
if (height0 < 0)
height0 = 0;
setSplitInfo(splitType(), height0, splitterWidth(), false);
auto rect0 = QRectF(xrect.topLeft(), QSizeF(xrect.width(), height0));
auto rect1 = QRectF(xrect.topLeft() + QPointF(0, rect0.height() + splitterWidth()),
QSizeF(xrect.width(), xrect.height() - splitterWidth() - rect0.height()));
return std::make_pair(rect0, rect1);
}
}
QRectF ViewPresent::handle_rect() const {
QRectF rect;
auto width_middle = splitterWidth() - 2;
if (splitType() == SplitType::SPLIT_H) {
rect = QRectF(splitterPos() + 1, 0, width_middle, outline().height());
} else {
rect = QRectF(0, splitterPos() + 1, outline().width(), width_middle);
}
return rect;
}
RectCom *ViewPresent::create_base_panel(QWidget *bview, const QIcon &icon, const QString &title, bool empty_flag) {
auto vinst = new BaseView(title, bview, empty_flag);
bview->setMouseTracking(true);
vinst->setTitle(title);
vinst->setIcon(icon);
return vinst;

View File

@ -65,6 +65,7 @@ namespace SplitFrame {
public:
virtual ~RectCom() = default;
virtual bool canReplace() const = 0;
virtual bool contains(QWidget *ptr) const = 0;
virtual QRectF outline() const = 0;
@ -82,7 +83,7 @@ namespace SplitFrame {
ViewPresent *const host_store;
public:
explicit FnWrap(ViewPresent *bind, QWidget *parent = nullptr) : QWidget(parent), host_store(bind) {}
explicit FnWrap(ViewPresent *bind) : QWidget(), host_store(bind) {}
virtual ~FnWrap() { this->closeProcess(); }
ViewPresent *bindHost() const { return host_store; }
@ -153,7 +154,7 @@ namespace SplitFrame {
if (view_inst->bindHost() != this)
throw new Config::SimpleException<QString>("非法操作", "不允许混用不同ViewPresent的成员");
auto panel = create_base_panel(view_inst, icon, title, _blank);
auto panel = create_base_panel(view_inst, icon, title, _blank, !_blank);
regist_basepanel(panel);
return panel;
@ -166,6 +167,7 @@ namespace SplitFrame {
virtual QRectF outline() const override;
virtual void relayout(const QRectF &outline) override;
virtual QString title() const override;
virtual bool canReplace() const override;
// ViewRes interface
public:
@ -209,9 +211,8 @@ namespace SplitFrame {
AttachPanel *const accept_panel;
// 拖拽属性===================================
RectCom *adjust_view_temp; // 拖拽中转
bool press_flags = false; // 空间调整标志
// 方向splitter位置splitter宽度
RectCom *adjust_view_temp; // 拖拽中转
// 方向splitter位置splitter宽度
std::tuple<SplitType, float, float> split_info_store = std::make_tuple(SplitType::SPLIT_H, 200, 8);
// 视图展现堆栈===============================
@ -221,11 +222,8 @@ namespace SplitFrame {
std::pair<DockType, RectCom *> temp_visible_view = std::make_pair(DockType::LEFT, nullptr);
std::pair<QRectF, QRectF> view_rects();
QRectF handle_rect() const;
virtual void relayout();
RectCom *create_base_panel(QWidget *bview, const QIcon &icon, const QString &title, bool empty_flag = false);
RectCom *create_base_panel(QWidget *bview, const QIcon &icon, const QString &title, bool empty_flag = false, bool replace_flag = true);
void regist_basepanel(RectCom *it);
};

View File

@ -53,6 +53,12 @@ SplitType SplitView::splitType() const { return std::get<0>(split_info_value); }
void SplitView::setSplitInfo(SplitType type, float pos, float width, bool relayout) {
this->split_info_value = std::make_tuple(type, pos, width);
if (type == SplitType::SPLIT_H)
setCursor(Qt::CursorShape::SplitHCursor);
else
setCursor(Qt::CursorShape::SplitVCursor);
if (relayout)
this->relayout();
}
@ -110,6 +116,8 @@ bool SplitView::contains(QWidget *) const { return false; }
QString SplitView::title() const { return ""; }
bool SplitView::canReplace() const { return true; }
void SplitView::resizeEvent(QResizeEvent *ev) {
QWidget::resizeEvent(ev);
relayout();
@ -120,7 +128,7 @@ void SplitView::mousePressEvent(QMouseEvent *event) {
if (event->button() == Qt::MouseButton::LeftButton) {
if (handle_rect().contains(event->pos()))
this->press_flags = true;
drags_state = true;
}
}
@ -128,26 +136,14 @@ void SplitView::mouseReleaseEvent(QMouseEvent *event) {
QWidget::mouseReleaseEvent(event);
if (event->button() == Qt::MouseButton::LeftButton) {
this->press_flags = false;
drags_state = false;
}
}
void SplitView::mouseMoveEvent(QMouseEvent *event) {
QWidget::mouseMoveEvent(event);
auto drag_rect = handle_rect() + QMargins(2, 2, 2, 2);
if (drag_rect.contains(event->pos())) {
if (splitType() == SplitType::SPLIT_H)
setCursor(QCursor(Qt::CursorShape::SplitHCursor));
else
setCursor(QCursor(Qt::CursorShape::SplitVCursor));
drags_flag = true;
} else {
setCursor(QCursor(Qt::CursorShape::ArrowCursor));
}
if (this->press_flags) {
if (drags_state) {
auto pos = this->mapFromGlobal(event->globalPos());
auto split_margin = splitterWidth();
if (std::get<0>(split_info_value) == SplitType::SPLIT_H) {
@ -159,20 +155,6 @@ void SplitView::mouseMoveEvent(QMouseEvent *event) {
}
}
bool SplitView::eventFilter(QObject *watched, QEvent *event) {
if (watched != this && this->drags_flag && event->type() == QEvent::MouseMove) {
auto x = static_cast<QMouseEvent *>(event);
auto pos = mapFromGlobal(x->globalPos());
if (!handle_rect().contains(pos)) {
setCursor(QCursor(Qt::CursorShape::ArrowCursor));
this->drags_flag = false;
}
return true;
}
return QWidget::eventFilter(watched, event);
}
void SplitView::relayout() {
auto rects = view_rects();
auto pair = child();

View File

@ -31,6 +31,7 @@ namespace SplitFrame {
virtual void paintEvent(QPaintEvent *ev) override;
virtual bool contains(QWidget *) const override;
virtual QString title() const override;
virtual bool canReplace() const override;
// SplitRect interface
public:
@ -42,10 +43,6 @@ namespace SplitFrame {
virtual SplitType splitType() const override;
virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override;
// QObject interface
public:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
// QWidget interface
protected:
virtual void mousePressEvent(QMouseEvent *event) override;
@ -58,7 +55,7 @@ namespace SplitFrame {
QList<RectCom *> child_store;
// type, pos, width
std::tuple<SplitType, float, float> split_info_value;
bool press_flags = false, drags_flag = false;
bool drags_state = false;
virtual void relayout();
std::pair<QRectF, QRectF> view_rects();

View File

@ -0,0 +1,24 @@
#include "blockdatas.h"
using namespace PresentDatas;
DisplayGroup::DisplayGroup(const QString &uid) : SpecificEntityData(EntityType::DISPLAY_GROUP, uid) {}
QString DisplayGroup::styledText() const {
QString retvs = QString("<group id='%1'>\n").arg(this->uID());
for (auto &i : children())
retvs += i->styledText();
retvs += "</group>\n";
return retvs;
}
QString DisplayGroup::plainText() const {
QString retvs = "";
for (auto &i : children())
retvs += i->plainText();
retvs += "\n";
return retvs;
}
TextRange::TextRange(const QString &uid) : SpecificEntityData(EntityType::TEXT_RANGE, uid) {}

46
libTextEdit/blockdatas.h Normal file
View File

@ -0,0 +1,46 @@
#ifndef BLOCKDATAS_H
#define BLOCKDATAS_H
#include "entitydata.h"
namespace PresentDatas {
/* enum class EntityType {
TEXT_RANGE, // 字符集合,包含段落和句子
IMAGE_CUBE, // 图片展示块
HREF_FRAGS, // 超链接
TABLE_VIEW, // 表格视图
LIST_VIEW, // 列表视图
INTERACTIVE_EXTENSION, // 交互式拓展插件视图
DISPLAY_GROUP, // 元素混合组织成包
DOCUMENT_ENTITY
};*/
class DisplayGroup : public SpecificEntityData {
public:
DisplayGroup(const QString &uid);
public:
// EntityData interface
public:
virtual QString styledText() const override;
virtual QString plainText() const override;
};
class TextRange : public SpecificEntityData {
public:
TextRange(const QString &uid);
void setStyledText(const QString &content);
void setPlainText(const QString &content);
// EntityData interface
public:
virtual QString styledText() const override;
virtual QString plainText() const override;
private:
};
} // namespace PresentDatas
#endif // BLOCKDATAS_H

View File

@ -0,0 +1,97 @@
#include "entitydata.h"
#include <QList>
using namespace PresentDatas;
SpecificEntityData::SpecificEntityData(EntityType type, const QString &uid) : type_store(type), document_id(uid) {
visible_bool = true;
oritation_store = MemberOri::H_LEFT_TO_RIGHT;
}
void SpecificEntityData::resetContentLayout(MemberOri oritation, MemberType child_type) {
this->oritation_store = oritation;
this->layout_type = child_type;
this->layout_type = MemberType::BLOCKS;
this->anchor_info = std::make_tuple(AnchorTarget::NONE, nullptr, AnchorPos::POINT_LEFT_TOP, 0, 0);
this->size_min = QSizeF(20, 20);
}
void SpecificEntityData::setVisible(bool state){
this->visible_bool = state;
}
void SpecificEntityData::setAnchorTo(AnchorTarget type, EntityData *tptr) {
anchor_info = std::make_tuple(type, tptr, std::get<2>(anchor_info), std::get<3>(anchor_info), std::get<4>(anchor_info));
}
void SpecificEntityData::setAnchorPos(AnchorPos point, offset_h hoffset, offset_v v_offset) {
anchor_info = std::make_tuple(std::get<0>(anchor_info), std::get<1>(anchor_info), point, hoffset, v_offset);
}
void SpecificEntityData::insertChild(EntityData *inst, int index) {
if (index >= 0 && index < children_store.size())
this->children_store.insert(index, inst);
else
this->children_store.append(inst);
}
void SpecificEntityData::removeChild(EntityData *inst) { this->children_store.removeAll(inst); }
void SpecificEntityData::setMinSizeHint(const QSizeF &hint) { this->size_min = hint; }
void SpecificEntityData::setMaxSizeHint(const QSizeF &hint) { this->size_max = hint; }
void SpecificEntityData::setStretchHint(const std::pair<float, float> &hint) { this->stretch_pair = hint; }
QString SpecificEntityData::uID() const { return document_id; }
EntityType SpecificEntityData::type() const { return type_store; }
MemberOri SpecificEntityData::oritation() const { return oritation_store; }
MemberType SpecificEntityData::displayType() const { return layout_type; }
std::pair<AnchorTarget, EntityData *> SpecificEntityData::anchorTarget() const {
return std::make_pair(std::get<0>(anchor_info), std::get<1>(anchor_info));
}
std::tuple<AnchorPos, EntityData::offset_h, EntityData::offset_v> SpecificEntityData::anchorPos() const {
return std::make_tuple(std::get<2>(anchor_info), std::get<3>(anchor_info), std::get<4>(anchor_info));
}
QList<EntityData *> SpecificEntityData::children() const { return children_store; }
bool SpecificEntityData::isVisible() const { return visible_bool; }
QSizeF SpecificEntityData::minSizeHint() const { return this->size_min; }
QSizeF SpecificEntityData::maxSizeHint() const { return this->size_max; }
std::pair<float, float> SpecificEntityData::sizeStretchHint() const { return stretch_pair; }
Document::Document(const QString &name) : SpecificEntityData(EntityType::DOCUMENT_ENTITY, "Document-Unique") {
resetContentLayout(MemberOri::H_LEFT_TO_RIGHT, MemberType::BLOCKS);
}
QString Document::styledText() const
{
QString values = "<docment type = '7' visible='true' >\n";
for(auto &i : children())
values += i->styledText();
values += "</document>";
return values;
}
QString Document::plainText() const
{
QString values = "";
for(auto &i : children())
if(i->isVisible())
values += i->plainText();
return values;
}
void Document::resetContentLayout(MemberOri oritation, MemberType) { SpecificEntityData::resetContentLayout(oritation, MemberType::BLOCKS); }

241
libTextEdit/entitydata.h Normal file
View File

@ -0,0 +1,241 @@
#ifndef ENTITYDATA_H
#define ENTITYDATA_H
#include <QList>
#include <QRectF>
#include <QString>
#include <tuple>
namespace PresentDatas {
enum class EntityType {
TEXT_RANGE, // 字符集合,包含段落和句子
IMAGE_CUBE, // 图片展示块
HREF_FRAGS, // 超链接
TABLE_VIEW, // 表格视图
LIST_VIEW, // 列表视图
INTERACTIVE_EXTENSION, // 交互式拓展插件视图
DISPLAY_GROUP, // 元素混合组织成包
DOCUMENT_ENTITY
};
enum class MemberOri {
H_LEFT_TO_RIGHT, // 从左到右横向排版
H_RIGHT_TO_LEFT, // 从右到左横向排版
H_CENTER_IN, // 中央对准横向排布
V_LEFT_TO_RIGHT, // 从左到右纵向排布
V_RIGHT_TO_LEFT, // 从右到左纵向排布
V_CENTER_IN // 中央对准纵向排布
};
enum class MemberType {
BLOCKS, // 成员被视为块元素
INLINES // 成员被视图行内元素
};
enum class AnchorTarget {
NONE, // 文档二维平面排版
WINDOW, // 窗口相对偏移定位
DOCUMENT, // 文档相对偏移定位
ELEMENT //元素相对偏移定位
};
enum class AnchorPos {
NONE,
POINT_LEFT_TOP,
POINT_LEFT_CENTER,
POINT_LEFT_BOTTOM,
POINT_CENTER_TOP,
POINT_CENTER_BOTH,
POINT_CENTER_BOTTOM,
POINT_RIGHT_TOP,
POINT_RIGHT_CENTER,
POINT_RIGHT_BOTTOM
};
/**
* @brief
*/
class EntityData {
public:
virtual ~EntityData() = default;
// 标定相关 =================================================================
/**
* @brief ID
* @return
*/
virtual QString uID() const = 0;
/**
* @brief
* @return
*/
virtual QString styledText() const = 0;
/**
* @brief
* @return
*/
virtual QString plainText() const = 0;
// 实体属性 ===================================================================
/**
* @brief
* @return
*/
virtual bool isVisible() const = 0;
/**
* @brief
* @return
*/
virtual EntityType type() const = 0;
// 排版相关 ===================================================================
/**
* @brief
* @return
*/
virtual MemberOri oritation() const = 0;
/**
* @brief
* @return
*/
virtual MemberType displayType() const = 0;
/**
* @brief
* // pair<NONE, nullptr> 文档二维平面排版
* // pair<ELEMENT, inst_ptr> 浮动排版,文档元素定位
* // pair<WINDOW, nullptr> 浮动排版,窗口偏移定位
* // pair<DOCUMENT, nullptr> 浮动排版,文档偏移定位
* @return
*/
virtual std::pair<AnchorTarget, EntityData *> anchorTarget() const = 0;
typedef float offset_h;
typedef float offset_v;
/**
* @brief
* @return
*/
virtual std::tuple<AnchorPos, offset_h, offset_v> anchorPos() const = 0;
virtual QSizeF minSizeHint() const = 0;
virtual QSizeF maxSizeHint() const = 0;
virtual std::pair<float, float> sizeStretchHint() const = 0;
/**
* @brief
* @return
*/
virtual QList<EntityData *> children() const = 0;
};
/**
*
*/
class SpecificEntityData : public EntityData {
public:
SpecificEntityData(EntityType type, const QString &uid);
virtual ~SpecificEntityData() = default;
/**
* @brief
* @param oritation
* @param child_type
*/
virtual void resetContentLayout(MemberOri oritation, MemberType child_type);
/**
* @brief
* @param state
*/
virtual void setVisible(bool state);
/**
* @brief
* @param type
* @param tptr
*/
virtual void setAnchorTo(AnchorTarget type, EntityData *tptr = nullptr);
/**
* @brief
* @param point
* @param hoffset
* @param v_offset
*/
virtual void setAnchorPos(AnchorPos point, EntityData::offset_h hoffset, EntityData::offset_v v_offset);
/**
* @brief
* @param inst
* @param index -1
*/
virtual void insertChild(EntityData *inst, int index = -1);
/**
* @brief
* @param inst
*/
virtual void removeChild(EntityData *inst);
virtual void setMinSizeHint(const QSizeF &hint);
virtual void setMaxSizeHint(const QSizeF &hint);
virtual void setStretchHint(const std::pair<float, float> &hint);
virtual void setStyledText(const QString &content) = 0;
virtual void setPlainText(const QString &content) = 0;
// EntityData ====================================================
virtual QString uID() const override;
virtual EntityType type() const override;
virtual MemberOri oritation() const override;
virtual MemberType displayType() const override;
virtual std::pair<AnchorTarget, EntityData *> anchorTarget() const override;
virtual std::tuple<AnchorPos, EntityData::offset_h, EntityData::offset_v> anchorPos() const override;
virtual QList<EntityData *> children() const override;
virtual bool isVisible() const override;
virtual QSizeF minSizeHint() const override;
virtual QSizeF maxSizeHint() const override;
virtual std::pair<float, float> sizeStretchHint() const override;
private:
bool visible_bool;
EntityType type_store;
QString document_id;
MemberOri oritation_store;
MemberType layout_type;
std::tuple<AnchorTarget, EntityData *, AnchorPos, EntityData::offset_h, EntityData::offset_v> anchor_info;
QList<EntityData *> children_store;
QSizeF size_min, size_max;
std::pair<float, float> stretch_pair;
protected:
float appoint_layout_minvalue() const;
};
/**
* @brief
*/
class Document : public SpecificEntityData {
public:
Document(const QString &name);
// EntityData interface
public:
virtual QString styledText() const override;
virtual QString plainText() const override;
// SpecificEntityData interface
public:
virtual void resetContentLayout(MemberOri oritation, MemberType) override;
};
} // namespace PresentDatas
#endif // ENTITYDATA_H

View File

@ -0,0 +1,32 @@
QT -= gui
TEMPLATE = lib
DEFINES += LIBTEXTEDIT_LIBRARY
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
blockdatas.cpp \
entitydata.cpp \
libtextedit.cpp
HEADERS += \
blockdatas.h \
entitydata.h \
libTextEdit_global.h \
libtextedit.h
msvc {
QMAKE_CFLAGS += /utf-8
QMAKE_CXXFLAGS += /utf-8
}
# Default rules for deployment.
unix {
target.path = /usr/lib
}
!isEmpty(target.path): INSTALLS += target

View File

@ -0,0 +1,12 @@
#ifndef LIBTEXTEDIT_GLOBAL_H
#define LIBTEXTEDIT_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(LIBTEXTEDIT_LIBRARY)
# define LIBTEXTEDIT_EXPORT Q_DECL_EXPORT
#else
# define LIBTEXTEDIT_EXPORT Q_DECL_IMPORT
#endif
#endif // LIBTEXTEDIT_GLOBAL_H

View File

@ -0,0 +1,5 @@
#include "libtextedit.h"
LibTextEdit::LibTextEdit()
{
}

12
libTextEdit/libtextedit.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef LIBTEXTEDIT_H
#define LIBTEXTEDIT_H
#include "libTextEdit_global.h"
class LIBTEXTEDIT_EXPORT LibTextEdit
{
public:
LibTextEdit();
};
#endif // LIBTEXTEDIT_H

View File

@ -7,6 +7,7 @@
#include <QMainWindow>
#include <QMenuBar>
#include <QPushButton>
#include <QStackedWidget>
#include <QStyle>
#include <QToolBar>
#include <baseview.h>
@ -15,69 +16,22 @@
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);
QWidget *secondPageWidget = new XWidget(nullptr, Qt::black);
QWidget *thirdPageWidget = new XWidget(nullptr, Qt::black);
QStackedWidget *stackedWidget = new QStackedWidget;
stackedWidget->addWidget(firstPageWidget);
stackedWidget->addWidget(secondPageWidget);
stackedWidget->addWidget(thirdPageWidget);
win->setCentralWidget(stackedWidget);
return a.exec();
}

View File

@ -3,7 +3,7 @@
#include <QPainter>
using namespace SplitFrame;
XWidget::XWidget(ViewPresent *host, Qt::GlobalColor c, QWidget *parent) : FnWrap<XWidget, false>(host, parent), c_store(c) {}
XWidget::XWidget(ViewPresent *host, Qt::GlobalColor c, QWidget *parent) : FnWrap<XWidget, false>(host), c_store(c) {}
void XWidget::paintEvent(QPaintEvent *ev) {
QPainter p(this);
@ -12,7 +12,7 @@ void XWidget::paintEvent(QPaintEvent *ev) {
void XWidget::closeProcess() {}
YWidget::YWidget(ViewPresent *host, QWidget *parent) : FnWrap<XWidget, true>(host, parent) {}
YWidget::YWidget(ViewPresent *host, QWidget *parent) : FnWrap<XWidget, true>(host) {}
void YWidget::paintEvent(QPaintEvent *ev) {
QPainter p(this);