对StorychainSourceEdit改造完成
This commit is contained in:
parent
d600890b53
commit
945ecdc7fc
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.15.0, 2023-02-25T22:04:49. -->
|
||||
<!-- Written by QtCreator 4.15.0, 2023-02-27T00:06:26. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -97,9 +97,9 @@
|
|||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.11 MSVC2017 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.11 MSVC2017 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51211.win64_msvc2017_64_kit</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">3</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">2</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Projects\Cpp\build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug</value>
|
||||
|
@ -344,7 +344,7 @@
|
|||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug/DesParser</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug2/DesParser</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
|
@ -417,7 +417,7 @@
|
|||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug/Testpad</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug2/Testpad</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
|
@ -490,9 +490,82 @@
|
|||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug/CoreTest</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug2/CoreTest</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.3">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||
<value type="QString">cpu-cycles</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
|
||||
<value type="QString">-e</value>
|
||||
<value type="QString">cpu-cycles</value>
|
||||
<value type="QString">--call-graph</value>
|
||||
<value type="QString">dwarf,4096</value>
|
||||
<value type="QString">-F</value>
|
||||
<value type="QString">250</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="QString" key="Analyzer.Valgrind.Callgrind.Arguments"></value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.Memcheck.Arguments"></value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindArguments"></value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Projects/Cpp/QtNovelDesc/WordsIDE/WordsIDE.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">D:/Projects/Cpp/QtNovelDesc/WordsIDE/WordsIDE.pro</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Projects/Cpp/build-QtNovelDesc-Desktop_Qt_5_12_11_MSVC2017_64bit-Debug2/WordsIDE</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">4</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
|
|
|
@ -9,21 +9,6 @@
|
|||
using namespace MakeTools;
|
||||
using namespace Core;
|
||||
|
||||
class SimpleException : public std::exception
|
||||
{
|
||||
public:
|
||||
explicit SimpleException(const QString &msg)
|
||||
: msg_store(msg) {}
|
||||
|
||||
private:
|
||||
QString msg_store;
|
||||
|
||||
// exception interface
|
||||
public:
|
||||
virtual const char *what() const override{
|
||||
return msg_store.toLocal8Bit();
|
||||
}
|
||||
};
|
||||
|
||||
DocsManager::DocsManager(StoryTool *tool, AppCore *host, MainWindow *views)
|
||||
: host_core(host), views_holder(views), make_core(tool)
|
||||
|
|
|
@ -20,9 +20,9 @@ msvc {
|
|||
SOURCES += \
|
||||
ContentPresent.cpp \
|
||||
DocsManager.cpp \
|
||||
SourceEditView.cpp \
|
||||
appcore.cpp \
|
||||
contentpresenttest.cpp \
|
||||
default_textpresent.cpp \
|
||||
fragmentsorderview.cpp \
|
||||
keywordshightlighter.cpp \
|
||||
main.cpp \
|
||||
|
@ -31,7 +31,7 @@ SOURCES += \
|
|||
sourcecodeeditor.cpp \
|
||||
storyboardsourceedit.cpp \
|
||||
storyboardspresent.cpp \
|
||||
storychainsourceeditor.cpp \
|
||||
storychain_sourceeditor.cpp \
|
||||
storychainspresent.cpp \
|
||||
storyconceptspresent.cpp \
|
||||
storyunitsourceedit.cpp \
|
||||
|
@ -44,9 +44,9 @@ SOURCES += \
|
|||
HEADERS += \
|
||||
ContentPresent.h \
|
||||
DocsManager.h \
|
||||
SourceEditView.h \
|
||||
appcore.h \
|
||||
contentpresenttest.h \
|
||||
default_textpresent.h \
|
||||
fragmentsorderview.h \
|
||||
keywordshightlighter.h \
|
||||
mainwindow.h \
|
||||
|
@ -55,7 +55,7 @@ HEADERS += \
|
|||
sourcecodeeditor.h \
|
||||
storyboardsourceedit.h \
|
||||
storyboardspresent.h \
|
||||
storychainsourceeditor.h \
|
||||
storychain_sourceeditor.h \
|
||||
storychainspresent.h \
|
||||
storyconceptspresent.h \
|
||||
storyunitsourceedit.h \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "appcore.h"
|
||||
#include "xmlconfig.h"
|
||||
#include "storychainsourceeditor.h"
|
||||
#include "storychain_sourceeditor.h"
|
||||
#include "storyunitsourceedit.h"
|
||||
#include "storyboardsourceedit.h"
|
||||
#include "storyvolumesourceedit.h"
|
||||
|
@ -25,7 +25,7 @@ AppCore::AppCore(MainWindow *win, QObject *parent)
|
|||
docs_manager(new DocsManager(makes_core, this, win))
|
||||
{
|
||||
global_config->loadFile(QDir(QApplication::applicationDirPath()).filePath(".software.xml"));
|
||||
extensions_list //<< new StoryChainSourceEditFactory()
|
||||
extensions_list << new StorychainSourceEdit()
|
||||
//<< new StoryUnitSourceEditFactory
|
||||
//<< new StoryBoardSourceEditFactory()
|
||||
//<< new StoryVolumeSourceEditFactory()
|
||||
|
@ -101,3 +101,10 @@ MakeTools::DocsManager *AppCore::getDocsManager() const
|
|||
|
||||
|
||||
|
||||
|
||||
SimpleException::SimpleException(const QString &msg)
|
||||
: msg_store(msg) {}
|
||||
|
||||
const char *SimpleException::what() const{
|
||||
return msg_store.toLocal8Bit();
|
||||
}
|
||||
|
|
|
@ -7,13 +7,25 @@
|
|||
#include <libProjectManager.h>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace MakeTools {
|
||||
class StoryTool;
|
||||
class DocsManager;
|
||||
class ContentPresent;
|
||||
}
|
||||
|
||||
class SimpleException : public std::exception
|
||||
{
|
||||
public:
|
||||
explicit SimpleException(const QString &msg);
|
||||
|
||||
private:
|
||||
QString msg_store;
|
||||
|
||||
// exception interface
|
||||
public:
|
||||
virtual const char *what() const override;
|
||||
};
|
||||
|
||||
namespace Core {
|
||||
class Extension;
|
||||
class AppCore;
|
||||
|
|
|
@ -36,6 +36,9 @@ void ContentPresentTest::test_Create_Load_SaveAs()
|
|||
{
|
||||
QDir curr("./");
|
||||
for(auto &s : inst->suffixes()){
|
||||
if(s == "*")
|
||||
continue;
|
||||
|
||||
auto files = curr.entryInfoList(QStringList() << s, QDir::Files);
|
||||
for(auto &x:files)
|
||||
curr.remove(x.fileName());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "SourceEditView.h"
|
||||
#include "default_textpresent.h"
|
||||
#include "keywordshightlighter.h"
|
||||
#include <QComboBox>
|
||||
#include <QFont>
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef SOURCEEDITVIEW_H
|
||||
#define SOURCEEDITVIEW_H
|
||||
#ifndef DEFAULT_TEXTPRESENT_H
|
||||
#define DEFAULT_TEXTPRESENT_H
|
||||
|
||||
#include "DocsManager.h"
|
||||
#include "ContentPresent.h"
|
||||
|
@ -11,7 +11,7 @@
|
|||
namespace Components {
|
||||
|
||||
/**
|
||||
* @brief 默认文本编辑视图
|
||||
* @brief Text和默认文本编辑视图
|
||||
*/
|
||||
class DefaultTextPresent : public MakeTools::ContentPresent, public Presents::ModeView
|
||||
{
|
||||
|
@ -51,4 +51,4 @@ namespace Components {
|
|||
}
|
||||
|
||||
|
||||
#endif // SOURCEEDITVIEW_H
|
||||
#endif // DEFAULT_TEXTPRESENT_H
|
|
@ -5,9 +5,20 @@
|
|||
#include <QSyntaxHighlighter>
|
||||
#include <libParse.h>
|
||||
|
||||
|
||||
namespace Core {
|
||||
class AppCore;
|
||||
}
|
||||
|
||||
namespace Enhancement {
|
||||
class HighlightDemand
|
||||
{
|
||||
public:
|
||||
virtual ~HighlightDemand() = default;
|
||||
|
||||
virtual void contexBind(Core::AppCore *app, Parse::Result::DocCore *core) = 0;
|
||||
virtual void reHighlighter() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 词语语法高亮
|
||||
*/
|
||||
|
@ -15,6 +26,7 @@ namespace Enhancement {
|
|||
{
|
||||
public:
|
||||
KeywordsHightlighter(QObject *parent = nullptr);
|
||||
|
||||
void reset(Parse::Result::DocCore *base);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "mainwindow.h"
|
||||
#include "xapplication.h"
|
||||
#include "contentpresenttest.h"
|
||||
#include "SourceEditView.h"
|
||||
#include "default_textpresent.h"
|
||||
#include "storychain_sourceeditor.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLocale>
|
||||
|
@ -17,7 +18,8 @@ int main(int argc, char *argv[])
|
|||
#ifdef UNIT_TEST
|
||||
|
||||
MakeTools::ContentPresent *array[] = {
|
||||
new Components::TextContentEdit()
|
||||
new Components::DefaultTextPresent(),
|
||||
new Components::StorychainSourceEdit()
|
||||
};
|
||||
|
||||
for(auto &it : array){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "SourceEditView.h"
|
||||
#include "default_textpresent.h"
|
||||
#include "mainwindow.h"
|
||||
#include "storyboardsourceedit.h"
|
||||
#include "storychainsourceeditor.h"
|
||||
#include "storychain_sourceeditor.h"
|
||||
#include "storyunitsourceedit.h"
|
||||
#include "storyvolumesourceedit.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SOURCECODEEDITOR_H
|
||||
#define SOURCECODEEDITOR_H
|
||||
|
||||
#include "SourceEditView.h"
|
||||
#include "default_textpresent.h"
|
||||
#include "appcore.h"
|
||||
|
||||
#include <QObject>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef STORYBOARDSOURCEEDIT_H
|
||||
#define STORYBOARDSOURCEEDIT_H
|
||||
|
||||
#include "SourceEditView.h"
|
||||
#include "default_textpresent.h"
|
||||
|
||||
namespace Components {
|
||||
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
#include "storychain_sourceeditor.h"
|
||||
#include "keywordshightlighter.h"
|
||||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
using namespace Enhancement;
|
||||
using namespace Parse::Result;
|
||||
using namespace Core;
|
||||
using namespace Components;
|
||||
|
||||
StorychainSourceEdit::StorychainSourceEdit()
|
||||
: highter_ins(new KeywordsHightlighter(this)), edit_square(new QTextEdit)
|
||||
{
|
||||
connect(edit_square, &QTextEdit::textChanged, [this](){
|
||||
emit this->dataChanged(filepath_store);
|
||||
});
|
||||
highter_ins->setDocument(edit_square->document());
|
||||
}
|
||||
|
||||
void StorychainSourceEdit::contexBind(AppCore *app, Parse::Result::DocCore *core)
|
||||
{
|
||||
core_ins = core;
|
||||
app_core = app;
|
||||
}
|
||||
|
||||
void StorychainSourceEdit::reHighlighter() const
|
||||
{
|
||||
highter_ins->rehighlight();
|
||||
}
|
||||
|
||||
void StorychainSourceEdit::modeReset(const QString &) const{}
|
||||
|
||||
QList<QString> StorychainSourceEdit::modes() const
|
||||
{
|
||||
return QList<QString>() << "源码";
|
||||
}
|
||||
|
||||
QString StorychainSourceEdit::currentMode() const
|
||||
{
|
||||
return modes()[0];
|
||||
}
|
||||
|
||||
QList<QString> StorychainSourceEdit::suffixes() const
|
||||
{
|
||||
return QList<QString>() << "storychain";
|
||||
}
|
||||
|
||||
std::tuple<bool, QString> StorychainSourceEdit::create(const QDir &target, const QString &name, const QString &suffix)
|
||||
{
|
||||
auto path = target.filePath(QString("%1.%2").arg(name, suffix));
|
||||
if(QFileInfo::exists(path))
|
||||
return std::make_tuple(false, path);
|
||||
|
||||
QFile nwf(path);
|
||||
if(!nwf.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
throw new SimpleException("指定文件");
|
||||
|
||||
return std::make_tuple(true, target.relativeFilePath(path));
|
||||
}
|
||||
|
||||
MakeTools::ContentPresent *StorychainSourceEdit::newInst() const
|
||||
{
|
||||
return new StorychainSourceEdit();
|
||||
}
|
||||
|
||||
QWidget *StorychainSourceEdit::widget() const
|
||||
{
|
||||
return edit_square;
|
||||
}
|
||||
|
||||
void StorychainSourceEdit::applySetting(const QString &name, Core::AppCore *core)
|
||||
{
|
||||
this->name_store = name;
|
||||
}
|
||||
|
||||
QString StorychainSourceEdit::name() const
|
||||
{
|
||||
return name_store;
|
||||
}
|
||||
|
||||
void StorychainSourceEdit::load(const QFileInfo &target_file)
|
||||
{
|
||||
if(!target_file.exists())
|
||||
throw new SimpleException("参数错误:传入的文件不存在");
|
||||
if(!target_file.isFile())
|
||||
throw new SimpleException("参数错误:传入参数非文件类型");
|
||||
|
||||
filepath_store = target_file.absoluteFilePath();
|
||||
QFile bin(filepath_store);
|
||||
if(!bin.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||
throw new SimpleException("参数错误:指定的文件无法打开");
|
||||
|
||||
QTextStream tin(&bin);
|
||||
tin.setCodec("UTF-8");
|
||||
this->edit_square->setText(tin.readAll());
|
||||
}
|
||||
|
||||
void StorychainSourceEdit::saveAs(const QString &path)
|
||||
{
|
||||
if(!path.isEmpty())
|
||||
filepath_store = path;
|
||||
|
||||
QFile bout(filepath_store);
|
||||
if(!bout.open(QIODevice::WriteOnly|QIODevice::Text))
|
||||
throw new SimpleException("参数错误:指定的文件无法打开");
|
||||
|
||||
QTextStream tout(&bout);
|
||||
tout.setCodec("UTF-8");
|
||||
tout << this->edit_square->toPlainText();
|
||||
tout.flush();
|
||||
}
|
||||
|
||||
QString StorychainSourceEdit::targetPath(const QDir &base) const
|
||||
{
|
||||
return base.relativeFilePath(filepath_store);
|
||||
}
|
||||
|
||||
QString StorychainSourceEdit::absulateTargetPath() const
|
||||
{
|
||||
return filepath_store;
|
||||
}
|
||||
|
||||
QString StorychainSourceEdit::getText() const
|
||||
{
|
||||
return edit_square->toPlainText();
|
||||
}
|
||||
|
||||
bool StorychainSourceEdit::isModified() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void StorychainSourceEdit::jumpTo(const QList<QString> &path)
|
||||
{
|
||||
auto fpath = this->absulateTargetPath();
|
||||
auto core = app_core->parseCore();
|
||||
if(path.size()){
|
||||
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();
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->edit_square->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());
|
||||
cur.setPosition(textblock.position());
|
||||
cur.select(QTextCursor::SelectionType::LineUnderCursor);
|
||||
this->edit_square->setTextCursor(cur);
|
||||
}
|
||||
}
|
||||
|
||||
this->widget()->setFocus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef STORYCHAIN_SOURCEEDITOR_H
|
||||
#define STORYCHAIN_SOURCEEDITOR_H
|
||||
|
||||
#include "ContentPresent.h"
|
||||
#include "DocsManager.h"
|
||||
#include "default_textpresent.h"
|
||||
#include "keywordshightlighter.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
namespace Components {
|
||||
|
||||
/**
|
||||
* @brief Storychain源码编辑器
|
||||
*/
|
||||
class StorychainSourceEdit : public Presents::ModeView,
|
||||
public MakeTools::ContentPresent, public Enhancement::HighlightDemand
|
||||
{
|
||||
public:
|
||||
StorychainSourceEdit();
|
||||
virtual ~StorychainSourceEdit() = default;
|
||||
|
||||
private:
|
||||
QSyntaxHighlighter *const highter_ins;
|
||||
Parse::Result::DocCore *core_ins;
|
||||
Core::AppCore *app_core;
|
||||
QTextEdit *edit_square;
|
||||
QString name_store;
|
||||
QString filepath_store;
|
||||
|
||||
// HighlightDemand interface
|
||||
public:
|
||||
virtual void contexBind(Core::AppCore *app, Parse::Result::DocCore *core) override;
|
||||
virtual void reHighlighter() const override;
|
||||
|
||||
// ModeView interface
|
||||
public:
|
||||
virtual void modeReset(const QString &) const override;
|
||||
virtual QList<QString> modes() const override;
|
||||
virtual QString currentMode() const override;
|
||||
|
||||
// ContentPresent interface
|
||||
public:
|
||||
virtual QList<QString> suffixes() const override;
|
||||
virtual std::tuple<bool, QString> create(const QDir &target, const QString &name, const QString &suffix) override;
|
||||
virtual MakeTools::ContentPresent *newInst() const override;
|
||||
virtual QWidget *widget() const override;
|
||||
virtual void applySetting(const QString &name, Core::AppCore *core) override;
|
||||
virtual QString name() const override;
|
||||
virtual void load(const QFileInfo &target_file) override;
|
||||
virtual void saveAs(const QString &path) override;
|
||||
virtual QString targetPath(const QDir &base) const override;
|
||||
virtual QString absulateTargetPath() const override;
|
||||
virtual QString getText() const override;
|
||||
virtual bool isModified() const override;
|
||||
virtual void jumpTo(const QList<QString> &path) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // STORYCHAIN_SOURCEEDITOR_H
|
|
@ -1,178 +0,0 @@
|
|||
#include "storychainsourceeditor.h"
|
||||
#include "keywordshightlighter.h"
|
||||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
using namespace Enhancement;
|
||||
using namespace Parse::Result;
|
||||
using namespace Core;
|
||||
using namespace Components;
|
||||
|
||||
//StoryChainSourceEdit::StoryChainSourceEdit(Core::FileExtensionFactory *factory)
|
||||
// : highter_ins(new KeywordsHightlighter(this)), doc_ins(nullptr), factory_ins(factory)
|
||||
//{
|
||||
|
||||
// highter_ins->setDocument(this->textDocument());
|
||||
|
||||
// this->setContexMenuProcess([this](QMenu *menu){
|
||||
// menu->addSeparator();
|
||||
// menu->addAction("刷新", [this](){highter_ins->rehighlight();});
|
||||
// });
|
||||
//}
|
||||
|
||||
//void StoryChainSourceEdit::modeReset(const QString &) const{}
|
||||
|
||||
//QList<QString> StoryChainSourceEdit::modes() const
|
||||
//{
|
||||
// return QList<QString>() << "源码";
|
||||
//}
|
||||
|
||||
//QString StoryChainSourceEdit::currentMode() const
|
||||
//{
|
||||
// return modes()[0];
|
||||
//}
|
||||
|
||||
//QString StoryChainSourceEdit::title() const
|
||||
//{
|
||||
// return doc_ins->filePath();
|
||||
//}
|
||||
|
||||
//void StoryChainSourceEdit::initSource(Core::AppCore *core, const QFileInfo &src, QWidget *parent)
|
||||
//{
|
||||
// FormattedTextEdit::initSource(core, src, parent);
|
||||
// this->doc_ins = core->parseCore()->queryDocument(src);
|
||||
// this->core_ins = core;
|
||||
// static_cast<Enhancement::KeywordsHightlighter*>(this->highter_ins)->reset(doc_ins);
|
||||
//}
|
||||
|
||||
//FileExtensionFactory *StoryChainSourceEdit::factory() const
|
||||
//{
|
||||
// return factory_ins;
|
||||
//}
|
||||
|
||||
//void StoryChainSourceEdit::reloadConfigrations(QList<Config::Configration *> configs)
|
||||
//{
|
||||
// // TODO: 设置格式
|
||||
// auto font_family = Config::ConfigHelper::getConfigAsDefaultSequence
|
||||
// (configs, {"sourcecode_chainedit","default_font","font_family"}, "微软雅黑");
|
||||
// auto font_size = Config::ConfigHelper::getConfigAsDefaultSequence(
|
||||
// configs, {"sourcecode_chainedit","default_font","font_sizept"}, "20");
|
||||
// QFont default_font;
|
||||
// default_font.setFamily(font_family);
|
||||
// default_font.setPointSize(font_size.toInt());
|
||||
|
||||
// this->textDocument()->setDefaultFont(default_font);
|
||||
//}
|
||||
|
||||
//void StoryChainSourceEdit::rehighlighter()
|
||||
//{
|
||||
// this->highter_ins->rehighlight();
|
||||
//}
|
||||
|
||||
//void StoryChainSourceEdit::resetProcsType(const QString &suffix)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
//void StoryChainSourceEdit::jumpTo(const QList<QString> &path)
|
||||
//{
|
||||
// auto fpath = this->absoluteFilePath();
|
||||
// auto core = core_ins->parseCore();
|
||||
// if(path.size()){
|
||||
// auto storynode = core->queryStoryChain(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->queryStoryPoint(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);
|
||||
// }
|
||||
// }
|
||||
|
||||
// this->textView()->setFocus();
|
||||
//}
|
||||
|
||||
//namespace __impl_temp {
|
||||
// class ChainSrcConfig : public QWidget
|
||||
// {
|
||||
// public:
|
||||
// virtual ~ChainSrcConfig(){
|
||||
// qDebug() << "析构";
|
||||
// }
|
||||
// void init(Config::Configration *port){}
|
||||
// };
|
||||
//}
|
||||
//StoryChainSourceEditFactory::StoryChainSourceEditFactory(){}
|
||||
|
||||
//Core::Extension *Components::StoryChainSourceEditFactory::newInstance(Core::AppCore *core)
|
||||
//{
|
||||
// return new StoryChainSourceEdit(this);
|
||||
//}
|
||||
|
||||
//QList<Core::Scale> Components::StoryChainSourceEditFactory::configs() const
|
||||
//{
|
||||
// return QList<Scale>() << Scale::Project << Scale::Global;
|
||||
//}
|
||||
|
||||
|
||||
//namespace __impl_temp {
|
||||
// class ChainConfigration : public QWidget
|
||||
// {
|
||||
// public:
|
||||
// ChainConfigration(Config::Configration* port)
|
||||
// {
|
||||
// auto layout = new QVBoxLayout(this);
|
||||
|
||||
// auto family = Config::ConfigHelper::getConfigAsDefault(
|
||||
// port, {"sourcecode_chainedit","default_font","font_family"}, "微软雅黑");
|
||||
// auto fontfamily = new QComboBox(this);
|
||||
// layout->addWidget(fontfamily);
|
||||
// auto families = QFontDatabase().families(QFontDatabase::WritingSystem::SimplifiedChinese);
|
||||
// fontfamily->addItems(families);
|
||||
// fontfamily->setCurrentText(family);
|
||||
// connect(fontfamily, &QComboBox::currentTextChanged, [port](const QString &text){
|
||||
// port->setConfig({"sourcecode_chainedit","default_font","font_family"}, text);
|
||||
// });
|
||||
|
||||
// auto size = Config::ConfigHelper::getConfigAsDefault(
|
||||
// port, {"sourcecode_chainedit","default_font","font_sizept"}, "20");
|
||||
// auto fontsize = new QSpinBox(this);
|
||||
// layout->addWidget(fontsize);
|
||||
// fontsize->setRange(10, 200);
|
||||
// fontsize->setSingleStep(1);
|
||||
// fontsize->setValue(size.toInt());
|
||||
// connect(fontsize, QOverload<int>::of(&QSpinBox::valueChanged), [port](int val){
|
||||
// port->setConfig({"sourcecode_chainedit","default_font","font_sizept"}, QString("%1").arg(val));
|
||||
// });
|
||||
|
||||
// layout->addWidget(new QWidget(this), 1);
|
||||
// }
|
||||
// };
|
||||
//}
|
||||
//QWidget *Components::StoryChainSourceEditFactory::getNewPanel(Config::Configration *config)
|
||||
//{
|
||||
// return new __impl_temp::ChainConfigration(config);
|
||||
//}
|
||||
|
||||
//QString StoryChainSourceEditFactory::extensionName() const
|
||||
//{
|
||||
// return "脉络编辑器";
|
||||
//}
|
||||
|
||||
//QList<QString> StoryChainSourceEditFactory::suffixPeers() const
|
||||
//{
|
||||
// return QList<QString>() << "storychain";
|
||||
//}
|
|
@ -1,72 +0,0 @@
|
|||
#ifndef STORYCHAINSOURCEEDITOR_H
|
||||
#define STORYCHAINSOURCEEDITOR_H
|
||||
|
||||
#include "ContentPresent.h"
|
||||
#include "DocsManager.h"
|
||||
#include "SourceEditView.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
namespace Components {
|
||||
|
||||
// class StoryChainSourceEditFactory : public Core::FileExtensionFactory
|
||||
// {
|
||||
// public:
|
||||
// StoryChainSourceEditFactory();
|
||||
// virtual ~StoryChainSourceEditFactory() = default;
|
||||
|
||||
// // PluginFactory 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;
|
||||
// virtual QList<QString> suffixPeers() const override;
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * @brief StoryChain源码编辑器
|
||||
// */
|
||||
// class StoryChainSourceEdit : public FormattedTextEdit
|
||||
// {
|
||||
// public:
|
||||
// StoryChainSourceEdit(Core::FileExtensionFactory *factory);
|
||||
// virtual ~StoryChainSourceEdit() = default;
|
||||
|
||||
// // ModeView interface
|
||||
// public:
|
||||
// virtual void modeReset(const QString &) const override;
|
||||
// virtual QList<QString> modes() const override;
|
||||
// virtual QString currentMode() const override;
|
||||
// virtual QString title() const override;
|
||||
|
||||
// // VariedTextView interface
|
||||
// public:
|
||||
// virtual void initSource(Core::AppCore *core, const QFileInfo &src, QWidget *parent=nullptr) override;
|
||||
// virtual void jumpTo(const QList<QString> &path) override;
|
||||
|
||||
// // Plugin interface
|
||||
// public:
|
||||
// virtual Core::FileExtensionFactory *factory() const override;
|
||||
// virtual void reloadConfigrations(QList<Config::Configration *> configs) override;
|
||||
|
||||
// // FormattedTextEdit interface
|
||||
// protected:
|
||||
// virtual void rehighlighter() override;
|
||||
|
||||
// private:
|
||||
// QSyntaxHighlighter *const highter_ins;
|
||||
// Parse::Result::DocCore * doc_ins;
|
||||
// Core::AppCore *core_ins;
|
||||
// Core::FileExtensionFactory *const factory_ins;
|
||||
|
||||
|
||||
// // Extension interface
|
||||
// public:
|
||||
// virtual void resetProcsType(const QString &suffix) override;
|
||||
// };
|
||||
|
||||
}
|
||||
|
||||
#endif // STORYCHAINSOURCEEDITOR_H
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef STORYUNITSOURCEEDIT_H
|
||||
#define STORYUNITSOURCEEDIT_H
|
||||
|
||||
#include "SourceEditView.h"
|
||||
#include "default_textpresent.h"
|
||||
|
||||
#include <QSplitter>
|
||||
#include <QTableView>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef STORYVOLUMESOURCEEDIT_H
|
||||
#define STORYVOLUMESOURCEEDIT_H
|
||||
|
||||
#include "SourceEditView.h"
|
||||
#include "default_textpresent.h"
|
||||
|
||||
|
||||
namespace Components {
|
||||
|
|
Loading…
Reference in New Issue