完善基础封装,更新部分接口实现
This commit is contained in:
parent
83364f679c
commit
df4933c839
|
@ -48,8 +48,6 @@ void TextContentEdit::jumpTo(const QList<QString> &path)
|
|||
|
||||
void TextContentEdit::reload(QList<Config::Configration *> configs)
|
||||
{
|
||||
this->configrations_host = configs;
|
||||
|
||||
// TODO: 设置格式
|
||||
auto font_family = Config::ConfigHelper::getConfigAsDefaultSequence
|
||||
(configs, {"sourcecode_edit","default_font","font_family"}, "微软雅黑");
|
||||
|
@ -68,18 +66,48 @@ void TextContentEdit::rehighlighter()
|
|||
|
||||
}
|
||||
|
||||
void TextContentEdit::resetProcsType(const QString &suffix)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
FormattedTextEdit::FormattedTextEdit()
|
||||
: edit_square(new QTextEdit())
|
||||
{
|
||||
ex_unit = [](QMenu*){};
|
||||
connect(edit_square, &QTextEdit::textChanged, [this](){
|
||||
emit this->dataChanged(this->filePath());
|
||||
});
|
||||
|
||||
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(edit_square, &QTextEdit::customContextMenuRequested,
|
||||
[this](const QPoint& p){
|
||||
auto menu = edit_square->createStandardContextMenu();
|
||||
ex_unit(menu);
|
||||
|
||||
menu->exec(edit_square->mapToGlobal(p));
|
||||
});
|
||||
}
|
||||
|
||||
void FormattedTextEdit::resetHighlighter(QSyntaxHighlighter *lighter)
|
||||
void FormattedTextEdit::setContexMenuProcess(std::function<void (QMenu *)> exu)
|
||||
{
|
||||
lighter->setDocument(this->edit_square->document());
|
||||
this->ex_unit = exu;
|
||||
}
|
||||
|
||||
QTextCursor FormattedTextEdit::getTextCursor()
|
||||
{
|
||||
return edit_square->textCursor();
|
||||
}
|
||||
|
||||
void FormattedTextEdit::setTextCursor(QTextCursor s)
|
||||
{
|
||||
edit_square->setTextCursor(s);
|
||||
}
|
||||
|
||||
QString FormattedTextEdit::title() const
|
||||
{
|
||||
return docName();
|
||||
}
|
||||
|
||||
QTextDocument *FormattedTextEdit::textDocument() const
|
||||
|
|
|
@ -17,8 +17,14 @@ namespace Components {
|
|||
FormattedTextEdit();
|
||||
virtual ~FormattedTextEdit() = default;
|
||||
|
||||
void resetHighlighter(QSyntaxHighlighter *lighter);
|
||||
QTextDocument *textDocument() const;
|
||||
virtual void rehighlighter() = 0;
|
||||
virtual void setContexMenuProcess(std::function<void(QMenu*)> exu);
|
||||
virtual QTextCursor getTextCursor();
|
||||
virtual void setTextCursor(QTextCursor s);
|
||||
|
||||
// ModeView interface
|
||||
public:
|
||||
virtual QString title() const override;
|
||||
|
||||
// VariedTextView interface
|
||||
public:
|
||||
|
@ -26,11 +32,13 @@ namespace Components {
|
|||
virtual QString textContent() const override;
|
||||
virtual void textContentReset(const QString &value) override;
|
||||
|
||||
private:
|
||||
QTextEdit *const edit_square;
|
||||
std::function<void(QMenu*)> ex_unit;
|
||||
|
||||
protected:
|
||||
QList<Config::Configration*> configrations_host;
|
||||
virtual void rehighlighter() = 0;
|
||||
QTextEdit *const edit_square;
|
||||
QTextDocument *textDocument() const;
|
||||
|
||||
};
|
||||
|
||||
class TextContentEditFactory : public Core::FileExtensionFactory
|
||||
|
@ -79,6 +87,9 @@ namespace Components {
|
|||
virtual void rehighlighter() override;
|
||||
|
||||
|
||||
// Extension interface
|
||||
public:
|
||||
virtual void resetProcsType(const QString &suffix) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ SOURCES += \
|
|||
mainwindow.cpp \
|
||||
messagepresent.cpp \
|
||||
projectview.cpp \
|
||||
sourcecodeeditor.cpp \
|
||||
storyboardsourceedit.cpp \
|
||||
storyboardspresent.cpp \
|
||||
storychainsourceeditor.cpp \
|
||||
|
@ -37,6 +38,7 @@ HEADERS += \
|
|||
mainwindow.h \
|
||||
messagepresent.h \
|
||||
projectview.h \
|
||||
sourcecodeeditor.h \
|
||||
storyboardsourceedit.h \
|
||||
storyboardspresent.h \
|
||||
storychainsourceeditor.h \
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "storyvolumesourceedit.h"
|
||||
#include "SensitiveCore.h"
|
||||
#include "mainwindow.h"
|
||||
#include "sourcecodeeditor.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
|
@ -29,7 +30,8 @@ AppCore::AppCore(MainWindow *win, QObject *parent)
|
|||
<< new StoryUnitSourceEditFactory
|
||||
<< new StoryBoardSourceEditFactory()
|
||||
<< new StoryVolumeSourceEditFactory()
|
||||
<< new TextContentEditFactory();
|
||||
<< new TextContentEditFactory()
|
||||
<< new SourceCodeEditorFactory();
|
||||
}
|
||||
|
||||
void AppCore::save()
|
||||
|
@ -100,24 +102,23 @@ MakeTools::SensitiveCore *AppCore::getFramework() const
|
|||
|
||||
void AppCore::openTextDocument(const QString &src, const QString &name)
|
||||
{
|
||||
auto xfactorys = extensions(QFileInfo(src).suffix());
|
||||
if(framework->contains(src)){
|
||||
auto ins = framework->queryTextComponent(QFileInfo(src));
|
||||
|
||||
dynamic_cast<Extension*>(ins)->resetProcsType(QFileInfo(src).suffix());
|
||||
dynamic_cast<Core::Extension*>(ins)->reload(this->getConfigs(xfactorys[0]->configs()));
|
||||
views->contentViewAppend(ins->textView(), name);
|
||||
return;
|
||||
}
|
||||
|
||||
auto xfactorys = extensions(QFileInfo(src).suffix());
|
||||
VariedTextView *tview = dynamic_cast<VariedTextView*>(xfactorys[0]->newInstance(this));
|
||||
dynamic_cast<Extension*>(tview)->resetProcsType(QFileInfo(src).suffix());
|
||||
dynamic_cast<Core::Extension*>(tview)->reload(this->getConfigs(xfactorys[0]->configs()));
|
||||
|
||||
auto doc = parse_core->queryDocument(QFileInfo(src));
|
||||
if(doc == nullptr){
|
||||
this->make_tool->compile(QFileInfo(src), name);
|
||||
doc = parse_core->queryDocument(QFileInfo(src));
|
||||
}
|
||||
|
||||
this->make_tool->compile(QFileInfo(src), name);
|
||||
tview->setSource(this, QFileInfo(src), name, views);
|
||||
framework->addPerceptionList(tview);
|
||||
dynamic_cast<Core::Extension*>(tview)->reload(this->getConfigs(QList<Scale>() << Scale::Global << Scale::Project));
|
||||
|
||||
QFile fin(src);
|
||||
if(!fin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
|
@ -130,3 +131,6 @@ void AppCore::openTextDocument(const QString &src, const QString &name)
|
|||
|
||||
views->contentViewAppend(tview->textView(), name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,8 @@ namespace Core {
|
|||
/**
|
||||
* @brief 功能拓展生成入口
|
||||
*/
|
||||
class ExtensionFactory{
|
||||
class ExtensionFactory
|
||||
{
|
||||
public:
|
||||
virtual ~ExtensionFactory() = default;
|
||||
|
||||
|
@ -51,6 +52,10 @@ namespace Core {
|
|||
*/
|
||||
virtual QWidget* getNewPanel(Config::Configration* config) = 0;
|
||||
|
||||
/**
|
||||
* @brief 拓展插件名称
|
||||
* @return
|
||||
*/
|
||||
virtual QString extensionName() const = 0;
|
||||
};
|
||||
|
||||
|
@ -68,6 +73,12 @@ namespace Core {
|
|||
*/
|
||||
virtual ExtensionFactory* factory() const = 0;
|
||||
|
||||
/**
|
||||
* @brief 通过后缀名设置处理模式
|
||||
* @param suffix
|
||||
*/
|
||||
virtual void resetProcsType(const QString &suffix) = 0;
|
||||
|
||||
/**
|
||||
* @brief 载入指定的配置端口实例
|
||||
* @param configs
|
||||
|
|
|
@ -348,6 +348,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
this->units_view->refresh();
|
||||
this->errors_present->refresh();
|
||||
this->boards_view->refresh();
|
||||
this->concept_view->refresh();
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
#include "sourcecodeeditor.h"
|
||||
#include "keywordshightlighter.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Components;
|
||||
using namespace Enhancement;
|
||||
|
||||
SourceCodeEditor::SourceCodeEditor(Core::FileExtensionFactory *factory)
|
||||
: factory_ins(factory),
|
||||
highlighter_ins(new KeywordsHightlighter(this))
|
||||
{
|
||||
highlighter_ins->setDocument(this->textDocument());
|
||||
|
||||
}
|
||||
|
||||
void SourceCodeEditor::concept_jump(const QList<QString> &path)
|
||||
{
|
||||
auto fpath = this->filePath();
|
||||
auto core = core_ins->parseCore();
|
||||
if(path.size()){
|
||||
auto storynode = core->queryStoryConcept(path[0]).first();
|
||||
auto first_word = storynode->refered()[0];
|
||||
|
||||
auto textblock = this->textDocument()->findBlockByNumber(first_word->row());
|
||||
auto cur = this->getTextCursor();
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->setTextCursor(cur);
|
||||
|
||||
if(path.size() > 1){
|
||||
auto storypoint = core->queryStoryStrongPoint(storynode, path[1]).first();
|
||||
first_word = storypoint->refered()[0];
|
||||
|
||||
auto textblock = this->textDocument()->findBlockByNumber(first_word->row());
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->setTextCursor(cur);
|
||||
}
|
||||
}
|
||||
|
||||
textView()->setFocus();
|
||||
}
|
||||
|
||||
Core::ExtensionFactory *SourceCodeEditor::factory() const
|
||||
{
|
||||
return factory_ins;
|
||||
}
|
||||
|
||||
void SourceCodeEditor::reload(QList<Config::Configration *> configs)
|
||||
{
|
||||
auto family = Config::ConfigHelper::getConfigAsDefaultSequence(configs, {"sourcecodeeditor-setting", "default", "font", "family"}, "微软雅黑");
|
||||
auto size = Config::ConfigHelper::getConfigAsDefaultSequence(configs, {"sourcecodeeditor-setting", "default", "font", "size"}, "20");
|
||||
|
||||
QFont font;
|
||||
font.setFamily(family);
|
||||
font.setPointSize(size.toUInt());
|
||||
this->textDocument()->setDefaultFont(font);
|
||||
}
|
||||
|
||||
void SourceCodeEditor::resetProcsType(const QString &suffix)
|
||||
{
|
||||
procs_type = suffix;
|
||||
}
|
||||
|
||||
void SourceCodeEditor::modeReset(const QString &type) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QList<QString> SourceCodeEditor::modes() const
|
||||
{
|
||||
return QList<QString>() << "源码编辑";
|
||||
}
|
||||
|
||||
QString SourceCodeEditor::currentMode() const
|
||||
{
|
||||
return "源码编辑";
|
||||
}
|
||||
|
||||
void SourceCodeEditor::jumpTo(const QList<QString> &path)
|
||||
{
|
||||
if(procs_type == "storyconcept")
|
||||
concept_jump(path);
|
||||
}
|
||||
|
||||
void SourceCodeEditor::setSource(Core::AppCore *core, const QFileInfo &src, QWidget *parent)
|
||||
{
|
||||
static_cast<KeywordsHightlighter*>(highlighter_ins)->reset(core->parseCore()->queryDocument(src));
|
||||
FormattedTextEdit::setSource(core, src, parent);
|
||||
this->core_ins = core;
|
||||
}
|
||||
|
||||
void SourceCodeEditor::rehighlighter()
|
||||
{
|
||||
this->highlighter_ins->rehighlight();
|
||||
}
|
||||
|
||||
Core::Extension *SourceCodeEditorFactory::newInstance(Core::AppCore *core)
|
||||
{
|
||||
return new SourceCodeEditor(this);
|
||||
}
|
||||
|
||||
QList<Core::Scale> SourceCodeEditorFactory::configs() const
|
||||
{
|
||||
return QList<Core::Scale>() << Core::Scale::Project << Core::Scale::Global;
|
||||
}
|
||||
|
||||
namespace __temp {
|
||||
class XMarksConfig : public QWidget
|
||||
{
|
||||
public:
|
||||
XMarksConfig(Config::Configration* port)
|
||||
{
|
||||
auto layout = new QVBoxLayout(this);
|
||||
auto font_family = Config::ConfigHelper::getConfigAsDefault(port, {"sourcecodeeditor-setting", "default", "font", "family"}, "微软雅黑");
|
||||
|
||||
auto fontfamily = new QComboBox(this);
|
||||
auto families = QFontDatabase().families(QFontDatabase::WritingSystem::SimplifiedChinese);
|
||||
fontfamily->addItems(families);
|
||||
fontfamily->setCurrentText(font_family);
|
||||
connect(fontfamily, &QComboBox::currentTextChanged, [port](const QString &text){
|
||||
port->setConfig({"sourcecodeeditor-setting", "default", "font", "family"}, text);
|
||||
});
|
||||
layout->addWidget(fontfamily);
|
||||
|
||||
auto font_size = Config::ConfigHelper::getConfigAsDefault(port, {"sourcecodeeditor-setting", "default", "font", "size"}, "20");
|
||||
auto fontsize = new QSpinBox(this);
|
||||
fontsize->setRange(10, 200);
|
||||
fontsize->setSingleStep(1);
|
||||
fontsize->setValue(font_size.toInt());
|
||||
connect(fontsize, QOverload<int>::of(&QSpinBox::valueChanged), [port](int val){
|
||||
port->setConfig({"sourcecodeeditor-setting", "default", "font", "size"}, QString("%1").arg(val));
|
||||
});
|
||||
layout->addWidget(fontsize);
|
||||
|
||||
layout->addWidget(new QWidget(this), 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
QWidget *SourceCodeEditorFactory::getNewPanel(Config::Configration *config)
|
||||
{
|
||||
return new __temp::XMarksConfig(config);
|
||||
}
|
||||
|
||||
QString SourceCodeEditorFactory::extensionName() const
|
||||
{
|
||||
return "源码编辑器";
|
||||
}
|
||||
|
||||
QList<QString> SourceCodeEditorFactory::suffixPeers() const
|
||||
{
|
||||
return QList<QString>() << "storyconcept";
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef SOURCECODEEDITOR_H
|
||||
#define SOURCECODEEDITOR_H
|
||||
|
||||
#include "SourceEditView.h"
|
||||
#include "appcore.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Components {
|
||||
class SourceCodeEditorFactory : public Core::FileExtensionFactory
|
||||
{
|
||||
// ExtensionFactory interface
|
||||
public:
|
||||
virtual Core::Extension *newInstance(Core::AppCore *core) override;
|
||||
virtual QList<Core::Scale> configs() const override;
|
||||
virtual QWidget *getNewPanel(Config::Configration *config) override;
|
||||
virtual QString extensionName() const override;
|
||||
|
||||
// FileExtensionFactory interface
|
||||
public:
|
||||
virtual QList<QString> suffixPeers() const override;
|
||||
};
|
||||
|
||||
class SourceCodeEditor : public FormattedTextEdit
|
||||
{
|
||||
public:
|
||||
SourceCodeEditor(Core::FileExtensionFactory *factory);
|
||||
|
||||
private:
|
||||
Core::FileExtensionFactory *const factory_ins;
|
||||
QSyntaxHighlighter *const highlighter_ins;
|
||||
Core::AppCore *core_ins;
|
||||
QString procs_type;
|
||||
|
||||
void concept_jump(const QList<QString> &path);
|
||||
|
||||
// Extension interface
|
||||
public:
|
||||
virtual Core::ExtensionFactory *factory() const override;
|
||||
virtual void reload(QList<Config::Configration *> configs) override;
|
||||
virtual void resetProcsType(const QString &suffix) override;
|
||||
|
||||
// ModeView interface
|
||||
public:
|
||||
virtual void modeReset(const QString &type) const override;
|
||||
virtual QList<QString> modes() const override;
|
||||
virtual QString currentMode() const override;
|
||||
|
||||
// VariedTextView interface
|
||||
public:
|
||||
virtual void jumpTo(const QList<QString> &path) override;
|
||||
virtual void setSource(Core::AppCore *core, const QFileInfo &src, QWidget *parent) override;
|
||||
|
||||
// FormattedTextEdit interface
|
||||
protected:
|
||||
virtual void rehighlighter() override;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // SOURCECODEEDITOR_H
|
|
@ -14,14 +14,12 @@ using namespace Core;
|
|||
StoryBoardSourceEdit::StoryBoardSourceEdit(FileExtensionFactory *factory)
|
||||
: words_highlighter(new KeywordsHightlighter(this)), factory_ins(factory)
|
||||
{
|
||||
this->resetHighlighter(words_highlighter);
|
||||
words_highlighter->setDocument(this->textDocument());
|
||||
|
||||
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(edit_square, &QTextEdit::customContextMenuRequested, [this](const QPoint &pos){
|
||||
auto menu = edit_square->createStandardContextMenu();
|
||||
|
||||
this->setContexMenuProcess([this](QMenu *menu){
|
||||
menu->addSeparator();
|
||||
menu->addAction("刷新", [this](){words_highlighter->rehighlight();});
|
||||
menu->exec(edit_square->mapToGlobal(pos));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,8 +30,6 @@ FileExtensionFactory *StoryBoardSourceEdit::factory() const
|
|||
|
||||
void StoryBoardSourceEdit::reload(QList<Config::Configration *> configs)
|
||||
{
|
||||
this->configrations_host = configs;
|
||||
|
||||
// TODO: 设置格式
|
||||
auto font_family = Config::ConfigHelper::getConfigAsDefaultSequence
|
||||
(configs, {"sourcecode_boardedit","default_font","font_family"}, "微软雅黑");
|
||||
|
@ -43,7 +39,7 @@ void StoryBoardSourceEdit::reload(QList<Config::Configration *> configs)
|
|||
default_font.setFamily(font_family);
|
||||
default_font.setPointSize(font_size.toInt());
|
||||
|
||||
this->edit_square->document()->setDefaultFont(default_font);
|
||||
this->textDocument()->setDefaultFont(default_font);
|
||||
this->rehighlighter();
|
||||
}
|
||||
|
||||
|
@ -82,10 +78,10 @@ void StoryBoardSourceEdit::jumpTo(const QList<QString> &path)
|
|||
auto storynode = core->queryStoryBoard(path[0]).first();
|
||||
auto first_word = storynode->refered()[0];
|
||||
|
||||
auto textblock = this->edit_square->document()->findBlockByNumber(first_word->row());
|
||||
auto cur = this->edit_square->textCursor();
|
||||
auto textblock = this->textDocument()->findBlockByNumber(first_word->row());
|
||||
auto cur = this->getTextCursor();
|
||||
cur.setPosition(textblock.position());
|
||||
this->edit_square->setTextCursor(cur);
|
||||
this->setTextCursor(cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,6 +90,11 @@ void StoryBoardSourceEdit::rehighlighter()
|
|||
this->words_highlighter->rehighlight();
|
||||
}
|
||||
|
||||
void StoryBoardSourceEdit::resetProcsType(const QString &suffix)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Extension *StoryBoardSourceEditFactory::newInstance(Core::AppCore *core)
|
||||
{
|
||||
return new StoryBoardSourceEdit(this);
|
||||
|
|
|
@ -50,6 +50,10 @@ namespace Components {
|
|||
Core::AppCore * core_temp;
|
||||
QFileInfo source_target;
|
||||
|
||||
|
||||
// Extension interface
|
||||
public:
|
||||
virtual void resetProcsType(const QString &suffix) override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,11 @@ StoryChainSourceEdit::StoryChainSourceEdit(Core::FileExtensionFactory *factory)
|
|||
: highter_ins(new KeywordsHightlighter(this)), doc_ins(nullptr), factory_ins(factory)
|
||||
{
|
||||
|
||||
highter_ins->setDocument(this->edit_square->document());
|
||||
highter_ins->setDocument(this->textDocument());
|
||||
|
||||
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(edit_square, &QTextEdit::customContextMenuRequested, [this](const QPoint &pos){
|
||||
auto menu = edit_square->createStandardContextMenu();
|
||||
this->setContexMenuProcess([this](QMenu *menu){
|
||||
menu->addSeparator();
|
||||
menu->addAction("刷新", [this](){highter_ins->rehighlight();});
|
||||
menu->exec(edit_square->mapToGlobal(pos));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,8 +56,6 @@ FileExtensionFactory *StoryChainSourceEdit::factory() const
|
|||
|
||||
void StoryChainSourceEdit::reload(QList<Config::Configration *> configs)
|
||||
{
|
||||
this->configrations_host = configs;
|
||||
|
||||
// TODO: 设置格式
|
||||
auto font_family = Config::ConfigHelper::getConfigAsDefaultSequence
|
||||
(configs, {"sourcecode_chainedit","default_font","font_family"}, "微软雅黑");
|
||||
|
@ -70,7 +65,7 @@ void StoryChainSourceEdit::reload(QList<Config::Configration *> configs)
|
|||
default_font.setFamily(font_family);
|
||||
default_font.setPointSize(font_size.toInt());
|
||||
|
||||
this->edit_square->document()->setDefaultFont(default_font);
|
||||
this->textDocument()->setDefaultFont(default_font);
|
||||
this->rehighlighter();
|
||||
}
|
||||
|
||||
|
@ -79,6 +74,11 @@ void StoryChainSourceEdit::rehighlighter()
|
|||
this->highter_ins->rehighlight();
|
||||
}
|
||||
|
||||
void StoryChainSourceEdit::resetProcsType(const QString &suffix)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StoryChainSourceEdit::jumpTo(const QList<QString> &path)
|
||||
{
|
||||
auto fpath = this->filePath();
|
||||
|
@ -87,24 +87,24 @@ void StoryChainSourceEdit::jumpTo(const QList<QString> &path)
|
|||
auto storynode = core->queryStoryChain(path[0]).first();
|
||||
auto first_word = storynode->refered()[0];
|
||||
|
||||
auto textblock = this->edit_square->document()->findBlockByNumber(first_word->row());
|
||||
auto cur = this->edit_square->textCursor();
|
||||
auto textblock = this->textDocument()->findBlockByNumber(first_word->row());
|
||||
auto cur = this->getTextCursor();
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->edit_square->setTextCursor(cur);
|
||||
this->setTextCursor(cur);
|
||||
|
||||
if(path.size() > 1){
|
||||
auto storypoint = core->queryStoryPoint(storynode, path[1]).first();
|
||||
first_word = storypoint->refered()[0];
|
||||
|
||||
auto textblock = this->edit_square->document()->findBlockByNumber(first_word->row());
|
||||
auto textblock = this->textDocument()->findBlockByNumber(first_word->row());
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->edit_square->setTextCursor(cur);
|
||||
this->setTextCursor(cur);
|
||||
}
|
||||
}
|
||||
|
||||
edit_square->setFocus();
|
||||
this->textView()->setFocus();
|
||||
}
|
||||
|
||||
namespace __temp {
|
||||
|
|
|
@ -61,6 +61,10 @@ namespace Components {
|
|||
Core::AppCore *core_ins;
|
||||
Core::FileExtensionFactory *const factory_ins;
|
||||
|
||||
|
||||
// Extension interface
|
||||
public:
|
||||
virtual void resetProcsType(const QString &suffix) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -13,14 +13,11 @@ using namespace Enhancement;
|
|||
StoryUnitSourceEdit::StoryUnitSourceEdit(FileExtensionFactory *factory)
|
||||
: words_highlighter(new KeywordsHightlighter(this)), factory_ins(factory)
|
||||
{
|
||||
words_highlighter->setDocument(this->edit_square->document());
|
||||
words_highlighter->setDocument(this->textDocument());
|
||||
|
||||
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(edit_square, &QTextEdit::customContextMenuRequested, [this](const QPoint &pos){
|
||||
auto menu = edit_square->createStandardContextMenu();
|
||||
this->setContexMenuProcess([this](QMenu *menu){
|
||||
menu->addSeparator();
|
||||
menu->addAction("刷新", [this](){words_highlighter->rehighlight();});
|
||||
menu->exec(edit_square->mapToGlobal(pos));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -31,8 +28,6 @@ FileExtensionFactory *StoryUnitSourceEdit::factory() const
|
|||
|
||||
void StoryUnitSourceEdit::reload(QList<Config::Configration *> configs)
|
||||
{
|
||||
this->configrations_host = configs;
|
||||
|
||||
// TODO: 设置格式
|
||||
auto font_family = Config::ConfigHelper::getConfigAsDefaultSequence
|
||||
(configs, {"sourcecode_unitedit","default_font","font_family"}, "微软雅黑");
|
||||
|
@ -42,7 +37,7 @@ void StoryUnitSourceEdit::reload(QList<Config::Configration *> configs)
|
|||
default_font.setFamily(font_family);
|
||||
default_font.setPointSize(font_size.toInt());
|
||||
|
||||
this->edit_square->document()->setDefaultFont(default_font);
|
||||
this->textDocument()->setDefaultFont(default_font);
|
||||
this->rehighlighter();
|
||||
}
|
||||
|
||||
|
@ -89,24 +84,29 @@ void StoryUnitSourceEdit::jumpTo(const QList<QString> &path)
|
|||
auto storynode = core->queryStoryUnit(path[0]).first();
|
||||
auto first_word = storynode->refered()[0];
|
||||
|
||||
auto textblock = this->edit_square->document()->findBlockByNumber(first_word->row());
|
||||
auto cur = this->edit_square->textCursor();
|
||||
auto textblock = this->textDocument()->findBlockByNumber(first_word->row());
|
||||
auto cur = this->getTextCursor();
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->edit_square->setTextCursor(cur);
|
||||
this->setTextCursor(cur);
|
||||
|
||||
if(path.size() > 1){
|
||||
auto storypoint = core->queryStoryFragment(storynode, path[1]).first();
|
||||
first_word = storypoint->refered()[0];
|
||||
|
||||
auto textblock = this->edit_square->document()->findBlockByNumber(first_word->row());
|
||||
auto textblock = this->textDocument()->findBlockByNumber(first_word->row());
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->edit_square->setTextCursor(cur);
|
||||
this->setTextCursor(cur);
|
||||
}
|
||||
}
|
||||
|
||||
edit_square->setFocus();
|
||||
textView()->setFocus();
|
||||
}
|
||||
|
||||
void StoryUnitSourceEdit::resetProcsType(const QString &suffix)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Extension *StoryUnitSourceEditFactory::newInstance(Core::AppCore *core)
|
||||
|
|
|
@ -51,6 +51,10 @@ namespace Components {
|
|||
// VariedTextView interface
|
||||
public:
|
||||
virtual void jumpTo(const QList<QString> &path) override;
|
||||
|
||||
// Extension interface
|
||||
public:
|
||||
virtual void resetProcsType(const QString &suffix) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ FileExtensionFactory *StoryVolumeSourceEdit::factory() const
|
|||
|
||||
void StoryVolumeSourceEdit::reload(QList<Config::Configration *> configs)
|
||||
{
|
||||
this->configrations_host = configs;
|
||||
|
||||
// TODO: 设置格式
|
||||
auto font_family = Config::ConfigHelper::getConfigAsDefaultSequence
|
||||
(configs, {"sourcecode_voledit","default_font","font_family"}, "微软雅黑");
|
||||
|
@ -29,21 +27,23 @@ void StoryVolumeSourceEdit::reload(QList<Config::Configration *> configs)
|
|||
default_font.setFamily(font_family);
|
||||
default_font.setPointSize(font_size.toInt());
|
||||
|
||||
this->edit_square->document()->setDefaultFont(default_font);
|
||||
this->textDocument()->setDefaultFont(default_font);
|
||||
this->rehighlighter();
|
||||
}
|
||||
|
||||
void StoryVolumeSourceEdit::resetProcsType(const QString &suffix)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
StoryVolumeSourceEdit::StoryVolumeSourceEdit(FileExtensionFactory *factory)
|
||||
: words_highlighter(new KeywordsHightlighter(this)), factory_ins(factory)
|
||||
{
|
||||
words_highlighter->setDocument(this->edit_square->document());
|
||||
words_highlighter->setDocument(this->textDocument());
|
||||
|
||||
edit_square->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(edit_square, &QTextEdit::customContextMenuRequested, [this](const QPoint &pos){
|
||||
auto menu = edit_square->createStandardContextMenu();
|
||||
this->setContexMenuProcess([this](QMenu *menu){
|
||||
menu->addSeparator();
|
||||
menu->addAction("刷新", [this](){words_highlighter->rehighlight();});
|
||||
menu->exec(edit_square->mapToGlobal(pos));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,11 @@ namespace Components {
|
|||
public:
|
||||
StoryVolumeSourceEdit(Core::FileExtensionFactory *factory);
|
||||
|
||||
// Plugin interface
|
||||
// Extension interface
|
||||
public:
|
||||
virtual Core::FileExtensionFactory *factory() const override;
|
||||
virtual void reload(QList<Config::Configration *> configs) override;
|
||||
virtual void resetProcsType(const QString &suffix) override;
|
||||
|
||||
// ModeView interface
|
||||
public:
|
||||
|
@ -51,6 +52,7 @@ namespace Components {
|
|||
// VariedTextView interface
|
||||
public:
|
||||
virtual void jumpTo(const QList<QString> &path) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,17 @@ Parse::NodeStoryConcept::NodeStoryConcept(const QString &name, DocCore *doc)
|
|||
|
||||
bool NodeStoryConcept::check(QList<ErrorMessage> &reasons) const
|
||||
{
|
||||
return true;
|
||||
auto nodes = doc()->core()->queryStoryConcept(name()[0]);
|
||||
if(nodes.size() > 1){
|
||||
ErrorMessage ins;
|
||||
ins.CodeRow = refered().first()->row();
|
||||
ins.CodeCol = refered().first()->column();
|
||||
ins.FilePath = doc()->filePath();
|
||||
ins.Reason = "概念重复定义";
|
||||
ins.Text = name()[0];
|
||||
reasons << ins;
|
||||
}
|
||||
return nodes.size() == 1;
|
||||
}
|
||||
|
||||
QString NodeStoryConcept::toString() const
|
||||
|
@ -53,7 +63,18 @@ NodeStoryStrongPoint::NodeStoryStrongPoint(NodeStoryConcept *parent, const QStri
|
|||
|
||||
bool NodeStoryStrongPoint::check(QList<ErrorMessage> &reasons) const
|
||||
{
|
||||
return true;
|
||||
auto concept = parent();
|
||||
auto nodes = doc()->core()->queryStoryStrongPoint(concept, name()[0]);
|
||||
if(nodes.size() > 1){
|
||||
ErrorMessage ins;
|
||||
ins.CodeRow = refered().first()->row();
|
||||
ins.CodeCol = refered().first()->column();
|
||||
ins.FilePath = doc()->filePath();
|
||||
ins.Reason = "要点重复定义";
|
||||
ins.Text = name()[0];
|
||||
reasons << ins;
|
||||
}
|
||||
return nodes.size() == 1;
|
||||
}
|
||||
|
||||
QString NodeStoryStrongPoint::toString() const
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
<file>故事.png</file>
|
||||
<file>叙述.png</file>
|
||||
<file>toplevel.png</file>
|
||||
<file>概念.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -368,6 +368,8 @@ void ProjectNode::setFile(const QString &name)
|
|||
setIcon(QIcon(":/icons/叙述.png"));
|
||||
if(name.endsWith("txt"))
|
||||
setIcon(QIcon(":/icons/文件.png"));
|
||||
if(name.endsWith("storyconcept"))
|
||||
setIcon(QIcon(":/icons/概念.png"));
|
||||
}
|
||||
|
||||
QString ProjectNode::file() const
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
Loading…
Reference in New Issue