111 lines
3.3 KiB
C++
111 lines
3.3 KiB
C++
#include "storyconceptspresent.h"
|
|
#include "DocsManager.h"
|
|
#include "opstream.h"
|
|
|
|
#include <QSplitter>
|
|
#include <QVBoxLayout>
|
|
|
|
using namespace Operate;
|
|
using namespace Components;
|
|
using namespace Core;
|
|
using namespace Parse::Result;
|
|
using namespace Tools;
|
|
|
|
StoryConceptsPresent::StoryConceptsPresent(Core::AppCore *core, QWidget *parent)
|
|
: QWidget(parent), core_ins(core),
|
|
tree_view(new QTreeView(this)),
|
|
model_base(new QStandardItemModel(this)),
|
|
details_view(new QTextBrowser(this)),
|
|
concept_model(new ModelSyncs<DesNode*>(
|
|
model_base,
|
|
[](DesNode* dbase, QStandardItem *it)->bool{ return static_cast<NamedNode*>(dbase)->name()[0] == it->text(); },
|
|
[](DesNode* dbase, QStandardItem *it){ it->setText(static_cast<NamedNode*>(dbase)->name()[0]); })){
|
|
tree_view->setHeaderHidden(true);
|
|
|
|
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);
|
|
|
|
tree_view->setModel(model_base);
|
|
details_view->setReadOnly(true);
|
|
|
|
connect(tree_view, &QTreeView::clicked, this, &StoryConceptsPresent::show_node_description);
|
|
connect(tree_view, &QTreeView::doubleClicked, this, &StoryConceptsPresent::click_to);
|
|
}
|
|
|
|
void StoryConceptsPresent::refresh()
|
|
{
|
|
this->concept_model->presentSync([this](DesNode *dit){
|
|
if(dit){
|
|
QList<DesNode*> rets;
|
|
auto children = dit->children();
|
|
for(auto &frag : children){
|
|
if(frag->typeValue() == NODE_STORYSTRONGPOINT){
|
|
rets << frag;
|
|
}
|
|
}
|
|
|
|
return rets;
|
|
}
|
|
else{
|
|
return core_ins->parseCore()->allStoryConcept();
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
void StoryConceptsPresent::show_node_description(const QModelIndex &curr)
|
|
{
|
|
if(!curr.isValid())
|
|
return;
|
|
|
|
details_view->clear();
|
|
auto item = model_base->itemFromIndex(curr);
|
|
if(item->parent() == nullptr){
|
|
auto node = core_ins->parseCore()->queryStoryConcept(item->text());
|
|
|
|
auto children = node.first()->children();
|
|
for(auto &it : children){
|
|
if(it->typeValue() != NODE_STORYSTRONGPOINT){
|
|
details_view->append(it->toString());
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
auto node = core_ins->parseCore()->queryStoryConcept(item->parent()->text());
|
|
auto point = core_ins->parseCore()->queryStoryStrongPoint(node.first(), item->text());
|
|
|
|
auto children = point.first()->children();
|
|
for(auto &it : children){
|
|
details_view->append(it->toString());
|
|
}
|
|
}
|
|
}
|
|
|
|
void StoryConceptsPresent::click_to(const QModelIndex &curr)
|
|
{
|
|
if(!curr.isValid())
|
|
return;
|
|
|
|
auto pnode = this->model_base->itemFromIndex(curr);
|
|
QList<QString> path;
|
|
while (pnode) {
|
|
path.insert(0, pnode->text());
|
|
pnode = pnode->parent();
|
|
}
|
|
|
|
auto unit_ins = this->core_ins->parseCore()->queryStoryConcept(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);
|
|
}
|
|
}
|