构建了基础地配置框架

This commit is contained in:
玉宇清音 2022-11-19 07:47:32 +08:00
parent dbbdece7fe
commit 946f948a20
26 changed files with 788 additions and 74 deletions

View File

@ -2,6 +2,7 @@ TEMPLATE = subdirs
SUBDIRS += \ SUBDIRS += \
DesParser \ DesParser \
TestWidget \
Testpad \ Testpad \
WordsIDE \ WordsIDE \
libConfig \ libConfig \

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.15.0, 2022-11-18T11:14:33. --> <!-- Written by QtCreator 4.15.0, 2022-11-19T00:53:17. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

26
TestWidget/TestWidget.pro Normal file
View File

@ -0,0 +1,26 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
widget.cpp
HEADERS += \
widget.h
TRANSLATIONS += \
TestWidget_zh_CN.ts
CONFIG += lrelease
CONFIG += embed_translations
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN"></TS>

29
TestWidget/main.cpp Normal file
View File

@ -0,0 +1,29 @@
#include "widget.h"
#include <QApplication>
#include <QFontDatabase>
#include <QLocale>
#include <QTranslator>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "TestWidget_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
Widget w;
w.show();
QFontDatabase xbase;
qDebug() << xbase.families(QFontDatabase::WritingSystem::SimplifiedChinese);
return a.exec();
}

11
TestWidget/widget.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
}
Widget::~Widget()
{
}

14
TestWidget/widget.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
};
#endif // WIDGET_H

View File

@ -2,18 +2,52 @@
#define CONTENTPRESENT_H #define CONTENTPRESENT_H
#include <QString> #include <QString>
#include <libConfig.h>
#include "appcore.h"
namespace Core
{
class ConfigHost
{
public:
virtual ~ConfigHost() = default;
/**
* @brief
* @return
*/
virtual QList<Scale> configs() const = 0;
/**
* @brief
* @param configs
*/
virtual void reload(QList<Config::Configration*> configs) = 0;
/**
* @brief getPanel
* @param config
* @return
*/
virtual QWidget* getPanel(Config::Configration* config) = 0;
};
}
namespace ContentPresent { namespace ContentPresent {
/** /**
* @brief * @brief
*/ */
class ModeView class ModeView
{ {
public: public:
virtual ~ModeView() = default; virtual ~ModeView() = default;
/**
* @brief
* @return
*/
virtual Core::ConfigHost* getConfigHost() const = 0;
/** /**
* @brief * @brief
* @param type * @param type

View File

@ -1,10 +1,13 @@
#include "SourceEditView.h" #include "SourceEditView.h"
#include "keywordshightlighter.h" #include "keywordshightlighter.h"
#include <QComboBox>
#include <QFont>
#include <QMenu> #include <QMenu>
using namespace Components; using namespace Components;
using namespace Parse::Result; using namespace Parse::Result;
using namespace Enhancement; using namespace Enhancement;
using namespace Core;
StoryChainSourceEdit::StoryChainSourceEdit(const QFileInfo &file, QWidget *parent) StoryChainSourceEdit::StoryChainSourceEdit(const QFileInfo &file, QWidget *parent)
: MakeTools::VariedTextView(file,parent), edit_square(new QTextEdit(parent)), : MakeTools::VariedTextView(file,parent), edit_square(new QTextEdit(parent)),
@ -64,14 +67,14 @@ void StoryChainSourceEdit::textContentReset(const QString &value)
this->edit_square->setText(value); this->edit_square->setText(value);
} }
TextContentEdit::TextContentEdit(const QFileInfo &refer, QWidget *parent) ConfigHost *StoryChainSourceEdit::getConfigHost() const
: MakeTools::VariedTextView(refer, parent), edit_square(new QTextEdit(parent)), source_target(refer)
{ {
connect(edit_square, &QTextEdit::textChanged, [this](){ return nullptr;
emit this->dataChanged(this->source_target.absoluteFilePath());
});
} }
TextContentEdit::TextContentEdit(const QFileInfo &refer, QWidget *parent)
: FormattedTextEdit(refer, parent){}
void TextContentEdit::modeReset(const QString &) const void TextContentEdit::modeReset(const QString &) const
{ {
@ -97,28 +100,29 @@ void TextContentEdit::reset(Parse::Result::DocCore *syntax_base)
} }
QWidget *TextContentEdit::textView() const void TextContentEdit::rehighlighter()
{ {
return edit_square;
}
QString TextContentEdit::textContent() const
{
return edit_square->toPlainText();
}
void TextContentEdit::textContentReset(const QString &value)
{
edit_square->setText(value);
} }
StoryUnitSourceEdit::StoryUnitSourceEdit(const QFileInfo &refer, QWidget *parent) StoryUnitSourceEdit::StoryUnitSourceEdit(const QFileInfo &refer, QWidget *parent)
: MakeTools::VariedTextView(refer,parent), edit_square(new QTextEdit(parent)), source_target(refer) : MakeTools::VariedTextView(refer,parent),
words_highlighter(new KeywordsHightlighter(this)),
edit_square(new QTextEdit(parent)), source_target(refer)
{ {
connect(edit_square, &QTextEdit::textChanged, [this](){ connect(edit_square, &QTextEdit::textChanged, [this](){
emit this->dataChanged(this->source_target.absoluteFilePath()); emit this->dataChanged(this->source_target.absoluteFilePath());
}); });
words_highlighter->setDocument(this->edit_square->document());
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
connect(edit_square, &QTextEdit::customContextMenuRequested, [this](const QPoint &pos){
auto menu = edit_square->createStandardContextMenu();
menu->addSeparator();
menu->addAction("刷新", [this](){words_highlighter->rehighlight();});
menu->exec(edit_square->mapToGlobal(pos));
});
} }
void StoryUnitSourceEdit::modeReset(const QString &) const void StoryUnitSourceEdit::modeReset(const QString &) const
@ -141,9 +145,15 @@ QString StoryUnitSourceEdit::title() const
return source_target.fileName(); return source_target.fileName();
} }
ConfigHost *StoryUnitSourceEdit::getConfigHost() const
{
return nullptr;
}
void StoryUnitSourceEdit::reset(Parse::Result::DocCore *syntax_base) void StoryUnitSourceEdit::reset(Parse::Result::DocCore *syntax_base)
{ {
static_cast<KeywordsHightlighter*>(words_highlighter)->reset(syntax_base);
} }
QWidget *StoryUnitSourceEdit::textView() const QWidget *StoryUnitSourceEdit::textView() const
@ -162,11 +172,23 @@ void StoryUnitSourceEdit::textContentReset(const QString &value)
} }
StoryBoardSourceEdit::StoryBoardSourceEdit(const QFileInfo &refer, QWidget *parent) StoryBoardSourceEdit::StoryBoardSourceEdit(const QFileInfo &refer, QWidget *parent)
: MakeTools::VariedTextView(refer,parent), edit_square(new QTextEdit(parent)), source_target(refer) : MakeTools::VariedTextView(refer,parent),
words_highlighter(new KeywordsHightlighter(this)),
edit_square(new QTextEdit(parent)), source_target(refer)
{ {
connect(edit_square, &QTextEdit::textChanged, [this](){ connect(edit_square, &QTextEdit::textChanged, [this](){
emit this->dataChanged(this->source_target.absoluteFilePath()); emit this->dataChanged(this->source_target.absoluteFilePath());
}); });
words_highlighter->setDocument(this->edit_square->document());
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
connect(edit_square, &QTextEdit::customContextMenuRequested, [this](const QPoint &pos){
auto menu = edit_square->createStandardContextMenu();
menu->addSeparator();
menu->addAction("刷新", [this](){words_highlighter->rehighlight();});
menu->exec(edit_square->mapToGlobal(pos));
});
} }
void StoryBoardSourceEdit::modeReset(const QString &) const{} void StoryBoardSourceEdit::modeReset(const QString &) const{}
@ -186,9 +208,14 @@ QString StoryBoardSourceEdit::title() const
return source_target.fileName(); return source_target.fileName();
} }
ConfigHost *StoryBoardSourceEdit::getConfigHost() const
{
return nullptr;
}
void StoryBoardSourceEdit::reset(Parse::Result::DocCore *syntax_base) void StoryBoardSourceEdit::reset(Parse::Result::DocCore *syntax_base)
{ {
static_cast<KeywordsHightlighter*>(words_highlighter)->reset(syntax_base);
} }
QWidget *StoryBoardSourceEdit::textView() const QWidget *StoryBoardSourceEdit::textView() const
@ -207,11 +234,23 @@ void StoryBoardSourceEdit::textContentReset(const QString &value)
} }
StoryVolumeSourceEdit::StoryVolumeSourceEdit(const QFileInfo &refer, QWidget *parent) StoryVolumeSourceEdit::StoryVolumeSourceEdit(const QFileInfo &refer, QWidget *parent)
: MakeTools::VariedTextView(refer,parent), edit_square(new QTextEdit(parent)), source_target(refer) : MakeTools::VariedTextView(refer,parent),
words_highlighter(new KeywordsHightlighter(this)),
edit_square(new QTextEdit(parent)), source_target(refer)
{ {
connect(edit_square, &QTextEdit::textChanged, [this](){ connect(edit_square, &QTextEdit::textChanged, [this](){
emit this->dataChanged(this->source_target.absoluteFilePath()); emit this->dataChanged(this->source_target.absoluteFilePath());
}); });
words_highlighter->setDocument(this->edit_square->document());
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
connect(edit_square, &QTextEdit::customContextMenuRequested, [this](const QPoint &pos){
auto menu = edit_square->createStandardContextMenu();
menu->addSeparator();
menu->addAction("刷新", [this](){words_highlighter->rehighlight();});
menu->exec(edit_square->mapToGlobal(pos));
});
} }
void StoryVolumeSourceEdit::modeReset(const QString &) const{} void StoryVolumeSourceEdit::modeReset(const QString &) const{}
@ -231,9 +270,14 @@ QString StoryVolumeSourceEdit::title() const
return source_target.fileName(); return source_target.fileName();
} }
ConfigHost *StoryVolumeSourceEdit::getConfigHost() const
{
return nullptr;
}
void StoryVolumeSourceEdit::reset(Parse::Result::DocCore *syntax_base) void StoryVolumeSourceEdit::reset(Parse::Result::DocCore *syntax_base)
{ {
static_cast<KeywordsHightlighter*>(words_highlighter)->reset(syntax_base);
} }
QWidget *StoryVolumeSourceEdit::textView() const QWidget *StoryVolumeSourceEdit::textView() const
@ -250,3 +294,61 @@ void StoryVolumeSourceEdit::textContentReset(const QString &value)
{ {
this->edit_square->setText(value); this->edit_square->setText(value);
} }
FormattedTextEdit::FormattedTextEdit(const QFileInfo &file, QWidget *parent)
: MakeTools::VariedTextView(file, parent), edit_square(new QTextEdit(parent)), source_target(file)
{
connect(edit_square, &QTextEdit::textChanged, [this](){
emit this->dataChanged(this->source_target.absoluteFilePath());
});
}
Core::ConfigHost *FormattedTextEdit::getConfigHost() const
{
return const_cast<FormattedTextEdit*>(this);
}
QWidget *FormattedTextEdit::textView() const
{
return edit_square;
}
QString FormattedTextEdit::textContent() const
{
return edit_square->toPlainText();
}
void FormattedTextEdit::textContentReset(const QString &value)
{
edit_square->setPlainText(value);
}
QList<Core::Scale> FormattedTextEdit::configs() const
{
return QList<Scale>() << Scale::Global << Scale::Project;
}
void FormattedTextEdit::reload(QList<Config::Configration *> configs)
{
this->configrations_host = configs;
// TODO 设置格式
auto font_family = Config::ConfigHelper::getConfigAsDefaultSequence
(configs, {"sourcecode_edit","default_font","font_family"}, "微软雅黑");
QFont default_font;
default_font.setFamily(font_family);
this->edit_square->document()->setDefaultFont(default_font);
this->rehighlighter();
}
QWidget *FormattedTextEdit::getPanel(Config::Configration *config)
{
auto combobox = new QComboBox();
combobox->addItems(QFontDatabase().families(QFontDatabase::WritingSystem::SimplifiedChinese));
connect(combobox, &QComboBox::currentTextChanged, [this](const QString &text){
this->edit_square->setFont(QFont(text));
});
return combobox;
}

View File

@ -9,6 +9,39 @@
#include <QTextEdit> #include <QTextEdit>
namespace Components { namespace Components {
class FormattedTextEdit : public MakeTools::VariedTextView,
public ContentPresent::ModeView, public Core::ConfigHost
{
public:
FormattedTextEdit(const QFileInfo &file, QWidget *parent = nullptr);
virtual ~FormattedTextEdit() = default;
// ModeView interface
public:
virtual Core::ConfigHost *getConfigHost() const override;
// VariedTextView interface
public:
virtual QWidget *textView() const override;
virtual QString textContent() const override;
virtual void textContentReset(const QString &value) override;
// ConfigHost interface
public:
virtual QList<Core::Scale> configs() const override;
virtual void reload(QList<Config::Configration *> configs) override;
virtual QWidget *getPanel(Config::Configration *config) override;
private:
QTextEdit *const edit_square;
QFileInfo source_target;
protected:
QList<Config::Configration*> configrations_host;
virtual void rehighlighter() = 0;
};
/** /**
* @brief StoryChain源码编辑器 * @brief StoryChain源码编辑器
*/ */
@ -24,6 +57,7 @@ namespace Components {
virtual QList<QString> modes() const override; virtual QList<QString> modes() const override;
virtual QString currentMode() const override; virtual QString currentMode() const override;
virtual QString title() const override; virtual QString title() const override;
virtual Core::ConfigHost *getConfigHost() const override;
// VariedTextView interface // VariedTextView interface
public: public:
@ -36,10 +70,11 @@ namespace Components {
QTextEdit *const edit_square; QTextEdit *const edit_square;
QSyntaxHighlighter *const highter_ins; QSyntaxHighlighter *const highter_ins;
Parse::Result::DocCore * core_ins; Parse::Result::DocCore * core_ins;
}; };
class TextContentEdit : public MakeTools::VariedTextView, public ContentPresent::ModeView class TextContentEdit : public FormattedTextEdit
{ {
public: public:
TextContentEdit(const QFileInfo &refer, QWidget *parent = nullptr); TextContentEdit(const QFileInfo &refer, QWidget *parent = nullptr);
@ -55,13 +90,13 @@ namespace Components {
// VariedTextView interface // VariedTextView interface
public: public:
virtual void reset(Parse::Result::DocCore *syntax_base) override; virtual void reset(Parse::Result::DocCore *syntax_base) override;
virtual QWidget *textView() const override;
virtual QString textContent() const override;
virtual void textContentReset(const QString &value) override;
private: private:
QTextEdit *const edit_square;
QFileInfo source_target; QFileInfo source_target;
// FormattedTextEdit interface
protected:
virtual void rehighlighter() override;
}; };
/** /**
@ -79,6 +114,7 @@ namespace Components {
virtual QList<QString> modes() const override; virtual QList<QString> modes() const override;
virtual QString currentMode() const override; virtual QString currentMode() const override;
virtual QString title() const override; virtual QString title() const override;
virtual Core::ConfigHost *getConfigHost() const override;
// VariedTextView interface // VariedTextView interface
public: public:
@ -88,6 +124,7 @@ namespace Components {
virtual void textContentReset(const QString &value) override; virtual void textContentReset(const QString &value) override;
private: private:
QSyntaxHighlighter *const words_highlighter;
QTextEdit *const edit_square; QTextEdit *const edit_square;
QFileInfo source_target; QFileInfo source_target;
}; };
@ -105,6 +142,7 @@ namespace Components {
virtual QList<QString> modes() const override; virtual QList<QString> modes() const override;
virtual QString currentMode() const override; virtual QString currentMode() const override;
virtual QString title() const override; virtual QString title() const override;
virtual Core::ConfigHost *getConfigHost() const override;
// VariedTextView interface // VariedTextView interface
public: public:
@ -114,6 +152,7 @@ namespace Components {
virtual void textContentReset(const QString &value) override; virtual void textContentReset(const QString &value) override;
private: private:
QSyntaxHighlighter *const words_highlighter;
QTextEdit *const edit_square; QTextEdit *const edit_square;
QFileInfo source_target; QFileInfo source_target;
}; };
@ -129,6 +168,7 @@ namespace Components {
virtual QList<QString> modes() const override; virtual QList<QString> modes() const override;
virtual QString currentMode() const override; virtual QString currentMode() const override;
virtual QString title() const override; virtual QString title() const override;
virtual Core::ConfigHost *getConfigHost() const override;
// VariedTextView interface // VariedTextView interface
public: public:
@ -138,6 +178,7 @@ namespace Components {
virtual void textContentReset(const QString &value) override; virtual void textContentReset(const QString &value) override;
private: private:
QSyntaxHighlighter *const words_highlighter;
QTextEdit *const edit_square; QTextEdit *const edit_square;
QFileInfo source_target; QFileInfo source_target;
}; };

View File

@ -12,22 +12,26 @@ SOURCES += \
ContentPresent.cpp \ ContentPresent.cpp \
SensitiveCore.cpp \ SensitiveCore.cpp \
SourceEditView.cpp \ SourceEditView.cpp \
appcore.cpp \
keywordshightlighter.cpp \ keywordshightlighter.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
messagepresent.cpp \ messagepresent.cpp \
projectview.cpp \ projectview.cpp \
storychainspresent.cpp storychainspresent.cpp \
storyunitspresent.cpp
HEADERS += \ HEADERS += \
ContentPresent.h \ ContentPresent.h \
SensitiveCore.h \ SensitiveCore.h \
SourceEditView.h \ SourceEditView.h \
appcore.h \
keywordshightlighter.h \ keywordshightlighter.h \
mainwindow.h \ mainwindow.h \
messagepresent.h \ messagepresent.h \
projectview.h \ projectview.h \
storychainspresent.h storychainspresent.h \
storyunitspresent.h
TRANSLATIONS += \ TRANSLATIONS += \
WordsIDE_zh_CN.ts WordsIDE_zh_CN.ts

8
WordsIDE/appcore.cpp Normal file
View File

@ -0,0 +1,8 @@
#include "appcore.h"
using namespace Core;
AppCore::AppCore()
{
}

28
WordsIDE/appcore.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef APPCORE_H
#define APPCORE_H
#include <QObject>
#include <libConfig.h>
namespace Core {
enum class Scale
{
Global,
Project,
File,
};
class AppCore
{
public:
AppCore();
virtual ~AppCore() = default;
QList<Config::Configration*> getConfigs(QList<Scale> types) const;
};
}
#endif // APPCORE_H

View File

@ -8,6 +8,7 @@
#include <QDateTime> #include <QDateTime>
#include <QTextEdit> #include <QTextEdit>
#include <QToolBar> #include <QToolBar>
#include <xmlconfig.h>
#include <xmlprojectmanager.h> #include <xmlprojectmanager.h>
#include <QFileDialog> #include <QFileDialog>
#include <QInputDialog> #include <QInputDialog>
@ -21,6 +22,8 @@ using namespace Components;
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), : QMainWindow(parent),
global_config(new Config::XMLConfig(this)),
sync_kernel(new StatusSyncCore(this)),
horizontal_split(new QSplitter(Qt::Horizontal, this)), horizontal_split(new QSplitter(Qt::Horizontal, this)),
vertical_split(new QSplitter(Qt::Vertical, this)), vertical_split(new QSplitter(Qt::Vertical, this)),
left_funcs(new QTabWidget(this)), left_funcs(new QTabWidget(this)),
@ -31,18 +34,30 @@ MainWindow::MainWindow(QWidget *parent)
parse_core(new ParseCore()), parse_core(new ParseCore()),
make_tool(new StoryTool(parse_core)), make_tool(new StoryTool(parse_core)),
project_list(new QListView(this)), project_list(new QListView(this)),
project_view(new ProjectView(project_manager, this)), project_structure(new ProjectView(project_manager, this)),
chains_view(new StoryChainsPresent(parse_core, this)), chains_view(new StoryChainsPresent(parse_core, this)),
units_view(new StoryUnitsPresent(parse_core, this)),
errors_present(new MessagePresent(make_tool, this)), errors_present(new MessagePresent(make_tool, this)),
framework(new SensitiveCore(make_tool)) framework(new SensitiveCore(make_tool))
{ {
QApplication::instance()->installEventFilter(this);
global_config->loadFile(QDir(QApplication::applicationDirPath()).filePath(".software.xml"));
setMinimumSize(1000, 600); setMinimumSize(1000, 600);
setWindowTitle("提线木偶集成开发工具"); setWindowTitle("提线木偶集成开发工具");
chains_view->setVisible(false);
units_view->setVisible(false);
errors_present->setVisible(false);
project_structure->setVisible(false);
left_funcs->setVisible(false);
right_funcs->setVisible(false);
bottom_funcs->setVisible(false);
auto xtool = new QToolBar(this); auto xtool = new QToolBar(this);
xtool->setVisible(false);
addToolBar(Qt::ToolBarArea::TopToolBarArea, xtool); addToolBar(Qt::ToolBarArea::TopToolBarArea, xtool);
auto xstatus = statusBar(); auto xstatus = statusBar();
xstatus->setVisible(false);
statusBar()->addWidget(new QLabel("文本消息", this)); statusBar()->addWidget(new QLabel("文本消息", this));
auto mbar = menuBar(); auto mbar = menuBar();
@ -72,25 +87,25 @@ MainWindow::MainWindow(QWidget *parent)
_xnew->addAction("小说章节"); _xnew->addAction("小说章节");
project->addSeparator(); project->addSeparator();
auto sav = project->addAction("保存"); auto sav = project->addAction("保存");
sav->setEnabled(false); sync_kernel->registerActionSync(sav, [this]()->bool{return project_manager->isOpen();});
connect(sav, &QAction::triggered, [this](){ connect(sav, &QAction::triggered, [this](){
this->project_manager->save(); this->project_manager->save();
framework->saveAll(); framework->saveAll();
}); });
project->addSeparator(); project->addSeparator();
auto opnp = project->addAction("打开项目"); auto opnp = project->addAction("打开项目");
connect(opnp, &QAction::triggered, [this, sav](){ sync_kernel->registerActionSync(opnp, [this]()->bool{return !project_manager->isOpen();});
connect(opnp, &QAction::triggered, [this](){
auto file = QFileDialog::getOpenFileName(this, "打开项目", QString(), "小说项目(*.nsf)"); auto file = QFileDialog::getOpenFileName(this, "打开项目", QString(), "小说项目(*.nsf)");
if(file == "") if(file == "")
return; return;
project_manager->openProject(file); project_manager->openProject(file);
sav->setEnabled(true);
build_internal(true); build_internal(true);
}); });
auto newp = project->addAction("新建项目"); auto newp = project->addAction("新建项目");
connect(newp, &QAction::triggered, [this, sav](){ sync_kernel->registerActionSync(newp, [this]()->bool{return !project_manager->isOpen();});
connect(newp, &QAction::triggered, [this](){
auto name = QInputDialog::getText(this, "输入项目名称", "项目名称"); auto name = QInputDialog::getText(this, "输入项目名称", "项目名称");
if(name == "") if(name == "")
return; return;
@ -98,13 +113,12 @@ MainWindow::MainWindow(QWidget *parent)
if(dir_path == "") if(dir_path == "")
return; return;
sav->setEnabled(true);
this->project_manager->newProject(dir_path, name); this->project_manager->newProject(dir_path, name);
}); });
auto clsp = project->addAction("关闭项目"); auto clsp = project->addAction("关闭项目");
connect(clsp, &QAction::triggered, [this, sav](){ sync_kernel->registerActionSync(clsp, [this]()->bool{return project_manager->isOpen();});
connect(clsp, &QAction::triggered, [this](){
this->project_manager->closeProject(); this->project_manager->closeProject();
sav->setEnabled(false);
}); });
project->addSeparator(); project->addSeparator();
project->addAction("项目配置"); project->addAction("项目配置");
@ -123,25 +137,21 @@ MainWindow::MainWindow(QWidget *parent)
// 视图菜单 // 视图菜单
auto view = mbar->addMenu("视图"); auto view = mbar->addMenu("视图");
auto area = view->addMenu("区域管理"); auto area = view->addMenu("区域管理");
auto act_tool = area->addAction("工具栏"); auto act_tool = area->addAction("工具栏");
act_tool->setCheckable(true); act_tool->setCheckable(true);
act_tool->setChecked(true);
connect(act_tool, &QAction::triggered, [xtool](bool v){ xtool->setVisible(v); }); connect(act_tool, &QAction::triggered, [xtool](bool v){ xtool->setVisible(v); });
auto act_status = area->addAction("状态栏"); auto act_status = area->addAction("状态栏");
act_status->setCheckable(true); act_status->setCheckable(true);
act_status->setChecked(true);
connect(act_status,&QAction::triggered, [xstatus](bool v){xstatus->setVisible(v);}); connect(act_status,&QAction::triggered, [xstatus](bool v){xstatus->setVisible(v);});
auto act_left = area->addAction("左侧功能区"); auto act_left = area->addAction("左侧功能区");
act_left->setCheckable(true); act_left->setCheckable(true);
act_left->setChecked(true);
connect(act_left, &QAction::triggered, [this](bool v){this->left_funcs->setVisible(v);}); connect(act_left, &QAction::triggered, [this](bool v){this->left_funcs->setVisible(v);});
auto act_right = area->addAction("右侧功能区"); auto act_right = area->addAction("右侧功能区");
act_right->setCheckable(true); act_right->setCheckable(true);
act_right->setChecked(true);
connect(act_right, &QAction::triggered, [this](bool v){this->right_funcs->setVisible(v);}); connect(act_right, &QAction::triggered, [this](bool v){this->right_funcs->setVisible(v);});
auto act_bottom = area->addAction("底部功能区"); auto act_bottom = area->addAction("底部功能区");
act_bottom->setCheckable(true); act_bottom->setCheckable(true);
act_bottom->setChecked(true);
connect(act_bottom, &QAction::triggered, [this](bool v){this->bottom_funcs->setVisible(v);}); connect(act_bottom, &QAction::triggered, [this](bool v){this->bottom_funcs->setVisible(v);});
view->addSeparator(); view->addSeparator();
auto change = view->addMenu("内容切换"); auto change = view->addMenu("内容切换");
@ -149,10 +159,44 @@ MainWindow::MainWindow(QWidget *parent)
change->addAction("编辑视图"); change->addAction("编辑视图");
view->addSeparator(); view->addSeparator();
auto func = view->addMenu("功能视图"); auto func = view->addMenu("功能视图");
func->addAction("项目结构"); // 项目管理
{
auto project_v = func->addAction("项目管理", [this](bool v){
toggle_widget_visible(v, left_funcs, project_structure, "项目管理");
});
project_v->setCheckable(true);
sync_kernel->registerAutoRun([this]()->bool{return this->project_structure->isVisible();},
[project_v](bool v){ if(v != project_v->isChecked()) project_v->setChecked(v); });
}
func->addAction("引用统计"); func->addAction("引用统计");
func->addAction("脉络分蘖"); func->addAction("脉络分蘖");
func->addAction("终端输出"); // 编译信息
{
auto msgs = func->addAction("终端输出", [this](bool v){
toggle_widget_visible(v, bottom_funcs, errors_present, "编译信息");
});
msgs->setCheckable(true);
sync_kernel->registerAutoRun([this]()->bool{return errors_present->isVisible();},
[msgs](bool v){if(v!=msgs->isChecked()) msgs->setChecked(v);});
}
// 脉络统计
{
auto chain_v = func->addAction("脉络统计", [this](bool v){
toggle_widget_visible(v, right_funcs, chains_view, "脉络统计");
});
chain_v->setCheckable(true);
sync_kernel->registerAutoRun([this]()->bool{return chains_view->isVisible();},
[chain_v](bool v){ if(v != chain_v->isChecked()) chain_v->setChecked(v);});
}
// 单元统计
{
auto unit_v = func->addAction("单元统计", [this](bool v){
toggle_widget_visible(v, right_funcs, units_view, "单元统计");
});
unit_v->setCheckable(true);
sync_kernel->registerAutoRun([this]()->bool{return units_view->isVisible();},
[unit_v](bool v){if(v != unit_v->isChecked()) unit_v->setChecked(v);});
}
// 工具菜单 // 工具菜单
auto tool = mbar->addMenu("工具"); auto tool = mbar->addMenu("工具");
@ -163,10 +207,13 @@ MainWindow::MainWindow(QWidget *parent)
vcs->addAction("工具配置"); vcs->addAction("工具配置");
vcs->addAction("启用"); vcs->addAction("启用");
auto exp = tool->addMenu("导入导出"); auto exp = tool->addMenu("导入导出");
exp->addAction("导入TXT"); exp->addAction("导入WsOutlines");
exp->addSeparator();
exp->addAction("导出TXT大纲");
exp->addAction("导出Web大纲");
exp->addAction("导出WsOutlines");
exp->addSeparator(); exp->addSeparator();
exp->addAction("导出TXT内容"); exp->addAction("导出TXT内容");
exp->addAction("导出TXT大纲");
tool->addAction("编译", [this](){ tool->addAction("编译", [this](){
this->build_internal(); this->build_internal();
}); });
@ -188,16 +235,30 @@ MainWindow::MainWindow(QWidget *parent)
sys->addAction("关于……"); sys->addAction("关于……");
setCentralWidget(this->horizontal_split);
this->horizontal_split->addWidget(left_funcs); this->horizontal_split->addWidget(left_funcs);
this->horizontal_split->addWidget(vertical_split); this->horizontal_split->addWidget(vertical_split);
this->horizontal_split->addWidget(right_funcs); this->horizontal_split->addWidget(right_funcs);
this->vertical_split->addWidget(center_funcs); this->vertical_split->addWidget(center_funcs);
this->vertical_split->addWidget(bottom_funcs); this->vertical_split->addWidget(bottom_funcs);
setCentralWidget(this->horizontal_split); left_funcs->setTabsClosable(true);
connect(left_funcs, &QTabWidget::tabCloseRequested,
[this](int index){ toggle_widget_visible(false, left_funcs, left_funcs->widget(index)); });
bottom_funcs->setTabsClosable(true);
connect(bottom_funcs, &QTabWidget::tabCloseRequested,
[this](int index){ toggle_widget_visible(false, bottom_funcs, bottom_funcs->widget(index)); });
right_funcs->setTabsClosable(true);
connect(right_funcs, &QTabWidget::tabCloseRequested,
[this](int index){ toggle_widget_visible(false, right_funcs, right_funcs->widget(index)); });
center_funcs->setTabsClosable(true);
connect(center_funcs, &QTabWidget::tabCloseRequested,
[this](int index){ toggle_widget_visible(false, center_funcs, center_funcs->widget(index)); });
center_funcs->addTab(project_list, "欢迎界面"); center_funcs->addTab(project_list, "欢迎界面");
left_funcs->addTab(project_view, "项目管理"); connect(project_structure, &ProjectView::activeDocument,
connect(project_view, &ProjectView::activeDocument, [this](const QString &file_path, const QString &name){ [this](const QString &file_path, const QString &name){
if(framework->contains(file_path)){ if(framework->contains(file_path)){
auto ins = framework->queryComponent(QFileInfo(file_path)); auto ins = framework->queryComponent(QFileInfo(file_path));
center_funcs->setCurrentWidget(ins->textView()); center_funcs->setCurrentWidget(ins->textView());
@ -218,17 +279,37 @@ MainWindow::MainWindow(QWidget *parent)
else if(file_path.endsWith("storyunit")){ else if(file_path.endsWith("storyunit")){
tview = new Components::StoryUnitSourceEdit(QFileInfo(file_path), this); tview = new Components::StoryUnitSourceEdit(QFileInfo(file_path), this);
framework->addPerceptionList(tview); framework->addPerceptionList(tview);
auto doc = parse_core->queryDocument(QFileInfo(file_path));
if(doc == nullptr){
this->make_tool->compile(QFileInfo(file_path));
doc = parse_core->queryDocument(QFileInfo(file_path));
}
tview->reset(doc);
} }
else if(file_path.endsWith("storyboard")){ else if(file_path.endsWith("storyboard")){
tview = new Components::StoryBoardSourceEdit(QFileInfo(file_path), this); tview = new Components::StoryBoardSourceEdit(QFileInfo(file_path), this);
framework->addPerceptionList(tview); framework->addPerceptionList(tview);
auto doc = parse_core->queryDocument(QFileInfo(file_path));
if(doc == nullptr){
this->make_tool->compile(QFileInfo(file_path));
doc = parse_core->queryDocument(QFileInfo(file_path));
}
tview->reset(doc);
} }
else if(file_path.endsWith("storyvolume")){ else if(file_path.endsWith("storyvolume")){
tview = new Components::StoryVolumeSourceEdit(QFileInfo(file_path), this); tview = new Components::StoryVolumeSourceEdit(QFileInfo(file_path), this);
framework->addPerceptionList(tview); framework->addPerceptionList(tview);
auto doc = parse_core->queryDocument(QFileInfo(file_path));
if(doc == nullptr){
this->make_tool->compile(QFileInfo(file_path));
doc = parse_core->queryDocument(QFileInfo(file_path));
}
tview->reset(doc);
} }
else{ else{
tview = new Components::TextContentEdit(QFileInfo(file_path), this); auto xview = new Components::TextContentEdit(QFileInfo(file_path), this);
xview->getConfigHost()->reload(QList<Config::Configration*>() << project_manager->configraions());
tview = xview;
framework->addPerceptionList(tview, SensitiveType::DoNothing); framework->addPerceptionList(tview, SensitiveType::DoNothing);
} }
if(tview == nullptr) if(tview == nullptr)
@ -249,12 +330,10 @@ MainWindow::MainWindow(QWidget *parent)
center_funcs->addTab(tview->textView(), name); center_funcs->addTab(tview->textView(), name);
center_funcs->setCurrentWidget(tview->textView()); center_funcs->setCurrentWidget(tview->textView());
}); });
bottom_funcs->addTab(errors_present, "错误列表");
right_funcs->addTab(chains_view, "脉络展示");
framework->addProcTrigger([this](){ framework->addProcTrigger([this](){
errors_present->refresh(); errors_present->refresh();
chains_view->refresh(); chains_view->refresh();
units_view->refresh();
}); });
} }
@ -285,6 +364,18 @@ void MainWindow::build_internal(bool all_from_disk)
errors_present->refresh(); errors_present->refresh();
chains_view->refresh(); chains_view->refresh();
units_view->refresh();
}
void MainWindow::toggle_widget_visible(bool visible, QTabWidget *con, QWidget *target, const QString &title)
{
if(visible && con->indexOf(target) == -1){
con->addTab(target, title);
target->setVisible(true);
}else if(!visible && con->indexOf(target) != -1){
target->setVisible(false);
con->removeTab(con->indexOf(target));
}
} }
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
@ -297,3 +388,88 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
} }
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
{
auto ev = event->type();
switch(ev){
case QEvent::Type::MouseButtonPress:
case QEvent::Type::MouseButtonRelease:
case QEvent::Type::Wheel:
case QEvent::Type::MouseMove:
case QEvent::Type::KeyPress:
case QEvent::Type::KeyRelease:
sync_kernel->sync();
break;
default:
break;
}
return QMainWindow::eventFilter(watched, event);
}
Run::Run(bool manual_flag, std::function<bool ()> judge, std::function<void (bool)> execution)
: manual(manual_flag), judgement(judge), execution(execution){}
void Run::exec()
{
if(!manual)
execution(judgement());
}
StatusSyncCore::StatusSyncCore(QObject *p)
: QObject(p){}
void StatusSyncCore::registerWidgetSync(QWidget *tar, std::function<bool ()> proc)
{
widget_trigger_map[tar] = proc;
}
void StatusSyncCore::registerActionSync(QAction *tar, std::function<bool ()> proc)
{
action_trigger_map[tar] = proc;
}
void StatusSyncCore::registerAutoRun(std::function<bool ()> judge, std::function<void (bool)> exec)
{
auto run = new Run(false, judge, exec);
alltriggers << run;
}
Run *StatusSyncCore::registerManualRun(std::function<bool ()> judge, std::function<void (bool)> exec)
{
auto run = new Run(true, judge, exec);
alltriggers << run;
return run;
}
void StatusSyncCore::sync()
{
for(auto &it : widget_trigger_map.keys()){
auto status = widget_trigger_map[it]();
if(it->isEnabled() != status)
it->setEnabled(status);
}
for(auto &it : action_trigger_map.keys()){
auto status = action_trigger_map[it]();
if(it->isEnabled() != status)
it->setEnabled(status);
}
for(auto &act : alltriggers){
act->exec();
}
}

View File

@ -4,15 +4,49 @@
#include <QMainWindow> #include <QMainWindow>
#include <QSplitter> #include <QSplitter>
#include <QTableView> #include <QTableView>
#include <ProjectManager.h> #include <libProjectManager.h>
#include <StoryTool.h> #include <StoryTool.h>
#include <QTreeView> #include <QTreeView>
#include <QListView> #include <QListView>
#include "SensitiveCore.h" #include "SensitiveCore.h"
#include "messagepresent.h" #include "messagepresent.h"
#include "storychainspresent.h" #include "storychainspresent.h"
#include "storyunitspresent.h"
#include "projectview.h" #include "projectview.h"
class Run
{
public:
Run(bool manual_flag, std::function<bool()> judge, std::function<void(bool)> execution);
void exec();
private:
bool manual;
std::function<bool()> judgement;
std::function<void(bool)> execution;
};
class StatusSyncCore : public QObject
{
public:
explicit StatusSyncCore(QObject *p = nullptr);
virtual ~StatusSyncCore() = default;
void registerWidgetSync(QWidget* tar, std::function<bool()> proc);
void registerActionSync(QAction* tar, std::function<bool()> proc);
void registerAutoRun(std::function<bool()> judge, std::function<void(bool)> exec);
Run* registerManualRun(std::function<bool()> judge, std::function<void (bool)> exec);
void sync();
private:
QHash<QWidget*, std::function<bool()>> widget_trigger_map;
QHash<QAction*, std::function<bool()>> action_trigger_map;
QList<Run*> alltriggers;
};
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -22,6 +56,8 @@ public:
~MainWindow(); ~MainWindow();
private: private:
Config::Configration *const global_config;
StatusSyncCore *const sync_kernel;
QSplitter *const horizontal_split; QSplitter *const horizontal_split;
QSplitter *const vertical_split; QSplitter *const vertical_split;
@ -36,8 +72,9 @@ private:
MakeTools::StoryTool *const make_tool; MakeTools::StoryTool *const make_tool;
QListView *const project_list; QListView *const project_list;
Components::ProjectView *const project_view; Components::ProjectView *const project_structure;
Components::StoryChainsPresent *const chains_view; Components::StoryChainsPresent *const chains_view;
Components::StoryUnitsPresent *const units_view;
Components::MessagePresent *const errors_present; Components::MessagePresent *const errors_present;
MakeTools::SensitiveCore *const framework; MakeTools::SensitiveCore *const framework;
@ -45,8 +82,14 @@ private:
// 内部逻辑 =========================================== // 内部逻辑 ===========================================
void build_internal(bool all_from_disk = false); void build_internal(bool all_from_disk = false);
void toggle_widget_visible(bool visible, QTabWidget *con, QWidget *target, const QString& title=QString());
// QWidget interface // QWidget interface
protected: protected:
virtual void closeEvent(QCloseEvent *event) override; virtual void closeEvent(QCloseEvent *event) override;
// QObject interface
public:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -3,7 +3,7 @@
#include <QTreeView> #include <QTreeView>
#include <QWidget> #include <QWidget>
#include <ProjectManager.h> #include <libProjectManager.h>
namespace Components { namespace Components {

View File

@ -0,0 +1,91 @@
#include "storyunitspresent.h"
#include <QSplitter>
#include <QVBoxLayout>
using namespace Components;
using namespace Parse::Result;
StoryUnitsPresent::StoryUnitsPresent(Parse::Result::ParseCore *core, QWidget *parent)
: QWidget(parent), core_ins(core),
model_ins(new QStandardItemModel(this)),
units_view(new QTreeView(this)),
details_show(new QPlainTextEdit(this))
{
units_view->setHeaderHidden(true);
auto layout = new QVBoxLayout(this);
layout->setMargin(0);
auto splitter = new QSplitter(Qt::Vertical, this);
layout->addWidget(splitter);
splitter->addWidget(units_view);
splitter->addWidget(details_show);
units_view->setModel(model_ins);
details_show->setReadOnly(true);
connect(units_view, &QTreeView::clicked, this, &StoryUnitsPresent::show_node_description);
}
void StoryUnitsPresent::refresh()
{
model_ins->clear();
auto units = core_ins->allStoryUnits();
for(auto &unit : units){
auto unit_node = new QStandardItem(static_cast<NamedNode*>(unit)->name());
unit_node->setEditable(false);
model_ins->appendRow(unit_node);
auto children = unit->children();
for(auto &frag : children){
if(frag->typeValue() == NODE_STORYFRAGMENT){
auto frag_node = new QStandardItem(static_cast<NamedNode*>(frag)->name());
frag_node->setEditable(false);
unit_node->appendRow(frag_node);
}
}
}
}
void StoryUnitsPresent::show_node_description(const QModelIndex &curr)
{
if(!curr.isValid())
return;
details_show->clear();
auto item = model_ins->itemFromIndex(curr);
if(item->parent() == nullptr){
auto node = core_ins->queryStoryUnit(item->text());
auto children = node.first()->children();
for(auto &it : children){
if(it->typeValue() != NODE_STORYFRAGMENT){
details_show->appendPlainText(it->toString());
}
}
}
else{
auto node = core_ins->queryStoryUnit(item->parent()->text());
auto point = core_ins->queryStoryFragment(node.first(), item->text());
auto children = point.first()->children();
for(auto &it : children){
details_show->appendPlainText(it->toString());
}
}
}

View File

@ -0,0 +1,36 @@
#ifndef STORYUNITSPRESENT_H
#define STORYUNITSPRESENT_H
#include <QPlainTextEdit>
#include <QStandardItemModel>
#include <QTextEdit>
#include <QTreeView>
#include <QWidget>
#include "libParse.h"
namespace Components {
class StoryUnitsPresent : public QWidget
{
Q_OBJECT
public:
explicit StoryUnitsPresent(Parse::Result::ParseCore *core, QWidget *parent = nullptr);
void refresh();
signals:
private:
Parse::Result::ParseCore *const core_ins;
QStandardItemModel *const model_ins;
QTreeView *const units_view;
QPlainTextEdit *const details_show;
void show_node_description(const QModelIndex &curr);
};
}
#endif // STORYUNITSPRESENT_H

View File

@ -1,5 +1,5 @@
#ifndef CONFIGRATION_H #ifndef LIBCONFIG_H
#define CONFIGRATION_H #define LIBCONFIG_H
#include <QObject> #include <QObject>
#include <QList> #include <QList>
@ -44,6 +44,24 @@ namespace Config {
} }
return xval; return xval;
} }
static QString getConfigAsDefaultSequence(QList<Configration*> seqs, const QList<QString> &path, const QString & default_v)
{
QString xval;
for(auto &ins : seqs){
if(!ins) continue;
xval = ins->getConfig(path);
if(xval.trimmed() != "")
break;
}
if(xval.trimmed() == ""){
seqs.last()->setConfig(path, default_v);
seqs.last()->save();
xval = default_v;
}
return xval;
}
static QList<QString> getListAsDefault(Configration *ins, const QList<QString> &path, const QList<QString> & default_v) static QList<QString> getListAsDefault(Configration *ins, const QList<QString> &path, const QList<QString> & default_v)
{ {
@ -55,6 +73,25 @@ namespace Config {
} }
return xval; return xval;
} }
static QList<QString> getListAsDefaultSequence(QList<Configration*> seqs, const QList<QString> &path, const QList<QString> & default_v)
{
QList<QString> xval;
for(auto &ins : seqs){
if(!ins) continue;
xval = ins->getList(path);
if(!xval.size())
break;
}
if(!xval.size()){
seqs.last()->setList(path, default_v);
seqs.last()->save();
xval = default_v;
}
return xval;
}
static QHash<QString,QString> getHashAsDefault(Configration *ins, const QList<QString> &path, const QHash<QString, QString> & default_v) static QHash<QString,QString> getHashAsDefault(Configration *ins, const QList<QString> &path, const QHash<QString, QString> & default_v)
{ {
@ -66,6 +103,25 @@ namespace Config {
} }
return xval; return xval;
} }
static QHash<QString,QString> getHashAsDefaultSequence(QList<Configration*> seqs, const QList<QString> &path, const QHash<QString, QString> & default_v)
{
QHash<QString, QString> xval;
for(auto &ins : seqs){
if(!ins) continue;
xval = ins->getMap(path);
if(!xval.size())
break;
}
if(!xval.size()){
seqs.last()->setMap(path, default_v);
seqs.last()->save();
xval = default_v;
}
return xval;
}
}; };
@ -74,4 +130,4 @@ namespace Config {
} }
#endif // CONFIGRATION_H #endif // LIBCONFIG_H

View File

@ -14,7 +14,7 @@ SOURCES += \
xmlconfig.cpp xmlconfig.cpp
HEADERS += \ HEADERS += \
Configration.h \ libConfig.h \
libConfig_global.h \ libConfig_global.h \
xmlconfig.h xmlconfig.h

View File

@ -2,7 +2,7 @@
#define XMLCONFIG_H #define XMLCONFIG_H
#include "libConfig_global.h" #include "libConfig_global.h"
#include "Configration.h" #include "libConfig.h"
#include <QDomDocument> #include <QDomDocument>

View File

@ -195,21 +195,31 @@ QList<Result::DesNode*> ParseCore::queryStoryPoint(DesNode *chain, const QString
return retlist; return retlist;
} }
QList<Result::DesNode*> ParseCore::queryStoryUnit(const QString &name) const QList<DesNode *> ParseCore::allStoryUnits() const
{ {
QList<Result::DesNode*> retlist; QList<Result::DesNode*> retlist;
auto keys = nodes_map.keys(); auto keys = nodes_map.keys();
for(auto &k : keys) for(auto &k : keys)
if(k->docType() == DocType::STORYUNIT) if(k->docType() == DocType::STORYUNIT)
for(auto &n : *nodes_map[k]){ for(auto &n : *nodes_map[k]){
if(n->typeValue()==NODE_STORYUNIT && if(n->typeValue()==NODE_STORYUNIT)
static_cast<NamedNode*>(n)->name() == name)
retlist << n; retlist << n;
} }
return retlist; return retlist;
} }
QList<Result::DesNode*> ParseCore::queryStoryUnit(const QString &name) const
{
QList<Result::DesNode*> retlist;
for(auto &k : allStoryUnits())
if(static_cast<NamedNode*>(k)->name() == name)
retlist << k;
return retlist;
}
QList<Result::DesNode*> ParseCore::queryStoryFragment(DesNode *unit, const QString &name) const QList<Result::DesNode*> ParseCore::queryStoryFragment(DesNode *unit, const QString &name) const
{ {
QList<Result::DesNode*> retlist; QList<Result::DesNode*> retlist;

View File

@ -309,6 +309,7 @@ namespace Parse
virtual QList<Result::DesNode*> queryStoryChain(const QString & name) const; virtual QList<Result::DesNode*> queryStoryChain(const QString & name) const;
virtual QList<Result::DesNode*> queryStoryPoint(Result::DesNode* chain, const QString &name) const; virtual QList<Result::DesNode*> queryStoryPoint(Result::DesNode* chain, const QString &name) const;
virtual QList<Result::DesNode*> allStoryUnits() const;
virtual QList<Result::DesNode*> queryStoryUnit(const QString &name) const; virtual QList<Result::DesNode*> queryStoryUnit(const QString &name) const;
virtual QList<Result::DesNode*> queryStoryFragment(Result::DesNode *unit, const QString &name) const; virtual QList<Result::DesNode*> queryStoryFragment(Result::DesNode *unit, const QString &name) const;

View File

@ -1,7 +1,7 @@
#ifndef PROJECTMANAGER_H #ifndef LIBPROJECTMANAGER_H
#define PROJECTMANAGER_H #define LIBPROJECTMANAGER_H
#include <Configration.h> #include <libConfig.h>
#include <QFileInfo> #include <QFileInfo>
#include <QObject> #include <QObject>
@ -119,4 +119,4 @@ namespace Project {
} }
#endif // PROJECTMANAGER_H #endif // LIBPROJECTMANAGER_H

View File

@ -14,7 +14,7 @@ SOURCES += \
xmlprojectmanager.cpp xmlprojectmanager.cpp
HEADERS += \ HEADERS += \
ProjectManager.h \ libProjectManager.h \
libProjectManager_global.h \ libProjectManager_global.h \
xmlprojectmanager.h xmlprojectmanager.h

View File

@ -5,7 +5,7 @@
#include <QDomDocument> #include <QDomDocument>
#include <QObject> #include <QObject>
#include "ProjectManager.h" #include "libProjectManager.h"
namespace Project { namespace Project {