移除冗余AppCore类型及其影响
This commit is contained in:
parent
b87399da16
commit
ec0519c950
|
@ -57,7 +57,7 @@ namespace MakeTools {
|
|||
* @param core
|
||||
* @param name
|
||||
*/
|
||||
virtual void applySetting(const QString &name, Core::AppCore *core = nullptr) = 0;
|
||||
virtual void applySetting(const QString &name) = 0;
|
||||
/**
|
||||
* @brief 使用此实例打开指定的路径文件,冲刷掉所有状态
|
||||
* @param target_file 指定文件的info
|
||||
|
|
|
@ -21,7 +21,7 @@ SOURCES += \
|
|||
DocsManager.cpp \
|
||||
appcore.cpp \
|
||||
command_list.cpp \
|
||||
contentpresenttest.cpp \
|
||||
# contentpresenttest.cpp \
|
||||
# keywordshighlighter.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
|
@ -41,7 +41,7 @@ HEADERS += \
|
|||
DocsManager.h \
|
||||
appcore.h \
|
||||
command_list.h \
|
||||
contentpresenttest.h \
|
||||
# contentpresenttest.h \
|
||||
# keywordshighlighter.h \
|
||||
mainwindow.h \
|
||||
manager_docs.h \
|
||||
|
|
|
@ -3,124 +3,16 @@
|
|||
#include "mainwindow.h"
|
||||
#include "manager_docs.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 "xmlconfig.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QTextStream>
|
||||
#include <StoryTool.h>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Components;
|
||||
using namespace Parse::Result;
|
||||
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)
|
||||
: msg_store(msg) {}
|
||||
|
|
|
@ -7,18 +7,6 @@
|
|||
#include <libConfig.h>
|
||||
#include <libProjectManager.h>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Enhancement {
|
||||
class HighlightFeature;
|
||||
}
|
||||
|
||||
namespace MakeTools {
|
||||
class StoryTool;
|
||||
class DocsManager;
|
||||
class FilePresent;
|
||||
}
|
||||
|
||||
class SimpleException : public std::exception
|
||||
{
|
||||
public:
|
||||
|
@ -33,8 +21,6 @@ public:
|
|||
};
|
||||
|
||||
namespace Core {
|
||||
class Extension;
|
||||
class AppCore;
|
||||
|
||||
enum class Scale
|
||||
{
|
||||
|
@ -43,52 +29,6 @@ namespace Core {
|
|||
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
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
#include "mainwindow.h"
|
||||
#include "srcedit_defaulttext.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 <QApplication>
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#include "mainwindow.h"
|
||||
#include "srcedit_defaulttext.h"
|
||||
#include "srcedit_storyboard.h"
|
||||
#include "srcedit_storychain.h"
|
||||
#include "srcedit_storyunit.h"
|
||||
#include "srcedit_storyvolume.h"
|
||||
#include "xapp.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
@ -26,7 +23,6 @@
|
|||
|
||||
using namespace Project;
|
||||
using namespace MakeTools;
|
||||
using namespace Parse::Result;
|
||||
using namespace Components;
|
||||
using namespace Core;
|
||||
using namespace Tools;
|
||||
|
@ -41,24 +37,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
split_second(new QSplitter(Qt::Vertical, this)),
|
||||
split_third(new QSplitter(Qt::Horizontal, 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()),
|
||||
errors_present(new MessagesPresent(app_core->getMakeCore(), 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)) {
|
||||
project_present(new ProjectPresent(XApp::disp_core, docs_container, this)) {
|
||||
|
||||
QApplication::instance()->installEventFilter(this);
|
||||
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 BOTTOM_SIDE "bottom"
|
||||
#define CENTER_SIDE "center"
|
||||
void MainWindow::append(PresentBase *ins, const Route &unique) {
|
||||
void MainWindow::append(PresentBase *ins) {
|
||||
auto cfg = project_manager->configraions();
|
||||
auto pos_query = QList<QString>() << "unique-record"
|
||||
<< "split-area"
|
||||
|
@ -429,15 +410,15 @@ void MainWindow::accept_view_transport(const Core::Route &key, Components::Group
|
|||
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};
|
||||
for (auto &it : array)
|
||||
it->active(unique);
|
||||
it->active(ins);
|
||||
|
||||
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};
|
||||
for (auto &it : array) {
|
||||
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; }
|
||||
|
||||
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) {
|
||||
// 关闭事件
|
||||
if (project_manager->isOpenning()) {
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "ContentPresent.h"
|
||||
#include "DocsManager.h"
|
||||
#include "fragmentsorderpresent.h"
|
||||
#include "manager_docs.h"
|
||||
#include "messagespresent.h"
|
||||
#include "presentcontainer.h"
|
||||
#include "projectpresent.h"
|
||||
#include "storyboardspresent.h"
|
||||
#include "storychainspresent.h"
|
||||
#include "storyconceptspresent.h"
|
||||
#include "storyunitspresent.h"
|
||||
#include "tools.h"
|
||||
#include "welcomepanel.h"
|
||||
#include <QListView>
|
||||
|
@ -19,19 +13,16 @@
|
|||
#include <QSplitter>
|
||||
#include <QTableView>
|
||||
#include <QTreeView>
|
||||
#include <StoryTool.h>
|
||||
#include <libProjectManager.h>
|
||||
|
||||
class MainWindow : public QMainWindow, public Components::PresentHost, public Components::HostListener {
|
||||
class MainWindow : public QMainWindow, public Components::PresentHost {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Core::AppCore *const app_core;
|
||||
|
||||
private:
|
||||
Tools::StatusSyncCore *const sync_kernel;
|
||||
QSplitter *const split_first;
|
||||
QSplitter *const split_second;
|
||||
|
@ -47,21 +38,11 @@ class MainWindow : public QMainWindow, public Components::PresentHost, public Co
|
|||
|
||||
// model ============================================
|
||||
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 =============================================
|
||||
Components::WelcomePanel *const welcome_list;
|
||||
Components::MessagesPresent *const errors_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);
|
||||
|
@ -76,22 +57,13 @@ class MainWindow : public QMainWindow, public Components::PresentHost, public Co
|
|||
void splitter_layout_save(const QList<QString> &path_type, const QList<int> &size);
|
||||
|
||||
// PresentContainer interface
|
||||
public:
|
||||
public:
|
||||
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 bool active(const Core::Route &unique) override;
|
||||
virtual MakeTools::PresentBase *remove(const Core::Route &unique) 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;
|
||||
virtual void append(MakeTools::PresentBase *ins) override;
|
||||
virtual bool active(const MakeTools::PresentBase *ins) override;
|
||||
virtual void remove(const MakeTools::PresentBase *ins) override;
|
||||
virtual bool contains(const MakeTools::PresentBase *ins) const override;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
|
|
|
@ -6,7 +6,7 @@ using namespace Components;
|
|||
using namespace Core;
|
||||
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; }
|
||||
|
||||
|
@ -38,7 +38,7 @@ void DocumentsManager::renameNode(const Core::Route &node_path, const QString &n
|
|||
auto activie_file_nodes = actives();
|
||||
if (activie_file_nodes.contains(node_path)) {
|
||||
auto inst = convertPresent(node_path);
|
||||
inst->applySetting(name, rtcore);
|
||||
inst->applySetting(name);
|
||||
doc_openning.remove(node_path);
|
||||
|
||||
auto old_link = node_path.links();
|
||||
|
@ -69,7 +69,7 @@ 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(), rtcore);
|
||||
doc_openning[it]->applySetting(it.links().last());
|
||||
active(it);
|
||||
continue;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void DocumentsManager::openFile(const QList<Route> &doc_paths) {
|
|||
auto view = factory_map[info.suffix()]->newInst(present_ui->hostWidget());
|
||||
doc_openning[it] = view;
|
||||
view->load(info);
|
||||
view->applySetting(it.links().last(), rtcore);
|
||||
view->applySetting(it.links().last());
|
||||
present_ui->append(view);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
#include <commandsdispatcher.h>
|
||||
#include <libProjectManager.h>
|
||||
|
||||
namespace Core {
|
||||
class AppCore;
|
||||
}
|
||||
|
||||
namespace MakeTools {
|
||||
class FilePresent;
|
||||
}
|
||||
|
@ -62,7 +58,7 @@ namespace DataModel {
|
|||
*/
|
||||
class DocumentsManager : public Schedule::AccessibleObject {
|
||||
public:
|
||||
DocumentsManager(Core::AppCore *src, Project::ProjectManager *project);
|
||||
DocumentsManager(Project::ProjectManager *project);
|
||||
virtual ~DocumentsManager() = default;
|
||||
|
||||
/**
|
||||
|
@ -183,7 +179,6 @@ namespace DataModel {
|
|||
virtual QString name() const override;
|
||||
|
||||
private:
|
||||
Core::AppCore *const rtcore;
|
||||
Project::ProjectManager *pjtins;
|
||||
Components::PresentHost *present_ui;
|
||||
|
||||
|
|
|
@ -7,78 +7,44 @@ using namespace Components;
|
|||
using namespace Core;
|
||||
using namespace MakeTools;
|
||||
|
||||
PresentContainer::PresentContainer(TabPosition pos, HostListener *host)
|
||||
: host_inst(host) {
|
||||
PresentContainer::PresentContainer(TabPosition pos, QWidget *parent) : QTabWidget(parent) {
|
||||
setTabPosition(pos);
|
||||
setTabsClosable(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);
|
||||
}
|
||||
|
||||
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());
|
||||
items_store[key] = ins;
|
||||
|
||||
if (host_inst)
|
||||
host_inst->hasBeenAccepted(key);
|
||||
if (!items_store.contains(ins))
|
||||
items_store.append(ins);
|
||||
}
|
||||
|
||||
bool PresentContainer::active(const Core::Route &unique) {
|
||||
if (!items_store.contains(unique))
|
||||
bool PresentContainer::active(const PresentBase *ins) {
|
||||
if (!items_store.contains(ins))
|
||||
return false;
|
||||
|
||||
auto inst = items_store[unique];
|
||||
inst->widget()->setVisible(true);
|
||||
ins->widget()->setVisible(true);
|
||||
|
||||
auto index = indexOf(inst->widget());
|
||||
auto index = indexOf(ins->widget());
|
||||
setCurrentIndex(index);
|
||||
setTabText(index, inst->name());
|
||||
setTabText(index, ins->name());
|
||||
return true;
|
||||
}
|
||||
|
||||
PresentBase *PresentContainer::remove(const Core::Route &key) {
|
||||
if (!items_store.contains(key))
|
||||
return nullptr;
|
||||
void PresentContainer::remove(const PresentBase *ins) {
|
||||
if (!items_store.contains(ins))
|
||||
return;
|
||||
|
||||
auto inst = items_store[key];
|
||||
auto index = indexOf(inst->widget());
|
||||
auto index = indexOf(ins->widget());
|
||||
removeTab(index);
|
||||
items_store.remove(key);
|
||||
|
||||
if (host_inst)
|
||||
host_inst->hasBeenRemoved(key);
|
||||
return inst;
|
||||
items_store.removeAll(ins);
|
||||
}
|
||||
|
||||
bool PresentContainer::contains(MakeTools::PresentBase *ins) const {
|
||||
bool PresentContainer::contains(const PresentBase *ins) const {
|
||||
for (auto &insit : items_store) {
|
||||
if (insit == ins)
|
||||
return true;
|
||||
|
@ -86,22 +52,12 @@ bool PresentContainer::contains(MakeTools::PresentBase *ins) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
void PresentContainer::setVisibleState(bool state) { hostWidget()->setVisible(state); }
|
||||
|
||||
bool PresentContainer::visibleState() const { return hostWidget()->isVisible(); }
|
||||
|
||||
void PresentContainer::accept_close_action(int index) {
|
||||
auto disp = widget(index);
|
||||
for (auto &key : items_store.keys()) {
|
||||
auto inst = items_store[key];
|
||||
if (inst->widget() == disp) {
|
||||
items_store.remove(key);
|
||||
for (auto &ins : items_store) {
|
||||
if (ins->widget() == disp) {
|
||||
items_store.removeAll(ins);
|
||||
removeTab(index);
|
||||
|
||||
if (host_inst)
|
||||
host_inst->hasBeenClosed(key);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,25 +11,19 @@ namespace Components {
|
|||
class PresentContainer : public QTabWidget, public PresentHost {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PresentContainer(QTabWidget::TabPosition pos, HostListener *host = nullptr);
|
||||
PresentContainer(QTabWidget::TabPosition pos, QWidget *parent = nullptr);
|
||||
|
||||
// PresentContainer interface
|
||||
public:
|
||||
virtual QWidget *hostWidget() const override;
|
||||
|
||||
virtual void append(MakeTools::PresentBase *ins, const Core::Route &key) override;
|
||||
virtual bool active(const Core::Route &key) override;
|
||||
virtual MakeTools::PresentBase *remove(const Core::Route &key) override;
|
||||
virtual bool contains(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);
|
||||
virtual void append(MakeTools::PresentBase *ins) override;
|
||||
virtual bool active(const MakeTools::PresentBase *ins) override;
|
||||
virtual void remove(const MakeTools::PresentBase *ins) override;
|
||||
virtual bool contains(const MakeTools::PresentBase *ins) const override;
|
||||
|
||||
private:
|
||||
HostListener *const host_inst;
|
||||
QHash<Core::Route, MakeTools::PresentBase *> items_store;
|
||||
QList<const MakeTools::PresentBase *> items_store;
|
||||
|
||||
void accept_close_action(int index);
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ void ProjectPresent::menu_popup(const QPoint &p)
|
|||
for (auto &it : views) {
|
||||
menu->addAction(it, [this, &it, &index, mgr]() {
|
||||
auto name = QInputDialog::getText(this, "输入文件名称", "文件名称");
|
||||
auto path = mgr->converter(index);
|
||||
auto path = mgr->convertPath(index);
|
||||
source->postCommand(NewFile(path, name, it));
|
||||
});
|
||||
}
|
||||
|
@ -69,6 +69,6 @@ void ProjectPresent::menu_popup(const QPoint &p)
|
|||
void ProjectPresent::open_target(const QModelIndex &t)
|
||||
{
|
||||
auto mgr = source->get<DocumentsManager>(NAME(DocumentsManager));
|
||||
auto path = mgr->converter(t);
|
||||
auto path = mgr->convertPath(t);
|
||||
source->postCommand(OpenFile(path));
|
||||
}
|
||||
|
|
|
@ -47,10 +47,7 @@ MakeTools::FilePresent::Features DefaultTextEdit::features()
|
|||
return Features();
|
||||
}
|
||||
|
||||
void DefaultTextEdit::applySetting(const QString &name, Core::AppCore *core)
|
||||
{
|
||||
name_store = name;
|
||||
}
|
||||
void DefaultTextEdit::applySetting(const QString &name) { name_store = name; }
|
||||
|
||||
QString DefaultTextEdit::name() const
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace Components {
|
|||
// ContentPresent interface
|
||||
public:
|
||||
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 void load(const QFileInfo &target_file) override;
|
||||
virtual void saveAs(const QString &path) override;
|
||||
|
|
|
@ -112,11 +112,7 @@ bool StorySourceEdit::isModified() const
|
|||
return true;
|
||||
}
|
||||
|
||||
void StorySourceEdit::applySetting(const QString &name, Core::AppCore *core)
|
||||
{
|
||||
this->name_store = name;
|
||||
|
||||
}
|
||||
void StorySourceEdit::applySetting(const QString &name) { this->name_store = name; }
|
||||
|
||||
void StorySourceEdit::jumpTo(const QList<QString> &path) {
|
||||
// auto fpath = this->absoluteTargetPath();
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Components {
|
|||
virtual QString absoluteTargetPath() const override;
|
||||
virtual QString getText() 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 Features features() override;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue