分割命名空间、命令命名
This commit is contained in:
parent
e53b2a3a49
commit
87cc9aca79
|
@ -74,8 +74,8 @@ QString SaveAll::name() const
|
|||
void SaveAll::run(Schedule::CommandsDispatcher *core) const
|
||||
{
|
||||
auto vmgr = core->get<DocumentsManager>(NAME(SaveAll));
|
||||
vmgr->projectManager()->save();
|
||||
vmgr->save();
|
||||
vmgr->projectManager()->save();
|
||||
}
|
||||
|
||||
QString SaveAll::toText() const
|
||||
|
@ -263,10 +263,11 @@ void StorychainJumpTo::fromText(const QString &line)
|
|||
jump_path=line.split("/");
|
||||
}
|
||||
|
||||
|
||||
#include "storyboardspresent.h"
|
||||
#include "storychainspresent.h"
|
||||
#include "storyunitspresent.h"
|
||||
using namespace Components;
|
||||
using namespace DataModel;
|
||||
|
||||
StorychainDetailShow::StorychainDetailShow(const QList<QString> &chain_path)
|
||||
: chain_path(chain_path)
|
||||
|
@ -383,23 +384,41 @@ void StoryconceptJumpTo::fromText(const QString &line) {
|
|||
navi_path = line.split("/");
|
||||
}
|
||||
|
||||
StoryfragmentJumpTo::StoryfragmentJumpTo(const QList<QString> &path) {
|
||||
StoryboardJumpTo::StoryboardJumpTo(const QList<QString> &path) {
|
||||
navi_path.append(path);
|
||||
}
|
||||
|
||||
QString StoryfragmentJumpTo::name() const { return NAME(StoryfragmentJumpTo); }
|
||||
QString StoryboardJumpTo::name() const { return NAME(StoryboardJumpTo); }
|
||||
|
||||
void StoryfragmentJumpTo::run(Schedule::CommandsDispatcher *core) const {
|
||||
void StoryboardJumpTo::run(Schedule::CommandsDispatcher *core) const {
|
||||
auto core_ins = core->get<AppCore>(NAME(AppCore));
|
||||
|
||||
auto unit_ins = core_ins->parseCore()->queryStoryUnit(navi_path[0]).first();
|
||||
auto unit_doc = unit_ins->doc();
|
||||
|
||||
auto vmgr =
|
||||
core_ins->disp_core->get<DocumentsManager>(NAME(DocumentsManager));
|
||||
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
|
||||
|
||||
auto index = vmgr->projectManager()->queryIndex(unit_doc->filePath());
|
||||
auto route = vmgr->converter(index);
|
||||
vmgr->openFile(route);
|
||||
vmgr->activePresentOf(route)->jumpTo(navi_path);
|
||||
}
|
||||
|
||||
StoryboardDetailShow::StoryboardDetailShow(const QList<QString> &path) {
|
||||
navi_path.append(path);
|
||||
}
|
||||
|
||||
QString StoryboardDetailShow::name() const {
|
||||
return NAME(StoryboardDetailShow);
|
||||
}
|
||||
|
||||
void StoryboardDetailShow::run(Schedule::CommandsDispatcher *core) const {
|
||||
auto vm = core->get<StoryboardsPresentModel>(NAME(StoryboardsPresentModel));
|
||||
vm->detailShow(navi_path);
|
||||
}
|
||||
|
||||
QString StoryboardDetailShow::toText() const { return navi_path.join("/"); }
|
||||
|
||||
void StoryboardDetailShow::fromText(const QString &line) {
|
||||
navi_path = line.split("/");
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ namespace CommandList {
|
|||
bool all_from_disk;
|
||||
};
|
||||
|
||||
// 故事脉络相关命令 ========================================================
|
||||
class StorychainDetailShow : public Schedule::GeCommand {
|
||||
public:
|
||||
StorychainDetailShow(const QList<QString> &chain_path);
|
||||
|
@ -150,6 +151,7 @@ namespace CommandList {
|
|||
QList<QString> jump_path;
|
||||
};
|
||||
|
||||
// 故事单元相关命令 ======================================================
|
||||
class StoryunitDetailShow : public Schedule::GeCommand {
|
||||
public:
|
||||
StoryunitDetailShow(const QList<QString> &path);
|
||||
|
@ -180,6 +182,7 @@ namespace CommandList {
|
|||
QList<QString> unit_nav;
|
||||
};
|
||||
|
||||
// 故事概念相关命令===================================================
|
||||
class StoryconceptDetailShow : public Schedule::GeCommand {
|
||||
public:
|
||||
StoryconceptDetailShow(const QList<QString> &path);
|
||||
|
@ -210,9 +213,24 @@ namespace CommandList {
|
|||
QList<QString> navi_path;
|
||||
};
|
||||
|
||||
class StoryfragmentJumpTo : public Schedule::GeCommand {
|
||||
class StoryboardDetailShow : public Schedule::GeCommand {
|
||||
public:
|
||||
StoryfragmentJumpTo(const QList<QString> &path);
|
||||
StoryboardDetailShow(const QList<QString> &path);
|
||||
|
||||
private:
|
||||
QList<QString> navi_path;
|
||||
|
||||
// GeCommand interface
|
||||
public:
|
||||
virtual QString name() const override;
|
||||
virtual void run(Schedule::CommandsDispatcher *core) const override;
|
||||
virtual QString toText() const override;
|
||||
virtual void fromText(const QString &line) override;
|
||||
};
|
||||
|
||||
class StoryboardJumpTo : public Schedule::GeCommand {
|
||||
public:
|
||||
StoryboardJumpTo(const QList<QString> &path);
|
||||
|
||||
// GeCommand interface
|
||||
public:
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
using namespace Components;
|
||||
using namespace Parse;
|
||||
using namespace DataModel;
|
||||
|
||||
FragmentsOrderView::FragmentsOrderView(Schedule::CommandsDispatcher *core,
|
||||
QWidget *parent)
|
||||
|
@ -32,7 +33,7 @@ void FragmentsOrderView::double_click(const QModelIndex &index)
|
|||
path << index.sibling(index.row(), 0).data().toString();
|
||||
path << index.sibling(index.row(), 1).data().toString();
|
||||
|
||||
core_ins->postCommand(StoryfragmentJumpTo(path));
|
||||
core_ins->postCommand(StoryboardJumpTo(path));
|
||||
}
|
||||
|
||||
QString FragmentsOrderView::name() const { return NAME(FragmentsOrderView); }
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
#include "appcore.h"
|
||||
#include <commandsdispatcher.h>
|
||||
|
||||
namespace Components {
|
||||
|
||||
namespace DataModel {
|
||||
class FragmentsOrderviewModel : public Schedule::AccessibleObject {
|
||||
public:
|
||||
FragmentsOrderviewModel(Core::AppCore *core);
|
||||
|
@ -26,7 +25,9 @@ namespace Components {
|
|||
public:
|
||||
virtual QString name() const override;
|
||||
};
|
||||
} // namespace DataModel
|
||||
|
||||
namespace Components {
|
||||
class FragmentsOrderView : public QWidget, public Schedule::AccessibleObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -32,7 +32,8 @@ using namespace Tools;
|
|||
using namespace CommandList;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), app_core(new AppCore(this, true, this)),
|
||||
: QMainWindow(parent), app_core(new AppCore(this, this)),
|
||||
disp_core(new Schedule::CommandsDispatcher(QDir::home(), true)),
|
||||
sync_kernel(new StatusSyncCore(this)),
|
||||
horizontal_split(new QSplitter(Qt::Horizontal, this)),
|
||||
vertical_split(new QSplitter(Qt::Vertical, this)),
|
||||
|
@ -42,17 +43,19 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
welcome_list(new QListView(this)),
|
||||
project_present(new ProjectPresent(app_core, this)),
|
||||
docs_container(new DocumentsManager(app_core, project_manager, this)),
|
||||
chains_view(new StorychainsPresent(app_core->disp_core, this)),
|
||||
units_view(new StoryunitsPresent(app_core->disp_core, this)),
|
||||
chains_view(new StorychainsPresent(disp_core, this)),
|
||||
units_view(new StoryunitsPresent(disp_core, this)),
|
||||
errors_present(new MessagePresent(app_core->getMakeCore(), this)),
|
||||
boards_view(new StoryBoardsPresent(app_core, this)),
|
||||
concept_view(new StoryconceptsPresent(app_core, this)),
|
||||
fragments_order(new FragmentsOrderView(app_core, this)) {
|
||||
boards_view(new StoryboardsPresent(app_core, this)),
|
||||
concept_view(new StoryconceptsPresent(disp_core, this)),
|
||||
fragments_order(new FragmentsOrderView(disp_core, this)) {
|
||||
|
||||
QApplication::instance()->installEventFilter(this);
|
||||
|
||||
this->app_core->setCurrentProject(project_manager);
|
||||
this->app_core->disp_core->registerMember(docs_container);
|
||||
this->app_core->disp_core->registerMember(project_present);
|
||||
this->app_core->disp_core->registerMember(this->app_core);
|
||||
disp_core->registerMember(docs_container);
|
||||
disp_core->registerMember(project_present);
|
||||
disp_core->registerMember(this->app_core);
|
||||
|
||||
setMinimumSize(1000, 600);
|
||||
setWindowTitle("提线木偶");
|
||||
|
@ -134,11 +137,11 @@ void MainWindow::initial_menubar(QMenuBar *mbar)
|
|||
if(file == "")
|
||||
return;
|
||||
|
||||
this->app_core->disp_core->postCommand(OpenProject(file));
|
||||
disp_core->postCommand(OpenProject(file));
|
||||
build_internal(true);});
|
||||
sync_kernel->actionSync(opnp, [this]()->bool{return !project_manager->isOpen();});
|
||||
|
||||
auto newp = project->addAction("新建项目", [this](){
|
||||
auto newp = project->addAction("新建项目", [this]() {
|
||||
auto name = QInputDialog::getText(this, "输入项目名称", "项目名称");
|
||||
if(name == "")
|
||||
return;
|
||||
|
@ -146,19 +149,22 @@ void MainWindow::initial_menubar(QMenuBar *mbar)
|
|||
if(dir_path == "")
|
||||
return;
|
||||
|
||||
this->app_core->disp_core->postCommand(NewProject(QDir(dir_path), name));});
|
||||
disp_core->postCommand(NewProject(QDir(dir_path), name));
|
||||
});
|
||||
sync_kernel->actionSync(newp, [this]()->bool{return !project_manager->isOpen();});
|
||||
|
||||
auto clsp = project->addAction("关闭项目", [this](){
|
||||
this->app_core->disp_core->postCommand(CloseProject());
|
||||
this->refresh_views();});
|
||||
auto clsp = project->addAction("关闭项目", [this]() {
|
||||
disp_core->postCommand(CloseProject());
|
||||
this->refresh_views();
|
||||
});
|
||||
sync_kernel->actionSync(clsp, [this]()->bool{return project_manager->isOpen();});
|
||||
project->addSeparator();
|
||||
|
||||
auto pnew = project->addAction("新建路径", [this](){
|
||||
auto pnew = project->addAction("新建路径", [this]() {
|
||||
auto packages = QInputDialog::getText(this, "输入包路径名称/PackA/PackB/PackC", "包路径:");
|
||||
if(packages != "")
|
||||
this->app_core->disp_core->postCommand(NewPackage(packages));});
|
||||
disp_core->postCommand(NewPackage(packages));
|
||||
});
|
||||
sync_kernel->actionSync(pnew, [this]()->bool{return project_manager->isOpen();});
|
||||
|
||||
auto _xnew = project->addMenu("新建文件");
|
||||
|
@ -180,17 +186,16 @@ void MainWindow::initial_menubar(QMenuBar *mbar)
|
|||
sync_kernel->widgetSync(_xnew, [this]()->bool{return project_manager->isOpen();});
|
||||
project->addSeparator();
|
||||
|
||||
auto sav = project->addAction("保存全部", [this](){
|
||||
this->app_core->disp_core->postCommand(SaveAll());});
|
||||
auto sav = project->addAction(
|
||||
"保存全部", [this]() { disp_core->postCommand(SaveAll()); });
|
||||
sav->setShortcut(QKeySequence::StandardKey::Save);
|
||||
sync_kernel->actionSync(sav, [this]()->bool{return project_manager->isOpen();});
|
||||
project->addSeparator();
|
||||
|
||||
project->addAction("退出", [this](){
|
||||
this->app_core->disp_core->postCommand(SaveAll());
|
||||
QApplication::exit(0);});
|
||||
|
||||
|
||||
project->addAction("退出", [this]() {
|
||||
disp_core->postCommand(SaveAll());
|
||||
QApplication::exit(0);
|
||||
});
|
||||
|
||||
// 编辑菜单
|
||||
auto edit = mbar->addMenu("编辑");
|
||||
|
@ -377,7 +382,7 @@ void MainWindow::refresh_views()
|
|||
|
||||
void MainWindow::build_internal(bool all_from_disk)
|
||||
{
|
||||
app_core->disp_core->postCommand(Build(all_from_disk));
|
||||
disp_core->postCommand(Build(all_from_disk));
|
||||
refresh_views();
|
||||
}
|
||||
|
||||
|
@ -468,14 +473,11 @@ void MainWindow::remove(MakeTools::ContentPresent *ins)
|
|||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// 关闭事件
|
||||
if(project_manager->isOpen()){
|
||||
project_manager->save();
|
||||
app_core->getDocsManager()->closeAll();
|
||||
if (project_manager->isOpen()) {
|
||||
disp_core->postCommand(CloseProject());
|
||||
}
|
||||
|
||||
uilayout_save();
|
||||
app_core->save();
|
||||
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "ContentPresent.h"
|
||||
#include "DocsManager.h"
|
||||
#include "fragmentsorderview.h"
|
||||
#include "manager_docs.h"
|
||||
#include "messagepresent.h"
|
||||
#include "projectpresent.h"
|
||||
#include "storyboardspresent.h"
|
||||
#include "storychainspresent.h"
|
||||
#include "storyconceptspresent.h"
|
||||
#include "storyunitspresent.h"
|
||||
#include "tools.h"
|
||||
#include <QListView>
|
||||
#include <QMainWindow>
|
||||
#include <QSplitter>
|
||||
#include <QTableView>
|
||||
#include <libProjectManager.h>
|
||||
#include <StoryTool.h>
|
||||
#include <QTreeView>
|
||||
#include <QListView>
|
||||
#include "DocsManager.h"
|
||||
#include "messagepresent.h"
|
||||
#include "storychainspresent.h"
|
||||
#include "storyunitspresent.h"
|
||||
#include "manager_docs.h"
|
||||
#include "ContentPresent.h"
|
||||
#include "storyboardspresent.h"
|
||||
#include "storyconceptspresent.h"
|
||||
#include "fragmentsorderview.h"
|
||||
#include "tools.h"
|
||||
#include "projectpresent.h"
|
||||
#include <StoryTool.h>
|
||||
#include <libProjectManager.h>
|
||||
|
||||
class MainWindow : public QMainWindow, public Components::PresentContainer
|
||||
{
|
||||
class MainWindow : public QMainWindow, public Components::PresentContainer {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
Core::AppCore *const app_core;
|
||||
Schedule::CommandsDispatcher *const disp_core;
|
||||
|
||||
Tools::StatusSyncCore *const sync_kernel;
|
||||
QSplitter *const horizontal_split;
|
||||
QSplitter *const vertical_split;
|
||||
|
@ -40,7 +40,6 @@ private:
|
|||
QTabWidget *const center_funcs;
|
||||
QTabWidget *const bottom_funcs;
|
||||
|
||||
|
||||
Project::ProjectManager *const project_manager;
|
||||
|
||||
QListView *const welcome_list;
|
||||
|
@ -49,7 +48,7 @@ private:
|
|||
Components::StorychainsPresent *const chains_view;
|
||||
Components::StoryunitsPresent *const units_view;
|
||||
Components::MessagePresent *const errors_present;
|
||||
Components::StoryBoardsPresent *const boards_view;
|
||||
Components::StoryboardsPresent *const boards_view;
|
||||
Components::StoryconceptsPresent *const concept_view;
|
||||
Components::FragmentsOrderView *const fragments_order;
|
||||
|
||||
|
@ -59,30 +58,30 @@ private:
|
|||
void refresh_views();
|
||||
|
||||
void build_internal(bool all_from_disk = false);
|
||||
void toggle_widget_visible(bool visible, QTabWidget *con, QWidget *target, const QString& title=QString());
|
||||
void toggle_widget_visible(bool visible, QTabWidget *con, QWidget *target,
|
||||
const QString &title = QString());
|
||||
|
||||
void splitter_layout_save(const QList<QString> &path_type, const QList<int> &size);
|
||||
void splitter_layout_save(const QList<QString> &path_type,
|
||||
const QList<int> &size);
|
||||
|
||||
void uilayout_save();
|
||||
void uilayout_load();
|
||||
|
||||
// PresentContainer interface
|
||||
public:
|
||||
public:
|
||||
virtual void append(MakeTools::ContentPresent *ins) override;
|
||||
virtual void active(MakeTools::ContentPresent *ins) override;
|
||||
virtual void remove(MakeTools::ContentPresent *ins) override;
|
||||
|
||||
|
||||
void contentViewAppend(QWidget *widget, const QString &name);
|
||||
void contentViewClose(QWidget *widget);
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
// QObject interface
|
||||
public:
|
||||
public:
|
||||
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -1,89 +1,168 @@
|
|||
#include "storyboardspresent.h"
|
||||
#include "command_list.h"
|
||||
#include "opstream.h"
|
||||
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Components;
|
||||
using namespace Parse::Result;
|
||||
using namespace DataModel;
|
||||
|
||||
StoryboardsPresent::StoryboardsPresent(Schedule::CommandsDispatcher *core,
|
||||
QWidget *parent)
|
||||
: QWidget(parent), core_ins(core), tree_view(new QTreeView(this)),
|
||||
details_view(new QTextEdit(this)) {
|
||||
auto backend =
|
||||
core->get<StoryboardsPresentModel>(NAME(StoryboardsPresentModel));
|
||||
|
||||
tree_view->setModel(backend->treeModel());
|
||||
details_view->setDocument(backend->detailBackend());
|
||||
details_view->setReadOnly(true);
|
||||
|
||||
StoryBoardsPresent::StoryBoardsPresent(Core::AppCore *core, QWidget *parent)
|
||||
: QWidget(parent), core_ins(core),
|
||||
tree_view(new QTreeView(this)), details_view(new QTextEdit(this)),
|
||||
model_base(new QStandardItemModel(this))
|
||||
{
|
||||
tree_view->setModel(model_base);
|
||||
auto layout = new QVBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
|
||||
auto splitter= new QSplitter(Qt::Vertical, this);
|
||||
layout->addWidget(splitter);
|
||||
|
||||
splitter->addWidget(tree_view);
|
||||
splitter->addWidget(details_view);
|
||||
details_view->setReadOnly(true);
|
||||
|
||||
connect(tree_view, &QTreeView::expanded, [this](){
|
||||
tree_view->resizeColumnToContents(0);
|
||||
tree_view->resizeColumnToContents(1);
|
||||
});
|
||||
|
||||
connect(tree_view, &QTreeView::clicked, this, &StoryBoardsPresent::show_current_details);
|
||||
connect(tree_view, &QTreeView::clicked, this, &StoryboardsPresent::show_current_details);
|
||||
}
|
||||
|
||||
void StoryBoardsPresent::refresh()
|
||||
{
|
||||
using namespace CommandList;
|
||||
void StoryboardsPresent::show_current_details(const QModelIndex &idx) {
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
QList<QString> path;
|
||||
auto node = idx;
|
||||
while (true) {
|
||||
auto name = node.data().toString();
|
||||
if (name.isEmpty())
|
||||
break;
|
||||
path.insert(0, name);
|
||||
node = node.parent();
|
||||
}
|
||||
core_ins->postCommand(StoryboardDetailShow(path));
|
||||
}
|
||||
|
||||
void StoryboardsPresent::jump_to(const QModelIndex &idx) {
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
QList<QString> path;
|
||||
auto node = idx;
|
||||
while (true) {
|
||||
auto name = node.data().toString();
|
||||
if (name.isEmpty())
|
||||
break;
|
||||
path.insert(0, name);
|
||||
node = node.parent();
|
||||
}
|
||||
core_ins->postCommand(StoryboardJumpTo(path));
|
||||
}
|
||||
|
||||
QString StoryboardsPresent::name() const { return NAME(StoryboardsPresent); }
|
||||
|
||||
DataModel::StoryboardsPresentModel::StoryboardsPresentModel(Core::AppCore *core)
|
||||
: core_ins(core), model_base(new QStandardItemModel),
|
||||
detail_backend(new QTextDocument) {}
|
||||
|
||||
void DataModel::StoryboardsPresentModel::refresh() {
|
||||
model_base->clear();
|
||||
model_base->setHorizontalHeaderLabels(QStringList() << "名称" << "单元");
|
||||
model_base->setHorizontalHeaderLabels(QStringList() << "名称"
|
||||
<< "单元");
|
||||
auto storys = core_ins->parseCore()->allStoryBoards();
|
||||
|
||||
for(auto &b : storys){
|
||||
auto item = new QStandardItem(static_cast<NamedNode*>(b)->name()[0]);
|
||||
for (auto &b : storys) {
|
||||
auto item = new QStandardItem(static_cast<NamedNode *>(b)->name()[0]);
|
||||
item->setEditable(false);
|
||||
model_base->appendRow(item);
|
||||
|
||||
auto refers = b->children();
|
||||
for(auto &ref : refers){
|
||||
if(ref->typeValue() != NODE_FRAGMENTREFERENCE)
|
||||
for (auto &ref : refers) {
|
||||
if (ref->typeValue() != NODE_FRAGMENTREFERENCE)
|
||||
continue;
|
||||
|
||||
QList<QStandardItem*> row;
|
||||
row << new QStandardItem("@"+static_cast<NamedNode*>(ref)->name()[0]);
|
||||
QList<QStandardItem *> row;
|
||||
row << new QStandardItem("@" +
|
||||
static_cast<NamedNode *>(ref)->name()[0]);
|
||||
row.last()->setEditable(false);
|
||||
row << new QStandardItem(static_cast<NamedNode*>(ref)->name()[1]);
|
||||
row << new QStandardItem(static_cast<NamedNode *>(ref)->name()[1]);
|
||||
row.last()->setEditable(false);
|
||||
|
||||
item->appendRow(row);
|
||||
}
|
||||
}
|
||||
|
||||
this->tree_view->resizeColumnToContents(0);
|
||||
}
|
||||
|
||||
void StoryBoardsPresent::show_current_details(const QModelIndex &idx)
|
||||
{
|
||||
if(!idx.isValid())
|
||||
return;
|
||||
using namespace Operate;
|
||||
void DataModel::StoryboardsPresentModel::detailShow(
|
||||
const QList<QString> &navi) {
|
||||
QList<QStandardItem *> items_list =
|
||||
OpStream<QStandardItem *>([this](int &cnt, int idx) -> QStandardItem * {
|
||||
cnt = model_base->rowCount();
|
||||
if (cnt <= 0)
|
||||
return nullptr;
|
||||
return model_base->item(idx);
|
||||
})
|
||||
.select()
|
||||
.toList();
|
||||
|
||||
details_view->clear();
|
||||
auto item = model_base->itemFromIndex(idx.sibling(idx.row(), 0));
|
||||
if(item->parent() == nullptr){
|
||||
for (auto &node : navi) {
|
||||
auto result = OpStream<QStandardItem *>(items_list)
|
||||
.filter([node](QStandardItem *const &it) {
|
||||
return node == it->text();
|
||||
})
|
||||
.toList();
|
||||
|
||||
if (!result.size())
|
||||
throw new SimpleException("指定的Storyunits路径无效:" +
|
||||
navi.join("/"));
|
||||
|
||||
items_list = OpStream<QStandardItem *>(
|
||||
[&result](int &cnt, int idx) -> QStandardItem * {
|
||||
cnt = result[0]->rowCount();
|
||||
if (cnt <= 0)
|
||||
return nullptr;
|
||||
return result[0]->child(idx);
|
||||
})
|
||||
.select()
|
||||
.toList();
|
||||
}
|
||||
|
||||
QString contents;
|
||||
QStandardItem *item = items_list[0];
|
||||
if (item->parent() == nullptr) {
|
||||
auto node = core_ins->parseCore()->queryStoryBoard(item->text());
|
||||
|
||||
auto children = node.first()->children();
|
||||
for(auto &it : children){
|
||||
if(it->typeValue() != NODE_FRAGMENTREFERENCE){
|
||||
details_view->append(it->toString());
|
||||
for (auto &it : children) {
|
||||
if (it->typeValue() != NODE_FRAGMENTREFERENCE) {
|
||||
contents += it->toString() + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
auto node = core_ins->parseCore()->queryStoryBoard(item->parent()->text());
|
||||
auto point = core_ins->parseCore()->queryStoryFragmentRefer(node.first(), item->text().mid(1));
|
||||
} else {
|
||||
auto node =
|
||||
core_ins->parseCore()->queryStoryBoard(item->parent()->text());
|
||||
auto point = core_ins->parseCore()->queryStoryFragmentRefer(
|
||||
node.first(), item->text().mid(1));
|
||||
|
||||
auto children = point.first()->children();
|
||||
for(auto &it : children){
|
||||
details_view->append(it->toString());
|
||||
for (auto &it : children) {
|
||||
contents += it->toString() + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
detail_backend->setPlainText(contents);
|
||||
}
|
||||
|
||||
QString DataModel::StoryboardsPresentModel::name() const {
|
||||
return NAME(StoryboardsPresentModel);
|
||||
}
|
||||
|
|
|
@ -7,25 +7,51 @@
|
|||
#include <QTreeView>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Components {
|
||||
namespace DataModel {
|
||||
|
||||
class StoryBoardsPresent : public QWidget
|
||||
{
|
||||
public:
|
||||
StoryBoardsPresent(Core::AppCore *core, QWidget *parent=nullptr);
|
||||
class StoryboardsPresentModel : public Schedule::AccessibleObject {
|
||||
public:
|
||||
StoryboardsPresentModel(Core::AppCore *core);
|
||||
virtual ~StoryboardsPresentModel();
|
||||
|
||||
void refresh();
|
||||
void detailShow(const QList<QString> &navi);
|
||||
|
||||
private:
|
||||
QStandardItemModel *treeModel() const;
|
||||
QTextDocument *detailBackend() const;
|
||||
|
||||
// AccessibleObject interface
|
||||
public:
|
||||
virtual QString name() const override;
|
||||
|
||||
private:
|
||||
Core::AppCore *const core_ins;
|
||||
QStandardItemModel *const model_base;
|
||||
QTextDocument *const detail_backend;
|
||||
};
|
||||
|
||||
} // namespace DataModel
|
||||
|
||||
namespace Components {
|
||||
|
||||
class StoryboardsPresent : public QWidget,
|
||||
public Schedule::AccessibleObject {
|
||||
public:
|
||||
StoryboardsPresent(Schedule::CommandsDispatcher *core,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
// AccessibleObject interface
|
||||
public:
|
||||
virtual QString name() const override;
|
||||
|
||||
private:
|
||||
Schedule::CommandsDispatcher *const core_ins;
|
||||
QTreeView *const tree_view;
|
||||
QTextEdit *const details_view;
|
||||
QStandardItemModel *const model_base;
|
||||
|
||||
void show_current_details(const QModelIndex &idx);
|
||||
void click_to(const QModelIndex &idx);
|
||||
void jump_to(const QModelIndex &idx);
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace Components
|
||||
|
||||
#endif // STORYBOARDSPRESENT_H
|
||||
|
|
|
@ -11,6 +11,7 @@ using namespace Parse;
|
|||
using namespace Parse::Result;
|
||||
using namespace Tools;
|
||||
using namespace CommandList;
|
||||
using namespace DataModel;
|
||||
|
||||
StorychainsPresentModel::StorychainsPresentModel(Core::AppCore *core)
|
||||
: core_ins(core), model_base(new QStandardItemModel),
|
||||
|
|
|
@ -10,35 +10,37 @@
|
|||
#include <QWidget>
|
||||
#include <libParse.h>
|
||||
|
||||
namespace Components {
|
||||
namespace DataModel {
|
||||
|
||||
/**
|
||||
* @brief 情节链展示后端
|
||||
*/
|
||||
class StorychainsPresentModel : public Schedule::AccessibleObject
|
||||
{
|
||||
public:
|
||||
class StorychainsPresentModel : public Schedule::AccessibleObject {
|
||||
public:
|
||||
StorychainsPresentModel(Core::AppCore *core);
|
||||
virtual ~StorychainsPresentModel();
|
||||
|
||||
QStandardItemModel* treeModel() const;
|
||||
QStandardItemModel *treeModel() const;
|
||||
QTextDocument *const detailsBackend() const;
|
||||
|
||||
void refreshTree();
|
||||
void showDetails(const QList<QString> &chain_path);
|
||||
|
||||
// AccessibleObject interface
|
||||
public:
|
||||
public:
|
||||
virtual QString name() const override;
|
||||
|
||||
private:
|
||||
private:
|
||||
Core::AppCore *const core_ins;
|
||||
QStandardItemModel *const model_base;
|
||||
QTextDocument *const details_base;
|
||||
Tools::TreeSyncs<Parse::Result::DesNode*> *sync_tools;
|
||||
|
||||
Tools::TreeSyncs<Parse::Result::DesNode *> *sync_tools;
|
||||
};
|
||||
|
||||
} // namespace DataModel
|
||||
|
||||
namespace Components {
|
||||
|
||||
/**
|
||||
* @brief 情节链展示视图
|
||||
*/
|
||||
|
|
|
@ -18,8 +18,8 @@ StoryconceptsPresent::StoryconceptsPresent(CommandsDispatcher *core,
|
|||
QWidget *parent)
|
||||
: QWidget(parent), core_ins(core), tree_view(new QTreeView(this)),
|
||||
details_view(new QTextBrowser(this)) {
|
||||
auto backend =
|
||||
core->get<StoryconceptsPresentModel>(NAME(StoryconceptsPresentModel));
|
||||
auto backend = core->get<DataModel::StoryconceptsPresentModel>(
|
||||
NAME(StoryconceptsPresentModel));
|
||||
|
||||
tree_view->setModel(backend->treeModel());
|
||||
tree_view->setHeaderHidden(true);
|
||||
|
@ -78,6 +78,7 @@ QString StoryconceptsPresent::name() const {
|
|||
return NAME(StoryconceptsPresent);
|
||||
}
|
||||
|
||||
using namespace DataModel;
|
||||
StoryconceptsPresentModel::StoryconceptsPresentModel(Core::AppCore *core)
|
||||
: core_ins(core), model_base(new QStandardItemModel),
|
||||
detail_backend(new QTextDocument) {
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
#include <QTreeView>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Components {
|
||||
namespace DataModel {
|
||||
|
||||
class StoryconceptsPresentModel : public Schedule::AccessibleObject {
|
||||
public:
|
||||
StoryconceptsPresentModel(Core::AppCore *core);
|
||||
|
@ -33,6 +34,9 @@ namespace Components {
|
|||
Tools::TreeSyncs<Parse::Result::DesNode *> *concept_model;
|
||||
};
|
||||
|
||||
} // namespace DataModel
|
||||
|
||||
namespace Components {
|
||||
class StoryconceptsPresent : public QWidget,
|
||||
public Schedule::AccessibleObject {
|
||||
public:
|
||||
|
@ -51,7 +55,6 @@ namespace Components {
|
|||
public:
|
||||
virtual QString name() const override;
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace Components
|
||||
|
||||
#endif // STORYCONCEPTSPRESENT_H
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
using namespace Components;
|
||||
using namespace Parse::Result;
|
||||
using namespace Operate;
|
||||
using namespace DataModel;
|
||||
|
||||
StoryunitsPresentModel::StoryunitsPresentModel(Core::AppCore *core)
|
||||
: core_ins(core), model_ins(new QStandardItemModel),
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "appcore.h"
|
||||
#include "libParse.h"
|
||||
|
||||
namespace Components {
|
||||
namespace DataModel {
|
||||
|
||||
class StoryunitsPresentModel : public Schedule::AccessibleObject {
|
||||
public:
|
||||
|
@ -33,6 +33,10 @@ namespace Components {
|
|||
QTextDocument *const details_backend;
|
||||
};
|
||||
|
||||
} // namespace DataModel
|
||||
|
||||
namespace Components {
|
||||
|
||||
class StoryunitsPresent : public QWidget,
|
||||
public Schedule::AccessibleObject {
|
||||
Q_OBJECT
|
||||
|
|
Loading…
Reference in New Issue