89 lines
2.3 KiB
C++
89 lines
2.3 KiB
C++
#include "storychainspresent.h"
|
|
|
|
#include <QSplitter>
|
|
#include <QVBoxLayout>
|
|
|
|
using namespace Components;
|
|
using namespace Parse;
|
|
using namespace Parse::Result;
|
|
|
|
StoryChainsPresent::StoryChainsPresent(Parse::Result::ParseCore *core, QWidget *parent)
|
|
: QWidget(parent), core_ins(core), model_base(new QStandardItemModel(this)),
|
|
tree_view(new QTreeView(this)), details_show(new QPlainTextEdit(this))
|
|
{
|
|
tree_view->setModel(model_base);
|
|
tree_view->setHeaderHidden(true);
|
|
|
|
auto layoutx = new QVBoxLayout(this);
|
|
layoutx->setMargin(0);
|
|
auto split = new QSplitter(Qt::Vertical, this);
|
|
layoutx->addWidget(split);
|
|
split->addWidget(tree_view);
|
|
split->addWidget(details_show);
|
|
details_show->setReadOnly(true);
|
|
|
|
connect(tree_view, &QTreeView::clicked, this, &StoryChainsPresent::action_details_show);
|
|
}
|
|
|
|
void StoryChainsPresent::refresh()
|
|
{
|
|
model_base->clear();
|
|
auto list = core_ins->allStoryChains();
|
|
for(auto &chain : list){
|
|
auto chain_node = new QStandardItem(static_cast<NamedNode*>(chain)->name());
|
|
chain_node->setEditable(false);
|
|
model_base->appendRow(chain_node);
|
|
|
|
auto children = chain->children();
|
|
for(auto &point : children){
|
|
if(point->typeValue() == NODE_STORYPOINT){
|
|
auto point_node = new QStandardItem(static_cast<NamedNode*>(point)->name());
|
|
point_node->setEditable(false);
|
|
chain_node->appendRow(point_node);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void StoryChainsPresent::action_details_show(const QModelIndex &curr)
|
|
{
|
|
if(!curr.isValid())
|
|
return;
|
|
|
|
details_show->clear();
|
|
auto item = model_base->itemFromIndex(curr);
|
|
if(item->parent() == nullptr){
|
|
auto node = core_ins->queryStoryChain(item->text());
|
|
|
|
auto children = node.first()->children();
|
|
for(auto &it : children){
|
|
if(it->typeValue() != NODE_STORYPOINT){
|
|
details_show->appendPlainText(it->toString());
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
auto node = core_ins->queryStoryChain(item->parent()->text());
|
|
auto point = core_ins->queryStoryPoint(node.first(), item->text());
|
|
|
|
auto children = point.first()->children();
|
|
for(auto &it : children){
|
|
details_show->appendPlainText(it->toString());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|