diff --git a/.gitignore b/.gitignore index c91295c..ddeb82d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ libParse/release/ libProjectManager/debug/ libConfig/release/ libProjectManager/release/ +/u_test/release/qmake/temp +/u_test/debug +/SplitView/debug +/u_test/release diff --git a/GenericConsole/GenericConsole.vcxproj b/GenericConsole/GenericConsole.vcxproj index 2fe63c6..ea3f97a 100644 --- a/GenericConsole/GenericConsole.vcxproj +++ b/GenericConsole/GenericConsole.vcxproj @@ -16,8 +16,7 @@ QtVS_v304 10.0.22621.0 10.0.22621.0 - $(MSBuildProjectDirectory)\QtMsBuild - + $(MSBuildProjectDirectory)\QtMsBuild v141 @@ -37,10 +36,7 @@ debug\ GenericConsole - - - - + @@ -48,34 +44,8 @@ - - - - - - ..\WordsIDE\debug - debug\ - GenericConsole - true - - - release\ - release\ - GenericConsole - true - false - - - 5.12.11_msvc2017_64 - core - - - 5.12.11_msvc2017_64 - core - - - - + debug\debug\GenericConsoletruerelease\release\GenericConsoletruefalse5.12.11_msvc2017_64core5.12.11_msvc2017_64core + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;release;%(AdditionalIncludeDirectories) @@ -89,14 +59,12 @@ MaxSpeed _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;GENERICCONSOLE_LIBRARY;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) false - - + MultiThreadedDLL true true Level3 - true - + true %(AdditionalDependencies) %(AdditionalLibraryDirectories) @@ -136,8 +104,7 @@ true true Level3 - true - + true %(AdditionalDependencies) %(AdditionalLibraryDirectories) @@ -175,13 +142,18 @@ Generate moc_predefs.h debug\moc_predefs.h;%(Outputs) + + Document + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h + Generate moc_predefs.h + release\moc_predefs.h;%(Outputs) + true + - - - - + \ No newline at end of file diff --git a/GenericConsole/GenericConsole.vcxproj.filters b/GenericConsole/GenericConsole.vcxproj.filters index 128c97c..807f519 100644 --- a/GenericConsole/GenericConsole.vcxproj.filters +++ b/GenericConsole/GenericConsole.vcxproj.filters @@ -53,6 +53,9 @@ Generated Files + + Generated Files + diff --git a/QtNovelDesc.pro.user b/QtNovelDesc.pro.user index e8b3a21..ed62b3e 100644 --- a/QtNovelDesc.pro.user +++ b/QtNovelDesc.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/QtNovelDesc.sln b/QtNovelDesc.sln index 38f3226..c5366be 100644 --- a/QtNovelDesc.sln +++ b/QtNovelDesc.sln @@ -1,65 +1,48 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.33026.149 +VisualStudioVersion = 15.0.33801.198 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreTest", "CoreTest\CoreTest.vcxproj", "{2CCAEF30-054D-3145-8644-812795679560}" - ProjectSection(ProjectDependencies) = postProject - {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} = {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} - {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6} = {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DesParser", "DesParser\DesParser.vcxproj", "{CDBA4FCE-9275-3B08-87C8-B4473EB323EA}" - ProjectSection(ProjectDependencies) = postProject - {BF0B8C4D-69F9-391A-85A1-237D14A69C5E} = {BF0B8C4D-69F9-391A-85A1-237D14A69C5E} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GenericConsole", "GenericConsole\GenericConsole.vcxproj", "{5BB4976A-6252-3E36-851D-7F17F16DF17D}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Testpad", "Testpad\Testpad.vcxproj", "{D35B67A8-36AB-3A8B-8F10-73A2007910CB}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SplitView", "SplitView\SplitView.vcxproj", "{DB7B1794-6682-38A2-B142-117D0E9F66E4}" ProjectSection(ProjectDependencies) = postProject {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} = {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} - {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6} = {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WordsIDE", "WordsIDE\WordsIDE.vcxproj", "{E0995577-1AB9-3B93-9990-97E99093D597}" ProjectSection(ProjectDependencies) = postProject {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} = {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6} = {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6} - {BF0B8C4D-69F9-391A-85A1-237D14A69C5E} = {BF0B8C4D-69F9-391A-85A1-237D14A69C5E} {5BB4976A-6252-3E36-851D-7F17F16DF17D} = {5BB4976A-6252-3E36-851D-7F17F16DF17D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libConfig", "libConfig\libConfig.vcxproj", "{584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libParse", "libParse\libParse.vcxproj", "{BF0B8C4D-69F9-391A-85A1-237D14A69C5E}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libProjectManager", "libProjectManager\libProjectManager.vcxproj", "{5CBE83F9-2019-33DC-8327-32F7A2AC9EF6}" ProjectSection(ProjectDependencies) = postProject {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} = {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "u_test", "u_test\u_test.vcxproj", "{2A348B24-97E4-3DE1-84FD-5A95F92CEADE}" + ProjectSection(ProjectDependencies) = postProject + {DB7B1794-6682-38A2-B142-117D0E9F66E4} = {DB7B1794-6682-38A2-B142-117D0E9F66E4} + {5BB4976A-6252-3E36-851D-7F17F16DF17D} = {5BB4976A-6252-3E36-851D-7F17F16DF17D} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2CCAEF30-054D-3145-8644-812795679560}.Debug|x64.ActiveCfg = Debug|x64 - {2CCAEF30-054D-3145-8644-812795679560}.Debug|x64.Build.0 = Debug|x64 - {2CCAEF30-054D-3145-8644-812795679560}.Release|x64.ActiveCfg = Release|x64 - {2CCAEF30-054D-3145-8644-812795679560}.Release|x64.Build.0 = Release|x64 - {CDBA4FCE-9275-3B08-87C8-B4473EB323EA}.Debug|x64.ActiveCfg = Debug|x64 - {CDBA4FCE-9275-3B08-87C8-B4473EB323EA}.Debug|x64.Build.0 = Debug|x64 - {CDBA4FCE-9275-3B08-87C8-B4473EB323EA}.Release|x64.ActiveCfg = Release|x64 - {CDBA4FCE-9275-3B08-87C8-B4473EB323EA}.Release|x64.Build.0 = Release|x64 {5BB4976A-6252-3E36-851D-7F17F16DF17D}.Debug|x64.ActiveCfg = Debug|x64 {5BB4976A-6252-3E36-851D-7F17F16DF17D}.Debug|x64.Build.0 = Debug|x64 {5BB4976A-6252-3E36-851D-7F17F16DF17D}.Release|x64.ActiveCfg = Release|x64 {5BB4976A-6252-3E36-851D-7F17F16DF17D}.Release|x64.Build.0 = Release|x64 - {D35B67A8-36AB-3A8B-8F10-73A2007910CB}.Debug|x64.ActiveCfg = Debug|x64 - {D35B67A8-36AB-3A8B-8F10-73A2007910CB}.Debug|x64.Build.0 = Debug|x64 - {D35B67A8-36AB-3A8B-8F10-73A2007910CB}.Release|x64.ActiveCfg = Release|x64 - {D35B67A8-36AB-3A8B-8F10-73A2007910CB}.Release|x64.Build.0 = Release|x64 + {DB7B1794-6682-38A2-B142-117D0E9F66E4}.Debug|x64.ActiveCfg = Debug|x64 + {DB7B1794-6682-38A2-B142-117D0E9F66E4}.Debug|x64.Build.0 = Debug|x64 + {DB7B1794-6682-38A2-B142-117D0E9F66E4}.Release|x64.ActiveCfg = Release|x64 + {DB7B1794-6682-38A2-B142-117D0E9F66E4}.Release|x64.Build.0 = Release|x64 {E0995577-1AB9-3B93-9990-97E99093D597}.Debug|x64.ActiveCfg = Debug|x64 {E0995577-1AB9-3B93-9990-97E99093D597}.Debug|x64.Build.0 = Debug|x64 {E0995577-1AB9-3B93-9990-97E99093D597}.Release|x64.ActiveCfg = Release|x64 @@ -68,20 +51,20 @@ Global {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9}.Debug|x64.Build.0 = Debug|x64 {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9}.Release|x64.ActiveCfg = Release|x64 {584ACAFD-87A5-3B62-B96B-4CE19B6FD6C9}.Release|x64.Build.0 = Release|x64 - {BF0B8C4D-69F9-391A-85A1-237D14A69C5E}.Debug|x64.ActiveCfg = Debug|x64 - {BF0B8C4D-69F9-391A-85A1-237D14A69C5E}.Debug|x64.Build.0 = Debug|x64 - {BF0B8C4D-69F9-391A-85A1-237D14A69C5E}.Release|x64.ActiveCfg = Release|x64 - {BF0B8C4D-69F9-391A-85A1-237D14A69C5E}.Release|x64.Build.0 = Release|x64 {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6}.Debug|x64.ActiveCfg = Debug|x64 {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6}.Debug|x64.Build.0 = Debug|x64 {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6}.Release|x64.ActiveCfg = Release|x64 {5CBE83F9-2019-33DC-8327-32F7A2AC9EF6}.Release|x64.Build.0 = Release|x64 + {2A348B24-97E4-3DE1-84FD-5A95F92CEADE}.Debug|x64.ActiveCfg = Debug|x64 + {2A348B24-97E4-3DE1-84FD-5A95F92CEADE}.Debug|x64.Build.0 = Debug|x64 + {2A348B24-97E4-3DE1-84FD-5A95F92CEADE}.Release|x64.ActiveCfg = Release|x64 + {2A348B24-97E4-3DE1-84FD-5A95F92CEADE}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution Qt5Version = 5.12.11_msvc2017_64 - SolutionGuid = {4A19B662-6911-4A57-99FE-053117EE4D99} + SolutionGuid = {55A4EA1C-4AF5-49EC-A1EF-A3CE53C97A13} EndGlobalSection EndGlobal diff --git a/SplitView/SplitView.vcxproj b/SplitView/SplitView.vcxproj new file mode 100644 index 0000000..9ec8cac --- /dev/null +++ b/SplitView/SplitView.vcxproj @@ -0,0 +1,192 @@ + + + + + Release + x64 + + + Debug + x64 + + + + {DB7B1794-6682-38A2-B142-117D0E9F66E4} + SplitView + QtVS_v304 + 10.0.22621.0 + 10.0.22621.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + v141 + release\ + false + NotSet + DynamicLibrary + release\ + SplitView + + + v141 + debug\ + false + NotSet + DynamicLibrary + debug\ + SplitView + + + + + + + + + + + + + + + + + + $(SolutionDir)x64\Debug + debug\ + SplitView + true + + + release\ + release\ + SplitView + true + false + + + 5.12.11_msvc2017_64 + core;gui;widgets + + + 5.12.11_msvc2017_64 + core;gui;widgets + + + + + + + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;release;/include;%(AdditionalIncludeDirectories) + -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) + release\ + false + None + 4577;4467;%(DisableSpecificWarnings) + Sync + release\ + MaxSpeed + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SPLITVIEW_LIBRARY;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) + false + + + MultiThreadedDLL + true + true + Level3 + true + + + libConfig.lib;%(AdditionalDependencies) + D:\Projects\Cpp\QtNovelDesc\libConfig\release;%(AdditionalLibraryDirectories) + true + false + true + true + false + $(OutDir)\SplitView.dll + true + Windows + true + + + Unsigned + None + 0 + + + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SPLITVIEW_LIBRARY;QT_NO_DEBUG;%(PreprocessorDefinitions) + + + + + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;debug;/include;%(AdditionalIncludeDirectories) + -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) + debug\ + false + ProgramDatabase + 4577;4467;%(DisableSpecificWarnings) + Sync + debug\ + Disabled + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SPLITVIEW_LIBRARY;%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + true + Level3 + true + + + D:\Projects\Cpp\QtNovelDesc\libConfig\debug\libConfig.lib;%(AdditionalDependencies) + D:\Projects\Cpp\QtNovelDesc\libConfig\debug;%(AdditionalLibraryDirectories) + true + true + true + true + $(OutDir)\SplitView.dll + true + Windows + true + + + Unsigned + None + 0 + + + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;SPLITVIEW_LIBRARY;_DEBUG;%(PreprocessorDefinitions) + + + + + + + + + + + + Document + true + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h + Generate moc_predefs.h + debug\moc_predefs.h;%(Outputs) + + + Document + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h + Generate moc_predefs.h + release\moc_predefs.h;%(Outputs) + true + + + + + + + + \ No newline at end of file diff --git a/SplitView/SplitView.vcxproj.filters b/SplitView/SplitView.vcxproj.filters new file mode 100644 index 0000000..28a0989 --- /dev/null +++ b/SplitView/SplitView.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + cpp;c;cxx;moc;h;def;odl;idl;res; + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + cpp;c;cxx;moc;h;def;odl;idl;res; + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + + + Header Files + + + Header Files + + + + + Generated Files + + + Generated Files + + + \ No newline at end of file diff --git a/SplitView/SplitView.vcxproj.user b/SplitView/SplitView.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/SplitView/SplitView.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SplitView/splitview.cpp b/SplitView/splitview.cpp index 2882aab..fd4b63c 100644 --- a/SplitView/splitview.cpp +++ b/SplitView/splitview.cpp @@ -15,174 +15,177 @@ using namespace SplitFrame; using namespace Config; BaseView::BaseView(const QString &title, QWidget *view, bool empty, QWidget *parent) : QWidget(parent), title_header(nullptr), parent_store(nullptr) { - auto layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); + auto layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); - registComp(this); + registComp(this); - if (!empty) { - title_header = new DragHeader(this); - title_header->setText(title); - title_header->setMaximumHeight(22); + if (!empty) { + title_header = new DragHeader(this); + title_header->setText(title); + title_header->setMaximumHeight(22); - layout->addWidget(title_header, 0); - registComp(title_header); - } + layout->addWidget(title_header, 0); + registComp(title_header); + } - registComp(view); - layout->addWidget(view, 1); - setMouseTracking(true); + registComp(view); + layout->addWidget(view, 1); + setMouseTracking(true); } void BaseView::setTitle(const QString &title) { - QWidget::setWindowTitle(title); - title_header->setText(title); + QWidget::setWindowTitle(title); + title_header->setText(title); } -QString BaseView::title() const { return this->title_header->text(); } +QString BaseView::title() const { + return this->title_header->text(); +} -void BaseView::setIcon(const QIcon &icon) { this->title_header->setIcon(icon); } +void BaseView::setIcon(const QIcon &icon) { + this->title_header->setIcon(icon); +} -QIcon BaseView::viewIcon() const { return title_header->icon(); } +QIcon BaseView::viewIcon() const { + return title_header->icon(); +} void BaseView::registComp(QWidget *child) { if (this->comps_list.contains(child)) return; + comps_list << child; + + if (child != this) + child->setParent(this); } -ViewPresent *BaseView::viewPanel() const { - if (!parentRect()) - return nullptr; - return parentRect()->viewPanel(); +ViewPresent *BaseView::viewPanel() const { return parentRect()->viewPanel(); } + +void BaseView::closeView() { } -void BaseView::closeView() {} +bool BaseView::contains(QWidget *ptr) const { + return comps_list.contains(ptr); +} -bool BaseView::contains(QWidget *ptr) const { return comps_list.contains(ptr); } +QWidget *BaseView::bind() const { + return const_cast(this); +} -QWidget *BaseView::bind() const { return const_cast(this); } - -SplitRect *BaseView::parentRect() const { return parent_store; } +SplitRect *BaseView::parentRect() const { + return parent_store; +} void BaseView::setParentRect(SplitRect *pinst) { - if (pinst) { - auto conv = pinst->bind(); - setParent(conv); - } else - setParent(nullptr); - this->parent_store = pinst; + + this->setParent(pinst->bind()); } -std::pair BaseView::child() const { return std::make_pair(nullptr, nullptr); } - -void BaseView::replaceComp(SplitRect *view, SplitRect *old) { throw new SimpleException("异常调用", "不能对ViewBase调用replace函数"); } - -float BaseView::splitterWidth() const { return 0; } - -float BaseView::splitterPos() const { return 0; } - -SplitType BaseView::splitType() const { return SplitType::SPLIT_H; } - -void BaseView::setSplitInfo(SplitType type, float pos, float width, bool relayout) { - throw new SimpleException("异常调用", "不能对ViewBase调用setSplitInfo函数"); +QRectF BaseView::outline() const { + return this->rect(); } -QRectF BaseView::outline() const { return this->rect(); } - -void BaseView::relayout(const QRectF &outline) { this->setGeometry(outline.toRect()); } +void BaseView::relayout(const QRectF &outline) { + this->setGeometry(outline.toRect()); + update(); +} void BaseView::installPerceptionHandle(ViewPresent *obj) { - for (auto &it : comps_list) { - it->setAcceptDrops(true); - it->removeEventFilter(obj); - it->installEventFilter(obj); - } + for (auto &it : comps_list) { + it->setAcceptDrops(true); + it->removeEventFilter(obj); + it->installEventFilter(obj); + } } -void BaseView::paintEvent(QPaintEvent *ev) { QWidget::paintEvent(ev); } +void BaseView::paintEvent(QPaintEvent *ev) { + QWidget::paintEvent(ev); +} -void BaseView::removeComp(SplitRect *child_inst) { throw new SimpleException("非法操作", "BaseView不支持retrieveComp操作"); } - -AttachPanel::AttachPanel(ViewPresent *host) : QWidget(), size_host(host) { +AttachPanel::AttachPanel(ViewPresent *host) : QWidget(host->bind()), adjust_host(host) { setWindowOpacity(50); setAcceptDrops(true); } -void AttachPanel::bind(BaseView *widget) { this->current_target = widget; } +void AttachPanel::bindAttachment(BaseView *widget) { this->current_target = widget; } -BaseView *AttachPanel::attachTarget() const { return this->current_target; } +BaseView *AttachPanel::attachmentTarget() const { return this->current_target; } void AttachPanel::paintEvent(QPaintEvent *event) { - QWidget::paintEvent(event); + QWidget::paintEvent(event); - QPainter p(this); - p.setBrush(Qt::lightGray); - p.fillRect(this->rect(), Qt::lightGray); + QPainter p(this); + p.setBrush(Qt::lightGray); + p.fillRect(this->rect(), Qt::lightGray); - auto rect = this->rect(); - p.setPen(QPen(Qt::black, 4)); - switch (active_comp) { - case ActiveArea::LEFT: - p.fillRect(QRectF(rect.topLeft(), QSizeF(rect.width() / 2, rect.height())), Qt::gray); - break; - case ActiveArea::RIGHT: - p.fillRect(QRectF(rect.center() - QPointF(0, rect.height() / 2), QSizeF(rect.width() / 2, rect.height())), Qt::gray); - break; - case ActiveArea::TOP: - p.fillRect(QRectF(rect.topLeft(), QSizeF(rect.width(), rect.height() / 2)), Qt::gray); - break; - case ActiveArea::BOTTOM: - p.fillRect(QRectF(rect.center() - QPointF(rect.width() / 2, 0), QSizeF(rect.width(), rect.height() / 2)), Qt::gray); - break; - case ActiveArea::CENTER: - p.fillRect(rect, Qt::gray); - break; - default: - break; - } + auto rect = this->rect(); + p.setPen(QPen(Qt::black, 4)); + switch (active_comp) { + case ActiveArea::LEFT: + p.fillRect(QRectF(rect.topLeft(), QSizeF(rect.width() / 2, rect.height())), Qt::gray); + break; + case ActiveArea::RIGHT: + p.fillRect(QRectF(rect.center() - QPointF(0, rect.height() / 2), QSizeF(rect.width() / 2, rect.height())), Qt::gray); + break; + case ActiveArea::TOP: + p.fillRect(QRectF(rect.topLeft(), QSizeF(rect.width(), rect.height() / 2)), Qt::gray); + break; + case ActiveArea::BOTTOM: + p.fillRect(QRectF(rect.center() - QPointF(rect.width() / 2, 0), QSizeF(rect.width(), rect.height() / 2)), Qt::gray); + break; + case ActiveArea::CENTER: + p.fillRect(rect, Qt::gray); + break; + default: + break; + } - p.setBrush(Qt::transparent); + p.setBrush(Qt::transparent); - auto lt0 = rect.center() - QPoint(50, 150); - p.drawRoundRect(QRectF(lt0, QSizeF(100, 300))); + auto lt0 = rect.center() - QPoint(50, 150); + p.drawRoundRect(QRectF(lt0, QSizeF(100, 300))); - auto lt1 = rect.center() - QPoint(150, 50); - p.drawRoundRect(QRectF(lt1, QSizeF(300, 100))); + auto lt1 = rect.center() - QPoint(150, 50); + p.drawRoundRect(QRectF(lt1, QSizeF(300, 100))); } -void AttachPanel::mouseMoveEvent(QMouseEvent *event) { QWidget::mouseMoveEvent(event); } - void AttachPanel::dragMoveEvent(QDragMoveEvent *event) { - QWidget::dragMoveEvent(event); + QWidget::dragMoveEvent(event); - auto tuple_list = view_rects(); - if (std::get<0>(tuple_list).contains(event->pos())) { - this->active_comp = ActiveArea::LEFT; - } else if (std::get<1>(tuple_list).contains(event->pos())) { - this->active_comp = ActiveArea::RIGHT; + auto tuple_list = view_rects(); + if (std::get<0>(tuple_list).contains(event->pos())) { + this->active_comp = ActiveArea::LEFT; + } + else if (std::get<1>(tuple_list).contains(event->pos())) { + this->active_comp = ActiveArea::RIGHT; - } else if (std::get<2>(tuple_list).contains(event->pos())) { - this->active_comp = ActiveArea::TOP; + } + else if (std::get<2>(tuple_list).contains(event->pos())) { + this->active_comp = ActiveArea::TOP; - } else if (std::get<3>(tuple_list).contains(event->pos())) { - this->active_comp = ActiveArea::BOTTOM; + } + else if (std::get<3>(tuple_list).contains(event->pos())) { + this->active_comp = ActiveArea::BOTTOM; - } else if (std::get<4>(tuple_list).contains(event->pos())) { - this->active_comp = ActiveArea::CENTER; - } else { - this->active_comp = ActiveArea::NONE; - } + } + else if (std::get<4>(tuple_list).contains(event->pos())) { + this->active_comp = ActiveArea::CENTER; + } + else { + this->active_comp = ActiveArea::NONE; + } - this->update(); + this->update(); } void AttachPanel::dragEnterEvent(QDragEnterEvent *event) { QWidget::dragEnterEvent(event); - if (size_host->adjustState()) + if (adjust_host->adjustState()) event->acceptProposedAction(); } @@ -190,71 +193,82 @@ void AttachPanel::dropEvent(QDropEvent *event) { QWidget::dropEvent(event); event->acceptProposedAction(); - auto xsource = size_host->adjustView(); - auto target = this->attachTarget(); + auto xfrom = adjust_host->adjustView(); + auto target = this->attachmentTarget(); - if (target != xsource) { - SplitRect *newsplit = nullptr; + if (target != xfrom && active_comp != ActiveArea::NONE) { + RectCom *newsplit = nullptr; - if (xsource->parentRect()) - xsource->parentRect()->removeComp(xsource); + xfrom->parentRect()->removeComp(xfrom); + adjust_host->objsRelateRebuild(); auto ptarget = target->parentRect(); auto target_rect = target->outline(); switch (this->active_comp) { case ActiveArea::LEFT: { - newsplit = new SplitView(xsource, target, size_host); + newsplit = new SplitView(xfrom, target, adjust_host); newsplit->relayout(target_rect); - newsplit->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, size_host->splitterWidth()); + static_cast(newsplit)->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, adjust_host->splitterWidth(), true); } break; case ActiveArea::RIGHT: { - newsplit = new SplitView(target, xsource, size_host); + newsplit = new SplitView(target, xfrom, adjust_host); newsplit->relayout(target_rect); - newsplit->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, size_host->splitterWidth()); + static_cast(newsplit)->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, adjust_host->splitterWidth(), true); } break; case ActiveArea::TOP: { - newsplit = new SplitView(xsource, target, size_host); + newsplit = new SplitView(xfrom, target, adjust_host); newsplit->relayout(target_rect); - newsplit->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, size_host->splitterWidth()); + static_cast(newsplit)->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, adjust_host->splitterWidth(), true); } break; case ActiveArea::BOTTOM: { - newsplit = new SplitView(target, xsource, size_host); + newsplit = new SplitView(target, xfrom, adjust_host); newsplit->relayout(target_rect); - newsplit->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, size_host->splitterWidth()); + static_cast(newsplit)->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, adjust_host->splitterWidth(), true); } break; case ActiveArea::CENTER: { - newsplit = xsource; + newsplit = xfrom; } break; default: return; } ptarget->replaceComp(newsplit, target); + adjust_host->objsRelateRebuild(); + adjust_host->unusedResRelease(); } + adjust_host->setViewAdjust(); this->setVisible(false); } std::tuple AttachPanel::view_rects() const { - auto rect = this->rect(); - auto lt0 = rect.center() - QPoint(50, 150); - auto lt1 = rect.center() - QPoint(150, 50); + auto rect = this->rect(); + auto lt0 = rect.center() - QPoint(50, 150); + auto lt1 = rect.center() - QPoint(150, 50); - return std::make_tuple(QRectF(lt1, QSizeF(100, 100)), QRectF(lt1 + QPoint(200, 0), QSizeF(100, 100)), QRectF(lt0, QSizeF(100, 100)), - QRectF(lt0 + QPointF(0, 200), QSizeF(100, 100)), QRectF(lt1 + QPointF(100, 0), QSizeF(100, 100))); + return std::make_tuple(QRectF(lt1, QSizeF(100, 100)), QRectF(lt1 + QPoint(200, 0), QSizeF(100, 100)), QRectF(lt0, QSizeF(100, 100)), + QRectF(lt0 + QPointF(0, 200), QSizeF(100, 100)), QRectF(lt1 + QPointF(100, 0), QSizeF(100, 100))); } -ViewPresent::ViewPresent(SplitRect *initial_view, QWidget *parent) : QWidget(parent), accept_panel(new AttachPanel(this)) { - accept_panel->hide(); - - this->split_info_store = std::make_tuple(SplitType::SPLIT_H, 100, 7, 1); - initial_view->setParentRect(this); - setMouseTracking(true); - view_anchors << initial_view; +ViewPresent::ViewPresent(QWidget *parent) : QWidget(parent), accept_panel(new AttachPanel(this)) { + accept_panel->hide(); + setMouseTracking(true); } -ViewPresent::~ViewPresent() { accept_panel->deleteLater(); } +ViewPresent::~ViewPresent() { + accept_panel->deleteLater(); +} + +void ViewPresent::addListener(FreedomViewsListener *lsn) { + if (lsn_list.contains(lsn)) + return; + lsn_list << lsn; +} + +void ViewPresent::removeListener(FreedomViewsListener *lsn) { + lsn_list.removeAll(lsn); +} void ViewPresent::registViewComp(BaseView *it) { if (this->all_sep_views.contains(it)) @@ -264,42 +278,61 @@ void ViewPresent::registViewComp(BaseView *it) { all_sep_views << it; } -void ViewPresent::setViewAdjust(bool state, BaseView *one) { - this->adjust_state = state; - if (!state) - one = nullptr; - - this->adjust_view_store = one; +void ViewPresent::markFreedom(BaseView *view) { + if (!freedom_views.contains(view)) + freedom_views << view; } -bool ViewPresent::adjustState() const { return this->adjust_state; } +// void ViewPresent::collectFreedomView(BaseView *invisible) { +// if (!freedom_views.contains(invisible)) { +// freedom_views << invisible; -BaseView *ViewPresent::adjustView() const { return this->adjust_view_store; } +// for (auto &it : lsn_list) +// it->freedomAppended(invisible); +// } -void ViewPresent::append(SplitRect *inst, uint index) { - auto pos = splitterPos(); - auto width = splitterWidth(); - auto idx = index ? 1 : 0; - auto type = splitType(); +// invisible->setParentRect(nullptr); +// invisible->bind()->setVisible(false); +//} - if (view_anchors.size() == 2) { - view_anchors[idx]->setParentRect(nullptr); - view_anchors[idx]->bind()->setVisible(false); - view_anchors[idx] = inst; - view_anchors[idx]->setParentRect(this); - view_anchors[idx]->bind()->setVisible(true); - } else if (view_anchors.size() == 1) { - view_anchors.insert(idx, inst); - view_anchors[idx] = inst; - view_anchors[idx]->setParentRect(this); - view_anchors[idx]->bind()->setVisible(true); - } else { - view_anchors << inst; - view_anchors.last()->setParentRect(this); - view_anchors.last()->bind()->setVisible(true); +void ViewPresent::setTempVisible(BaseView *target) { + if (target != nullptr && !this->freedom_views.contains(target)) + throw new SimpleException("参数异常", "非闲置视图不可以设置为临时视图"); + + if (this->temp_visible_view) { + // collectFreedomView(temp_visible_view); } - this->split_info_store = std::make_tuple(type, pos, width, idx); + temp_visible_view = target; + if (temp_visible_view) { + temp_visible_view->setParentRect(this); + temp_visible_view->bind()->setVisible(true); + temp_visible_view->bind()->raise(); + } + + relayout(); +} + +void ViewPresent::setViewAdjust(BaseView *one) { + this->adjust_view_temp = one; +} + +bool ViewPresent::adjustState() const { + return this->adjust_view_temp != nullptr; +} + +BaseView *ViewPresent::adjustView() const { + return this->adjust_view_temp; +} + +void ViewPresent::resetViews(RectCom *center, RectCom *extend) { + view_anchors << center; + + if (extend) { + view_anchors << extend; + } + + this->objsRelateRebuild(); this->relayout(); } @@ -311,32 +344,65 @@ bool ViewPresent::eventFilter(QObject *watched, QEvent *event) { if (v->contains((QWidget *)watched)) { auto outline = v->outline(); QPoint gpos(v->bind()->mapToGlobal(outline.topLeft().toPoint())); + QPoint localpos(mapFromGlobal(gpos)); - accept_panel->setWindowFlag(Qt::FramelessWindowHint); - accept_panel->show(); - accept_panel->setGeometry(QRect(gpos, outline.size().toSize())); + accept_panel->raise(); + accept_panel->setGeometry(QRect(localpos, outline.size().toSize())); accept_panel->setVisible(true); - accept_panel->bind(v); + accept_panel->bindAttachment(v); event->accept(); return true; } } } + if (event->type() == QEvent::Drop) { + accept_panel->hide(); + accept_panel->lower(); + } + + if (this->temp_visible_view && event->type() == QEvent::MouseButtonPress) { + if (!temp_visible_view->contains((QWidget *)watched)) { + setTempVisible(nullptr); + } + } + return QWidget::eventFilter(watched, event); } QWidget *ViewPresent::bind() const { return const_cast(this); } -ViewPresent *ViewPresent::viewPanel() const { return const_cast(this); } +bool ViewPresent::contains(QWidget *ptr) const { return false; } + +ViewPresent *ViewPresent::viewPanel() const { + return const_cast(this); +} SplitRect *ViewPresent::parentRect() const { return nullptr; } -void ViewPresent::setParentRect(SplitRect *pinst) { throw new SimpleException("非法操作", "不允许对ViewPresent调用setParentRect!"); } +void ViewPresent::objsRelateRebuild() { setParentRect(nullptr); } -std::pair ViewPresent::child() const { - SplitRect *inst0 = nullptr, *inst1 = nullptr; +void ViewPresent::markUnused(SplitRect *item) { + if (!this->unused_splits.contains(item)) + unused_splits << item; +} + +void ViewPresent::unusedResRelease() { + for (auto &it : unused_splits) + delete it; + unused_splits.clear(); +} + +void ViewPresent::setParentRect(SplitRect *) { + auto pair = child(); + pair.first->setParentRect(this); + if (pair.second) + pair.second->setParentRect(this); +} + +std::pair ViewPresent::child() const { + RectCom *inst0 = nullptr, *inst1 = nullptr; if (view_anchors.size() > 1) inst1 = view_anchors[1]; if (view_anchors.size() > 0) @@ -345,7 +411,7 @@ std::pair ViewPresent::child() const { return std::make_pair(inst0, inst1); } -void ViewPresent::replaceComp(SplitRect *view, SplitRect *old) { +void ViewPresent::replaceComp(RectCom *view, RectCom *old) { if (!view_anchors.contains(old)) throw new SimpleException("参数错误", "指定替换的界面不属于此界面"); @@ -353,25 +419,35 @@ void ViewPresent::replaceComp(SplitRect *view, SplitRect *old) { return; view_anchors.replace(view_anchors.indexOf(old), view); - - relayout(); + objsRelateRebuild(); + update(); } -float ViewPresent::splitterWidth() const { return std::get<2>(split_info_store); } +float ViewPresent::splitterWidth() const { + return std::get<2>(split_info_store); +} -float ViewPresent::splitterPos() const { return std::get<1>(split_info_store); } +float ViewPresent::splitterPos() const { + return std::get<1>(split_info_store); +} -SplitType ViewPresent::splitType() const { return std::get<0>(split_info_store); } +SplitType ViewPresent::splitType() const { + return std::get<0>(split_info_store); +} void ViewPresent::setSplitInfo(SplitType type, float pos, float width, bool relayout) { - this->split_info_store = std::make_tuple(type, pos, width, std::get<3>(split_info_store)); - if (relayout) - this->relayout(); + this->split_info_store = std::make_tuple(type, pos, width); + if (relayout) + this->relayout(); } -QRectF ViewPresent::outline() const { return this->rect(); } +QRectF ViewPresent::outline() const { + return this->rect(); +} -void ViewPresent::relayout(const QRectF &outline) { setGeometry(outline.toRect()); } +void ViewPresent::relayout(const QRectF &outline) { + setGeometry(outline.toRect()); +} void ViewPresent::paintEvent(QPaintEvent *ev) { QWidget::paintEvent(ev); @@ -382,207 +458,235 @@ void ViewPresent::paintEvent(QPaintEvent *ev) { p.fillRect(handle_rect, QBrush(Qt::gray)); } - for (auto &it : view_anchors) + for (auto &it : view_anchors) { + it->bind()->setVisible(true); it->bind()->update(); + } + + if (temp_visible_view) { + temp_visible_view->bind()->setVisible(true); + temp_visible_view->bind()->update(); + } + + for (auto &it : freedom_views) { + it->bind()->setVisible(false); + it->bind()->update(); + } } -void ViewPresent::removeComp(SplitRect *child_inst) { - if (!view_anchors.contains(child_inst)) - throw new SimpleException("参数非法", "回收的指定视图不属于本ViewPresent"); +void ViewPresent::removeComp(BaseView *child_inst) { + if (temp_visible_view == child_inst) { + temp_visible_view = nullptr; - if (child_inst) - child_inst->bind()->setVisible(false); + freedom_views.removeAll(child_inst); + for (auto &lsn : lsn_list) + lsn->freedomRemoved(static_cast(child_inst)); + } else { + if (!view_anchors.contains(child_inst)) + throw new SimpleException("参数非法", "回收的指定视图不属于本ViewPresent"); - view_anchors.removeAll(child_inst); - relayout(); + markFreedom(child_inst); + view_anchors.removeAll(child_inst); + } + + viewPanel()->objsRelateRebuild(); + viewPanel()->unusedResRelease(); + + update(); } void ViewPresent::resizeEvent(QResizeEvent *ev) { - QWidget::resizeEvent(ev); - relayout(); + QWidget::resizeEvent(ev); + relayout(); } - void ViewPresent::mousePressEvent(QMouseEvent *event) { - QWidget::mousePressEvent(event); + QWidget::mousePressEvent(event); - if (event->button() == Qt::MouseButton::LeftButton) { - if (handleRect().contains(event->pos())) - this->press_flags = true; - } + if (event->button() == Qt::MouseButton::LeftButton) { + if (handleRect().contains(event->pos())) + this->press_flags = true; + } } - void ViewPresent::mouseReleaseEvent(QMouseEvent *event) { - QWidget::mouseReleaseEvent(event); + QWidget::mouseReleaseEvent(event); - if (event->button() == Qt::MouseButton::LeftButton) { - this->press_flags = false; - } + if (event->button() == Qt::MouseButton::LeftButton) { + this->press_flags = false; + } } - void ViewPresent::mouseMoveEvent(QMouseEvent *event) { - QWidget::mouseMoveEvent(event); + QWidget::mouseMoveEvent(event); - auto drag_rect = handleRect(); - if (drag_rect.contains(event->pos())) { - if (splitType() == SplitType::SPLIT_H) - setCursor(QCursor(Qt::CursorShape::SplitHCursor)); - else - setCursor(QCursor(Qt::CursorShape::SplitVCursor)); - } else { - setCursor(QCursor(Qt::CursorShape::ArrowCursor)); - } + auto drag_rect = handleRect(); + if (drag_rect.contains(event->pos())) { + if (splitType() == SplitType::SPLIT_H) + setCursor(QCursor(Qt::CursorShape::SplitHCursor)); + else + setCursor(QCursor(Qt::CursorShape::SplitVCursor)); + } + else { + setCursor(QCursor(Qt::CursorShape::ArrowCursor)); + } - if (this->press_flags) { - auto pos = this->mapFromGlobal(event->globalPos()); - auto split_margin = splitterWidth(); - if (std::get<0>(split_info_store) == SplitType::SPLIT_H) { - setSplitInfo(splitType(), pos.x() - split_margin / 2, split_margin, true); - } else { - setSplitInfo(splitType(), pos.y() - split_margin / 2, split_margin, true); - } + if (this->press_flags) { + auto pos = this->mapFromGlobal(event->globalPos()); + auto split_margin = splitterWidth(); + if (std::get<0>(split_info_store) == SplitType::SPLIT_H) { + setSplitInfo(splitType(), pos.x() - split_margin / 2, split_margin, true); + } + else { + setSplitInfo(splitType(), pos.y() - split_margin / 2, split_margin, true); + } - update(); - } + update(); + } } void ViewPresent::relayout() { auto rects = viewRects(); if (view_anchors.size() == 2) { - view_anchors[0]->setParentRect(this); view_anchors[0]->relayout(rects.first.toRect()); - view_anchors[0]->bind()->setVisible(true); - - view_anchors[1]->setParentRect(this); view_anchors[1]->relayout(rects.second.toRect()); - view_anchors[1]->bind()->setVisible(true); } else if (view_anchors.size() == 1) { - view_anchors[0]->setParentRect(this); view_anchors[0]->relayout(this->rect()); - view_anchors[0]->bind()->setVisible(true); + } + + if (temp_visible_view) { + temp_visible_view->relayout(QRectF(QPointF(), QSizeF(300, this->height()))); } update(); } - std::pair ViewPresent::viewRects() { - auto xrect = this->rect(); + auto xrect = this->rect(); - auto type = (int)splitType(); - if (!type) { - auto width0 = splitterPos(); - if (width0 + splitterWidth() > xrect.width()) - width0 = xrect.width() - splitterWidth(); - if (width0 < 0) - width0 = 0; + auto type = (int)splitType(); + if (!type) { + auto width0 = splitterPos(); + if (width0 + splitterWidth() > xrect.width()) + width0 = xrect.width() - splitterWidth(); + if (width0 < 0) + width0 = 0; - setSplitInfo(splitType(), width0, splitterWidth(), false); + setSplitInfo(splitType(), width0, splitterWidth(), false); - auto rect0 = QRectF(xrect.topLeft(), QSizeF(width0, xrect.height())); - auto rect1 = QRectF(xrect.topLeft() + QPointF(rect0.width() + splitterWidth(), 0), - QSizeF(xrect.width() - rect0.width() - splitterWidth(), xrect.height())); - return std::make_pair(rect0, rect1); - } else { - auto height0 = splitterPos(); - if (height0 + splitterWidth() > xrect.height()) - height0 = xrect.height() - splitterWidth(); - if (height0 < 0) - height0 = 0; + auto rect0 = QRectF(xrect.topLeft(), QSizeF(width0, xrect.height())); + auto rect1 = QRectF(xrect.topLeft() + QPointF(rect0.width() + splitterWidth(), 0), + QSizeF(xrect.width() - rect0.width() - splitterWidth(), xrect.height())); + return std::make_pair(rect0, rect1); + } + else { + auto height0 = splitterPos(); + if (height0 + splitterWidth() > xrect.height()) + height0 = xrect.height() - splitterWidth(); + if (height0 < 0) + height0 = 0; - setSplitInfo(splitType(), height0, splitterWidth(), false); + setSplitInfo(splitType(), height0, splitterWidth(), false); - auto rect0 = QRectF(xrect.topLeft(), QSizeF(xrect.width(), height0)); - auto rect1 = QRectF(xrect.topLeft() + QPointF(0, rect0.height() + splitterWidth()), - QSizeF(xrect.width(), xrect.height() - splitterWidth() - rect0.height())); - return std::make_pair(rect0, rect1); - } + auto rect0 = QRectF(xrect.topLeft(), QSizeF(xrect.width(), height0)); + auto rect1 = QRectF(xrect.topLeft() + QPointF(0, rect0.height() + splitterWidth()), + QSizeF(xrect.width(), xrect.height() - splitterWidth() - rect0.height())); + return std::make_pair(rect0, rect1); + } } - QRectF ViewPresent::handleRect() const { - QRectF rect; + QRectF rect; - auto width_middle = splitterWidth() - 2; - if (splitType() == SplitType::SPLIT_H) { - rect = QRectF(splitterPos() + 1, 0, width_middle, outline().height()); - } else { - rect = QRectF(0, splitterPos() + 1, outline().width(), width_middle); - } + auto width_middle = splitterWidth() - 2; + if (splitType() == SplitType::SPLIT_H) { + rect = QRectF(splitterPos() + 1, 0, width_middle, outline().height()); + } + else { + rect = QRectF(0, splitterPos() + 1, outline().width(), width_middle); + } - return rect; + return rect; } -SplitView::SplitView(SplitRect *first, SplitRect *next, QWidget *parent) : QWidget(parent) { +SplitView::SplitView(RectCom *first, RectCom *next, QWidget *parent) : QWidget(parent) { this->split_info_value = std::make_tuple(SplitType::SPLIT_H, 100, 7); this->child_store << first; this->child_store << next; setMouseTracking(true); - - first->setParentRect(this); - next->setParentRect(this); } -QWidget *SplitView::bind() const { return const_cast(this); } - -ViewPresent *SplitView::viewPanel() const { - if (parentRect() == nullptr) - return nullptr; - return parentRect()->viewPanel(); +SplitFrame::SplitView::~SplitView() { } -SplitRect *SplitView::parentRect() const { return parent_inst; } +QWidget *SplitView::bind() const { + return const_cast(this); +} + +ViewPresent *SplitView::viewPanel() const { return parentRect()->viewPanel(); } + +SplitRect *SplitView::parentRect() const { + return parent_inst; +} void SplitView::setParentRect(SplitRect *pinst) { - if (pinst) { - auto pwidget = pinst->bind(); - this->setParent(pwidget); - } else - this->setParent(nullptr); + QWidget::setParent(pinst->bind()); - this->parent_inst = pinst; + auto pair = child(); + pair.first->setParentRect(this); + pair.second->setParentRect(this); } -std::pair SplitView::child() const { return std::make_pair(child_store[0], child_store[1]); } +std::pair SplitView::child() const { return std::make_pair(child_store[0], child_store[1]); } -float SplitView::splitterWidth() const { return std::get<2>(split_info_value); } +float SplitView::splitterWidth() const { + return std::get<2>(split_info_value); +} -float SplitView::splitterPos() const { return std::get<1>(split_info_value); } +float SplitView::splitterPos() const { + return std::get<1>(split_info_value); +} -SplitType SplitView::splitType() const { return std::get<0>(split_info_value); } +SplitType SplitView::splitType() const { + return std::get<0>(split_info_value); +} void SplitView::setSplitInfo(SplitType type, float pos, float width, bool relayout) { - this->split_info_value = std::make_tuple(type, pos, width); - if (relayout) - this->relayout(); + this->split_info_value = std::make_tuple(type, pos, width); + if (relayout) + this->relayout(); } -void SplitView::replaceComp(SplitRect *view, SplitRect *old) { - if (child_store.contains(old) && !child_store.contains(view)) { - auto index = child_store.indexOf(old); - child_store.replace(index, view); +void SplitView::replaceComp(RectCom *view, RectCom *old) { + if (!child_store.contains(old) || child_store.contains(view)) { + throw new SimpleException("参数非法", "要替换的视图不属于本构件,或者新视图本就属于本构件"); } - relayout(); + auto index = child_store.indexOf(old); + child_store.replace(index, view); + + viewPanel()->objsRelateRebuild(); } -QRectF SplitView::outline() const { return this->rect(); } +QRectF SplitView::outline() const { + return this->rect(); +} void SplitView::relayout(const QRectF &outlinex) { - this->setGeometry(outlinex.toRect()); - update(); + this->setGeometry(outlinex.toRect()); + update(); } -void SplitView::removeComp(SplitRect *child_inst) { +void SplitView::removeComp(BaseView *child_inst) { auto pinst = parentRect(); auto sib = this->child().first; if (child_inst == sib) sib = this->child().second; - child_inst->bind()->setVisible(false); pinst->replaceComp(sib, this); - child_inst->setParentRect(nullptr); - delete this; + viewPanel()->markUnused(this); + viewPanel()->markFreedom(child_inst); + + viewPanel()->objsRelateRebuild(); + viewPanel()->unusedResRelease(); } void SplitView::paintEvent(QPaintEvent *ev) { @@ -596,26 +700,28 @@ void SplitView::paintEvent(QPaintEvent *ev) { it->bind()->update(); } +bool SplitView::contains(QWidget *ptr) const { return false; } + void SplitView::resizeEvent(QResizeEvent *ev) { - QWidget::resizeEvent(ev); - relayout(); + QWidget::resizeEvent(ev); + relayout(); } void SplitView::mousePressEvent(QMouseEvent *event) { - QWidget::mousePressEvent(event); + QWidget::mousePressEvent(event); - if (event->button() == Qt::MouseButton::LeftButton) { - if (handleRect().contains(event->pos())) - this->press_flags = true; - } + if (event->button() == Qt::MouseButton::LeftButton) { + if (handleRect().contains(event->pos())) + this->press_flags = true; + } } void SplitView::mouseReleaseEvent(QMouseEvent *event) { - QWidget::mouseReleaseEvent(event); + QWidget::mouseReleaseEvent(event); - if (event->button() == Qt::MouseButton::LeftButton) { - this->press_flags = false; - } + if (event->button() == Qt::MouseButton::LeftButton) { + this->press_flags = false; + } } void SplitView::mouseMoveEvent(QMouseEvent *event) { @@ -660,134 +766,136 @@ bool SplitView::eventFilter(QObject *watched, QEvent *event) { } void SplitView::relayout() { - auto rects = viewRects(); - auto pair = child(); + auto rects = viewRects(); + auto pair = child(); - pair.first->setParentRect(this); - pair.first->relayout(std::get<0>(rects)); - pair.second->setParentRect(this); - pair.second->relayout(std::get<1>(rects)); + pair.first->relayout(std::get<0>(rects)); + pair.second->relayout(std::get<1>(rects)); - auto awidget = dynamic_cast(pair.first); - auto bwidget = dynamic_cast(pair.second); - awidget->setVisible(true); - bwidget->setVisible(true); - - update(); + update(); } std::pair SplitView::viewRects() { - auto xrect = this->rect(); + auto xrect = this->rect(); - auto type = (int)splitType(); - if (!type) { - auto width0 = splitterPos(); - if (width0 + splitterWidth() > xrect.width()) - width0 = xrect.width() - splitterWidth(); - if (width0 < 0) - width0 = 0; + auto type = (int)splitType(); + if (!type) { + auto width0 = splitterPos(); + if (width0 + splitterWidth() > xrect.width()) + width0 = xrect.width() - splitterWidth(); + if (width0 < 0) + width0 = 0; - setSplitInfo(splitType(), width0, splitterWidth(), false); + setSplitInfo(splitType(), width0, splitterWidth(), false); - auto rect0 = QRectF(xrect.topLeft(), QSizeF(width0, xrect.height())); - auto rect1 = QRectF(xrect.topLeft() + QPointF(rect0.width() + splitterWidth(), 0), - QSizeF(xrect.width() - rect0.width() - splitterWidth(), xrect.height())); - return std::make_pair(rect0, rect1); - } else { - auto height0 = splitterPos(); - if (height0 + splitterWidth() > xrect.height()) - height0 = xrect.height() - splitterWidth(); - if (height0 < 0) - height0 = 0; + auto rect0 = QRectF(xrect.topLeft(), QSizeF(width0, xrect.height())); + auto rect1 = QRectF(xrect.topLeft() + QPointF(rect0.width() + splitterWidth(), 0), + QSizeF(xrect.width() - rect0.width() - splitterWidth(), xrect.height())); + return std::make_pair(rect0, rect1); + } + else { + auto height0 = splitterPos(); + if (height0 + splitterWidth() > xrect.height()) + height0 = xrect.height() - splitterWidth(); + if (height0 < 0) + height0 = 0; - setSplitInfo(splitType(), height0, splitterWidth(), false); + setSplitInfo(splitType(), height0, splitterWidth(), false); - auto rect0 = QRectF(xrect.topLeft(), QSizeF(xrect.width(), height0)); - auto rect1 = QRectF(xrect.topLeft() + QPointF(0, rect0.height() + splitterWidth()), - QSizeF(xrect.width(), xrect.height() - splitterWidth() - rect0.height())); - return std::make_pair(rect0, rect1); - } + auto rect0 = QRectF(xrect.topLeft(), QSizeF(xrect.width(), height0)); + auto rect1 = QRectF(xrect.topLeft() + QPointF(0, rect0.height() + splitterWidth()), + QSizeF(xrect.width(), xrect.height() - splitterWidth() - rect0.height())); + return std::make_pair(rect0, rect1); + } } QRectF SplitView::handleRect() const { - QRectF rect; + QRectF rect; - auto width_middle = splitterWidth() - 2; - if (splitType() == SplitType::SPLIT_H) { - rect = QRectF(splitterPos() + 1, 0, width_middle, outline().height()); - } else { - rect = QRectF(0, splitterPos() + 1, outline().width(), width_middle); - } + auto width_middle = splitterWidth() - 2; + if (splitType() == SplitType::SPLIT_H) { + rect = QRectF(splitterPos() + 1, 0, width_middle, outline().height()); + } + else { + rect = QRectF(0, splitterPos() + 1, outline().width(), width_middle); + } - return rect; + return rect; } DragHeader::DragHeader(BaseView *bind) : QFrame(bind->bind()), icon_store(new QLabel(this)), title_store(new QLabel(this)), view_core(bind) { - setFrameShadow(QFrame::Shadow::Raised); - setFrameShape(QFrame::Shape::Box); - setStyleSheet("background-color: rgb(200, 200, 255);"); + setFrameShadow(QFrame::Shadow::Raised); + setFrameShape(QFrame::Shape::Box); + setStyleSheet("background-color: rgb(200, 200, 255);"); - auto layout = new QHBoxLayout(this); - layout->setMargin(1); - layout->setSpacing(2); - layout->addWidget(icon_store, 0); - layout->addWidget(title_store, 1); + auto layout = new QHBoxLayout(this); + layout->setMargin(1); + layout->setSpacing(2); + layout->addWidget(icon_store, 0); + layout->addWidget(title_store, 1); - auto hide = new QPushButton("-", this); - layout->addWidget(hide, 0); - hide->setMaximumSize(20, 20); - auto close = new QPushButton("X", this); - layout->addWidget(close, 0); - close->setMaximumSize(20, 20); + auto hide = new QPushButton("-", this); + layout->addWidget(hide, 0); + hide->setMaximumSize(20, 20); + auto close = new QPushButton("X", this); + layout->addWidget(close, 0); + close->setMaximumSize(20, 20); - connect(hide, &QPushButton::clicked, [=]() { - auto con = this->view_core->parentRect(); - con->removeComp(view_core); - }); + connect(hide, &QPushButton::clicked, [=]() { + auto con = this->view_core->parentRect(); + con->removeComp(view_core); + }); - connect(close, &QPushButton::clicked, [=]() { - hide->click(); - view_core->closeView(); - }); + connect(close, &QPushButton::clicked, [=]() { + hide->click(); + view_core->closeView(); + }); } void DragHeader::setIcon(const QIcon &icon) { - icon_inst = icon; - auto len = this->height() - 2; - this->icon_store->setPixmap(icon.pixmap(QSize(len, len))); + icon_inst = icon; + auto len = this->height() - 2; + this->icon_store->setPixmap(icon.pixmap(QSize(len, len))); } -QIcon DragHeader::icon() const { return this->icon_inst; } +QIcon DragHeader::icon() const { + return this->icon_inst; +} -void DragHeader::setText(const QString &title) { this->title_store->setText(title); } +void DragHeader::setText(const QString &title) { + this->title_store->setText(title); +} -QString DragHeader::text() const { return title_store->text(); } +QString DragHeader::text() const { + return title_store->text(); +} void DragHeader::mousePressEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton && !std::get<0>(press_flag)) { - this->press_flag = std::make_tuple(true, event->pos()); - } + if (event->button() == Qt::LeftButton && !std::get<0>(press_flag)) { + this->press_flag = std::make_tuple(true, event->pos()); + } } void DragHeader::mouseReleaseEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton) { - this->press_flag = std::make_tuple(false, QPointF()); - } + if (event->button() == Qt::LeftButton) { + this->press_flag = std::make_tuple(false, QPointF()); + } } void DragHeader::mouseMoveEvent(QMouseEvent *event) { - if (std::get<0>(press_flag) && QLineF(std::get<1>(press_flag), event->pos()).length() > QApplication::startDragDistance()) { + auto distance = QLineF(std::get<1>(press_flag), event->pos()).length(); + if (std::get<0>(press_flag) && distance > QApplication::startDragDistance()) { auto panel = view_core->viewPanel(); - panel->setViewAdjust(true, view_core); + panel->setViewAdjust(view_core); - QDrag *drag = new QDrag(this); - auto pix = view_core->grab(); - drag->setPixmap(pix); - drag->setHotSpot(QPoint(20, 20)); + QDrag *drag = new QDrag(this); + auto pix = view_core->grab(); + drag->setPixmap(pix); + drag->setHotSpot(QPoint(20, 20)); - QMimeData *mimeData = new QMimeData; - mimeData->setText("移动视图:" + view_core->title()); - drag->setMimeData(mimeData); + QMimeData *mimeData = new QMimeData; + mimeData->setText("移动视图:" + view_core->title()); + drag->setMimeData(mimeData); drag->exec(); } diff --git a/SplitView/splitview.h b/SplitView/splitview.h index 5c118ba..535d997 100644 --- a/SplitView/splitview.h +++ b/SplitView/splitview.h @@ -21,17 +21,16 @@ namespace SplitFrame { public: AttachPanel(ViewPresent *host); - void bind(BaseView *widget); - BaseView *attachTarget() const; + void bindAttachment(BaseView *widget); + BaseView *attachmentTarget() const; virtual void paintEvent(QPaintEvent *event) override; - virtual void mouseMoveEvent(QMouseEvent *event) override; virtual void dragMoveEvent(QDragMoveEvent *event) override; virtual void dragEnterEvent(QDragEnterEvent *event) override; virtual void dropEvent(QDropEvent *event) override; private: - ViewPresent *const size_host; + ViewPresent *const adjust_host; BaseView *current_target; ActiveArea active_comp; @@ -40,71 +39,94 @@ namespace SplitFrame { enum class SplitType { SPLIT_H = 0, SPLIT_V = 1 }; - /** - * @brief 分裂视图规划和约束组件 - */ - class SplitRect { + class RectCom { public: - virtual ~SplitRect() = default; + virtual ~RectCom() = default; - virtual QWidget *bind() const = 0; virtual ViewPresent *viewPanel() const = 0; - - virtual SplitRect *parentRect() const = 0; - virtual void setParentRect(SplitRect *pinst) = 0; - - virtual std::pair child() const = 0; - virtual void removeComp(SplitRect *child) = 0; - virtual void replaceComp(SplitRect *view, SplitRect *old) = 0; - virtual float splitterWidth() const = 0; - virtual float splitterPos() const = 0; - virtual SplitType splitType() const = 0; - virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout = true) = 0; + virtual QWidget *bind() const = 0; + virtual bool contains(QWidget *ptr) const = 0; virtual QRectF outline() const = 0; virtual void relayout(const QRectF &outline) = 0; + virtual void setParentRect(SplitRect *inst) = 0; + virtual SplitRect *parentRect() const = 0; + virtual void paintEvent(QPaintEvent *ev) = 0; }; + class ResManager { + public: + virtual ~ResManager() = default; + + virtual void objsRelateRebuild() = 0; + + virtual void markFreedom(BaseView *view) = 0; + virtual void markUnused(SplitRect *item) = 0; + virtual void unusedResRelease() = 0; + }; + + /** + * @brief 分裂视图规划和约束组件 + */ + class SplitRect : public RectCom { + public: + virtual ~SplitRect() = default; + + virtual std::pair child() const = 0; + virtual void removeComp(BaseView *child) = 0; + virtual void replaceComp(RectCom *view, RectCom *old) = 0; + virtual float splitterWidth() const = 0; + virtual float splitterPos() const = 0; + virtual SplitType splitType() const = 0; + virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout = true) = 0; + }; + + /** + * @brief 分割视图 + */ class SPLITVIEW_EXPORT SplitView : public QWidget, public SplitRect { public: - SplitView(SplitRect *first, SplitRect *next, QWidget *parent = nullptr); + SplitView(RectCom *first, RectCom *next, QWidget *parent = nullptr); + virtual ~SplitView(); - // SplitRect interface + // RectCom interface public: virtual QWidget *bind() const override; virtual ViewPresent *viewPanel() const override; + virtual QRectF outline() const override; + virtual void relayout(const QRectF &outline) override; + virtual void setParentRect(SplitRect *inst) override; virtual SplitRect *parentRect() const override; - virtual void setParentRect(SplitRect *pinst) override; + virtual void paintEvent(QPaintEvent *ev) override; + virtual bool contains(QWidget *ptr) const override; - virtual std::pair child() const override; + // SplitRect interface + public: + virtual std::pair child() const override; + virtual void removeComp(BaseView *child) override; + virtual void replaceComp(RectCom *view, RectCom *old) override; virtual float splitterWidth() const override; virtual float splitterPos() const override; virtual SplitType splitType() const override; virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override; - virtual void replaceComp(SplitRect *view, SplitRect *old) override; - - virtual QRectF outline() const override; - virtual void relayout(const QRectF &outline) override; - virtual void removeComp(SplitRect *child_inst) override; - - // QWidget interface - protected: - virtual void paintEvent(QPaintEvent *ev) override; - virtual void resizeEvent(QResizeEvent *ev) override; - virtual void mousePressEvent(QMouseEvent *event) override; - virtual void mouseReleaseEvent(QMouseEvent *event) override; - virtual void mouseMoveEvent(QMouseEvent *event) override; // QObject interface public: virtual bool eventFilter(QObject *watched, QEvent *event) override; + // QWidget interface + protected: + virtual void mousePressEvent(QMouseEvent *event) override; + virtual void mouseReleaseEvent(QMouseEvent *event) override; + virtual void mouseMoveEvent(QMouseEvent *event) override; + virtual void resizeEvent(QResizeEvent *event) override; + private: SplitRect *parent_inst; - QList child_store; + QList child_store; // type, pos, width std::tuple split_info_value; bool press_flags = false, drags_flag = false; @@ -139,7 +161,7 @@ namespace SplitFrame { /** * @brief 基础内容视图组件 */ - class SPLITVIEW_EXPORT BaseView : public QWidget, public SplitRect { + class SPLITVIEW_EXPORT BaseView : public QWidget, public RectCom { friend class ViewPresent; public: @@ -152,25 +174,17 @@ namespace SplitFrame { virtual QIcon viewIcon() const; virtual void closeView(); - virtual bool contains(QWidget *ptr) const; + virtual bool contains(QWidget *inst) const override; - // SplitRect interface + // RectCom interface public: virtual QWidget *bind() const override; virtual ViewPresent *viewPanel() const override; - virtual SplitRect *parentRect() const override; - virtual void setParentRect(SplitRect *pinst) override; - virtual std::pair child() const override; - virtual void replaceComp(SplitRect *view, SplitRect *old) override; - virtual float splitterWidth() const override; - virtual float splitterPos() const override; - virtual SplitType splitType() const override; - virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override; virtual QRectF outline() const override; virtual void relayout(const QRectF &outline) override; - + virtual void setParentRect(SplitRect *inst) override; + virtual SplitRect *parentRect() const override; virtual void paintEvent(QPaintEvent *ev) override; - virtual void removeComp(SplitRect *child_inst) override; private: DragHeader *title_header; @@ -182,46 +196,76 @@ namespace SplitFrame { virtual void registComp(QWidget *child); }; + class FreedomViewsListener { + public: + virtual ~FreedomViewsListener() = default; + /** + * @brief 闲置视图增加 + * @param ins + */ + virtual void freedomAppended(RectCom *ins) = 0; + /** + * @brief 闲置视图减少 + * @param ins + */ + virtual void freedomRemoved(RectCom *ins) = 0; + }; + /** * @brief 分裂视图呈现组件 */ - class SPLITVIEW_EXPORT ViewPresent : public QWidget, public SplitRect { + class SPLITVIEW_EXPORT ViewPresent : public QWidget, public SplitRect, public ResManager { public: - ViewPresent(SplitRect *initial_view, QWidget *parent = nullptr); + ViewPresent(QWidget *parent = nullptr); virtual ~ViewPresent(); + void addListener(FreedomViewsListener *lsn); + void removeListener(FreedomViewsListener *lsn); + //====================================================== void registViewComp(BaseView *it); + //====================================================== + virtual void markFreedom(BaseView *view) override; + void setTempVisible(BaseView *target = nullptr); /** * @brief 切换视图调整状态 * @param state 状态开关 */ - void setViewAdjust(bool state, BaseView *one = nullptr); + void setViewAdjust(BaseView *one = nullptr); bool adjustState() const; BaseView *adjustView() const; - void append(SplitRect *inst, uint index); + void resetViews(RectCom *center, RectCom *extend = nullptr); - // QObject interface + // RectCom interface public: - virtual bool eventFilter(QObject *watched, QEvent *event) override; + virtual ViewPresent *viewPanel() const override; + virtual QWidget *bind() const override; + virtual bool contains(QWidget *ptr) const override; + virtual QRectF outline() const override; + virtual void relayout(const QRectF &outline) override; + virtual void setParentRect(SplitRect *) override; + virtual SplitRect *parentRect() const override; + + // ResManager interface + public: + virtual void objsRelateRebuild() override; + virtual void markUnused(SplitRect *item) override; + virtual void unusedResRelease() override; // SplitRect interface public: - virtual QWidget *bind() const override; - virtual ViewPresent *viewPanel() const override; - virtual SplitRect *parentRect() const override; - virtual void setParentRect(SplitRect *pinst) override; - - virtual std::pair child() const override; - virtual void replaceComp(SplitRect *view, SplitRect *old) override; + virtual std::pair child() const override; + virtual void removeComp(BaseView *child) override; + virtual void replaceComp(RectCom *view, RectCom *old) override; virtual float splitterWidth() const override; virtual float splitterPos() const override; virtual SplitType splitType() const override; virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override; - virtual QRectF outline() const override; - virtual void relayout(const QRectF &outline) override; - virtual void removeComp(SplitRect *child_inst) override; + + // QObject interface + public: + virtual bool eventFilter(QObject *watched, QEvent *event) override; // QWidget interface protected: @@ -233,14 +277,20 @@ namespace SplitFrame { private: AttachPanel *const accept_panel; - BaseView *adjust_view_store; - bool press_flags = false; - bool adjust_state = false; - QList view_anchors; - // 方向,splitter位置,splitter宽度,extend索引 - std::tuple split_info_store; + QList unused_splits; + + BaseView *adjust_view_temp; // 拖拽中转 + bool press_flags = false; // 空间调整标志 + // 方向,splitter位置,splitter宽度 + std::tuple split_info_store = std::make_tuple(SplitType::SPLIT_H, 200, 8); + + QList view_anchors; QList all_sep_views; + QList lsn_list; + QList freedom_views; + RectCom *temp_visible_view = nullptr; + virtual void relayout(); std::pair viewRects(); QRectF handleRect() const; diff --git a/WordsIDE/WordsIDE.vcxproj b/WordsIDE/WordsIDE.vcxproj index 6283c07..022e979 100644 --- a/WordsIDE/WordsIDE.vcxproj +++ b/WordsIDE/WordsIDE.vcxproj @@ -16,8 +16,7 @@ QtVS_v304 10.0.22621.0 10.0.22621.0 - $(MSBuildProjectDirectory)\QtMsBuild - + $(MSBuildProjectDirectory)\QtMsBuild v141 @@ -37,10 +36,7 @@ debug\ WordsIDE - - - - + @@ -48,37 +44,11 @@ - - - - - - debug\ - debug\ - WordsIDE - true - - - release\ - release\ - WordsIDE - true - false - - - 5.12.11_msvc2017_64 - core;xml;gui;testlib;widgets - - - 5.12.11_msvc2017_64 - core;xml;gui;testlib;widgets - - - - + debug\debug\WordsIDEtruerelease\release\WordsIDEtruefalse5.12.11_msvc2017_64core;xml;gui;testlib;widgets5.12.11_msvc2017_64core;xml;gui;testlib;widgets + - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;..\libProjectManager;..\libParse;..\GenericConsole;release;/include;%(AdditionalIncludeDirectories) + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;..\libProjectManager;..\GenericConsole;release;/include;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) release\ false @@ -89,17 +59,15 @@ MaxSpeed _CONSOLE;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;QT_TESTCASE_BUILDDIR=".";NDEBUG;%(PreprocessorDefinitions) false - - + MultiThreadedDLL true true Level3 - true - + true - libConfig.lib;libProjectManager.lib;libParse.lib;GenericConsole.lib;%(AdditionalDependencies) - D:\Projects\Cpp\QtNovelDesc\libConfig\release;D:\Projects\Cpp\QtNovelDesc\libProjectManager\release;D:\Projects\Cpp\QtNovelDesc\libParse\release;D:\Projects\Cpp\QtNovelDesc\GenericConsole\release;%(AdditionalLibraryDirectories) + libConfig.lib;libProjectManager.lib;GenericConsole.lib;%(AdditionalDependencies) + D:\Projects\Cpp\QtNovelDesc\libConfig\release;D:\Projects\Cpp\QtNovelDesc\libProjectManager\release;D:\Projects\Cpp\QtNovelDesc\GenericConsole\release;%(AdditionalLibraryDirectories) "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) true false @@ -118,25 +86,10 @@ _CONSOLE;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;QT_TESTCASE_BUILDDIR=".";%(PreprocessorDefinitions) - - msvc - ./$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - output - $(Configuration) - moc_%(Filename).cpp - - - qmake_qmake_qm_files - default - Rcc'ing %(Identity)... - $(Configuration) - qrc_%(Filename).cpp - - + msvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cppqmake_qmake_qm_filesdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cpp - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;..\libProjectManager;..\libParse;..\GenericConsole;debug;/include;%(AdditionalIncludeDirectories) + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;..\libProjectManager;..\GenericConsole;debug;/include;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) debug\ false @@ -151,11 +104,10 @@ true true Level3 - true - + true - libConfig.lib;libProjectManager.lib;libParse.lib;GenericConsole.lib;%(AdditionalDependencies) - D:\Projects\Cpp\QtNovelDesc\libConfig\debug;D:\Projects\Cpp\QtNovelDesc\libProjectManager\debug;D:\Projects\Cpp\QtNovelDesc\libParse\debug;D:\Projects\Cpp\QtNovelDesc\GenericConsole\debug;%(AdditionalLibraryDirectories) + D:\Projects\Cpp\QtNovelDesc\libConfig\debug\libConfig.lib;D:\Projects\Cpp\QtNovelDesc\libProjectManager\debug\libProjectManager.lib;D:\Projects\Cpp\QtNovelDesc\GenericConsole\debug\GenericConsole.lib;%(AdditionalDependencies) + D:\Projects\Cpp\QtNovelDesc\libConfig\debug;D:\Projects\Cpp\QtNovelDesc\libProjectManager\debug;D:\Projects\Cpp\QtNovelDesc\GenericConsole\debug;%(AdditionalLibraryDirectories) "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) true true @@ -173,88 +125,84 @@ _CONSOLE;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_TESTCASE_BUILDDIR=".";_DEBUG;%(PreprocessorDefinitions) - - qmake_qmake_qm_files - default - Rcc'ing %(Identity)... - $(Configuration) - qrc_%(Filename).cpp - - - msvc - ./$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - output - $(Configuration) - moc_%(Filename).cpp - - + qmake_qmake_qm_filesdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cppmsvc./$(Configuration)/moc_predefs.hMoc'ing %(Identity)...output$(Configuration)moc_%(Filename).cpp - - - - + - - - - - - - - - + - + + + + + + + + - - - - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + Document true @@ -263,6 +211,20 @@ Generate moc_predefs.h debug\moc_predefs.h;%(Outputs) + + Document + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -O2 -MD -EHsc -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h + Generate moc_predefs.h + release\moc_predefs.h;%(Outputs) + true + + + + + + + @@ -280,15 +242,29 @@ true + + true + + + + + + + + + + + + + + + - - - - + \ No newline at end of file diff --git a/WordsIDE/WordsIDE.vcxproj.filters b/WordsIDE/WordsIDE.vcxproj.filters index 614eb91..0b10928 100644 --- a/WordsIDE/WordsIDE.vcxproj.filters +++ b/WordsIDE/WordsIDE.vcxproj.filters @@ -57,9 +57,6 @@ - - Source Files - Source Files @@ -69,15 +66,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - Source Files @@ -90,6 +78,9 @@ Source Files + + Source Files + Source Files @@ -105,44 +96,17 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files Source Files - + Source Files - - Header Files - Header Files @@ -152,15 +116,6 @@ Header Files - - Header Files - - - Header Files - - - Header Files - Header Files @@ -173,9 +128,12 @@ Header Files - + Header Files + + Header Files + Header Files @@ -188,44 +146,33 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files Header Files - + Header Files + + + + Generated Files + + Generated Files + + + + + + + @@ -236,9 +183,15 @@ Resource Files + + Resource Files + Resource Files + + Resource Files + diff --git a/libConfig/libConfig.vcxproj b/libConfig/libConfig.vcxproj index cad7ba4..f466975 100644 --- a/libConfig/libConfig.vcxproj +++ b/libConfig/libConfig.vcxproj @@ -16,8 +16,7 @@ QtVS_v304 10.0.22621.0 10.0.22621.0 - $(MSBuildProjectDirectory)\QtMsBuild - + $(MSBuildProjectDirectory)\QtMsBuild v141 @@ -37,10 +36,7 @@ debug\ libConfig - - - - + @@ -48,34 +44,8 @@ - - - - - - ..\WordsIDE\debug - debug\ - libConfig - true - - - release\ - release\ - libConfig - true - false - - - 5.12.11_msvc2017_64 - core;xml - - - 5.12.11_msvc2017_64 - core;xml - - - - + debug\debug\libConfigtruerelease\release\libConfigtruefalse5.12.11_msvc2017_64core;xml5.12.11_msvc2017_64core;xml + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;release;%(AdditionalIncludeDirectories) @@ -89,14 +59,12 @@ MaxSpeed _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;LIBCONFIG_LIBRARY;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) false - - + MultiThreadedDLL true true Level3 - true - + true %(AdditionalDependencies) %(AdditionalLibraryDirectories) @@ -136,8 +104,7 @@ true true Level3 - true - + true %(AdditionalDependencies) %(AdditionalLibraryDirectories) @@ -176,13 +143,18 @@ Generate moc_predefs.h debug\moc_predefs.h;%(Outputs) + + Document + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -O2 -MD -EHsc -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h + Generate moc_predefs.h + release\moc_predefs.h;%(Outputs) + true + - - - - + \ No newline at end of file diff --git a/libConfig/libConfig.vcxproj.filters b/libConfig/libConfig.vcxproj.filters index ce7dfa3..5fc2cf9 100644 --- a/libConfig/libConfig.vcxproj.filters +++ b/libConfig/libConfig.vcxproj.filters @@ -56,6 +56,9 @@ Generated Files + + Generated Files + diff --git a/libProjectManager/libProjectManager.vcxproj b/libProjectManager/libProjectManager.vcxproj index 3611e98..0960c95 100644 --- a/libProjectManager/libProjectManager.vcxproj +++ b/libProjectManager/libProjectManager.vcxproj @@ -16,8 +16,7 @@ QtVS_v304 10.0.22621.0 10.0.22621.0 - $(MSBuildProjectDirectory)\QtMsBuild - + $(MSBuildProjectDirectory)\QtMsBuild v141 @@ -37,10 +36,7 @@ debug\ libProjectManager - - - - + @@ -48,34 +44,8 @@ - - - - - - ..\WordsIDE\debug - debug\ - libProjectManager - true - - - release\ - release\ - libProjectManager - true - false - - - 5.12.11_msvc2017_64 - core;xml;gui - - - 5.12.11_msvc2017_64 - core;xml;gui - - - - + debug\debug\libProjectManagertruerelease\release\libProjectManagertruefalse5.12.11_msvc2017_64core;xml;gui5.12.11_msvc2017_64core;xml;gui + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;release;/include;%(AdditionalIncludeDirectories) @@ -89,14 +59,12 @@ MaxSpeed _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;LIBPROJECTMANAGER_LIBRARY;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) false - - + MultiThreadedDLL true true Level3 - true - + true libConfig.lib;%(AdditionalDependencies) D:\Projects\Cpp\QtNovelDesc\libConfig\release;%(AdditionalLibraryDirectories) @@ -118,14 +86,7 @@ _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;LIBPROJECTMANAGER_LIBRARY;QT_NO_DEBUG;%(PreprocessorDefinitions) - - icons - default - Rcc'ing %(Identity)... - $(Configuration) - qrc_%(Filename).cpp - - + iconsdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cpp GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\libConfig;debug;/include;%(AdditionalIncludeDirectories) @@ -143,10 +104,9 @@ true true Level3 - true - + true - libConfig.lib;%(AdditionalDependencies) + D:\Projects\Cpp\QtNovelDesc\libConfig\debug\libConfig.lib;%(AdditionalDependencies) D:\Projects\Cpp\QtNovelDesc\libConfig\debug;%(AdditionalLibraryDirectories) true true @@ -165,14 +125,7 @@ _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;LIBPROJECTMANAGER_LIBRARY;_DEBUG;%(PreprocessorDefinitions) - - icons - default - Rcc'ing %(Identity)... - $(Configuration) - qrc_%(Filename).cpp - - + iconsdefaultRcc'ing %(Identity)...$(Configuration)qrc_%(Filename).cpp @@ -190,6 +143,16 @@ Generate moc_predefs.h debug\moc_predefs.h;%(Outputs) + + Document + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus /utf-8 -O2 -MD -EHsc -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h + Generate moc_predefs.h + release\moc_predefs.h;%(Outputs) + true + + + @@ -197,12 +160,18 @@ + + + + + + + + + - - - - + \ No newline at end of file diff --git a/libProjectManager/libProjectManager.vcxproj.filters b/libProjectManager/libProjectManager.vcxproj.filters index cfd171c..a2129ca 100644 --- a/libProjectManager/libProjectManager.vcxproj.filters +++ b/libProjectManager/libProjectManager.vcxproj.filters @@ -66,17 +66,16 @@ Generated Files + + Generated Files + + + Translation Files - - - - - - diff --git a/u_test/main.cpp b/u_test/main.cpp index f41d246..78cdba2 100644 --- a/u_test/main.cpp +++ b/u_test/main.cpp @@ -29,21 +29,34 @@ int main(int argc, char *argv[]) { win->menuBar()->addMenu("文件"); auto tbar = new QToolBar(); win->addToolBar(Qt::ToolBarArea::LeftToolBarArea, tbar); - tbar->addAction("添加"); + auto b = tbar->addAction("添加"); auto aview = new BaseView("hello", new QWidget); auto bview = new BaseView("world", new QWidget); auto cview = new BaseView("everyone", new QWidget); + auto dview = new BaseView("forth", new XWidget); auto conv0 = new SplitView(aview, bview); conv0->setSplitInfo(SplitType::SPLIT_V, 100, 8, true); - auto conv = new ViewPresent(conv0); + auto conv = new ViewPresent(); win->setCentralWidget(conv); - conv->append(cview, 0); + conv->resetViews(conv0, cview); conv->registViewComp(aview); conv->registViewComp(bview); conv->registViewComp(cview); + conv->registViewComp(dview); + conv->markFreedom(dview); + + conv->objsRelateRebuild(); + + b->setCheckable(true); + win->connect(b, &QAction::triggered, [=](bool v) { + if (v) + conv->setTempVisible(dview); + else + conv->setTempVisible(nullptr); + }); win->show(); diff --git a/u_test/u_test.vcxproj b/u_test/u_test.vcxproj new file mode 100644 index 0000000..ab5609f --- /dev/null +++ b/u_test/u_test.vcxproj @@ -0,0 +1,193 @@ + + + + + Release + x64 + + + Debug + x64 + + + + {2A348B24-97E4-3DE1-84FD-5A95F92CEADE} + u_test + QtVS_v304 + 10.0.22621.0 + 10.0.22621.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + v141 + release\ + false + NotSet + Application + release\ + u_test + + + v141 + debug\ + false + NotSet + Application + debug\ + u_test + + + + + + + + + + + + + + + + + + $(SolutionDir)x64\Debug + debug\ + u_test + true + $(SolutionDir)x64\Debug;$(LibraryPath) + + + release\ + release\ + u_test + true + false + + + 5.12.11_msvc2017_64 + core;xml;gui;widgets + + + 5.12.11_msvc2017_64 + core;xml;gui;widgets + + + + + + + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\SplitView;..\GenericConsole;release;/include;%(AdditionalIncludeDirectories) + -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) + release\ + false + None + 4577;4467;%(DisableSpecificWarnings) + Sync + release\ + MaxSpeed + _CONSOLE;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions) + false + + + MultiThreadedDLL + true + true + Level3 + true + + + SplitView.lib;GenericConsole.lib;%(AdditionalDependencies) + D:\Projects\Cpp\QtNovelDesc\SplitView\release;D:\Projects\Cpp\QtNovelDesc\GenericConsole\release;%(AdditionalLibraryDirectories) + "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) + true + false + true + false + $(OutDir)\u_test.exe + true + Console + true + + + Unsigned + None + 0 + + + _CONSOLE;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_NO_DEBUG;%(PreprocessorDefinitions) + + + + + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\SplitView;..\GenericConsole;debug;/include;%(AdditionalIncludeDirectories) + -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) + debug\ + false + ProgramDatabase + 4577;4467;%(DisableSpecificWarnings) + Sync + debug\ + Disabled + _CONSOLE;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;%(PreprocessorDefinitions) + false + MultiThreadedDebugDLL + true + true + Level3 + true + + + SplitView.lib;D:\Projects\Cpp\QtNovelDesc\GenericConsole\debug\GenericConsole.lib;%(AdditionalDependencies) + D:\Projects\Cpp\QtNovelDesc\SplitView\debug;D:\Projects\Cpp\QtNovelDesc\GenericConsole\debug;%(AdditionalLibraryDirectories) + "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) + true + true + true + $(OutDir)\u_test.exe + true + Console + true + + + Unsigned + None + 0 + + + _CONSOLE;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;_DEBUG;%(PreprocessorDefinitions) + + + + + + + + + + + + Document + true + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h + Generate moc_predefs.h + debug\moc_predefs.h;%(Outputs) + + + Document + $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) + cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h + Generate moc_predefs.h + release\moc_predefs.h;%(Outputs) + true + + + + + + + + \ No newline at end of file diff --git a/u_test/u_test.vcxproj.filters b/u_test/u_test.vcxproj.filters new file mode 100644 index 0000000..0b5fbf1 --- /dev/null +++ b/u_test/u_test.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + cpp;c;cxx;moc;h;def;odl;idl;res; + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + cpp;c;cxx;moc;h;def;odl;idl;res; + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Source Files + + + Source Files + + + + + Header Files + + + + + Generated Files + + + Generated Files + + + \ No newline at end of file diff --git a/u_test/u_test.vcxproj.user b/u_test/u_test.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/u_test/u_test.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file