移除冗余AppCore类型及其影响
This commit is contained in:
parent
b87399da16
commit
ec0519c950
|
@ -57,7 +57,7 @@ namespace MakeTools {
|
||||||
* @param core
|
* @param core
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
virtual void applySetting(const QString &name, Core::AppCore *core = nullptr) = 0;
|
virtual void applySetting(const QString &name) = 0;
|
||||||
/**
|
/**
|
||||||
* @brief 使用此实例打开指定的路径文件,冲刷掉所有状态
|
* @brief 使用此实例打开指定的路径文件,冲刷掉所有状态
|
||||||
* @param target_file 指定文件的info
|
* @param target_file 指定文件的info
|
||||||
|
|
|
@ -21,7 +21,7 @@ SOURCES += \
|
||||||
DocsManager.cpp \
|
DocsManager.cpp \
|
||||||
appcore.cpp \
|
appcore.cpp \
|
||||||
command_list.cpp \
|
command_list.cpp \
|
||||||
contentpresenttest.cpp \
|
# contentpresenttest.cpp \
|
||||||
# keywordshighlighter.cpp \
|
# keywordshighlighter.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
|
@ -41,7 +41,7 @@ HEADERS += \
|
||||||
DocsManager.h \
|
DocsManager.h \
|
||||||
appcore.h \
|
appcore.h \
|
||||||
command_list.h \
|
command_list.h \
|
||||||
contentpresenttest.h \
|
# contentpresenttest.h \
|
||||||
# keywordshighlighter.h \
|
# keywordshighlighter.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
manager_docs.h \
|
manager_docs.h \
|
||||||
|
|
|
@ -3,124 +3,16 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "manager_docs.h"
|
#include "manager_docs.h"
|
||||||
#include "srcedit_storyboard.h"
|
#include "srcedit_storyboard.h"
|
||||||
#include "srcedit_storychain.h"
|
|
||||||
#include "srcedit_storyconcept.h"
|
|
||||||
#include "srcedit_storyunit.h"
|
|
||||||
#include "srcedit_storyvolume.h"
|
|
||||||
#include "xapp.h"
|
#include "xapp.h"
|
||||||
#include "xmlconfig.h"
|
#include "xmlconfig.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <StoryTool.h>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Components;
|
using namespace Components;
|
||||||
using namespace Parse::Result;
|
|
||||||
using namespace MakeTools;
|
using namespace MakeTools;
|
||||||
|
|
||||||
AppCore::AppCore(QObject *parent) : QObject(parent), global_config(new Config::XMLConfig(this)), makes_core(new StoryTool()) {
|
|
||||||
global_config->loadFile(QDir(QApplication::applicationDirPath()).filePath(".software.xml"));
|
|
||||||
|
|
||||||
auto ins0 = new StorychainSourceEdit();
|
|
||||||
auto ins1 = new StoryunitSourceEdit();
|
|
||||||
auto ins2 = new StorySourceEdit();
|
|
||||||
auto ins3 = new StoryvolumeSourceEdit();
|
|
||||||
auto ins4 = new StoryconceptSourceEdit();
|
|
||||||
registerHighlightType(ins0);
|
|
||||||
registerHighlightType(ins1);
|
|
||||||
registerHighlightType(ins2);
|
|
||||||
registerHighlightType(ins3);
|
|
||||||
registerHighlightType(ins4);
|
|
||||||
|
|
||||||
|
|
||||||
present_types << ins0 << ins1 << ins2 << ins3 << ins4
|
|
||||||
<< new DefaultTextEdit();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppCore::registerHighlightType(Enhancement::HighlightFeature *base_type)
|
|
||||||
{
|
|
||||||
render_types << base_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppCore::isHighlightDemand(void *ins) const
|
|
||||||
{
|
|
||||||
return render_types.contains((Enhancement::HighlightFeature*)ins);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<FilePresent *> AppCore::allViews() const
|
|
||||||
{
|
|
||||||
return present_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppCore::save()
|
|
||||||
{
|
|
||||||
global_config->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
Config::Configration *AppCore::globalConfig() const
|
|
||||||
{
|
|
||||||
return global_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppCore::setCurrentProject(Project::ProjectManager *project)
|
|
||||||
{
|
|
||||||
this->current_project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
Project::ProjectManager *AppCore::currentProject() const
|
|
||||||
{
|
|
||||||
return this->current_project;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Config::Configration *> AppCore::getConfigs(QList<Scale> types) const
|
|
||||||
{
|
|
||||||
QList<Config::Configration*> rets;
|
|
||||||
|
|
||||||
for(auto &x : types){
|
|
||||||
if(x == Scale::Global)
|
|
||||||
rets << global_config;
|
|
||||||
if(x == Scale::Project && current_project->isOpenning())
|
|
||||||
rets << current_project->configraions();
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets;
|
|
||||||
}
|
|
||||||
|
|
||||||
Parse::Result::ParseCore *AppCore::parseCore() const
|
|
||||||
{
|
|
||||||
return makes_core->getCore();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<FilePresent *> AppCore::extensions(const QString &suffix) const
|
|
||||||
{
|
|
||||||
if(suffix.isEmpty())
|
|
||||||
return this->present_types;
|
|
||||||
|
|
||||||
QList<FilePresent*> rets;
|
|
||||||
for(auto &ext : present_types)
|
|
||||||
if(ext->suffixes().contains(suffix))
|
|
||||||
rets << ext;
|
|
||||||
|
|
||||||
for(auto &ext : present_types)
|
|
||||||
if(ext->suffixes().contains("*"))
|
|
||||||
rets << ext;
|
|
||||||
|
|
||||||
return rets;
|
|
||||||
}
|
|
||||||
|
|
||||||
MakeTools::StoryTool *AppCore::getMakeCore() const
|
|
||||||
{
|
|
||||||
return makes_core;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AppCore::name() const
|
|
||||||
{
|
|
||||||
return NAME(AppCore);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SimpleException::SimpleException(const QString &msg)
|
SimpleException::SimpleException(const QString &msg)
|
||||||
: msg_store(msg) {}
|
: msg_store(msg) {}
|
||||||
|
|
|
@ -7,18 +7,6 @@
|
||||||
#include <libConfig.h>
|
#include <libConfig.h>
|
||||||
#include <libProjectManager.h>
|
#include <libProjectManager.h>
|
||||||
|
|
||||||
class MainWindow;
|
|
||||||
|
|
||||||
namespace Enhancement {
|
|
||||||
class HighlightFeature;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MakeTools {
|
|
||||||
class StoryTool;
|
|
||||||
class DocsManager;
|
|
||||||
class FilePresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SimpleException : public std::exception
|
class SimpleException : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -33,8 +21,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class Extension;
|
|
||||||
class AppCore;
|
|
||||||
|
|
||||||
enum class Scale
|
enum class Scale
|
||||||
{
|
{
|
||||||
|
@ -43,52 +29,6 @@ namespace Core {
|
||||||
File,
|
File,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 软件内核类型
|
|
||||||
*/
|
|
||||||
class AppCore : public QObject, public Schedule::AccessibleObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AppCore(QObject *parent = nullptr);
|
|
||||||
virtual ~AppCore() = default;
|
|
||||||
|
|
||||||
void registerHighlightType(Enhancement::HighlightFeature *base_type);
|
|
||||||
bool isHighlightDemand(void* ins) const;
|
|
||||||
|
|
||||||
QList<MakeTools::FilePresent *> allViews() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 全局保存操作
|
|
||||||
*/
|
|
||||||
void save();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 全局配置端口
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Config::Configration * globalConfig() const;
|
|
||||||
|
|
||||||
void setCurrentProject(Project::ProjectManager *project);
|
|
||||||
Project::ProjectManager* currentProject() const;
|
|
||||||
QList<Config::Configration *> getConfigs(QList<Scale> types) const;
|
|
||||||
|
|
||||||
QList<MakeTools::FilePresent*> extensions(const QString &suffix = QString()) const;
|
|
||||||
|
|
||||||
MakeTools::StoryTool *getMakeCore() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Config::Configration *const global_config;
|
|
||||||
Project::ProjectManager * current_project;
|
|
||||||
QList<MakeTools::FilePresent*> present_types;
|
|
||||||
QList<Enhancement::HighlightFeature *> render_types;
|
|
||||||
|
|
||||||
MakeTools::StoryTool *const makes_core;
|
|
||||||
|
|
||||||
// AccessibleObject interface
|
|
||||||
public:
|
|
||||||
virtual QString name() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // APPCORE_H
|
#endif // APPCORE_H
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "srcedit_defaulttext.h"
|
#include "srcedit_defaulttext.h"
|
||||||
#include "srcedit_storyboard.h"
|
#include "srcedit_storyboard.h"
|
||||||
#include "srcedit_storychain.h"
|
|
||||||
#include "srcedit_storyconcept.h"
|
|
||||||
#include "srcedit_storyunit.h"
|
|
||||||
#include "srcedit_storyvolume.h"
|
|
||||||
#include "xapp.h"
|
#include "xapp.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "srcedit_defaulttext.h"
|
#include "srcedit_defaulttext.h"
|
||||||
#include "srcedit_storyboard.h"
|
#include "srcedit_storyboard.h"
|
||||||
#include "srcedit_storychain.h"
|
|
||||||
#include "srcedit_storyunit.h"
|
|
||||||
#include "srcedit_storyvolume.h"
|
|
||||||
#include "xapp.h"
|
#include "xapp.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -26,7 +23,6 @@
|
||||||
|
|
||||||
using namespace Project;
|
using namespace Project;
|
||||||
using namespace MakeTools;
|
using namespace MakeTools;
|
||||||
using namespace Parse::Result;
|
|
||||||
using namespace Components;
|
using namespace Components;
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Tools;
|
using namespace Tools;
|
||||||
|
@ -41,24 +37,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
split_second(new QSplitter(Qt::Vertical, this)),
|
split_second(new QSplitter(Qt::Vertical, this)),
|
||||||
split_third(new QSplitter(Qt::Horizontal, this)),
|
split_third(new QSplitter(Qt::Horizontal, this)),
|
||||||
project_manager(new XMLProjectManager(this)),
|
project_manager(new XMLProjectManager(this)),
|
||||||
left_funcs(new PresentContainer(QTabWidget::West, this)),
|
|
||||||
right_funcs(new PresentContainer(QTabWidget::West, this)),
|
|
||||||
center_funcs(new PresentContainer(QTabWidget::North, this)),
|
|
||||||
bottom_funcs(new PresentContainer(QTabWidget::North, this)),
|
|
||||||
docs_container(new DocumentsManager(app_core, project_manager, this)),
|
|
||||||
fragments_model(new FragmentsOrderviewModel(app_core)),
|
|
||||||
boards_model(new StoryboardsPresentModel(app_core)),
|
|
||||||
chains_model(new StorychainsPresentModel(app_core)),
|
|
||||||
concepts_model(new StoryconceptsPresentModel(app_core)),
|
|
||||||
units_model(new StoryunitsPresentModel(app_core)),
|
|
||||||
welcome_list(new WelcomePanel()),
|
welcome_list(new WelcomePanel()),
|
||||||
errors_present(new MessagesPresent(app_core->getMakeCore(), this)),
|
errors_present(new MessagesPresent(app_core->getMakeCore(), this)),
|
||||||
project_present(new ProjectPresent(XApp::disp_core, docs_container, this)),
|
project_present(new ProjectPresent(XApp::disp_core, docs_container, this)) {
|
||||||
fragments_order(new FragmentsOrderPresent(XApp::disp_core, fragments_model, this)),
|
|
||||||
boards_view(new StoryboardsPresent(XApp::disp_core, boards_model, this)),
|
|
||||||
chains_view(new StorychainsPresent(XApp::disp_core, chains_model, this)),
|
|
||||||
concept_view(new StoryconceptsPresent(XApp::disp_core, concepts_model, this)),
|
|
||||||
units_view(new StoryunitsPresent(XApp::disp_core, units_model, this)) {
|
|
||||||
|
|
||||||
QApplication::instance()->installEventFilter(this);
|
QApplication::instance()->installEventFilter(this);
|
||||||
initial_commandlist(XApp::disp_core);
|
initial_commandlist(XApp::disp_core);
|
||||||
|
@ -378,7 +359,7 @@ void MainWindow::splitter_layout_save(const QList<QString> &path_type, const QLi
|
||||||
#define RIGHT_SIDE "right"
|
#define RIGHT_SIDE "right"
|
||||||
#define BOTTOM_SIDE "bottom"
|
#define BOTTOM_SIDE "bottom"
|
||||||
#define CENTER_SIDE "center"
|
#define CENTER_SIDE "center"
|
||||||
void MainWindow::append(PresentBase *ins, const Route &unique) {
|
void MainWindow::append(PresentBase *ins) {
|
||||||
auto cfg = project_manager->configraions();
|
auto cfg = project_manager->configraions();
|
||||||
auto pos_query = QList<QString>() << "unique-record"
|
auto pos_query = QList<QString>() << "unique-record"
|
||||||
<< "split-area"
|
<< "split-area"
|
||||||
|
@ -429,15 +410,15 @@ void MainWindow::accept_view_transport(const Core::Route &key, Components::Group
|
||||||
append(xins, key);
|
append(xins, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::active(const Route &unique) {
|
bool MainWindow::active(const PresentBase *ins) {
|
||||||
PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs};
|
PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs};
|
||||||
for (auto &it : array)
|
for (auto &it : array)
|
||||||
it->active(unique);
|
it->active(ins);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PresentBase *MainWindow::remove(const Route &unique) {
|
void MainWindow::remove(const PresentBase *ins) {
|
||||||
PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs};
|
PresentHost *array[4] = {left_funcs, right_funcs, bottom_funcs, center_funcs};
|
||||||
for (auto &it : array) {
|
for (auto &it : array) {
|
||||||
auto ins = it->remove(unique);
|
auto ins = it->remove(unique);
|
||||||
|
@ -446,41 +427,10 @@ PresentBase *MainWindow::remove(const Route &unique) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::contains(MakeTools::PresentBase *ins) const { return false; }
|
bool MainWindow::contains(const PresentBase *ins) const { return false; }
|
||||||
|
|
||||||
QWidget *MainWindow::hostWidget() const { return (QWidget *)this; }
|
QWidget *MainWindow::hostWidget() const { return (QWidget *)this; }
|
||||||
|
|
||||||
void MainWindow::setVisibleState(bool state) { QMainWindow::setVisible(state); }
|
|
||||||
|
|
||||||
bool MainWindow::visibleState() const { return QMainWindow::isVisible(); }
|
|
||||||
|
|
||||||
void MainWindow::hasBeenAccepted(const Core::Route &key) {
|
|
||||||
auto cfg = project_manager->configraions();
|
|
||||||
auto pos_query = QList<QString>() << "unique-record"
|
|
||||||
<< "split-area"
|
|
||||||
<< "index-hash"
|
|
||||||
<< "store-point";
|
|
||||||
|
|
||||||
auto hash_pos = cfg->getMap(pos_query);
|
|
||||||
auto unique_key = key.links().join("/");
|
|
||||||
if (left_funcs->active(key)) {
|
|
||||||
hash_pos[unique_key] = LEFT_SIDE;
|
|
||||||
} else if (right_funcs->active(key)) {
|
|
||||||
hash_pos[unique_key] = RIGHT_SIDE;
|
|
||||||
} else if (bottom_funcs->active(key)) {
|
|
||||||
hash_pos[unique_key] = BOTTOM_SIDE;
|
|
||||||
} else {
|
|
||||||
hash_pos[unique_key] = CENTER_SIDE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg->setMap(pos_query, hash_pos);
|
|
||||||
docs_container->hasBeenAccepted(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::hasBeenRemoved(const Core::Route &key) { docs_container->hasBeenRemoved(key); }
|
|
||||||
|
|
||||||
void MainWindow::hasBeenClosed(const Core::Route &key) { docs_container->hasBeenClosed(key); }
|
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
// 关闭事件
|
// 关闭事件
|
||||||
if (project_manager->isOpenning()) {
|
if (project_manager->isOpenning()) {
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "ContentPresent.h"
|
|
||||||
#include "DocsManager.h"
|
#include "DocsManager.h"
|
||||||
#include "fragmentsorderpresent.h"
|
|
||||||
#include "manager_docs.h"
|
#include "manager_docs.h"
|
||||||
#include "messagespresent.h"
|
#include "messagespresent.h"
|
||||||
#include "presentcontainer.h"
|
#include "presentcontainer.h"
|
||||||
#include "projectpresent.h"
|
#include "projectpresent.h"
|
||||||
#include "storyboardspresent.h"
|
|
||||||
#include "storychainspresent.h"
|
|
||||||
#include "storyconceptspresent.h"
|
|
||||||
#include "storyunitspresent.h"
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "welcomepanel.h"
|
#include "welcomepanel.h"
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
|
@ -19,10 +13,9 @@
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <StoryTool.h>
|
|
||||||
#include <libProjectManager.h>
|
#include <libProjectManager.h>
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, public Components::PresentHost, public Components::HostListener {
|
class MainWindow : public QMainWindow, public Components::PresentHost {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -30,8 +23,6 @@ class MainWindow : public QMainWindow, public Components::PresentHost, public Co
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::AppCore *const app_core;
|
|
||||||
|
|
||||||
Tools::StatusSyncCore *const sync_kernel;
|
Tools::StatusSyncCore *const sync_kernel;
|
||||||
QSplitter *const split_first;
|
QSplitter *const split_first;
|
||||||
QSplitter *const split_second;
|
QSplitter *const split_second;
|
||||||
|
@ -47,21 +38,11 @@ class MainWindow : public QMainWindow, public Components::PresentHost, public Co
|
||||||
|
|
||||||
// model ============================================
|
// model ============================================
|
||||||
DataModel::DocumentsManager *const docs_container;
|
DataModel::DocumentsManager *const docs_container;
|
||||||
DataModel::FragmentsOrderviewModel *const fragments_model;
|
|
||||||
DataModel::StoryboardsPresentModel *const boards_model;
|
|
||||||
DataModel::StorychainsPresentModel *const chains_model;
|
|
||||||
DataModel::StoryconceptsPresentModel *const concepts_model;
|
|
||||||
DataModel::StoryunitsPresentModel *const units_model;
|
|
||||||
|
|
||||||
// view =============================================
|
// view =============================================
|
||||||
Components::WelcomePanel *const welcome_list;
|
Components::WelcomePanel *const welcome_list;
|
||||||
Components::MessagesPresent *const errors_present;
|
Components::MessagesPresent *const errors_present;
|
||||||
Components::ProjectPresent *const project_present;
|
Components::ProjectPresent *const project_present;
|
||||||
Components::FragmentsOrderPresent *const fragments_order;
|
|
||||||
Components::StoryboardsPresent *const boards_view;
|
|
||||||
Components::StorychainsPresent *const chains_view;
|
|
||||||
Components::StoryconceptsPresent *const concept_view;
|
|
||||||
Components::StoryunitsPresent *const units_view;
|
|
||||||
|
|
||||||
// 内部逻辑 ===========================================
|
// 内部逻辑 ===========================================
|
||||||
void initial_menubar(QMenuBar *mbar);
|
void initial_menubar(QMenuBar *mbar);
|
||||||
|
@ -78,20 +59,11 @@ class MainWindow : public QMainWindow, public Components::PresentHost, public Co
|
||||||
// PresentContainer interface
|
// PresentContainer interface
|
||||||
public:
|
public:
|
||||||
virtual QWidget *hostWidget() const override;
|
virtual QWidget *hostWidget() const override;
|
||||||
virtual void setVisibleState(bool state) override;
|
|
||||||
virtual bool visibleState() const override;
|
|
||||||
|
|
||||||
virtual void append(MakeTools::PresentBase *ins, const Core::Route &unique) override;
|
virtual void append(MakeTools::PresentBase *ins) override;
|
||||||
virtual bool active(const Core::Route &unique) override;
|
virtual bool active(const MakeTools::PresentBase *ins) override;
|
||||||
virtual MakeTools::PresentBase *remove(const Core::Route &unique) override;
|
virtual void remove(const MakeTools::PresentBase *ins) override;
|
||||||
|
virtual bool contains(const MakeTools::PresentBase *ins) const override;
|
||||||
virtual bool contains(MakeTools::PresentBase *ins) const override;
|
|
||||||
|
|
||||||
// HostListener interface
|
|
||||||
public:
|
|
||||||
virtual void hasBeenAccepted(const Core::Route &key) override;
|
|
||||||
virtual void hasBeenRemoved(const Core::Route &key) override;
|
|
||||||
virtual void hasBeenClosed(const Core::Route &key) override;
|
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -6,7 +6,7 @@ using namespace Components;
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace DataModel;
|
using namespace DataModel;
|
||||||
|
|
||||||
DocumentsManager::DocumentsManager(Core::AppCore *src, Project::ProjectManager *project) : rtcore(src), pjtins(project), present_ui(nullptr) {}
|
DocumentsManager::DocumentsManager(Project::ProjectManager *project) : pjtins(project), present_ui(nullptr) {}
|
||||||
|
|
||||||
void DocumentsManager::setPresent(Components::PresentHost *container) { present_ui = container; }
|
void DocumentsManager::setPresent(Components::PresentHost *container) { present_ui = container; }
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ void DocumentsManager::renameNode(const Core::Route &node_path, const QString &n
|
||||||
auto activie_file_nodes = actives();
|
auto activie_file_nodes = actives();
|
||||||
if (activie_file_nodes.contains(node_path)) {
|
if (activie_file_nodes.contains(node_path)) {
|
||||||
auto inst = convertPresent(node_path);
|
auto inst = convertPresent(node_path);
|
||||||
inst->applySetting(name, rtcore);
|
inst->applySetting(name);
|
||||||
doc_openning.remove(node_path);
|
doc_openning.remove(node_path);
|
||||||
|
|
||||||
auto old_link = node_path.links();
|
auto old_link = node_path.links();
|
||||||
|
@ -69,7 +69,7 @@ void DocumentsManager::openFile(const QList<Route> &doc_paths) {
|
||||||
for (auto &it : doc_paths) {
|
for (auto &it : doc_paths) {
|
||||||
auto openning = actives();
|
auto openning = actives();
|
||||||
if (openning.contains(it)) {
|
if (openning.contains(it)) {
|
||||||
doc_openning[it]->applySetting(it.links().last(), rtcore);
|
doc_openning[it]->applySetting(it.links().last());
|
||||||
active(it);
|
active(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void DocumentsManager::openFile(const QList<Route> &doc_paths) {
|
||||||
auto view = factory_map[info.suffix()]->newInst(present_ui->hostWidget());
|
auto view = factory_map[info.suffix()]->newInst(present_ui->hostWidget());
|
||||||
doc_openning[it] = view;
|
doc_openning[it] = view;
|
||||||
view->load(info);
|
view->load(info);
|
||||||
view->applySetting(it.links().last(), rtcore);
|
view->applySetting(it.links().last());
|
||||||
present_ui->append(view);
|
present_ui->append(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,6 @@
|
||||||
#include <commandsdispatcher.h>
|
#include <commandsdispatcher.h>
|
||||||
#include <libProjectManager.h>
|
#include <libProjectManager.h>
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class AppCore;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MakeTools {
|
namespace MakeTools {
|
||||||
class FilePresent;
|
class FilePresent;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +58,7 @@ namespace DataModel {
|
||||||
*/
|
*/
|
||||||
class DocumentsManager : public Schedule::AccessibleObject {
|
class DocumentsManager : public Schedule::AccessibleObject {
|
||||||
public:
|
public:
|
||||||
DocumentsManager(Core::AppCore *src, Project::ProjectManager *project);
|
DocumentsManager(Project::ProjectManager *project);
|
||||||
virtual ~DocumentsManager() = default;
|
virtual ~DocumentsManager() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +179,6 @@ namespace DataModel {
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::AppCore *const rtcore;
|
|
||||||
Project::ProjectManager *pjtins;
|
Project::ProjectManager *pjtins;
|
||||||
Components::PresentHost *present_ui;
|
Components::PresentHost *present_ui;
|
||||||
|
|
||||||
|
|
|
@ -7,78 +7,44 @@ using namespace Components;
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace MakeTools;
|
using namespace MakeTools;
|
||||||
|
|
||||||
PresentContainer::PresentContainer(TabPosition pos, HostListener *host)
|
PresentContainer::PresentContainer(TabPosition pos, QWidget *parent) : QTabWidget(parent) {
|
||||||
: host_inst(host) {
|
|
||||||
setTabPosition(pos);
|
setTabPosition(pos);
|
||||||
setTabsClosable(true);
|
setTabsClosable(true);
|
||||||
setMovable(true);
|
setMovable(true);
|
||||||
|
|
||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(this, &QWidget::customContextMenuRequested, [this](const QPoint &p) {
|
|
||||||
auto index = this->tabBar()->tabAt(p);
|
|
||||||
setCurrentIndex(index);
|
|
||||||
|
|
||||||
Route key_peaks;
|
|
||||||
for (auto &v : items_store) {
|
|
||||||
if (v->widget() == widget(index)) {
|
|
||||||
key_peaks = items_store.key(v);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu m;
|
|
||||||
|
|
||||||
auto trans = m.addMenu("转移标签页");
|
|
||||||
trans->setEnabled(key_peaks.isValid());
|
|
||||||
trans->addAction("到左侧视图", [this, key_peaks]() { emit presentTransTo(key_peaks, GroupType::LEFT); });
|
|
||||||
trans->addAction("到右侧视图", [this, key_peaks]() { emit presentTransTo(key_peaks, GroupType::RIGHT); });
|
|
||||||
trans->addAction("到底部视图", [this, key_peaks]() { emit presentTransTo(key_peaks, GroupType::BOTTOM); });
|
|
||||||
trans->addAction("到中央视图", [this, key_peaks]() { emit presentTransTo(key_peaks, GroupType::CENTER); });
|
|
||||||
|
|
||||||
m.exec(mapToGlobal(p));
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(this, &QTabWidget::tabCloseRequested, this, &PresentContainer::accept_close_action);
|
connect(this, &QTabWidget::tabCloseRequested, this, &PresentContainer::accept_close_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *PresentContainer::hostWidget() const { return (QWidget *)this; }
|
QWidget *PresentContainer::hostWidget() const { return (QWidget *)this; }
|
||||||
|
|
||||||
void PresentContainer::append(PresentBase *ins, const Core::Route &key) {
|
void PresentContainer::append(PresentBase *ins) {
|
||||||
addTab(ins->widget(), ins->name());
|
addTab(ins->widget(), ins->name());
|
||||||
items_store[key] = ins;
|
if (!items_store.contains(ins))
|
||||||
|
items_store.append(ins);
|
||||||
if (host_inst)
|
|
||||||
host_inst->hasBeenAccepted(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PresentContainer::active(const Core::Route &unique) {
|
bool PresentContainer::active(const PresentBase *ins) {
|
||||||
if (!items_store.contains(unique))
|
if (!items_store.contains(ins))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto inst = items_store[unique];
|
ins->widget()->setVisible(true);
|
||||||
inst->widget()->setVisible(true);
|
|
||||||
|
|
||||||
auto index = indexOf(inst->widget());
|
auto index = indexOf(ins->widget());
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
setTabText(index, inst->name());
|
setTabText(index, ins->name());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PresentBase *PresentContainer::remove(const Core::Route &key) {
|
void PresentContainer::remove(const PresentBase *ins) {
|
||||||
if (!items_store.contains(key))
|
if (!items_store.contains(ins))
|
||||||
return nullptr;
|
return;
|
||||||
|
|
||||||
auto inst = items_store[key];
|
auto index = indexOf(ins->widget());
|
||||||
auto index = indexOf(inst->widget());
|
|
||||||
removeTab(index);
|
removeTab(index);
|
||||||
items_store.remove(key);
|
items_store.removeAll(ins);
|
||||||
|
|
||||||
if (host_inst)
|
|
||||||
host_inst->hasBeenRemoved(key);
|
|
||||||
return inst;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PresentContainer::contains(MakeTools::PresentBase *ins) const {
|
bool PresentContainer::contains(const PresentBase *ins) const {
|
||||||
for (auto &insit : items_store) {
|
for (auto &insit : items_store) {
|
||||||
if (insit == ins)
|
if (insit == ins)
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,22 +52,12 @@ bool PresentContainer::contains(MakeTools::PresentBase *ins) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresentContainer::setVisibleState(bool state) { hostWidget()->setVisible(state); }
|
|
||||||
|
|
||||||
bool PresentContainer::visibleState() const { return hostWidget()->isVisible(); }
|
|
||||||
|
|
||||||
void PresentContainer::accept_close_action(int index) {
|
void PresentContainer::accept_close_action(int index) {
|
||||||
auto disp = widget(index);
|
auto disp = widget(index);
|
||||||
for (auto &key : items_store.keys()) {
|
for (auto &ins : items_store) {
|
||||||
auto inst = items_store[key];
|
if (ins->widget() == disp) {
|
||||||
if (inst->widget() == disp) {
|
items_store.removeAll(ins);
|
||||||
items_store.remove(key);
|
|
||||||
removeTab(index);
|
removeTab(index);
|
||||||
|
|
||||||
if (host_inst)
|
|
||||||
host_inst->hasBeenClosed(key);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,25 +11,19 @@ namespace Components {
|
||||||
class PresentContainer : public QTabWidget, public PresentHost {
|
class PresentContainer : public QTabWidget, public PresentHost {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PresentContainer(QTabWidget::TabPosition pos, HostListener *host = nullptr);
|
PresentContainer(QTabWidget::TabPosition pos, QWidget *parent = nullptr);
|
||||||
|
|
||||||
// PresentContainer interface
|
// PresentContainer interface
|
||||||
public:
|
public:
|
||||||
virtual QWidget *hostWidget() const override;
|
virtual QWidget *hostWidget() const override;
|
||||||
|
|
||||||
virtual void append(MakeTools::PresentBase *ins, const Core::Route &key) override;
|
virtual void append(MakeTools::PresentBase *ins) override;
|
||||||
virtual bool active(const Core::Route &key) override;
|
virtual bool active(const MakeTools::PresentBase *ins) override;
|
||||||
virtual MakeTools::PresentBase *remove(const Core::Route &key) override;
|
virtual void remove(const MakeTools::PresentBase *ins) override;
|
||||||
virtual bool contains(MakeTools::PresentBase *ins) const override;
|
virtual bool contains(const MakeTools::PresentBase *ins) const override;
|
||||||
virtual void setVisibleState(bool state) override;
|
|
||||||
virtual bool visibleState() const override;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void presentTransTo(const Core::Route &key, GroupType type);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HostListener *const host_inst;
|
QList<const MakeTools::PresentBase *> items_store;
|
||||||
QHash<Core::Route, MakeTools::PresentBase *> items_store;
|
|
||||||
|
|
||||||
void accept_close_action(int index);
|
void accept_close_action(int index);
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,7 +53,7 @@ void ProjectPresent::menu_popup(const QPoint &p)
|
||||||
for (auto &it : views) {
|
for (auto &it : views) {
|
||||||
menu->addAction(it, [this, &it, &index, mgr]() {
|
menu->addAction(it, [this, &it, &index, mgr]() {
|
||||||
auto name = QInputDialog::getText(this, "输入文件名称", "文件名称");
|
auto name = QInputDialog::getText(this, "输入文件名称", "文件名称");
|
||||||
auto path = mgr->converter(index);
|
auto path = mgr->convertPath(index);
|
||||||
source->postCommand(NewFile(path, name, it));
|
source->postCommand(NewFile(path, name, it));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,6 @@ void ProjectPresent::menu_popup(const QPoint &p)
|
||||||
void ProjectPresent::open_target(const QModelIndex &t)
|
void ProjectPresent::open_target(const QModelIndex &t)
|
||||||
{
|
{
|
||||||
auto mgr = source->get<DocumentsManager>(NAME(DocumentsManager));
|
auto mgr = source->get<DocumentsManager>(NAME(DocumentsManager));
|
||||||
auto path = mgr->converter(t);
|
auto path = mgr->convertPath(t);
|
||||||
source->postCommand(OpenFile(path));
|
source->postCommand(OpenFile(path));
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,7 @@ MakeTools::FilePresent::Features DefaultTextEdit::features()
|
||||||
return Features();
|
return Features();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultTextEdit::applySetting(const QString &name, Core::AppCore *core)
|
void DefaultTextEdit::applySetting(const QString &name) { name_store = name; }
|
||||||
{
|
|
||||||
name_store = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DefaultTextEdit::name() const
|
QString DefaultTextEdit::name() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Components {
|
||||||
// ContentPresent interface
|
// ContentPresent interface
|
||||||
public:
|
public:
|
||||||
virtual QWidget *widget() const override;
|
virtual QWidget *widget() const override;
|
||||||
virtual void applySetting(const QString &name, Core::AppCore *core) override;
|
virtual void applySetting(const QString &name) override;
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
virtual void load(const QFileInfo &target_file) override;
|
virtual void load(const QFileInfo &target_file) override;
|
||||||
virtual void saveAs(const QString &path) override;
|
virtual void saveAs(const QString &path) override;
|
||||||
|
|
|
@ -112,11 +112,7 @@ bool StorySourceEdit::isModified() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorySourceEdit::applySetting(const QString &name, Core::AppCore *core)
|
void StorySourceEdit::applySetting(const QString &name) { this->name_store = name; }
|
||||||
{
|
|
||||||
this->name_store = name;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void StorySourceEdit::jumpTo(const QList<QString> &path) {
|
void StorySourceEdit::jumpTo(const QList<QString> &path) {
|
||||||
// auto fpath = this->absoluteTargetPath();
|
// auto fpath = this->absoluteTargetPath();
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Components {
|
||||||
virtual QString absoluteTargetPath() const override;
|
virtual QString absoluteTargetPath() const override;
|
||||||
virtual QString getText() const override;
|
virtual QString getText() const override;
|
||||||
virtual bool isModified() const override;
|
virtual bool isModified() const override;
|
||||||
virtual void applySetting(const QString &name, Core::AppCore *core) override;
|
virtual void applySetting(const QString &name) override;
|
||||||
virtual void jumpTo(const QList<QString> &path) override;
|
virtual void jumpTo(const QList<QString> &path) override;
|
||||||
virtual Features features() override;
|
virtual Features features() override;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue