storyunitspresent改造完成
This commit is contained in:
parent
4e7354d075
commit
6def2aa88e
|
@ -265,6 +265,7 @@ void StorychainJumpTo::fromText(const QString &line)
|
||||||
|
|
||||||
|
|
||||||
#include "storychainspresent.h"
|
#include "storychainspresent.h"
|
||||||
|
#include "storyunitspresent.h"
|
||||||
using namespace Components;
|
using namespace Components;
|
||||||
|
|
||||||
StorychainDetailShow::StorychainDetailShow(const QList<QString> &chain_path)
|
StorychainDetailShow::StorychainDetailShow(const QList<QString> &chain_path)
|
||||||
|
@ -294,27 +295,44 @@ void StorychainDetailShow::fromText(const QString &line)
|
||||||
chain_path = line.split("/");
|
chain_path = line.split("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StoryunitDetailShow::StoryunitDetailShow(const QList<QString> &path) {
|
||||||
|
unit_nav.append(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StoryunitDetailShow::name() const { return NAME(StoryunitDetailShow); }
|
||||||
|
|
||||||
|
void StoryunitDetailShow::run(Schedule::CommandsDispatcher *core) const {
|
||||||
|
auto backend =
|
||||||
|
core->get<StoryunitsPresentModel>(NAME(StoryunitsPresentModel));
|
||||||
|
backend->details_show(unit_nav);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StoryunitDetailShow::toText() const { return unit_nav.join("/"); }
|
||||||
|
|
||||||
|
void StoryunitDetailShow::fromText(const QString &line) {
|
||||||
|
unit_nav = line.split("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
StoryunitJumpTo::StoryunitJumpTo(const QList<QString> &path) {
|
||||||
|
unit_nav = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StoryunitJumpTo::name() const { return NAME(StoryunitJumpTo); }
|
||||||
|
|
||||||
|
void StoryunitJumpTo::run(Schedule::CommandsDispatcher *core) const {
|
||||||
|
auto core_ins = core->get<AppCore>(NAME(AppCore));
|
||||||
|
auto vmgr = core->get<DocumentsManager>(NAME(DocumentsManager));
|
||||||
|
|
||||||
|
auto unit_ins = core_ins->parseCore()->queryStoryUnit(unit_nav[0]).first();
|
||||||
|
auto index =
|
||||||
|
vmgr->projectManager()->queryIndex(unit_ins->doc()->filePath());
|
||||||
|
auto pjt_path = vmgr->converter(index);
|
||||||
|
vmgr->openFile(pjt_path);
|
||||||
|
vmgr->activePresentOf(pjt_path)->jumpTo(unit_nav);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StoryunitJumpTo::toText() const { return unit_nav.join("/"); }
|
||||||
|
|
||||||
|
void StoryunitJumpTo::fromText(const QString &line) {
|
||||||
|
unit_nav = line.split("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,36 @@ namespace CommandList {
|
||||||
QList<QString> jump_path;
|
QList<QString> jump_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class StoryunitDetailShow : public Schedule::GeCommand {
|
||||||
|
public:
|
||||||
|
StoryunitDetailShow(const QList<QString> &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;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<QString> unit_nav;
|
||||||
|
};
|
||||||
|
|
||||||
|
class StoryunitJumpTo : public Schedule::GeCommand {
|
||||||
|
public:
|
||||||
|
StoryunitJumpTo(const QList<QString> &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;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<QString> unit_nav;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace CommandList
|
} // namespace CommandList
|
||||||
|
|
||||||
#endif // COMMAND_LIST_H
|
#endif // COMMAND_LIST_H
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "storychainspresent.h"
|
#include "storychainspresent.h"
|
||||||
#include "DocsManager.h"
|
#include "DocsManager.h"
|
||||||
#include "manager_docs.h"
|
|
||||||
#include "command_list.h"
|
#include "command_list.h"
|
||||||
|
#include "manager_docs.h"
|
||||||
|
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
@ -12,110 +12,105 @@ using namespace Parse::Result;
|
||||||
using namespace Tools;
|
using namespace Tools;
|
||||||
using namespace CommandList;
|
using namespace CommandList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StorychainsPresentModel::StorychainsPresentModel(Core::AppCore *core)
|
StorychainsPresentModel::StorychainsPresentModel(Core::AppCore *core)
|
||||||
:core_ins(core),
|
: core_ins(core), model_base(new QStandardItemModel),
|
||||||
model_base(new QStandardItemModel),
|
details_base(new QTextDocument) {
|
||||||
details_base(new QTextDocument)
|
sync_tools = new ModelSyncs<DesNode *>(
|
||||||
{
|
|
||||||
sync_tools = new ModelSyncs<DesNode*>(
|
|
||||||
model_base,
|
model_base,
|
||||||
[](DesNode *const &d, QStandardItem *it)->bool {
|
[](DesNode *const &d, QStandardItem *it) -> bool {
|
||||||
return static_cast<NamedNode*>(d)->name().first() == it->text();},
|
return static_cast<NamedNode *>(d)->name().first() == it->text();
|
||||||
|
},
|
||||||
[](DesNode *const &d, QStandardItem *it) {
|
[](DesNode *const &d, QStandardItem *it) {
|
||||||
it->setText(static_cast<NamedNode*>(d)->name().first()); });
|
it->setText(static_cast<NamedNode *>(d)->name().first());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
StorychainsPresentModel::~StorychainsPresentModel()
|
StorychainsPresentModel::~StorychainsPresentModel() {
|
||||||
{
|
|
||||||
delete model_base;
|
delete model_base;
|
||||||
delete details_base;
|
delete details_base;
|
||||||
delete sync_tools;
|
delete sync_tools;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItemModel *StorychainsPresentModel::treeModel() const
|
QStandardItemModel *StorychainsPresentModel::treeModel() const {
|
||||||
{
|
|
||||||
return model_base;
|
return model_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextDocument *const StorychainsPresentModel::detailsBackend() const
|
QTextDocument *const StorychainsPresentModel::detailsBackend() const {
|
||||||
{
|
|
||||||
return details_base;
|
return details_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorychainsPresentModel::refreshTree()
|
void StorychainsPresentModel::refreshTree() {
|
||||||
{
|
sync_tools->presentSync([this](DesNode *p) -> QList<DesNode *> {
|
||||||
sync_tools->presentSync(
|
if (p) {
|
||||||
[this](DesNode *p)->QList<DesNode*>{
|
QList<DesNode *> retv;
|
||||||
if(p){
|
for (auto &point : p->children()) {
|
||||||
QList<DesNode*> retv;
|
if (point->typeValue() == NODE_STORYPOINT) {
|
||||||
for(auto &point : p->children()){
|
retv << point;
|
||||||
if(point->typeValue() == NODE_STORYPOINT){
|
|
||||||
retv << point;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return retv;
|
|
||||||
}
|
}
|
||||||
else
|
return retv;
|
||||||
return this->core_ins->parseCore()->allStoryChains();
|
} else
|
||||||
});
|
return this->core_ins->parseCore()->allStoryChains();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace Operate;
|
using namespace Operate;
|
||||||
void StorychainsPresentModel::showDetails(const QList<QString> &chain_path)
|
void StorychainsPresentModel::showDetails(const QList<QString> &chain_path) {
|
||||||
{
|
|
||||||
// 获取第一级初始集合
|
// 获取第一级初始集合
|
||||||
QList<QStandardItem*> item_list = \
|
QList<QStandardItem *> item_list =
|
||||||
OpStream<QStandardItem*>([this](int &cnt, int idx)->QStandardItem*
|
OpStream<QStandardItem *>([this](int &cnt, int idx) -> QStandardItem * {
|
||||||
{
|
cnt = model_base->rowCount();
|
||||||
cnt = model_base->rowCount();
|
if (cnt <= 0)
|
||||||
if(cnt <= 0)
|
return nullptr;
|
||||||
return nullptr;
|
return model_base->item(idx);
|
||||||
return model_base->item(idx);
|
})
|
||||||
}).select().toList();
|
.select()
|
||||||
|
.toList();
|
||||||
|
|
||||||
// 迭代路径获取故事链节点
|
// 迭代路径获取故事链节点
|
||||||
for(auto it : chain_path){
|
for (auto it : chain_path) {
|
||||||
auto result = \
|
auto result = OpStream<QStandardItem *>(item_list)
|
||||||
OpStream<QStandardItem*>(item_list)
|
.filter([it](QStandardItem *const &xit) {
|
||||||
.filter([it](QStandardItem *const &xit)
|
return it == xit->text();
|
||||||
{return it == xit->text();})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if(!result.size()){
|
if (!result.size()) {
|
||||||
throw new SimpleException("指定的Storychain路径无效:" + chain_path.join("/"));
|
throw new SimpleException("指定的Storychain路径无效:" +
|
||||||
|
chain_path.join("/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
item_list = \
|
item_list = OpStream<QStandardItem *>(
|
||||||
OpStream<QStandardItem*>([&result](int &cnt, int idx)->QStandardItem*
|
[&result](int &cnt, int idx) -> QStandardItem * {
|
||||||
{
|
cnt = result[0]->rowCount();
|
||||||
cnt = result[0]->rowCount();
|
if (cnt <= 0)
|
||||||
if(cnt <= 0)
|
return nullptr;
|
||||||
return nullptr;
|
return result[0]->child(idx);
|
||||||
return result[0]->child(idx);
|
})
|
||||||
}).select().toList();
|
.select()
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 填充详细内容
|
// 填充详细内容
|
||||||
auto item = item_list[0];
|
auto item = item_list[0];
|
||||||
QString text_lines;
|
QString text_lines;
|
||||||
if(item->parent() == nullptr){
|
if (item->parent() == nullptr) {
|
||||||
auto node = core_ins->parseCore()->queryStoryChain(item->text());
|
auto node = core_ins->parseCore()->queryStoryChain(item->text());
|
||||||
|
|
||||||
auto children = node.first()->children();
|
auto children = node.first()->children();
|
||||||
for(auto &it : children){
|
for (auto &it : children) {
|
||||||
if(it->typeValue() != NODE_STORYPOINT){
|
if (it->typeValue() != NODE_STORYPOINT) {
|
||||||
text_lines += it->toString() + "\n";
|
text_lines += it->toString() + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
auto node =
|
||||||
auto node = core_ins->parseCore()->queryStoryChain(item->parent()->text());
|
core_ins->parseCore()->queryStoryChain(item->parent()->text());
|
||||||
auto point = core_ins->parseCore()->queryStoryPoint(node.first(), item->text());
|
auto point =
|
||||||
|
core_ins->parseCore()->queryStoryPoint(node.first(), item->text());
|
||||||
|
|
||||||
auto children = point.first()->children();
|
auto children = point.first()->children();
|
||||||
for(auto &it : children){
|
for (auto &it : children) {
|
||||||
text_lines += it->toString() + "\n";
|
text_lines += it->toString() + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,25 +118,22 @@ void StorychainsPresentModel::showDetails(const QList<QString> &chain_path)
|
||||||
details_base->setPlainText(text_lines);
|
details_base->setPlainText(text_lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StorychainsPresentModel::name() const
|
QString StorychainsPresentModel::name() const {
|
||||||
{
|
|
||||||
return NAME(StorychainsPresentModel);
|
return NAME(StorychainsPresentModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StorychainsPresent::StorychainsPresent(Schedule::CommandsDispatcher *disp,
|
||||||
|
QWidget *parent)
|
||||||
StorychainsPresent::StorychainsPresent(Schedule::CommandsDispatcher *disp, QWidget *parent)
|
: QWidget(parent), disp_core(disp), tree_view(new QTreeView(this)),
|
||||||
: QWidget(parent), disp_core(disp),
|
details_show(new QPlainTextEdit) {
|
||||||
tree_view(new QTreeView(this)), details_show(new QPlainTextEdit)
|
auto backend =
|
||||||
{
|
disp->get<StorychainsPresentModel>(NAME(StorychainsPresentModel));
|
||||||
auto backend = disp->get<StorychainsPresentModel>(NAME(StorychainsPresentModel));
|
|
||||||
|
|
||||||
tree_view->setModel(backend->treeModel());
|
tree_view->setModel(backend->treeModel());
|
||||||
tree_view->setHeaderHidden(true);
|
tree_view->setHeaderHidden(true);
|
||||||
details_show->setDocument(backend->detailsBackend());
|
details_show->setDocument(backend->detailsBackend());
|
||||||
details_show->setReadOnly(true);
|
details_show->setReadOnly(true);
|
||||||
|
|
||||||
|
|
||||||
auto layoutx = new QVBoxLayout(this);
|
auto layoutx = new QVBoxLayout(this);
|
||||||
auto split = new QSplitter(Qt::Vertical, this);
|
auto split = new QSplitter(Qt::Vertical, this);
|
||||||
layoutx->addWidget(split);
|
layoutx->addWidget(split);
|
||||||
|
@ -149,20 +141,16 @@ StorychainsPresent::StorychainsPresent(Schedule::CommandsDispatcher *disp, QWidg
|
||||||
split->addWidget(details_show);
|
split->addWidget(details_show);
|
||||||
layoutx->setMargin(0);
|
layoutx->setMargin(0);
|
||||||
|
|
||||||
connect(tree_view, &QTreeView::clicked,
|
connect(tree_view, &QTreeView::clicked, this,
|
||||||
this, &StorychainsPresent::details_show);
|
&StorychainsPresent::detail_show);
|
||||||
connect(tree_view, &QTreeView::doubleClicked,
|
connect(tree_view, &QTreeView::doubleClicked, this,
|
||||||
this, &StorychainsPresent::jump_to);
|
&StorychainsPresent::jump_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StorychainsPresent::name() const
|
QString StorychainsPresent::name() const { return NAME(StorychainsPresent); }
|
||||||
{
|
|
||||||
return NAME(StorychainsPresent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StorychainsPresent::jump_to(const QModelIndex &curr)
|
void StorychainsPresent::jump_to(const QModelIndex &curr) {
|
||||||
{
|
if (!curr.isValid())
|
||||||
if(!curr.isValid())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<QString> path;
|
QList<QString> path;
|
||||||
|
@ -179,9 +167,8 @@ void StorychainsPresent::jump_to(const QModelIndex &curr)
|
||||||
disp_core->postCommand(StorychainJumpTo(path));
|
disp_core->postCommand(StorychainJumpTo(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorychainsPresent::detail_show(const QModelIndex &curr)
|
void StorychainsPresent::detail_show(const QModelIndex &curr) {
|
||||||
{
|
if (!curr.isValid())
|
||||||
if(!curr.isValid())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<QString> path;
|
QList<QString> path;
|
||||||
|
@ -197,16 +184,3 @@ void StorychainsPresent::detail_show(const QModelIndex &curr)
|
||||||
|
|
||||||
disp_core->postCommand(StorychainDetailShow(path));
|
disp_core->postCommand(StorychainDetailShow(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
#include "storyunitspresent.h"
|
#include "storyunitspresent.h"
|
||||||
#include "DocsManager.h"
|
#include "DocsManager.h"
|
||||||
|
#include "command_list.h"
|
||||||
|
#include "opstream.h"
|
||||||
|
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
using namespace Components;
|
using namespace Components;
|
||||||
using namespace Parse::Result;
|
using namespace Parse::Result;
|
||||||
|
using namespace Operate;
|
||||||
|
|
||||||
StoryunitsPresentModel::StoryunitsPresentModel(Core::AppCore *core)
|
StoryunitsPresentModel::StoryunitsPresentModel(Core::AppCore *core)
|
||||||
: core_ins(core), model_ins(new QStandardItemModel),
|
: core_ins(core), model_ins(new QStandardItemModel),
|
||||||
|
@ -24,7 +27,7 @@ QTextDocument *StoryunitsPresentModel::detailsBackend() const {
|
||||||
return details_backend;
|
return details_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoryunitsPresentModel::refresh() {
|
void StoryunitsPresentModel::refreshTree() {
|
||||||
model_ins->clear();
|
model_ins->clear();
|
||||||
auto units = core_ins->parseCore()->allStoryUnits();
|
auto units = core_ins->parseCore()->allStoryUnits();
|
||||||
for (auto &unit : units) {
|
for (auto &unit : units) {
|
||||||
|
@ -45,19 +48,49 @@ void StoryunitsPresentModel::refresh() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoryunitsPresentModel::show_node_description(const QModelIndex &curr) {
|
void StoryunitsPresentModel::details_show(const QList<QString> &path) {
|
||||||
if (!curr.isValid())
|
QList<QStandardItem *> items_list =
|
||||||
return;
|
OpStream<QStandardItem *>([this](int &cnt, int idx) -> QStandardItem * {
|
||||||
|
cnt = model_ins->rowCount();
|
||||||
|
if (cnt <= 0)
|
||||||
|
return nullptr;
|
||||||
|
return model_ins->item(idx);
|
||||||
|
})
|
||||||
|
.select()
|
||||||
|
.toList();
|
||||||
|
|
||||||
details_show->clear();
|
for (auto &node : path) {
|
||||||
auto item = model_ins->itemFromIndex(curr);
|
auto result = OpStream<QStandardItem *>(items_list)
|
||||||
|
.filter([node](QStandardItem *const &it) {
|
||||||
|
return node == it->text();
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!result.size())
|
||||||
|
throw new SimpleException("指定的Storyunits路径无效:" +
|
||||||
|
path.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;
|
||||||
|
auto item = items_list[0];
|
||||||
if (item->parent() == nullptr) {
|
if (item->parent() == nullptr) {
|
||||||
auto node = core_ins->parseCore()->queryStoryUnit(item->text());
|
auto node = core_ins->parseCore()->queryStoryUnit(item->text());
|
||||||
|
|
||||||
auto children = node.first()->children();
|
auto children = node.first()->children();
|
||||||
for (auto &it : children) {
|
for (auto &it : children) {
|
||||||
if (it->typeValue() != NODE_STORYFRAGMENT) {
|
if (it->typeValue() != NODE_STORYFRAGMENT) {
|
||||||
details_show->appendPlainText(it->toString());
|
contents += it->toString() + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,38 +101,16 @@ void StoryunitsPresentModel::show_node_description(const QModelIndex &curr) {
|
||||||
|
|
||||||
auto children = point.first()->children();
|
auto children = point.first()->children();
|
||||||
for (auto &it : children) {
|
for (auto &it : children) {
|
||||||
details_show->appendPlainText(it->toString());
|
contents += it->toString() + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void StoryunitsPresentModel::click_to(const QModelIndex &curr) {
|
details_backend->setPlainText(contents);
|
||||||
if (!curr.isValid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto pnode = this->model_ins->itemFromIndex(curr);
|
|
||||||
QList<QString> path;
|
|
||||||
while (pnode) {
|
|
||||||
path.insert(0, pnode->text());
|
|
||||||
pnode = pnode->parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto unit_ins =
|
|
||||||
this->core_ins->parseCore()->queryStoryUnit(path[0]).first();
|
|
||||||
auto chain_doc = unit_ins->doc();
|
|
||||||
this->core_ins->getDocsManager()->openTextDocument(chain_doc->filePath(),
|
|
||||||
chain_doc->docName());
|
|
||||||
auto present = this->core_ins->getDocsManager()->queryTextComponent(
|
|
||||||
QFileInfo(chain_doc->filePath()));
|
|
||||||
|
|
||||||
if (path.size()) {
|
|
||||||
present->jumpTo(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StoryunitsPresent::StoryunitsPresent(Schedule::CommandsDispatcher *core,
|
StoryunitsPresent::StoryunitsPresent(Schedule::CommandsDispatcher *core,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent), core_ins(core), units_view(new QTreeView(this)),
|
: QWidget(parent), disp_core(core), units_view(new QTreeView(this)),
|
||||||
details_show(new QTextEdit(this)) {
|
details_show(new QTextEdit(this)) {
|
||||||
auto backend =
|
auto backend =
|
||||||
core->get<StoryunitsPresentModel>(NAME(StoryunitsPresentModel));
|
core->get<StoryunitsPresentModel>(NAME(StoryunitsPresentModel));
|
||||||
|
@ -123,3 +134,32 @@ StoryunitsPresent::StoryunitsPresent(Schedule::CommandsDispatcher *core,
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StoryunitsPresent::name() const { return NAME(StoryunitsPresent); }
|
QString StoryunitsPresent::name() const { return NAME(StoryunitsPresent); }
|
||||||
|
|
||||||
|
using namespace CommandList;
|
||||||
|
void StoryunitsPresent::jump_to(const QModelIndex &curr) {
|
||||||
|
QList<QString> path;
|
||||||
|
QModelIndex node = curr;
|
||||||
|
while (true) {
|
||||||
|
auto node_name = node.data().toString();
|
||||||
|
if (node_name.isEmpty())
|
||||||
|
break;
|
||||||
|
path.insert(0, node_name);
|
||||||
|
node = node.parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
disp_core->postCommand(StoryunitJumpTo(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StoryunitsPresent::show_details(const QModelIndex &curr) {
|
||||||
|
QList<QString> path;
|
||||||
|
QModelIndex node = curr;
|
||||||
|
while (true) {
|
||||||
|
auto node_name = node.data().toString();
|
||||||
|
if (node_name.isEmpty())
|
||||||
|
break;
|
||||||
|
path.insert(0, node_name);
|
||||||
|
node = node.parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
disp_core->postCommand(StoryunitDetailShow(path));
|
||||||
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace Components {
|
||||||
QStandardItemModel *treeModel() const;
|
QStandardItemModel *treeModel() const;
|
||||||
QTextDocument *detailsBackend() const;
|
QTextDocument *detailsBackend() const;
|
||||||
|
|
||||||
void refresh();
|
void refreshTree();
|
||||||
void show_node_description(const QModelIndex &curr);
|
void details_show(const QList<QString> &path);
|
||||||
|
|
||||||
// AccessibleObject interface
|
// AccessibleObject interface
|
||||||
public:
|
public:
|
||||||
|
@ -45,7 +45,7 @@ namespace Components {
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Schedule::CommandsDispatcher *const core_ins;
|
Schedule::CommandsDispatcher *const disp_core;
|
||||||
QTreeView *const units_view;
|
QTreeView *const units_view;
|
||||||
QTextEdit *const details_show;
|
QTextEdit *const details_show;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue