78 lines
1.9 KiB
C++
78 lines
1.9 KiB
C++
#include "fragmentsorderview.h"
|
|
#include "SensitiveCore.h"
|
|
#include <comdef.h>
|
|
#include <StoryUnitDocumentParser.h>
|
|
#include <QVBoxLayout>
|
|
|
|
using namespace Components;
|
|
using namespace Parse;
|
|
|
|
FragmentsOrderView::FragmentsOrderView(Core::AppCore *core, QWidget *parent)
|
|
: QWidget(parent), core_ins(core), table_view(new QTableView(this)),
|
|
table_base(new QStandardItemModel(this))
|
|
{
|
|
this->table_view->setModel(table_base);
|
|
table_base->setHorizontalHeaderLabels(QStringList() << "情节名称" << "单元名称" << "索引值");
|
|
|
|
auto layout = new QVBoxLayout(this);
|
|
layout->addWidget(table_view);
|
|
connect(this->table_view, &QTableView::doubleClicked, this, &FragmentsOrderView::double_click);
|
|
}
|
|
|
|
void FragmentsOrderView::refresh()
|
|
{
|
|
table_base->clear();
|
|
table_base->setHorizontalHeaderLabels(QStringList() << "情节名称" << "单元名称" << "索引值");
|
|
|
|
auto node_list = core_ins->parseCore()->queryOrdersFragment();
|
|
|
|
for(auto &ins : node_list){
|
|
QList<QStandardItem*> row;
|
|
row << new QStandardItem(ins.first->name()[0]);
|
|
row << new QStandardItem(ins.first->name()[1]);
|
|
row << new QStandardItem(QString("%1").arg(ins.second, 8, 'f'));
|
|
|
|
for(auto &i : row) i->setEditable(false);
|
|
|
|
table_base->appendRow(row);
|
|
}
|
|
}
|
|
|
|
void FragmentsOrderView::double_click(const QModelIndex &index)
|
|
{
|
|
if(!index.isValid())
|
|
return;
|
|
|
|
auto frag = table_base->item(index.row());
|
|
auto unit = table_base->item(index.row(), 1);
|
|
|
|
QList<QString> path;
|
|
path << unit->text() << frag->text();
|
|
|
|
|
|
auto unit_ins = this->core_ins->parseCore()->queryStoryUnit(path[0]).first();
|
|
auto unit_doc = unit_ins->doc();
|
|
this->core_ins->openTextDocument(unit_doc->filePath(), unit_doc->docName());
|
|
auto present = this->core_ins->getFramework()->queryTextComponent(QFileInfo(unit_doc->filePath()));
|
|
|
|
if(path.size()){
|
|
present->jumpTo(path);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|