中期汇报

中期汇报PPT
代码更新
设计说明书补充
需求文档补充
需求说明书补充
软件模型
pull/2/head
pya9flm25 2 years ago
commit ae4cb70283

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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

@ -0,0 +1,427 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 5.0.2, 2023-05-30T21:54:35. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{9ae9cba5-5ab5-4831-839f-36c967a0caed}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
<value type="QString">-fno-delayed-template-parsing</value>
</valuelist>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.BuildSystem</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">4</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
<value type="bool" key="UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.12 MinGW 32-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.12 MinGW 32-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51212.win32_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:\QTUWE\UWEproject\build-UWE_file-Desktop_Qt_5_12_12_MinGW_32_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">E:/QTUWE/UWEproject/build-UWE_file-Desktop_Qt_5_12_12_MinGW_32_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:\QTUWE\UWEproject\build-UWE_file-Desktop_Qt_5_12_12_MinGW_32_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">E:/QTUWE/UWEproject/build-UWE_file-Desktop_Qt_5_12_12_MinGW_32_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:\QTUWE\UWEproject\build-UWE_file-Desktop_Qt_5_12_12_MinGW_32_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">E:/QTUWE/UWEproject/build-UWE_file-Desktop_Qt_5_12_12_MinGW_32_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<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:E:/QTUWE/UWEproject/UWE_file/UWE_file.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">E:/QTUWE/UWEproject/UWE_file/UWE_file.pro</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">E:/QTUWE/UWEproject/build-UWE_file-Desktop_Qt_5_12_12_MinGW_32_bit-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.12 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.12 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51212.win64_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:\QTUWE\UWEproject\build-UWE_file-Desktop_Qt_5_12_12_MinGW_64_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">E:/QTUWE/UWEproject/build-UWE_file-Desktop_Qt_5_12_12_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:\QTUWE\UWEproject\build-UWE_file-Desktop_Qt_5_12_12_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">E:/QTUWE/UWEproject/build-UWE_file-Desktop_Qt_5_12_12_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:\QTUWE\UWEproject\build-UWE_file-Desktop_Qt_5_12_12_MinGW_64_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">E:/QTUWE/UWEproject/build-UWE_file-Desktop_Qt_5_12_12_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<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">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">2</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

@ -0,0 +1,135 @@
#include "finddialog.h"
#include "mainwindow.h"
#include <QEvent>
#include <QTextCursor>
#include <QMessageBox>
#include <QtWidgets/QPlainTextEdit>
#include <QtGui>
#include <QtWidgets>
#include <QPalette>
FindDialog::FindDialog(QWidget *parent, QPlainTextEdit* pText)
: QDialog(parent, Qt::WindowCloseButtonHint | Qt::Drawer)
{
initControl();
connectSlot();
setLayout(&m_layout);
setWindowTitle("Find");
setPlainTextEdit(pText);
}
void FindDialog::initControl()
{
m_findLbl.setText("Find What:");
m_findBtn.setText("Find Next");
m_closeBtn.setText("Close");
m_matchChkBx.setText("Match Case");
m_backwardBtn.setText("Backward");
m_forwardBtn.setText("Forward");
m_forwardBtn.setChecked(true);
m_radioGrpBx.setTitle("Direction");
m_hbLayout.addWidget(&m_forwardBtn);
m_hbLayout.addWidget(&m_backwardBtn);
m_radioGrpBx.setLayout(&m_hbLayout);
m_layout.setSpacing(10);
m_layout.addWidget(&m_findLbl, 0, 0);
m_layout.addWidget(&m_findEdit, 0, 1);
m_layout.addWidget(&m_findBtn, 0, 2);
m_layout.addWidget(&m_matchChkBx, 1, 0);
m_layout.addWidget(&m_radioGrpBx, 1, 1);
m_layout.addWidget(&m_closeBtn, 1, 2);
}
void FindDialog::connectSlot()
{
connect(&m_findBtn, SIGNAL(clicked()), this, SLOT(onFindClicked()));
connect(&m_closeBtn, SIGNAL(clicked()), this, SLOT(onCloseClicked()));
}
void FindDialog::setPlainTextEdit(QPlainTextEdit* pText)
{
m_pText = pText;
}
QPlainTextEdit* FindDialog::getPlainTextEdit()
{
return m_pText;
}
bool FindDialog::event(QEvent* evt)
{
if( evt->type() == QEvent::Close )
{
hide();
return true;
}
return QDialog::event(evt);
}
void FindDialog::onFindClicked()
{
QString target = m_findEdit.text();
if( (m_pText != NULL) && (target != "") )
{
QString text = m_pText->toPlainText();
QTextCursor c = m_pText->textCursor();
int index = -1;
if( m_forwardBtn.isChecked() )
{
index = text.indexOf(target, c.position(), m_matchChkBx.isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive);
if( index >= 0 )
{
c.setPosition(index);
c.setPosition(index + target.length(), QTextCursor::KeepAnchor);
m_pText->setTextCursor(c);
QTextCharFormat highlight;
highlight.setBackground(Qt::red);
c.mergeCharFormat(highlight);
m_pText->mergeCurrentCharFormat(highlight);
}
}
if( m_backwardBtn.isChecked() )
{
index = text.lastIndexOf(target, c.position() - text.length() - 1, m_matchChkBx.isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive);
if( index >= 0 )
{
c.setPosition(index + target.length());
c.setPosition(index, QTextCursor::KeepAnchor);
m_pText->setTextCursor(c);
QTextCharFormat highlight;
highlight.setBackground(Qt::red);
c.mergeCharFormat(highlight);
m_pText->mergeCurrentCharFormat(highlight);
}
}
if( index < 0 )
{
QMessageBox msg(this);
msg.setWindowTitle("Find");
msg.setText("Can not find \"" + target + "\" any more...");
msg.setIcon(QMessageBox::Information);
msg.setStandardButtons(QMessageBox::Ok);
msg.exec();
}
}
}
void FindDialog::onCloseClicked()
{
close();
}

@ -0,0 +1,53 @@
#ifndef _FINDDIALOG_H_
#define _FINDDIALOG_H_
#include <QDialog>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QCheckBox>
#include <QGroupBox>
#include <QPlainTextEdit>
#include <QPointer>
class FindDialog : public QDialog
{
Q_OBJECT
protected:
QGroupBox m_radioGrpBx;
QGridLayout m_layout;
QHBoxLayout m_hbLayout;
QLabel m_findLbl;
QLineEdit m_findEdit;
QPushButton m_findBtn;
QPushButton m_closeBtn;
QCheckBox m_matchChkBx;
QRadioButton m_forwardBtn;
QRadioButton m_backwardBtn;
QPointer<QPlainTextEdit> m_pText; // FindDialog 聚合使用 QPlainTextEdit
QSharedPointer<FindDialog> m_pFindDlg;
QTextCharFormat m_format;
void initControl();
void connectSlot();
protected slots:
void onFindClicked();
void onCloseClicked();
public:
explicit FindDialog(QWidget* parent = 0, QPlainTextEdit* pText = 0);
void setPlainTextEdit(QPlainTextEdit* pText);
void highlightText(QPlainTextEdit* pText);
QPlainTextEdit* getPlainTextEdit();
bool event(QEvent* evt);
};
#endif // _FINDDIALOG_H_

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

@ -0,0 +1,116 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>//QFileDialog类是Qt提供的一个用于指定操作文件的对话框小部件,使用前要先导入
#include <QMessageBox>//弹出对话框
#include <QDebug>//调试
#include<QBitmap>
#include <QFile>
#include "finddialog.h"
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->actionFind,SIGNAL(triggered()),this,SLOT(onFindClicked()));
connect(ui->newAction,&QAction::triggered,this,&MainWindow::newActionSlot);//创建链接newAcion发出取地址信号(newAction),triggered 单击信号this类mainwindow窗口处理信号
//mainwindow.h创建槽函数
//newActionSlot创建链接
connect(ui->openAction,&QAction::triggered,this,&MainWindow::openActionSlot);//打开文件的槽点链接
connect(ui->saveAction,&QAction::triggered,this,&MainWindow::saveActionSlot);
connect(ui->changeAction,&QAction::triggered,this,&MainWindow::changeActionSlot);
m_pFindDlg = QSharedPointer<FindDialog>(new FindDialog(this, &plainTextEdit));
m_format.setBackground(Qt::yellow);
m_format.setForeground(Qt::red);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionFind_clicked()
{
QPlainTextEdit* pText = ui->plainTextEdit;
FindDialog dlg(this,pText);
dlg.exec();
}
void MainWindow::newActionSlot()
{
ui->textEdit->clear();
this->setWindowTitle("新建文本文档.txt");
//ctrl+R运行
//实现新建文本文档功能
//之后仿照实现openAction(打开文件)等功能,添加槽函数
}
void MainWindow::openActionSlot()
{
//getOpenFileName和getOpenFileNames一个是获取单个文件路径另一个是多个文件
//获取单个文件的本地或者网络路径
//QUrl getOpenFileUrl(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QUrl &dir = QUrl(), const QString &filter = QString(), QString *selectedFilter = Q_NULLPTR, Options options = Options(), const QStringList &supportedSchemes = QStringList())
//获取多个文件的本地或者网络路径
//QList<QUrl> getOpenFileUrls(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QUrl &dir = QUrl(), const QString &filter = QString(), QString *selectedFilter = Q_NULLPTR, Options options = Options(), const QStringList &supportedSchemes = QStringList())
QString fileName=QFileDialog::getOpenFileName(this,"选择一个文件",
QCoreApplication::applicationFilePath(),
"images(*.png *jpeg *bmp);;text files(*.txt *.doc *.docx);;video files(*.avi *.mp4 *.wmv);;*.cpp;;All files(*.*)");//静态函数用以返回用户当前选择的目录,(&dir默认打开文件目录需要获取路径Linux可以直接输入window需要用QCoreApplication::applicationFilePath()获取)
if (fileName.isEmpty())
{
QMessageBox::warning(this,"警告","请选择一个文件");
}
else
{
//返回文件路径
//qDebug()<<fileName;
QFile file(fileName);//创建文件对象
file.open(QIODevice::ReadWrite);//设定打开文件模式,否则会报错
QByteArray ba=file.readAll();
ui->textEdit->setText(QString(ba));//toPlainText获取string文本
file.close();
}
}
void MainWindow::saveActionSlot()
{
QString fileName=QFileDialog::getSaveFileName(this,"选择一个文件",QCoreApplication::applicationFilePath());
if(fileName.isEmpty())
{
QMessageBox::warning(this,"警告","请选择一个文件");
}
else
{
QFile file(fileName);
file.open(QIODevice::WriteOnly);
//ui->textEdit->toPlainText();//获取打开文件的内容 String格式
QByteArray ba;//进行格式转换,变成字节格式
ba.append(ui->textEdit->toPlainText());
file.write(ba);
file.close();
}
}
//事件鼠标点击键盘点击在客户端都叫做事件通过捕捉事件来实现一些响应事件被封装成QEvent类
void MainWindow::changeActionSlot(){
}
void MainWindow::keyPressEvent(QKeyEvent *k)
{
if(k->modifiers()==Qt::ControlModifier&&k->key()==Qt::Key_S)//modifiers()表示按键的附加信息
{
saveActionSlot();
}
if(k->modifiers()==Qt::ControlModifier&&k->key()==Qt::Key_F){
on_actionFind_clicked();
}
}
void MainWindow::mousePressEvent(QMouseEvent *m)
{
//QPoint类被用于获取位置
QPoint pt=m->pos();
qDebug()<<pt;
if(m->button()==Qt::LeftButton)
{
qDebug()<<"左键被按下";
}
else if(m->button()==Qt::RightButton)
{
qDebug()<<"右键被按下";
}
}

@ -0,0 +1,49 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QFileDialog> //QFileDialog类是Qt提供的一个用于指定操作文件的对话框小部件,使用前要先导入
#include <QKeyEvent>
#include <QMouseEvent>
#include <finddialog.h>
#include <QTextCharFormat>
//头文件用来写 类的声明 (包括类的成员的声明和方法声明)、函数原型、#define 常数等
//必须按照以下格式来写
/*
#ifndef MYCLASS_H
#define MYCLASS_H
// code here
#endif*/
//源文件主要写实现头文件中已经声明的那些函数的具体代码。需要注意的是,开头必须#include一下实现的头文件以及要用到的头文件
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void keyPressEvent(QKeyEvent *k);
void mousePressEvent(QMouseEvent *m);
private slots://创建槽函数 slot插槽
void newActionSlot();//新建文件的槽点 创建之后进入mainwindow.cpp继续处理信息编辑
void openActionSlot();//打开文件的槽点
void saveActionSlot();
void changeActionSlot();
void on_actionFind_clicked();
private:
Ui::MainWindow *ui;
QPlainTextEdit plainTextEdit; // mainEditor为文本编辑框对象
QSharedPointer<FindDialog> m_pFindDlg; // MainWindow 组合使用 FindDialog 和 QPlainTextEdit
QTextCharFormat m_format;
};
#endif // MAINWINDOW_H !!!必须要有的东西

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QPlainTextEdit" name="plainTextEdit"/>
</item>
<item row="1" column="0">
<widget class="QPlainTextEdit" name="plainTextEdit_2"/>
</item>
<item row="6" column="0">
<widget class="QPushButton" name="actionFind">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextEdit" name="textEdit"/>
</item>
<item row="2" column="0">
<widget class="QTextEdit" name="textEdit_2">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt; font-weight:600; font-style:italic; text-decoration: underline; vertical-align:sub;&quot;&gt;sdasdasda&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menu_F">
<property name="title">
<string>文件(&amp;F)</string>
</property>
<addaction name="newAction"/>
<addaction name="openAction"/>
<addaction name="saveAction"/>
<addaction name="changeAction"/>
</widget>
<widget class="QMenu" name="menu_N">
<property name="title">
<string>编译(&amp;E)</string>
</property>
</widget>
<widget class="QMenu" name="menu_B">
<property name="title">
<string>构建(&amp;B)</string>
</property>
</widget>
<widget class="QMenu" name="menu_C">
<property name="title">
<string>修改(C)</string>
</property>
</widget>
<addaction name="menu_F"/>
<addaction name="menu_N"/>
<addaction name="menu_B"/>
<addaction name="menu_C"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="newAction">
<property name="text">
<string>新建(&amp;N)</string>
</property>
</action>
<action name="openAction">
<property name="text">
<string>打开(&amp;O)</string>
</property>
</action>
<action name="saveAction">
<property name="text">
<string>另存为(&amp;S)</string>
</property>
</action>
<action name="changeAction">
<property name="text">
<string>修改(C)</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,63 @@
#include "widget.h"
#include <QPalette>
#include <QMessageBox>
Widget::Widget(QWidget *parent)
: QWidget(parent), m_button(this), m_edit(this), m_label(this)
{
m_label.move(10, 10);
m_label.resize(150, 25);
m_label.setText("Test");
m_edit.move(10, 45);
m_edit.resize(150, 25);
m_button.move(10, 80);
m_button.resize(150, 25);
m_button.setText("Test");
connect(&m_button, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(&m_edit, SIGNAL(textEdited(const QString&)), this, SLOT(onTextChange(const QString&)));
QPalette p = m_button.palette(); // 获取m_button的调色板
p.setColor(QPalette::Active, QPalette::ButtonText, Qt::red); // 设置激活时,按钮文本为红色
p.setColor(QPalette::Inactive, QPalette::ButtonText, Qt::red); // 设置非激活时,按钮文本为红色
m_button.setPalette(p); // 给m_button设置调色板
p = m_edit.palette();
p.setColor(QPalette::Active, QPalette::Highlight, Qt::red); // 高亮背景为红色
p.setColor(QPalette::Active, QPalette::HighlightedText, Qt::white); // 高亮文本为白色
p.setColor(QPalette::Inactive, QPalette::Highlight, Qt::yellow); // 高亮背景为黄色
p.setColor(QPalette::Inactive, QPalette::HighlightedText, Qt::green); // 高亮文本为白色
m_edit.setPalette(p);
}
// 点击按钮更改m_label的调色板方案
void Widget::onButtonClicked()
{
QPalette p = m_label.palette();
p.setColor(QPalette::Active, QPalette::WindowText, Qt::green);
p.setColor(QPalette::Inactive, QPalette::WindowText, Qt::green);
m_label.setPalette(p);
}
void Widget::onTextChange(const QString&)
{
if(m_edit.text().count() > 6)
{
m_edit.selectAll();
QMessageBox::information(this, "tip", "字符超出限制", QMessageBox::Ok);
}
}
Widget::~Widget()
{
}

@ -0,0 +1,24 @@
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
class Widget : public QWidget
{
Q_OBJECT
QPushButton m_button;
QLineEdit m_edit;
QLabel m_label;
protected slots:
void onButtonClicked();
void onTextChange(const QString&);
public:
Widget(QWidget *parent = 0);
~Widget();
};
#endif // WIDGET_H

@ -1,32 +0,0 @@
#include "highlighter.h"
HighLighter::HighLighter(QTextDocument *parent) :
QSyntaxHighlighter(parent)
{
HighlightRule num_rule;
num_rule.pattern.setPattern("[0-9]{1,1}");
num_rule.format.setForeground(QColor(144,238,144));
highlightrules.append(num_rule);
HighlightRule key_rule;
key_rule.pattern.setPattern("\\b(char|string|int|float|double|bool|void|true|flase)\\b");
key_rule.format.setForeground(QColor(30,144,255));
highlightrules.append(key_rule);
HighlightRule code_rule;
code_rule.pattern.setPattern("\\b(if|while|for|else|break|return|switch|case)\\b");
code_rule.format.setForeground(QColor(186,85,211));
highlightrules.append(code_rule);
}
void HighLighter::highlightBlock(const QString &text)
{
for(const HighlightRule &rule : highlightrules){
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
while(index>=0){
int length = expression.matchedLength();
setFormat(index,length,rule.format);
index = expression.indexIn(text,index+length);}
}
}

@ -1,22 +0,0 @@
#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H
#include<QSyntaxHighlighter>
#include<QTextCharFormat>
#include<QTextDocument>
#include<QRegularExpression>
class HighLighter :public QSyntaxHighlighter{
Q_OBJECT
public:
explicit HighLighter(QTextDocument *parent=0);
protected:
void highlightBlock(const QString &text);
private:
struct HighlightRule{
QRegExp pattern;
QTextCharFormat format;
};
QVector<HighlightRule> highlightrules;
};
#endif // HIGHLIGHTER_H

@ -1,711 +0,0 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDialog>
#include <QFileDialog>
#include <QDebug>
#include <QPushButton>
#include <QStackedLayout>
#include <QListWidget>
#include <QHBoxLayout>
#include <QLabel>
#include <QFormLayout>
#include <QLineEdit>
#include <QWidgetAction>
#include <QScrollBar>
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <string.h>
#include <QMessageBox>
#include "highlighter.h"
using namespace std;
// 是否启用QMainWindow自带的菜单栏
//#define USE_DEFAULT_MENU_BAR
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->variate_map = new Variate_Map;
//建立项目与主界面的联系
this->work_project = new Work_Project;
this->work_project->father = this;
// 在右侧浮动窗口中添加report窗口
dockWidget_report = new QDockWidget(tr("report"), this);
dockWidget_report->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetClosable);
dockWidget_report->setVisible(true);
addDockWidget(Qt::RightDockWidgetArea, dockWidget_report);
tabifyDockWidget(ui->dockWidget_src, dockWidget_report);
ui->dockWidget_src->raise();
// 在左侧浮动窗口中添加module窗口
tabifyDockWidget(ui->dockWidget_file, ui->dockWidget_module);
ui->dockWidget_file->raise();
//指定菜单栏
#ifdef USE_DEFAULT_MENU_BAR
//添加菜单栏(此处添加为的为QMainWindow自带的菜单
pMenuBar = this->menuBar();
#else
//添加自定义菜单
pMenuBar = new QMenuBar(this);
#endif
//定义菜单项
//&n)代表快捷方式当窗口获得焦点时按alt+n即可打开“测试”菜单项
pMenu1 = new QMenu("文件(&n)",this);
pMenu2 = new QMenu("执行",this);
pMenu3 = new QMenu("工具",this);
//定义子菜单
//&s为子菜单快捷键当打开该菜单项后按下s键即可响应
pAction_newproject = new QAction("新建项目(&s)",this);
//新建一个带图标的菜单项,图标使用资源文件中的资源
pAction_openproject = new QAction(QIcon(":/new/prefix1/resource/soccer_ball.ico"),"打开项目",this);
pAction_save = new QAction("保存",this);
pAction_syn = new QAction("run syn(&y)",this);
pAction_parameter_config = new QAction("参数配置",this);
pActionTest5 = new QAction("测试5(&M)",this);
pActionTest6 = new QAction("测试6",this);
//将菜单项添加到子菜单
pMenu1->addAction(pAction_newproject);
pMenu1->addAction(pAction_openproject);
//在菜单项之间添加分割线
pMenu1->addSeparator();
pMenu1->addAction(pAction_save);
pMenu2->addAction(pAction_parameter_config);
pMenu2->addAction(pAction_syn);
pMenu3->addAction(pActionTest5);
pMenu3->addAction(pActionTest6);
//将子菜单添加到菜单栏
pMenuBar->addMenu(pMenu1);
pMenuBar->addMenu(pMenu2);
pMenuBar->addMenu(pMenu3);
// 终端窗口
ui->pushButton_run_cmd->setFocus();
ui->pushButton_run_cmd->setShortcut(Qt::Key_Return);
m_process_bash = new QProcess;
m_process_bash->start("bash");
m_process_bash->waitForStarted();
m_process_bash->write("cd / \n");
// 设置module列表
this->model_module = new QStandardItemModel;
model_module->setHorizontalHeaderLabels(QStringList()<<"module name"<<"state");
this->ui->treeView_module->setModel(model_module);
this->ui->treeView_module->setColumnWidth(0, 200);
this->ui->treeView_module->setColumnWidth(1, 50);
QMenu *menu_module = new QMenu(this);
QAction *pAction_newmodule = new QAction("new module", this);
QAction *pAction_delmodule = new QAction("delete module", this);
menu_module->addAction(pAction_newmodule);
menu_module->addAction(pAction_delmodule);
ui->treeView_module->setContextMenuPolicy(Qt::CustomContextMenu);
// 建立信号槽连接处理module树形列表右键菜单事件
connect(ui->treeView_module, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
// 显示右键菜单
menu_module->popup(ui->treeView_module->viewport()->mapToGlobal(pos));
});
// new mdoule槽连接
connect(pAction_newmodule, &QAction::triggered, this, &MainWindow::New_module);
#ifndef USE_DEFAULT_MENU_BAR
//当不使用QMainWindow自带的菜单栏时必须要加上此行
setMenuBar(pMenuBar);
#endif
//添加菜单响应函数
connect(pAction_newproject, &QAction::triggered, this->work_project, &Work_Project::New_Project_1);
connect(pAction_openproject,&QAction::triggered,this,&MainWindow::OpenProject);
connect(pAction_parameter_config, &QAction::triggered, this, &MainWindow::Parameter_Config);
connect(m_process_bash, &QProcess::readyReadStandardOutput, this, &MainWindow::readBashStandardOutputInfo);
connect(m_process_bash, &QProcess::readyReadStandardError, this, &MainWindow::readBashStandardErrorInfo);
//int Index = ui->tabWidget_src->currentIndex();
//QTextEdit *editor = dynamic_cast<QTextEdit*>(ui->tabWidget_src->currentWidget());
//highlighter = new HighLighter(editor->document());
// highlighter = new HighLighter(ui->tabWidget_src->currentWidget()->->document());
}
// 打开项目响应函数
void MainWindow::OpenProject()
{
this->work_project->work_project_path = QFileDialog::getExistingDirectory(this, "打开项目", "/");
chdir(work_project->work_project_path.toStdString().data());
work_project->Get_Work_config();
//设置树形文件列表
this->model_file = new QFileSystemModel;
this->model_file->setRootPath(this->work_project->work_project_path);
this->ui->treeView_file->setModel(this->model_file);
this->ui->treeView_file->setRootIndex(this->model_file->index(this->work_project->work_project_path));
this->ui->treeView_file->setHeaderHidden(true);
this->ui->treeView_file->setColumnHidden(1, true);
this->ui->treeView_file->setColumnHidden(2, true);
this->ui->treeView_file->setColumnHidden(3, true);
connect(this->ui->treeView_file, &QTreeView::clicked, this, &MainWindow::TreeClicked);
//终端进入工作项目
string cmd_cd = "cd " + work_project->work_project_path.toStdString() + "\n pwd \n";
this->m_process_bash->write(cmd_cd.data());
}
MainWindow::~MainWindow()
{
delete ui;
}
string get_current_date();
// 参数配置响应函数
void MainWindow::Parameter_Config()
{
this->variate_map->add_variate("TCLPATH", ".");
this->variate_map->add_variate("DCWORK", "./dc.work");
this->variate_map->add_variate("current_date", get_current_date());
//this->variate_map->Generate_Config_File();
this->ui->textEdit_cmd->append("Parameter config completed!\n");
}
// 新建项目1响应函数
void Work_Project::New_Project_1()
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("新建项目");
qdialog->setFixedSize(800, 450);
QHBoxLayout *layout = new QHBoxLayout(qdialog);
QListWidget *listWidget = new QListWidget;
listWidget->setMinimumWidth(150);
listWidget->setFont(QFont("宋体",14));
listWidget->addItem("Project1");
listWidget->addItem("");
QWidget *widget1 = new QWidget, *widget2 = new QWidget;
widget1->setMaximumHeight(350); widget2->setMaximumHeight(350);
QLabel *lab1 = new QLabel("创建项目流程主要包括导入项目路径、导入代码\n路径、选择顶层模块", widget1);
lab1->setFont(QFont("宋体", 15));
lab1->setWordWrap(true);
lab1->adjustSize();
lab1->setMinimumSize(500, 100);
QLabel *lab2 = new QLabel("", widget2);
QStackedLayout *stackedLayout = new QStackedLayout;
stackedLayout->addWidget(widget1);
stackedLayout->addWidget(widget2);
layout->addWidget(listWidget, 2);
layout->addLayout(stackedLayout, 3);
qdialog->setLayout(layout);
QPushButton *button_next = new QPushButton("下一步", qdialog);
button_next->move(568, 400);
QPushButton *button_cancel = new QPushButton("取消", qdialog);
button_cancel->move(675, 400);
QObject::connect(listWidget, &QListWidget::currentRowChanged, stackedLayout, &QStackedLayout::setCurrentIndex);
QObject::connect(button_next, &QPushButton::clicked, qdialog, &QDialog::close);
QObject::connect(button_next, &QPushButton::clicked, this, &Work_Project::New_Project_2);
QObject::connect(button_cancel, &QPushButton::clicked, qdialog, &QDialog::close);
qdialog->exec();
}
// 新建项目2响应函数新建项目2对话框
void Work_Project::New_Project_2()
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("新建项目");
qdialog->setFixedSize(800,450);
//添加表格布局
QFormLayout* layout = new QFormLayout();
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
edit_work_project_path = new QLineEdit();
edit_work_project_name = new QLineEdit();
layout->addRow("项目路径:", edit_work_project_path);
layout->addRow("新建项目名称:", edit_work_project_name);
// 选择路径按钮
QPushButton *button_work_project_path = new QPushButton(edit_work_project_path);
button_work_project_path->setText("......");
button_work_project_path->setCursor(Qt::ArrowCursor);
QWidgetAction* action = new QWidgetAction(edit_work_project_path);
action->setDefaultWidget(button_work_project_path);
edit_work_project_path->addAction(action, QLineEdit::TrailingPosition);
// 将布局添加到对话框
qdialog->setLayout(layout);
// 操作按键
QPushButton *button_next = new QPushButton("下一步", qdialog);
button_next->move(568, 400);
QPushButton *button_back = new QPushButton("上一步", qdialog);
button_back->move(675, 400);
// 按键响应信号槽函数
connect(button_work_project_path, &QPushButton::clicked, this, &Work_Project::Work_Project_path_choose);
connect(button_next, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_next, &QPushButton::clicked, this, &Work_Project::New_Project_setup);
QObject::connect(button_back, &QPushButton::clicked, qdialog, &QDialog::close);
QObject::connect(button_back, &QPushButton::clicked, this, &Work_Project::New_Project_1);
// 显示对话框
qdialog->exec();
}
// 工作项目setup设置界面
void Work_Project::New_Project_setup()
{
// 新建对话框
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("setup");
qdialog->setFixedSize(800,490);
// 新建输入框
QFormLayout* layout = new QFormLayout();
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
edit_designer = new QLineEdit(); layout->addRow("designer:", edit_designer);
edit_company = new QLineEdit(); layout->addRow("company:", edit_company);
edit_synthetic_library = new QLineEdit(); layout->addRow("synthetic_library:", edit_synthetic_library);
edit_target_library = new QLineEdit(); layout->addRow("target_library:", edit_target_library);
edit_link_library = new QLineEdit(); layout->addRow("link_library:", edit_link_library);
edit_symbol_library=new QLineEdit(); layout->addRow("symbol_library:", edit_symbol_library);
edit_cache_write=new QLineEdit(); layout->addRow("cache_write:", edit_cache_write);
edit_cache_read=new QLineEdit(); layout->addRow("cache_read:", edit_cache_read);
edit_my_lib_path=new QLineEdit(); layout->addRow("my_lib_path:", edit_my_lib_path);
edit_search_path=new QLineEdit(); layout->addRow("search_path:", edit_search_path);
edit_suppress_message=new QLineEdit(); layout->addRow("suppress_message:", edit_suppress_message);
edit_define_design_lib=new QLineEdit(); layout->addRow("define_design_lib:", edit_define_design_lib);
edit_view_script_submenu_items=new QLineEdit(); layout->addRow("view_script_submenu_items:", edit_view_script_submenu_items);
// 将布局添加到对话框
qdialog->setLayout(layout);
// 操作按键
QPushButton *button_next = new QPushButton("下一步", qdialog);
button_next->move(568, 455);
QPushButton *button_back = new QPushButton("上一步", qdialog);
button_back->move(675, 455);
// 按键响应信号槽函数
connect(button_next, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_next, &QPushButton::clicked, this, &Work_Project::Src_Project_Environment_set);
QObject::connect(button_back, &QPushButton::clicked, qdialog, &QDialog::close);
QObject::connect(button_back, &QPushButton::clicked, this, &Work_Project::New_Project_2);
// 显示对话框
qdialog->exec();
}
// 按钮选择工作项目路径响应函数
void Work_Project::Work_Project_path_choose()
{
this->work_project_path = QFileDialog::getExistingDirectory(0, "选择目录", "/");
edit_work_project_path->setText(work_project_path);
}
// 芯片环境设置响应函数
void Work_Project::Src_Project_Environment_set()
{
work_project_name = edit_work_project_name->text();
work_project_path = edit_work_project_path->text();
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("芯片项目环境设置");
qdialog->setFixedSize(800, 450);
//输入框及其按钮
QFormLayout *layout = new QFormLayout;
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
edit_src_project_path = new QLineEdit;
edit_src_path = new QLineEdit;
// edit_module_name = new QLineEdit;
layout->addRow("芯片项目路径:", edit_src_project_path);
layout->addRow("代码路径", edit_src_path);
// layout->addRow("模块名称", edit_module_name);
QPushButton *button_src_project_path = new QPushButton(edit_src_project_path);
QPushButton *button_src_path = new QPushButton(edit_src_path);
button_src_project_path->setText("..."); button_src_path->setText("...");
button_src_project_path->setCursor(Qt::ArrowCursor); button_src_path->setCursor(Qt::ArrowCursor);
QWidgetAction *action_Project_path = new QWidgetAction(edit_src_project_path), *action_src_path = new QWidgetAction(edit_src_path);
action_Project_path->setDefaultWidget(button_src_project_path); action_src_path->setDefaultWidget(button_src_path);
edit_src_project_path->addAction(action_Project_path, QLineEdit::TrailingPosition); edit_src_path->addAction(action_src_path, QLineEdit::TrailingPosition);
qdialog->setLayout(layout);
//单独按钮
QPushButton *button_determine = new QPushButton("确定", qdialog), *button_back = new QPushButton("上一步", qdialog);
button_determine->move(568, 400); button_back->move(675, 400);
//按钮对应槽函数
connect(button_src_project_path, &QPushButton::clicked, this, &Work_Project::Src_Project_path_choose);
connect(button_src_path, &QPushButton::clicked, this, &Work_Project::Src_path_choose);
connect(button_determine, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_determine, &QPushButton::clicked, this, &Work_Project::Src_Prokect_Environment_set_Determine);
connect(button_back, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_back, &QPushButton::clicked, this, &Work_Project::New_Project_setup);
qdialog->exec();
}
// 选择芯片项目路径响应函数
void Work_Project::Src_Project_path_choose()
{
this->src_project_path = QFileDialog::getExistingDirectory(0, "选择目录", "/");
edit_src_project_path->setText(src_project_path);
}
// 选择代码路径响应函数
void Work_Project::Src_path_choose()
{
src_path = QFileDialog::getExistingDirectory(0, "选择目录", "/");
edit_src_path->setText(src_path);
}
// 芯片项目环境配置确定响应函数
void Work_Project::Src_Prokect_Environment_set_Determine()
{
src_project_path = edit_src_project_path->text();
src_path = edit_src_path->text();
// module_name = edit_module_name->text();
// 生成工作项目对应文件夹
string str_work_project_path = work_project_path.toStdString(), str_work_project_name = work_project_name.toStdString();
chdir(str_work_project_path.data());
mkdir(str_work_project_name.data(), 0755);
str_work_project_path += '/' + str_work_project_name;
chdir(str_work_project_path.data());
work_project_path = QString::fromStdString(str_work_project_path);
qDebug() << work_project_path;
// 保存配置信息
Generate_UWE_Work_config();
// 设置树形文件列表
this->father->model_file = new QFileSystemModel;
this->father->model_file->setRootPath(work_project_path);
this->father->ui->treeView_file->setModel(this->father->model_file);
this->father->ui->treeView_file->setRootIndex(this->father->model_file->index(work_project_path));
this->father->ui->treeView_file->setHeaderHidden(true);
this->father->ui->treeView_file->setColumnHidden(1, true);
this->father->ui->treeView_file->setColumnHidden(2, true);
this->father->ui->treeView_file->setColumnHidden(3, true);
connect(this->father->ui->treeView_file, &QTreeView::clicked, this->father, &MainWindow::TreeClicked);
// 终端进入项目文件夹链接src代码文件夹
string ln_cmd = " ln -s " + this->src_path.toStdString() + ' ' + "./src"; ln_cmd += "\nln -s /home/UWE/zj/tmp/Scripts ./Scripts";
string cmd_1 = "cd "+str_work_project_path+'\n' + "pwd\n" + ln_cmd+'\n';
this->father->m_process_bash->write(cmd_1.data());
// 生成执行所需tcl文件
ofstream out1("ProjectPathSetting.tcl", ios::out);
out1 << "set PROJECTPATH " << this->src_project_path.toStdString() << "\n" << "puts ${PROJECTPATH}";
out1.close();
// ofstream out2("setModuleName.tcl", ios::out);
// out2 << "set Design " << this->module_name.toStdString() << "\n" << "puts ${Design}";
// out2.close();
// make Prepare的一系列操作
string cmd_2 = "echo 'ProjectPathSetting.tcl is generated successfully!\n./src soft link is created.\nsetModuleName.tcl is created.'\n";
string cmd_cp = "cp -r /home/UWE/zj/tmp/Template/* ./ \ntouch tmp.log \necho 'copy files in Template here.' \ncp -r /home/UWE/zj/tmp/Makefile ./ \n"
"cp -r /home/UWE/zj/test_1/syn_main.tcl ./ \n";
string cmd_flist = "filelistpath=`find ./src/ -maxdepth 1 -name '*flist*' -type f` \nfilelistname=${filelistpath#*src/} \necho '`include \"./\"' > ./dc.work/filelist.v \n";
string cmd_incdir = "incdirlistpath=`find ./src/ -maxdepth 1 -name '*incdir*' -type f` \nincdirlistname=${incdirlistpath#*src/} \necho -f ./src/$incdirlistname \ > ./nc.work/sim_filelist.f \n";
string cmd_nc = "echo '-f ./src/'$filelistname'' \ >> ./nc.work/sim_filelist.f \necho \" \" >> ./nc.work/sim_filelist.f \necho //Add simulation files bellow >> ./nc.work/sim_filelist.f \n";
string cmd_mv = "mv ./spyglass.work/demo.prj ./spyglass.work/"; cmd_mv += this->module_name.toStdString(); cmd_mv += ".prj \n";
cmd_mv += "mv ./spyglass.work/waiver/demo.awl ./spyglass.work/waiver/"+this->module_name.toStdString()+".awl\n";
cmd_2 += cmd_cp + cmd_flist + cmd_incdir + cmd_nc + cmd_mv;
//cout << cmd_2;
this->father->m_process_bash->write(cmd_2.data());
// 生成synopsys_dc.setup文件
ofstream out_setup("synopsys_dc.setup", ios::out);
out_setup << "set designer " << this->edit_designer->text().toStdString() << '\n';
out_setup << "set company " << this->edit_company->text().toStdString() << '\n';
out_setup << "set synthetic_library " << this->edit_synthetic_library->text().toStdString() << '\n';
out_setup << "set target_library " << this->edit_target_library->text().toStdString() << '\n';
out_setup << "set link_library " << this->edit_link_library->text().toStdString() << '\n';
out_setup << "set symbol_library " << this->edit_symbol_library->text().toStdString() << '\n';
out_setup << "set cache_write " << this->edit_cache_write->text().toStdString() << '\n';
out_setup << "set cache_read $cache_write\n";
out_setup << "set my_lib_path " << this->edit_my_lib_path->text().toStdString() << '\n';
out_setup << "set search_path " << this->edit_search_path->text().toStdString() << '\n';
out_setup << "suppress_message " << this->edit_suppress_message->text().toStdString() << '\n';
out_setup << "define_design_lib DEFAULT -path " << this->edit_define_design_lib->text().toStdString() << '\n';
out_setup << "set view_script_submenu_items " << this->edit_view_script_submenu_items->text().toStdString() << '\n';
out_setup.close();
}
// 生成工作项目配置文件
void Work_Project::Generate_UWE_Work_config()
{
ofstream out("UWE_work_config", ios::out);
out << "work_project_path = " << work_project_path.toStdString() << endl;
out << "work_project_name = " << work_project_name.toStdString() << endl;
out << "src_project_path = " << src_project_path.toStdString() << endl;
out << "src_path = " << src_path.toStdString() << endl;
out << "module_name = " << module_name.toStdString() << endl;
out.close();
}
// 根据配置文件获取工作项目配置
void Work_Project::Get_Work_config()
{
ifstream in("UWE_work_config", ios::in);
string str;
in >> str >> str >> str;
in >> str >> str >> str; work_project_name = QString::fromStdString(str);
in >> str >> str >> str; src_project_path = QString::fromStdString(str);
in >> str >> str >> str; src_path = QString::fromStdString(str);
in >> str >> str >> str; module_name = QString::fromStdString(str);
in.close();
}
// 获取当前系统时间
string get_current_date()
{
time_t timeReal;
time(&timeReal);
timeReal = timeReal + 8*3600;
tm* t = gmtime(&timeReal);
string str = to_string(t->tm_year+1900) + '_' + to_string(t->tm_mon+1)+to_string(t->tm_mday) + '_' + to_string(t->tm_hour)+to_string(t->tm_min);
return str;
}
// 点击树形文件列表展示文本内容
void MainWindow::TreeClicked(const QModelIndex &index)
{
ui->dockWidget_src->show();
QString context, file_name = model_file->fileName(index);
QString path = model_file->filePath(index);
for (int i = 0; i < ui->tabWidget_src->count(); ++i) {
if (ui->tabWidget_src->tabText(i) == file_name) {
ui->tabWidget_src->setCurrentIndex(i);
ui->dockWidget_src->show();
ui->dockWidget_src->raise();
return;
}
}
QFile file(path);
file.open(QFile::ReadOnly | QFile::Text);
context = file.readAll();
file.close();
if (!context.isEmpty()){
QTextEdit *textEdit_src = new QTextEdit;
textEdit_src->setText(context);
textEdit_src->setFont(QFont("Consolas", 12));
ui->tabWidget_src->addTab(textEdit_src, file_name);
ui->tabWidget_src->setCurrentWidget(textEdit_src);
}
ui->dockWidget_src->raise();
}
// 终端输出内容响应函数
void MainWindow::readBashStandardOutputInfo()
{
QByteArray cmdout = m_process_bash->readAllStandardOutput();
// 综合完成响应函数
if (cmdout.indexOf("Thank you...") != -1){
qDebug() << "syn sucessfully!" << endl;
QStandardItem *item = model_module->item(row_current_module_treeview, 1);
item->setIcon(style()->standardIcon(QStyle::SP_DialogApplyButton));
}
if (!cmdout.isEmpty()){
ui->textEdit_cmd->append(QString::fromLocal8Bit(cmdout));
}
QScrollBar *scroll = ui->textEdit_cmd->verticalScrollBar();
scroll->setSliderPosition(scroll->maximum());
}
// 终端输出错误信息响应函数
void MainWindow::readBashStandardErrorInfo()
{
QByteArray cmdout = m_process_bash->readAllStandardError();
if (!cmdout.isEmpty()){
ui->textEdit_cmd->append(QString::fromLocal8Bit(cmdout));
}
QScrollBar *scroll = ui->textEdit_cmd->verticalScrollBar();
scroll->setSliderPosition(scroll->maximum());
}
// 字符串变量替换
void MainWindow::String_Replace(string &str, string variate_key)
{
string variate_value = this->variate_map->get_value(variate_key);
int variate_size = variate_key.size();
while (str.find(variate_key) != string::npos)
str = str.replace(str.find(variate_key), variate_size, variate_value);
}
// 生成配置文件
void Variate_Map::Generate_Config_File()
{
ofstream out("parameter.tcl", ios::out);
for (auto i : mapper)
out << "set " << i.first << ' ' << i.second << endl;
out.close();
}
// 保存参数配置
void MainWindow::on_buttonBox_Save_accepted()
{
string FLOW_value = (ui->radioButton_FLOW_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("FLOW", FLOW_value);
string LOADDDC_value = (ui->radioButton_LOADDDC_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("LOADDDC", LOADDDC_value);
string CHECKCODE_value = (ui->radioButton_CHECKCODE_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("CHECKCODE", CHECKCODE_value);
string DEBUGSDC_value = (ui->radioButton_DEBUGSDC_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("DEBUGSDC", DEBUGSDC_value);
variate_map->Generate_Config_File();
ui->textEdit_cmd->append("parameter.tcl has been generated sucessfully!\n");
}
// 运行综合按钮响应函数
void MainWindow::on_pushButton_runsyn_clicked()
{
Parameter_Config();
string syn_cmd = "dc_shell-t -f TCLPATH/syn_main.tcl | tee dc.log DCWORK/Logs/dc_current_date.log \nmake c_R0 \n";
this->String_Replace(syn_cmd, "TCLPATH");
this->String_Replace(syn_cmd, "DCWORK");
this->String_Replace(syn_cmd, "current_date");
cout << syn_cmd << endl;
this->ui->textEdit_cmd->append("run syn \n");
this->m_process_bash->write(syn_cmd.data());
}
// 代码窗口关闭响应函数
void MainWindow::on_tabWidget_src_tabCloseRequested(int index)
{
QTextEdit *text_edit = qobject_cast<QTextEdit *>(ui->tabWidget_src->widget(index));
QString file_name = ui->tabWidget_src->tabText(index);
QString file_path = model_file->rootPath() + "/" + file_name;
if (text_edit) {
// »ñÈ¡µ±Ç°Îı¾¿òÖеÄÄÚÈÝ
QString curr_content = text_edit->toPlainText();
// ¶ÁȡԭʼÎļþÄÚÈÝ
QString orig_content;
QFile file(file_path);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
orig_content = file.readAll();
file.close();
}
// Èç¹ûµ±Ç°ÄÚÈÝÓëԭʼÄÚÈݲ»Í¬£¬Ôò˵Ã÷ÎļþÒѱ»±à¼­£¬ÐèÒª±£´æÐÞ¸Ä
if (curr_content != orig_content) {
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&file);
out << curr_content;
file.close();
}
}
}
// ½«±êǩҳ´Ó±êÇ©¿Ø¼þÖÐɾ³ý
ui->tabWidget_src->removeTab(index);
}
// R0_check result按钮响应函数
void MainWindow::on_pushButton_result_clicked()
{
ktextEdit = new KTextEdit(dockWidget_report);
//获取result内容
QString result_path = QDir::currentPath() + "/R0_check.result";
QFile file(result_path);
QString context;
file.open(QFile::ReadOnly | QFile::Text);
while (!file.atEnd()) {
QByteArray line = file.readLine();
QString str(line);
context.append(str);
}
ktextEdit->SetText(context);
//设置文本游标到文本头
QTextCursor cursor = ktextEdit->textCursor();
cursor.movePosition(QTextCursor::Start);
ktextEdit->setTextCursor(cursor);
dockWidget_report->setWidget(ktextEdit);
dockWidget_report->raise();
}
//终端运行按钮响应函数
void MainWindow::on_pushButton_run_cmd_clicked()
{
QString strCmd = ui->lineEdit->text();
ui->textEdit_cmd->append("Linux:~$ " + strCmd);
m_process_bash->write(ui->lineEdit->text().toLocal8Bit() + '\n');
ui->lineEdit->clear();
}
// New nodule响应函数
void MainWindow::New_module()
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("module name");
qdialog->setFixedSize(500, 50);
//输入框及其按钮
QFormLayout *layout = new QFormLayout;
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
QLineEdit *edit_module_name = new QLineEdit;
layout->addRow("module name:", edit_module_name);
qdialog->setLayout(layout);
//单独按钮
QPushButton *button_determine = new QPushButton("确定", qdialog);
button_determine->move(300, 100);
//按钮对应槽函数
connect(button_determine, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_determine, &QPushButton::clicked, this, [=]{
QList<QStandardItem *> items;
items.append(new QStandardItem(edit_module_name->text()));
// childItem->setIcon(style()->standardIcon(QStyle::SP_DialogApplyButton));
QStandardItem *Item_state = new QStandardItem();
Item_state->setIcon(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
items.append(Item_state);
model_module->appendRow(items);
row_current_module_treeview++;
this->work_project->module_name = edit_module_name->text();
ofstream out2("setModuleName.tcl", ios::out);
out2 << "set Design " << edit_module_name->text().toStdString() << "\n" << "puts ${Design}";
out2.close();
});
qdialog->exec();
}

@ -1,168 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMenuBar>
#include <QDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QFileSystemModel>
#include <QProcess>
#include <map>
#include <string>
#include <fstream>
#include <QObject>
#include <QTextEdit>
#include <QTreeView>
#include <QStandardItemModel>
using namespace std;
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class Variate_Map;
class Work_Project;
class KTextEdit;
class HighLighter;
//????
class MainWindow : public QMainWindow
{
Q_OBJECT
private:
HighLighter *highlighter;
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void String_Replace(string& str, string variate);
//???
QMenuBar *pMenuBar;
//???
QMenu *pMenu1;
QMenu *pMenu2;
QMenu *pMenu3;
//???
QAction *pAction_newproject;
QAction *pAction_openproject;
QAction *pAction_save;
QAction *pAction_parameter_config;
QAction *pAction_syn;
QAction *pActionTest5;
QAction *pActionTest6;
QFileSystemModel *model_file;
QStandardItemModel *model_module;
int row_current_module_treeview = -1;
Ui::MainWindow *ui;
QProcess *m_process_bash;
Variate_Map *variate_map;
QDockWidget *dockWidget_report, *dockWidget_module;
QTreeView *treeView_module;
KTextEdit *ktextEdit;
// flag set
bool ready_syn, ready_r0_result, ready_setup, ready_prepare;
//????
Work_Project *work_project;
public slots:
//????????
//????????
void OpenProject();
void TreeClicked(const QModelIndex &index);
void readBashStandardOutputInfo();
void readBashStandardErrorInfo();
void Parameter_Config();
void New_module();
private slots:
void on_buttonBox_Save_accepted();
void on_pushButton_runsyn_clicked();
void on_tabWidget_src_tabCloseRequested(int index);
void on_pushButton_result_clicked();
void on_pushButton_run_cmd_clicked();
// void on_treeView_module_clicked(const QModelIndex &index);
void on_treeView_file_collapsed(const QModelIndex &index);
};
//????map?
class Variate_Map
{
public:
Variate_Map(){}
~Variate_Map(){}
string get_value(string str){return mapper[str];}
int add_variate(string key, string value){mapper[key] = value;}
bool alter_variate(string key, string value)
{
if (mapper.find(key) == mapper.end())
return false;
else{
mapper[key] = value;
return true;
}
}
void Generate_Config_File();
private:
map<string, string> mapper;
};
//?????
class Work_Project : public QObject
{
Q_OBJECT
public:
MainWindow *father;
QLineEdit *edit_work_project_path, *edit_work_project_name, *edit_src_project_path, *edit_src_path, *edit_module_name;
QLineEdit *edit_designer, *edit_company, *edit_synthetic_library, *edit_target_library, *edit_link_library, *edit_symbol_library, *edit_cache_write,
*edit_cache_read, *edit_my_lib_path, *edit_search_path, *edit_suppress_message, *edit_define_design_lib , *edit_view_script_submenu_items;
QString work_project_path, work_project_name, src_project_path, src_path, module_name;
Work_Project(){}
~Work_Project(){}
void Generate_UWE_Work_config();
void Get_Work_config();
public slots:
void New_Project_1();
void New_Project_2();
void New_Project_setup();
void Work_Project_path_choose();
void Src_Project_Environment_set();
void Src_Project_path_choose();
void Src_path_choose();
void Src_Prokect_Environment_set_Determine();
};
class KTextEdit : public QTextEdit
{
Q_OBJECT
public:
KTextEdit(QWidget *parent = nullptr);
void SetText(const QString &text);
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
QList<QString> clickable_text_list;
QString error_type;
QProcess *m_process_report_man;
QByteArray man_out;
public slots:
void OnCursorMove();
void readBash_manOutputInfo();
};
#endif // MAINWINDOW_H

@ -1,415 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1851</width>
<height>781</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>50</x>
<y>40</y>
<width>151</width>
<height>601</height>
</rect>
</property>
<widget class="QDialogButtonBox" name="buttonBox_Save">
<property name="geometry">
<rect>
<x>60</x>
<y>370</y>
<width>81</width>
<height>28</height>
</rect>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Save</set>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_FLOW">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>131</width>
<height>80</height>
</rect>
</property>
<property name="title">
<string>FLOW</string>
</property>
<widget class="QRadioButton" name="radioButton_FLOW_TRUE">
<property name="geometry">
<rect>
<x>0</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>TRUE</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_FLOW_FALSE">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>FALSE</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_LOADDDC">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>131</width>
<height>80</height>
</rect>
</property>
<property name="title">
<string>LOADDDC</string>
</property>
<widget class="QRadioButton" name="radioButton_LOADDDC_TRUE">
<property name="geometry">
<rect>
<x>0</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>TRUE</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="QRadioButton" name="radioButton__LOADDDC_FALSE">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>FALSE</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_CHECKCODE">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>131</width>
<height>80</height>
</rect>
</property>
<property name="title">
<string>CHECKCODE</string>
</property>
<widget class="QRadioButton" name="radioButton_CHECKCODE_TRUE">
<property name="geometry">
<rect>
<x>0</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>TRUE</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_CHECKCODE_FALSE">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>FALSE</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_DEBUGSDC">
<property name="geometry">
<rect>
<x>10</x>
<y>270</y>
<width>131</width>
<height>80</height>
</rect>
</property>
<property name="title">
<string>DEBUGSDC</string>
</property>
<widget class="QRadioButton" name="radioButton_DEBUGSDC_TRUE">
<property name="geometry">
<rect>
<x>0</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>TRUE</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_DEBUGSDC_FALSE">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>106</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>FALSE</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QPushButton" name="pushButton_runsyn">
<property name="geometry">
<rect>
<x>10</x>
<y>450</y>
<width>121</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>run syn</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_result">
<property name="geometry">
<rect>
<x>10</x>
<y>540</y>
<width>121</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>R0_check result</string>
</property>
</widget>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>40</x>
<y>10</y>
<width>91</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>13</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>参数配置</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1851</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="dockWidget_src">
<property name="minimumSize">
<size>
<width>1350</width>
<height>500</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16000</width>
<height>524287</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="features">
<set>QDockWidget::DockWidgetClosable</set>
</property>
<property name="windowTitle">
<string>代码</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_5">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget_src">
<property name="currentIndex">
<number>-1</number>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<property name="movable">
<bool>true</bool>
</property>
<property name="tabBarAutoHide">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="dockWidget_cmd">
<property name="minimumSize">
<size>
<width>126</width>
<height>146</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="windowTitle">
<string>bash</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_6">
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_run_cmd">
<property name="text">
<string>run</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QTextEdit" name="textEdit_cmd"/>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="dockWidget_file">
<property name="minimumSize">
<size>
<width>200</width>
<height>110</height>
</size>
</property>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>项目</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTreeView" name="treeView_file"/>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="dockWidget_module">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>module</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3">
<widget class="QTreeView" name="treeView_module">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>256</width>
<height>800</height>
</rect>
</property>
</widget>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

@ -0,0 +1,954 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDialog>
#include <QFileDialog>
#include <QDebug>
#include <QPushButton>
#include <QStackedLayout>
#include <QListWidget>
#include <QHBoxLayout>
#include <QLabel>
#include <QFormLayout>
#include <QLineEdit>
#include <QWidgetAction>
#include <QScrollBar>
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <string.h>
#include <QMessageBox>
#include <QComboBox>
#include <QTableView>
#include <QSplitter>
using namespace std;
// 是å<C2AF>¦å<C2A6>¯ç”¨QMainWindow自带的è<E2809E>œå<C593>•æ <20>
//#define USE_DEFAULT_MENU_BAR
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->variate_map = new Variate_Map;
// 建ç«é¡¹ç®ä¸Žä¸»ç•Œé<C592>¢çš„è<E2809E>”ç³»
this->work_project = new Work_Project;
this->work_project->father = this;
// syn界é<C592>¢å¸ƒå±€è®¾ç½®
qmainwindow_syn = new QMainWindow();
QWidget *widget_syn = new QWidget();
QHBoxLayout *layout_syn = new QHBoxLayout(widget_syn);
layout_syn->addWidget(ui->widget);
widget_syn->setLayout(layout_syn);
qmainwindow_syn->setCentralWidget(widget_syn);
qmainwindow_syn->addDockWidget(Qt::TopDockWidgetArea, ui->dockWidget_src_syn);
// qmainwindow_syn->addDockWidget(Qt::BottomDockWidgetArea, ui->dockWidget_cmd_syn);
// QVBoxLayout *layout = new QVBoxLayout(widget_syn);
// layout->addWidget(ui->widget, 0, Qt::AlignLeft);
// QVBoxLayout *layout = new QVBoxLayout;
// layout->addWidget(ui->widget);
// QHBoxLayout *hLayout = new QHBoxLayout;
// hLayout->addWidget(ui->widget);
// QWidget *centralWidget = new QWidget;
// centralWidget->setLayout(hLayout);
// qmainwindow_syn->setCentralWidget(ui->widget);
// layout1->addWidget(button);
// ui->widget->setLayout(layout1);
// ui->widget->setGeometry(0, 0, 150, 600);
ui->tabWidget_flow->addTab(qmainwindow_syn, "Syn");
ui->tabWidget_flow->removeTab(0);
// pt界é<C592>¢å¸ƒå±€è®¾ç½®
qmainwindow_pt = new QMainWindow();
qmainwindow_pt->setCentralWidget(new QWidget());
qmainwindow_pt->addDockWidget(Qt::TopDockWidgetArea, ui->dockWidget_src_pt);
qmainwindow_pt->addDockWidget(Qt::BottomDockWidgetArea, ui->dockWidget_cmd_pt);
ui->tabWidget_flow->removeTab(0);
ui->tabWidget_flow->addTab(qmainwindow_pt, "PT");
// 在å<C2A8>³ä¾§æµ®åŠ¨çª—å<E28094>£ä¸­æ·»åŠ report窗å<E28094>£
// dockWidget_report_syn = new QDockWidget(tr("report"), this);
// dockWidget_report_syn->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetClosable);
// dockWidget_report_syn->setVisible(true);
// addDockWidget(Qt::RightDockWidgetArea, dockWidget_report_syn);
// qmainwindow_syn->tabifyDockWidget(ui->dockWidget_src_syn, dockWidget_report_syn);
// ui->dockWidget_src_syn->raise();
// 在左侧浮动窗å<E28094>£ä¸­æ·»åŠ module窗å<E28094>£
tabifyDockWidget(ui->dockWidget_file, ui->dockWidget_module);
ui->dockWidget_file->raise();
//指定è<C5A1>œå<C593>•æ <20>
#ifdef USE_DEFAULT_MENU_BAR
//æ·»åŠ è<>œå<C593>•æ <20>(æ­¤å¤„æ·»åŠ ä¸ºçš„ä¸ºQMainWindow自带的è<E2809E>œå<C593>•)
pMenuBar = this->menuBar();
#else
//æ·»åŠ è‡ªå®šä¹‰è<E280B0>œå<C593>
pMenuBar = new QMenuBar(this);
#endif
//定义è<E280B0>œå<C593>•项
//(&n)代表快æ<C2AB>·æ¹å¼<C3A5>,当窗å<E28094>£èŽ·å¾—ç„¦ç¹æ—¶æŒ‰alt+nå<6E>³å<C2B3>¯æ‰“开“æµè¯•â€<C3A2>è<EFBFBD>œå<C593>•项
pMenu1 = new QMenu("文件(&n)",this);
pMenu2 = new QMenu("执行",this);
pMenu3 = new QMenu("工具",this);
//定义å­<C3A5>è<EFBFBD>œå<C593>
//(&s)为å­<C3A5>è<EFBFBD>œå<C593>•å¿«æ<C2AB>·é”®ï¼Œå½“打开该è<C2A5>œå<C593>•项å<C2B9>Žï¼ŒæŒ‰ä¸â€˜s’键å<C2AE>³å<C2B3>¯å“<C3A5>应
pAction_newproject = new QAction("新建项目(&s)",this);
//æ–°å»ºä¸€ä¸ªå¸¦å›¾æ ‡çš„è<E2809E>œå<C593>•é¡¹ï¼Œå¾æ ‡ä½¿ç”¨èµ„æº<C3A6>æ‡ä»¶ä¸­çš„资æº<C3A6>
pAction_openproject = new QAction(QIcon(":/new/prefix1/resource/soccer_ball.ico"),"打开项目",this);
pAction_save = new QAction("ä¿<C3A4>å­˜",this);
pAction_syn = new QAction("run syn(&y)",this);
pAction_parameter_config = new QAction("å<>æ•°é…<C3A9>ç½®",this);
pActionTest5 = new QAction("æµè¯•5(&M)",this);
pActionTest6 = new QAction("æµè¯•6",this);
//å°†è<E280A0>œå<C593>•é¡¹æ·»åŠ åˆ°å­<C3A5>è<EFBFBD>œå<C593>
pMenu1->addAction(pAction_newproject);
pMenu1->addAction(pAction_openproject);
//在è<C2A8>œå<C593>•项ä¹é—´æ·»åŠ åˆ†å‰²çº¿
pMenu1->addSeparator();
pMenu1->addAction(pAction_save);
pMenu2->addAction(pAction_parameter_config);
pMenu2->addAction(pAction_syn);
pMenu3->addAction(pActionTest5);
pMenu3->addAction(pActionTest6);
//å°†å­<C3A5>è<EFBFBD>œå<C593>•æ·»åŠ åˆ°è<C2B0>œå<C593>•æ <20>
pMenuBar->addMenu(pMenu1);
pMenuBar->addMenu(pMenu2);
pMenuBar->addMenu(pMenu3);
// 终端窗å<E28094>£
ui->pushButton_run_cmd_syn->setFocus();
ui->pushButton_run_cmd_syn->setShortcut(Qt::Key_Return);
m_process_bash = new QProcess;
m_process_bash->start("bash");
m_process_bash->waitForStarted();
m_process_bash->write("cd / \n");
// 设置module列表
this->model_module = new QStandardItemModel;
model_module->setHorizontalHeaderLabels(QStringList()<<"module name"<<"state");
this->ui->treeView_module->setModel(model_module);
this->ui->treeView_module->setColumnWidth(0, 200);
this->ui->treeView_module->setColumnWidth(1, 50);
QMenu *menu_module = new QMenu(this);
QAction *pAction_newmodule = new QAction("new module", this);
QAction *pAction_delmodule = new QAction("delete module", this);
menu_module->addAction(pAction_newmodule);
menu_module->addAction(pAction_delmodule);
ui->treeView_module->setContextMenuPolicy(Qt::CustomContextMenu);
// 建ç«ä¿¡å<C2A1>·æ§½è¿žæŽ¥ï¼Œå¤„ç<E2809E>†moduleæ 形列表å<C2A8>³é”®è<C2AE>œå<C593>•äºä»¶
connect(ui->treeView_module, &QTreeView::customContextMenuRequested, this, [=](const QPoint &pos) {
// 显示å<C2BA>³é”®è<C2AE>œå<C593>
menu_module->popup(ui->treeView_module->viewport()->mapToGlobal(pos));
});
// new mdoule槽连接
connect(pAction_newmodule, &QAction::triggered, this, &MainWindow::New_module);
#ifndef USE_DEFAULT_MENU_BAR
//当ä¸<C3A4>使用QMainWindow自带的è<E2809E>œå<C593>•æ <20>时,必须è¦<C3A8>åŠ ä¸Šæ­¤è¡Œ
setMenuBar(pMenuBar);
#endif
//æ·»åŠ è<>œå<C593>•å“<C3A5>应函数
connect(pAction_newproject, &QAction::triggered, this->work_project, &Work_Project::New_Project_1);
connect(pAction_openproject,&QAction::triggered,this,&MainWindow::OpenProject);
connect(pAction_parameter_config, &QAction::triggered, this, &MainWindow::Parameter_Config);
connect(m_process_bash, &QProcess::readyReadStandardOutput, this, &MainWindow::readBashStandardOutputInfo);
connect(m_process_bash, &QProcess::readyReadStandardError, this, &MainWindow::readBashStandardErrorInfo);
}
// 打开项ç®å“<C3A5>应函数
void MainWindow::OpenProject()
{
this->work_project->uwe_project_path = QFileDialog::getExistingDirectory(this, "打开项目", "/home/UWE/zj");
chdir(work_project->uwe_project_path.toStdString().data());
work_project->Get_Work_config();
//è®¾ç½®æ ‘å½¢æ–‡ä»¶åˆ—è¡¨
this->model_file = new QFileSystemModel;
this->model_file->setRootPath(this->work_project->uwe_project_path);
this->ui->treeView_file->setModel(this->model_file);
this->ui->treeView_file->setRootIndex(this->model_file->index(this->work_project->uwe_project_path));
this->ui->treeView_file->setHeaderHidden(true);
this->ui->treeView_file->setColumnHidden(1, true);
this->ui->treeView_file->setColumnHidden(2, true);
this->ui->treeView_file->setColumnHidden(3, true);
connect(this->ui->treeView_file, &QTreeView::clicked, this, &MainWindow::TreeClicked);
//终端进入工作项目
string cmd_cd = "cd " + work_project->uwe_project_path.toStdString() + "\n pwd \n";
this->m_process_bash->write(cmd_cd.data());
}
MainWindow::~MainWindow()
{
delete ui;
}
string get_current_date();
// å<>æ•°é…<C3A9>ç½®å“<C3A5>应函数
void MainWindow::Parameter_Config()
{
this->variate_map->add_variate("TCLPATH", ".");
this->variate_map->add_variate("DCWORK", "./dc.work");
this->variate_map->add_variate("current_date", get_current_date());
//this->variate_map->Generate_Config_File();
this->ui->textEdit_cmd_syn->append("Parameter config completed!\n");
}
// æ°å»ºé¡¹ç®1å“<C3A5>应函数
void Work_Project::New_Project_1()
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("新建项目");
qdialog->setFixedSize(800, 450);
QHBoxLayout *layout = new QHBoxLayout(qdialog);
QListWidget *listWidget = new QListWidget;
listWidget->setMinimumWidth(150);
listWidget->setFont(QFont("宋体",14));
listWidget->addItem("Project1");
listWidget->addItem("");
QWidget *widget1 = new QWidget, *widget2 = new QWidget;
widget1->setMaximumHeight(350); widget2->setMaximumHeight(350);
QLabel *lab1 = new QLabel("åˆå»ºé¡¹ç®æµ<C3A6>ç¨ä¸»è¦<C3A8>包æ¬å¯¼å…¥é¡¹ç®è·¯å¾„ã€<C3A3>导入代ç <20>\n路径ã€<C3A3>选æ©é¡¶å±æ¨¡å<C2A1>—", widget1);
lab1->setFont(QFont("宋体", 15));
lab1->setWordWrap(true);
lab1->adjustSize();
lab1->setMinimumSize(500, 100);
QLabel *lab2 = new QLabel("", widget2);
QStackedLayout *stackedLayout = new QStackedLayout;
stackedLayout->addWidget(widget1);
stackedLayout->addWidget(widget2);
layout->addWidget(listWidget, 2);
layout->addLayout(stackedLayout, 3);
qdialog->setLayout(layout);
QPushButton *button_next = new QPushButton("下一步", qdialog);
button_next->move(568, 400);
QPushButton *button_cancel = new QPushButton("å<>消", qdialog);
button_cancel->move(675, 400);
QObject::connect(listWidget, &QListWidget::currentRowChanged, stackedLayout, &QStackedLayout::setCurrentIndex);
QObject::connect(button_next, &QPushButton::clicked, qdialog, &QDialog::close);
QObject::connect(button_next, &QPushButton::clicked, this, &Work_Project::New_Project_2);
QObject::connect(button_cancel, &QPushButton::clicked, qdialog, &QDialog::close);
qdialog->exec();
}
// æ°å»ºé¡¹ç®2å“<C3A5>应函数(æ°å»ºé¡¹ç®2对è¯<C3A8>框)
void Work_Project::New_Project_2()
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("新建项目");
qdialog->setFixedSize(800,450);
//æ·»åŠ è¡¨æ ¼å¸ƒå±€
QFormLayout* layout = new QFormLayout();
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
edit_uwe_project_path = new QLineEdit();
edit_uwe_project_name = new QLineEdit();
layout->addRow("项目路径:", edit_uwe_project_path);
layout->addRow("æ°å»ºé¡¹ç®å<C2AE><C3A5>ç§°:", edit_uwe_project_name);
// 选择路径按钮
QPushButton *button_work_project_path = new QPushButton(edit_uwe_project_path);
button_work_project_path->setText("......");
button_work_project_path->setCursor(Qt::ArrowCursor);
QWidgetAction* action = new QWidgetAction(edit_uwe_project_path);
action->setDefaultWidget(button_work_project_path);
edit_uwe_project_path->addAction(action, QLineEdit::TrailingPosition);
// å°†å¸ƒå±€æ·»åŠ åˆ°å¯¹è¯<C3A8>框
qdialog->setLayout(layout);
// æ“<C3A6>作按键
QPushButton *button_next = new QPushButton("下一步", qdialog);
button_next->move(568, 400);
QPushButton *button_back = new QPushButton("上一步", qdialog);
button_back->move(675, 400);
// 按键å“<C3A5>应信å<C2A1>·æ§½å‡½æ•°
connect(button_work_project_path, &QPushButton::clicked, [=](){
this->uwe_project_path = QFileDialog::getExistingDirectory(0, "选择目录", "/home/UWE/zj");
edit_uwe_project_path->setText(uwe_project_path);
});
connect(button_next, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_next, &QPushButton::clicked, this, &Work_Project::New_setup_lib_path);
QObject::connect(button_back, &QPushButton::clicked, qdialog, &QDialog::close);
QObject::connect(button_back, &QPushButton::clicked, this, &Work_Project::New_Project_1);
// 显示对è¯<C3A8>框
qdialog->exec();
}
// lib_path setup设置界é<C592>¢
void Work_Project::New_setup_lib_path()
{
// ä¿<C3A4>å­˜UWE项ç®ä¿¡æ<C2A1>¯
uwe_project_name = edit_uwe_project_name->text();
uwe_project_path = edit_uwe_project_path->text();
// æ°å»ºå¯¹è¯<C3A8>框
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("库路径é…<C3A9>ç½®");
qdialog->setFixedSize(800,400);
// æ°å»ºmy_lib_path列表
QListWidget *qlistwidget_lib_path = new QListWidget(qdialog);
qlistwidget_lib_path->resize(600, 350);
// 妿žœlist_lib_pathä¸<C3A4>为空(å<CB86>³ä¸Šä¸€æ­¥é€€åžï¼‰
if (!list_lib_path.isEmpty()){
foreach(QString lib_path, list_lib_path)
qlistwidget_lib_path->addItem(lib_path);
}
// æ·»åŠ æ·»åŠ è·¯å¾„, åˆ é™¤è·¯å¾„ï¼Œä¸‹ä¸€æ­¥ï¼Œä¸Šä¸€æ­¥æŒ‰é”®
QPushButton *button_addpath = new QPushButton("æ·»åŠ è·¯å¾„", qdialog);
button_addpath->move(650, 100);
QPushButton *button_delpath = new QPushButton("åˆ é™¤è·¯å¾„", qdialog);
button_delpath->move(650, 160);
QPushButton *button_next = new QPushButton("下一步", qdialog);
button_next->move(670, 270);
QPushButton *button_previous = new QPushButton("上一步", qdialog);
button_previous->move(670, 310);
// add path按键å“<C3A5>应
connect(button_addpath, &QPushButton::clicked, [=](){
QString lib_path = QFileDialog::getExistingDirectory(0, "选择库路径", "/home/UWE/zj", QFileDialog::ShowDirsOnly);
if (!list_lib_path.contains(lib_path)){
qlistwidget_lib_path->addItem(lib_path);
list_lib_path.append(lib_path);
}
});
// del path按键å“<C3A5>应
connect(button_delpath, &QPushButton::clicked, [=](){
QListWidgetItem* selectedItem = qlistwidget_lib_path->currentItem();
if (selectedItem != nullptr) {
QString lib_path = selectedItem->text();
list_lib_path.removeOne(lib_path);
qlistwidget_lib_path->takeItem(qlistwidget_lib_path->row(selectedItem));
delete selectedItem;
}
});
// next step按键å“<C3A5>应
connect(button_next, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_next, &QPushButton::clicked, this, &Work_Project::New_setup_target_library);
// previous step按键å“<C3A5>应
connect(button_previous, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_previous, &QPushButton::clicked, this, &Work_Project::New_Project_2);
// 显示对è¯<C3A8>框
qdialog->exec();
}
// 从lib_path中æ<C2AD><C3A6>å<EFBFBD>lib 函数
void Work_Project::Extract_lib()
{
// lib_pathä¸<C3A4>为空
if (!list_lib_path.isEmpty()){
// é<><C3A9>历所有lib_path,æ<C592><C3A6>å<EFBFBD>其中的lib
foreach (QString lib_path, list_lib_path){
QDir dir(lib_path);
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
if (fileInfo.isFile()) {
QString fileName = fileInfo.fileName();
if ((list_lib.indexOf(fileName) == -1) && (fileName.endsWith(".db", Qt::CaseInsensitive) || fileName.endsWith(".lib", Qt::CaseInsensitive)))
list_lib.append(fileName);
QString filePath = fileInfo.filePath();
// 处ç<E2809E>†å­<C3A5>ç®å½•
} else if (fileInfo.isDir() && fileInfo.fileName() != "." && fileInfo.fileName() != "..") {
QDir subDir(fileInfo.filePath());
subDir.setFilter(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QFileInfoList subList = subDir.entryInfoList();
for (int j = 0; j < subList.size(); ++j) {
QFileInfo subFileInfo = subList.at(j);
QString fileName = subFileInfo.fileName();
if ((list_lib.indexOf(fileName) == -1) && (fileName.endsWith(".db", Qt::CaseInsensitive) || fileName.endsWith(".lib", Qt::CaseInsensitive)))
list_lib.append(fileName);
}
}
}
}
}
}
// 展示lib 函数
QTableView* Work_Project::Show_lib(QList<QString>& list_lib, QStandardItemModel *model)
{
QTableView *tableView = new QTableView();
int size = list_lib.size();
int remainder = size % 4;
for (int i = 0; i < size-remainder; i=i+4) {
QList<QStandardItem*> rowItems;
rowItems.append(new QStandardItem(list_lib[i]));
rowItems.append(new QStandardItem(list_lib[i+1]));
rowItems.append(new QStandardItem(list_lib[i+2]));
rowItems.append(new QStandardItem(list_lib[i+3]));
model->appendRow(rowItems);
}
QList<QStandardItem*> rowItems;
for (int i = size-remainder; i < size; i++)
rowItems.append(new QStandardItem(list_lib[i]));
model->appendRow(rowItems);
tableView->setModel(model);
tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableView->resizeColumnsToContents();
tableView->resizeRowsToContents();
tableView->setWordWrap(true);
return tableView;
}
// target_library选æ©ç•Œé<C592>¢
void Work_Project::New_setup_target_library()
{
// æ<><C3A6>å<EFBFBD>lib
Extract_lib();
// 展示lib
QStandardItemModel *model = new QStandardItemModel();
QTableView *tableView = Show_lib(list_lib, model);
// 对è¯<C3A8>框å<E280A0>ŠæŒ‰é”®
QDialog *dialog = new QDialog();
dialog->setWindowTitle("target_library选æ©");
dialog->resize(1400, 800);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(tableView);
QHBoxLayout *buttonLayout = new QHBoxLayout();
QPushButton *button_next = new QPushButton("确定");
QPushButton *button_previous = new QPushButton("上一步");
buttonLayout->addWidget(button_next);
buttonLayout->addWidget(button_previous);
layout->addLayout(buttonLayout);
dialog->setLayout(layout);
// å“<C3A5>应函数
connect(button_next, &QPushButton::clicked, dialog, &QDialog::accept);
connect(button_previous, &QPushButton::clicked, dialog, &QDialog::close);
connect(button_previous, &QPushButton::clicked, this, &Work_Project::New_setup_lib_path);
if (dialog->exec() == QDialog::Accepted) {
QItemSelectionModel *selectionModel = tableView->selectionModel();
QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
// iterate over the selected indexes and add their rows to the set
for (const QModelIndex &index : selectedIndexes) {
QString lib = model->data(model->index(index.row(), index.column())).toString();
list_target_lib_selected.append(lib);
}
// è¿å…¥ä¸ä¸€ç•Œé<C592>¢
New_setup_link_library();
}
}
// link_library选æ©ç•Œé<C592>¢
void Work_Project::New_setup_link_library()
{
// 展示lib
QStandardItemModel *model = new QStandardItemModel();
QTableView *tableView = Show_lib(list_lib, model);
// 对è¯<C3A8>框å<E280A0>ŠæŒ‰é”®
QDialog *dialog = new QDialog();
dialog->setWindowTitle("link_library选æ©");
dialog->resize(1400, 800);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(tableView);
QHBoxLayout *buttonLayout = new QHBoxLayout();
QPushButton *button_next = new QPushButton("确定");
QPushButton *button_previous = new QPushButton("上一步");
buttonLayout->addWidget(button_next);
buttonLayout->addWidget(button_previous);
layout->addLayout(buttonLayout);
dialog->setLayout(layout);
// å“<C3A5>应函数
connect(button_next, &QPushButton::clicked, dialog, &QDialog::accept);
connect(button_previous, &QPushButton::clicked, dialog, &QDialog::close);
connect(button_previous, &QPushButton::clicked, this, &Work_Project::New_setup_target_library);
if (dialog->exec() == QDialog::Accepted) {
QItemSelectionModel *selectionModel = tableView->selectionModel();
QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
// iterate over the selected indexes and add their rows to the set
for (const QModelIndex &index : selectedIndexes) {
QString lib = model->data(model->index(index.row(), index.column())).toString();
list_link_lib_selected.append(lib);
}
// è¿å…¥ä¸ä¸€ç•Œé<C592>¢
Src_Project_Environment_set();
}
}
// 芯片环境设置å“<C3A5>应函数
void Work_Project::Src_Project_Environment_set()
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("芯片项目环境设置");
qdialog->setFixedSize(800, 450);
//输入框å<E280A0>Šå…¶æŒ‰é®
QFormLayout *layout = new QFormLayout;
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
edit_src_project_path = new QLineEdit;
edit_src_path = new QLineEdit;
layout->addRow("芯片项目路径:", edit_src_project_path);
layout->addRow("代ç <20>路径", edit_src_path);
QPushButton *button_src_project_path = new QPushButton(edit_src_project_path);
QPushButton *button_src_path = new QPushButton(edit_src_path);
button_src_project_path->setText("..."); button_src_path->setText("...");
button_src_project_path->setCursor(Qt::ArrowCursor); button_src_path->setCursor(Qt::ArrowCursor);
QWidgetAction *action_Project_path = new QWidgetAction(edit_src_project_path), *action_src_path = new QWidgetAction(edit_src_path);
action_Project_path->setDefaultWidget(button_src_project_path); action_src_path->setDefaultWidget(button_src_path);
edit_src_project_path->addAction(action_Project_path, QLineEdit::TrailingPosition); edit_src_path->addAction(action_src_path, QLineEdit::TrailingPosition);
qdialog->setLayout(layout);
//å<>•ç¬æŒ‰é®
QPushButton *button_determine = new QPushButton("确定", qdialog), *button_back = new QPushButton("上一步", qdialog);
button_determine->move(568, 400); button_back->move(675, 400);
//按钮对应槽函数
connect(button_src_project_path, &QPushButton::clicked, [=](){
this->src_project_path = QFileDialog::getExistingDirectory(0, "选择目录", "/home/UWE/zj");
edit_src_project_path->setText(src_project_path);
});
connect(button_src_path, &QPushButton::clicked, [=](){
src_path = QFileDialog::getExistingDirectory(0, "选择目录", "/home/UWE/zj");
edit_src_path->setText(src_path);
});
connect(button_determine, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_determine, &QPushButton::clicked, this, &Work_Project::Src_Project_Environment_set_Determine);
connect(button_back, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_back, &QPushButton::clicked, this, &Work_Project::New_setup_link_library);
qdialog->exec();
}
// 芯片项ç®çŽ¯å¢ƒé…<C3A9>置确定å“<C3A5>应函数
void Work_Project::Src_Project_Environment_set_Determine()
{
src_project_path = edit_src_project_path->text();
src_path = edit_src_path->text();
// module_name = edit_module_name->text();
// 生æˆ<C3A6>工作项ç®å¯¹åº”æ‡ä»¶å¤¹
string str_work_project_path = uwe_project_path.toStdString(), str_work_project_name = uwe_project_name.toStdString();
chdir(str_work_project_path.data());
mkdir(str_work_project_name.data(), 0755);
str_work_project_path += '/' + str_work_project_name;
chdir(str_work_project_path.data());
uwe_project_path = QString::fromStdString(str_work_project_path);
qDebug() << uwe_project_path;
// ä¿<C3A4>å­˜é…<C3A9>置信æ<C2A1>¯
Generate_UWE_Work_config();
// è®¾ç½®æ ‘å½¢æ–‡ä»¶åˆ—è¡¨
this->father->model_file = new QFileSystemModel;
this->father->model_file->setRootPath(uwe_project_path);
this->father->ui->treeView_file->setModel(this->father->model_file);
this->father->ui->treeView_file->setRootIndex(this->father->model_file->index(uwe_project_path));
this->father->ui->treeView_file->setHeaderHidden(true);
this->father->ui->treeView_file->setColumnHidden(1, true);
this->father->ui->treeView_file->setColumnHidden(2, true);
this->father->ui->treeView_file->setColumnHidden(3, true);
connect(this->father->ui->treeView_file, &QTreeView::clicked, this->father, &MainWindow::TreeClicked);
// 终端è¿å…¥é¡¹ç®æ‡ä»¶å¤¹ï¼Œé“¾æŽ¥src代ç <20>æ‡ä»¶å¤¹
string ln_cmd = " ln -s " + this->src_path.toStdString() + ' ' + "./src"; ln_cmd += "\nln -s /home/UWE/zj/tmp/Scripts ./Scripts";
string cmd_1 = "cd "+str_work_project_path+'\n' + "pwd\n" + ln_cmd+'\n';
this->father->m_process_bash->write(cmd_1.data());
// 生æˆ<C3A6>执行所需tclæ‡ä»¶
ofstream out1("ProjectPathSetting.tcl", ios::out);
out1 << "set PROJECTPATH " << this->src_project_path.toStdString() << "\n" << "puts ${PROJECTPATH}";
out1.close();
// make Prepare的一系列æ“<C3A6>作
string cmd_2 = "echo 'ProjectPathSetting.tcl is generated successfully!\n./src soft link is created.'\n";
string cmd_cp = "cp -r /home/UWE/zj/tmp/Template/* ./ \ntouch tmp.log \necho 'copy files in Template here.' \ncp -r /home/UWE/zj/tmp/Makefile ./ \n"
"cp -r /home/UWE/zj/test_1/syn_main.tcl ./ \n";
string cmd_flist = "filelistpath=`find ./src/ -maxdepth 1 -name '*flist*' -type f` \nfilelistname=${filelistpath#*src/} \necho '`include \"./\"' > ./dc.work/filelist.v \n";
string cmd_incdir = "incdirlistpath=`find ./src/ -maxdepth 1 -name '*incdir*' -type f` \nincdirlistname=${incdirlistpath#*src/} \necho -f ./src/$incdirlistname \ > ./nc.work/sim_filelist.f \n";
string cmd_nc = "echo '-f ./src/'$filelistname'' \ >> ./nc.work/sim_filelist.f \necho \" \" >> ./nc.work/sim_filelist.f \necho //Add simulation files bellow >> ./nc.work/sim_filelist.f \n";
string cmd_mv = "mv ./spyglass.work/demo.prj ./spyglass.work/"; cmd_mv += this->module_name.toStdString(); cmd_mv += ".prj \n";
cmd_mv += "mv ./spyglass.work/waiver/demo.awl ./spyglass.work/waiver/"+this->module_name.toStdString()+".awl\n";
cmd_2 += cmd_cp + cmd_flist + cmd_incdir + cmd_nc + cmd_mv;
//cout << cmd_2;
this->father->m_process_bash->write(cmd_2.data());
// 生æˆ<C3A6>synopsys_dc.setupæ‡ä»¶
Generate_Setup_File();
}
// 生æˆ<C3A6>工作项ç®é…<C3A9>ç½®æ‡ä»¶
void Work_Project::Generate_UWE_Work_config()
{
ofstream out("UWE_Project_config", ios::out);
out << "uwe_project_path = " << uwe_project_path.toStdString() << endl;
out << "uwe_project_name = " << uwe_project_name.toStdString() << endl;
out << "src_project_path = " << src_project_path.toStdString() << endl;
out << "src_path = " << src_path.toStdString() << endl;
out.close();
}
// 生æˆ<C3A6>setupæ‡ä»¶
void Work_Project::Generate_Setup_File()
{
// é…<C3A9>ç½®setup默认值
edit_designer = new QLineEdit(); edit_designer->setText("{c64 group}");
edit_company = new QLineEdit(); edit_company->setText("{nudt c64}");
edit_synthetic_library = new QLineEdit(); edit_synthetic_library->setText("{dw_foundation.sldb}");
edit_target_library = new QLineEdit();
edit_link_library = new QLineEdit();
edit_symbol_library=new QLineEdit(); edit_symbol_library->setText("{dw_foundation.sldb}");
edit_cache_write=new QLineEdit(); edit_cache_write->setText("./cache");
edit_cache_read=new QLineEdit(); edit_cache_read->setText("$cache_write");
edit_my_lib_path=new QLineEdit();
edit_search_path=new QLineEdit(); edit_search_path->setText("$search_path $my_lib_path ");
edit_suppress_message=new QLineEdit(); edit_suppress_message->setText("{UID-401}");
edit_define_design_lib=new QLineEdit(); edit_define_design_lib->setText("-path ./analyzed");
edit_view_script_submenu_items=new QLineEdit(); edit_view_script_submenu_items->setText("{\"Clean Sweep" "remove_design -design\"}");
// 生æˆ<C3A6>synopsys_dc.setupæ‡ä»¶
ofstream out_setup("synopsys_dc.setup", ios::out);
out_setup << "set designer " << this->edit_designer->text().toStdString() << '\n';
out_setup << "set company " << this->edit_company->text().toStdString() << '\n';
out_setup << "set synthetic_library " << this->edit_synthetic_library->text().toStdString() << '\n';
out_setup << "set target_library {";
for (int i = 0; i < list_target_lib_selected.size(); i++){
out_setup << list_target_lib_selected.at(i).toStdString() << ' ';
} out_setup << '}' << endl;
out_setup << "set link_library {";
for (int i = 0; i < list_link_lib_selected.size(); i++){
out_setup << list_link_lib_selected.at(i).toStdString() << ' ';
} out_setup << '}' << endl;
out_setup << "set symbol_library " << this->edit_symbol_library->text().toStdString() << '\n';
out_setup << "set cache_write " << this->edit_cache_write->text().toStdString() << '\n';
out_setup << "set cache_read $cache_write\n";
out_setup << "set my_lib_path \" ../ \\n ./ \\n";
for (int i = 0; i < list_lib_path.size()-1; i++){
out_setup << list_lib_path.at(i).toStdString() << " \\\t";
} out_setup << list_lib_path.at(list_lib_path.size()-1).toStdString() << " \"" << endl;
out_setup << "set search_path " << this->edit_search_path->text().toStdString() << '\n';
out_setup << "suppress_message " << this->edit_suppress_message->text().toStdString() << '\n';
out_setup << "define_design_lib DEFAULT -path " << this->edit_define_design_lib->text().toStdString() << '\n';
out_setup << "set view_script_submenu_items " << this->edit_view_script_submenu_items->text().toStdString() << '\n';
out_setup.close();
}
// æ ¹æ<C2B9>®é…<C3A9>ç½®æ‡ä»¶èŽ·å<C2B7>工作项ç®é…<C3A9>ç½®
void Work_Project::Get_Work_config()
{
ifstream in("UWE_Project_config", ios::in);
string str;
in >> str >> str >> str;
in >> str >> str >> str; uwe_project_name = QString::fromStdString(str);
in >> str >> str >> str; src_project_path = QString::fromStdString(str);
in >> str >> str >> str; src_path = QString::fromStdString(str);
in >> str >> str >> str; module_name = QString::fromStdString(str);
in.close();
}
// 获å<C2B7>当å‰<C3A5>系统时间
string get_current_date()
{
time_t timeReal;
time(&timeReal);
timeReal = timeReal + 8*3600;
tm* t = gmtime(&timeReal);
string str = to_string(t->tm_year+1900) + '_' + to_string(t->tm_mon+1)+to_string(t->tm_mday) + '_' + to_string(t->tm_hour)+to_string(t->tm_min);
return str;
}
// ç‚¹å‡»æ ‘å½¢æ–‡ä»¶åˆ—è¡¨å±•ç¤ºæ–‡æœ¬å†…å®¹
void MainWindow::TreeClicked(const QModelIndex &index)
{
ui->dockWidget_src_syn->show();
QString context, file_name = model_file->fileName(index);
QString path = model_file->filePath(index);
QFile file(path);
file.open(QFile::ReadOnly | QFile::Text);
while (!file.atEnd()) {
QByteArray line = file.readLine();
QString str(line);
context.append(str);
}
if (!context.isEmpty()){
QTextEdit *textEdit_src = new QTextEdit;
textEdit_src->setText(context);
textEdit_src->setFont(QFont("Consolas", 12));
ui->tabWidget_src_syn->addTab(textEdit_src, file_name);
ui->tabWidget_src_syn->setCurrentWidget(textEdit_src);
}
ui->dockWidget_src_syn->raise();
}
// 终端输出内容å“<C3A5>应函数
void MainWindow::readBashStandardOutputInfo()
{
QByteArray cmdout = m_process_bash->readAllStandardOutput();
// 综å<C2BC>ˆå®Œæˆ<C3A6>å“<C3A5>应函数
if (cmdout.indexOf("Thank you...") != -1){
qDebug() << "syn sucessfully!" << endl;
QStandardItem *item = model_module->item(row_current_module_treeview, 1);
item->setIcon(style()->standardIcon(QStyle::SP_DialogApplyButton));
}
if (!cmdout.isEmpty()){
ui->textEdit_cmd_syn->append(QString::fromLocal8Bit(cmdout));
}
QScrollBar *scroll = ui->textEdit_cmd_syn->verticalScrollBar();
scroll->setSliderPosition(scroll->maximum());
}
// 终端输出错误信æ<C2A1>¯å“<C3A5>应函数
void MainWindow::readBashStandardErrorInfo()
{
QByteArray cmdout = m_process_bash->readAllStandardError();
if (!cmdout.isEmpty()){
ui->textEdit_cmd_syn->append(QString::fromLocal8Bit(cmdout));
}
QScrollBar *scroll = ui->textEdit_cmd_syn->verticalScrollBar();
scroll->setSliderPosition(scroll->maximum());
}
// 字符串å<C2B2>˜é‡<C3A9>æ¿æ<C2BF>¢
void MainWindow::String_Replace(string &str, string variate_key)
{
string variate_value = this->variate_map->get_value(variate_key);
int variate_size = variate_key.size();
while (str.find(variate_key) != string::npos)
str = str.replace(str.find(variate_key), variate_size, variate_value);
}
// 生æˆ<C3A6>é…<C3A9>ç½®æ‡ä»¶
void Variate_Map::Generate_Parameter_File()
{
ofstream out("parameter.tcl", ios::out);
for (auto i : mapper)
out << "set " << i.first << ' ' << i.second << endl;
out.close();
}
// ä¿<C3A4>å­˜å<CB9C>æ•°é…<C3A9>ç½®
void MainWindow::on_buttonBox_Save_accepted()
{
string FLOW_value = (ui->radioButton_FLOW_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("FLOW", FLOW_value);
string LOADDDC_value = (ui->radioButton_LOADDDC_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("LOADDDC", LOADDDC_value);
string CHECKCODE_value = (ui->radioButton_CHECKCODE_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("CHECKCODE", CHECKCODE_value);
string DEBUGSDC_value = (ui->radioButton_DEBUGSDC_TRUE->isChecked()) ? "TRUE" : "FALSE";
variate_map->add_variate("DEBUGSDC", DEBUGSDC_value);
variate_map->Generate_Parameter_File();
ui->textEdit_cmd_syn->append("parameter.tcl has been generated sucessfully!\n");
}
// è¿<C3A8>行综å<C2BC>ˆæŒ‰é®å“<C3A5>应函数
void MainWindow::on_pushButton_runsyn_clicked()
{
Parameter_Config();
string syn_cmd = "dc_shell-t -f TCLPATH/syn_main.tcl | tee dc.log DCWORK/Logs/dc_current_date.log \nmake c_R0 \n";
this->String_Replace(syn_cmd, "TCLPATH");
this->String_Replace(syn_cmd, "DCWORK");
this->String_Replace(syn_cmd, "current_date");
cout << syn_cmd << endl;
this->ui->textEdit_cmd_syn->append("run syn \n");
this->m_process_bash->write(syn_cmd.data());
}
// 代ç <20>窗å<E28094>£å…³é—­å“<C3A5>应函数
void MainWindow::on_tabWidget_src_tabCloseRequested(int index)
{
ui->tabWidget_src_syn->removeTab(index);
}
// R0_check result按é®å“<C3A5>应函数
void MainWindow::on_pushButton_result_clicked()
{
ktextEdit = new KTextEdit(dockWidget_report_syn);
//获å<C2B7>result内容
QString result_path = QDir::currentPath() + "/R0_check.result";
QFile file(result_path);
QString context;
file.open(QFile::ReadOnly | QFile::Text);
while (!file.atEnd()) {
QByteArray line = file.readLine();
QString str(line);
context.append(str);
}
ktextEdit->SetText(context);
//è®¾ç½®æ–‡æœ¬æ¸¸æ ‡åˆ°æ–‡æœ¬å¤´
QTextCursor cursor = ktextEdit->textCursor();
cursor.movePosition(QTextCursor::Start);
ktextEdit->setTextCursor(cursor);
dockWidget_report_syn->setWidget(ktextEdit);
dockWidget_report_syn->raise();
}
//终端è¿<C3A8>行按é®å“<C3A5>应函数
void MainWindow::on_pushButton_run_cmd_clicked()
{
QString strCmd = ui->lineEdit_syn->text();
ui->textEdit_cmd_syn->append("Linux:~$ " + strCmd);
m_process_bash->write(ui->lineEdit_syn->text().toLocal8Bit() + '\n');
ui->lineEdit_syn->clear();
}
// New noduleå“<C3A5>应函数
void MainWindow::New_module()
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("module name");
qdialog->setFixedSize(500, 50);
//输入框å<E280A0>Šå…¶æŒ‰é®
QFormLayout *layout = new QFormLayout;
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
QLineEdit *edit_module_name = new QLineEdit;
layout->addRow("module name:", edit_module_name);
qdialog->setLayout(layout);
//å<>•ç¬æŒ‰é®
QPushButton *button_determine = new QPushButton("确定", qdialog);
button_determine->move(300, 100);
//按钮对应槽函数
connect(button_determine, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_determine, &QPushButton::clicked, this, [=]{
QList<QStandardItem *> items;
items.append(new QStandardItem(edit_module_name->text()));
// childItem->setIcon(style()->standardIcon(QStyle::SP_DialogApplyButton));
QStandardItem *Item_state = new QStandardItem();
Item_state->setIcon(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
items.append(Item_state);
model_module->appendRow(items);
row_current_module_treeview++;
this->work_project->module_name = edit_module_name->text();
ofstream out2("setModuleName.tcl", ios::out);
out2 << "set Design " << edit_module_name->text().toStdString() << "\n" << "puts ${Design}";
out2.close();
});
qdialog->exec();
}
// code_checkå“<C3A5>应函数
void MainWindow::on_pushButton_code_check_clicked()
{
string cmd_code_check_date = "c_date=`date +%Y_%m%d_%H%M` \n";
string cmd_code_check_filelist = "echo 'Checking filelist.v ...' > code_check.result \n"
"filelistpath=`find ./src/ -name '*flist*' -type f` \n"
"echo filelistpath: $filelistpath \n"
"for file in $filelistpath; \n"
"do filelistname+=${file#*src/}' ' \n done \n"
"echo filelistname: $filelistname \n"
"if [ -z \"$filelistname\" ]; \n then echo \"Error: Filelist is not exist or the name is not matching '*_filelist' format. exit.\" "
"echo \"Error: Filelist is not exist or the name is not matching '*_filelist' format. exit.\" >> code_check.result exit \n fi \n"
"SIMEMU=`grep -n \"_SIMULATION_\|_EMULATION_\" $filelistpath` \n"
"if [ -z \"$SIMEMU\" ]; \n then echo \"Info: There are no _SIMULATION_ or _EMULATION_ definition in file $filelistname .\" \n fi \n";
string cmd_code_check_src = "echo " " >> code_check.result \n"
"echo \"Checking 'timescale' in *.v files ... (Warning)\" >> code_check.result \n"
"find ./src/ -name \"*.v\" | xargs grep -n 'timescale' >> code_check.result \n"
"echo " " >> code_check.result \n"
"echo \"Checking Chinese words in *.v files .. (Warning).\" >> code_check.result \n"
"find ./src/ -name \"*.v\" | xargs grep -nP '[\p{Han}]' >> code_check.result \n"
"echo " " >> code_check.result \n"
"echo \"Checking Synophsis key words in *.v files ... (Info)\" >> code_check.result \n"
"find ./src/ -name \"*.v\" | xargs grep -n 'full_case' >> code_check.result \n"
"find ./src/ -name \"*.v\" | xargs grep -n 'parallel_case' >> code_check.result \n"
"find ./src/ -name \"*.v\" | xargs grep -n 'translate on' >> code_check.result \n"
"find ./src/ -name \"*.v\" | xargs grep -n 'translate off' >> code_check.result \n";
string cmd_code_check_author = "echo " " >> code_check.result \n"
"echo \"Checking author notes in *.v files .. (Warning).\" >> code_check.result \n"
"for file in `find ./src/ -regex \".*\.vh\|.*\.v\|.*\.h\"` \n"
"do authorname=`grep -n \"author\|Author\|AUTHOR\|Generated by\|created\" $file` \n"
"if [ -z \"$authorname\" ]; \n "
"then echo \"Warning: Author notes is not exist or the name is not matching 'author|Author|AUTHOR|Generated by|created' format in file $file\" \n"
"echo \"Warning: Author notes is not exist or the name is not matching 'author|Author|AUTHOR|Generated by|created' format in file $file\" >> code_check.result \n"
"fi \n done \n";
string cmd_code_check_xrun_log = "echo \" \" >> code_check.result \n"
"echo \"Checking NC log in xrun.log ... \" >> code_check.result \n"
"find . -maxdepth 1 -name \"xrun.log\" | xargs grep \"*E\" >> code_check.result \n"
"find . -maxdepth 1 -name \"xrun.log\" | xargs grep \"*W,RECOME\" >> code_check.result \n"
"find . -maxdepth 1 -name \"xrun.log\" | xargs grep \"*W,CUVWSP\" >> code_check.result \n"
"find . -maxdepth 1 -name \"xrun.log\" | xargs grep \"*W,CUVWSI\" >> code_check.result \n"
"find . -maxdepth 1 -name \"xrun.log\" | xargs grep \"*W,CUVMPW\" >> code_check.result \n";
string cmd_code_check_dc_log = "echo \" \" >> code_check.result \n"
"echo \"Checking DC dc.log ...\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"Error:\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"Latch \" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"Timing loop\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"FFGEN\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"have the default net type\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"unresolved\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"unmapped\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"(LINT-5)\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"sensiti\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"MV-038\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"MV-039\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"MV-513\" >> code_check.result \n"
"find . -maxdepth 1 -name \"dc.log\" | xargs grep \"MV-514\" >> code_check.result \n";
string cmd_code_check_copy = "cp code_check.result Logs/code_check_${c_date}.result \n";
string cmd_code_check = cmd_code_check_date + cmd_code_check_filelist + cmd_code_check_src + cmd_code_check_author + cmd_code_check_xrun_log + cmd_code_check_dc_log + cmd_code_check_copy;
this->ui->textEdit_cmd_syn->append("Beginning check code \n");
this->m_process_bash->write(cmd_code_check.data());
}

@ -25,17 +25,23 @@ DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += c++11 CONFIG += c++11
SOURCES += \ SOURCES += \
main.cpp \ highlighter.cpp \
mainwindow.cpp \
ktextedit.cpp \ ktextedit.cpp \
highlighter.cpp main.cpp \
mainwindow.cpp \
mytreeview.cpp
HEADERS += \ HEADERS += \
mainwindow.h \ highlighter.h \
highlighter.h mainwindow.h \
mytreeview.h
FORMS += \ FORMS += \
mainwindow.ui mainwindow.ui
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2023-03-24T20:38:16. --> <!-- Written by QtCreator 4.8.2, 2023-06-07T11:08:23. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@ -69,7 +69,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/UWE/jhq/Qt/Project/build-test-JHQ-Desktop_Qt_5_12_2_GCC_64bit-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/UWE/zj/Qt/Project/build-test-ZJ-Desktop_Qt_5_12_2_GCC_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -125,7 +125,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/UWE/jhq/Qt/Project/build-test-JHQ-Desktop_Qt_5_12_2_GCC_64bit-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/UWE/zj/Qt/Project/build-test-ZJ-Desktop_Qt_5_12_2_GCC_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -181,7 +181,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/UWE/jhq/Qt/Project/build-test-JHQ-Desktop_Qt_5_12_2_GCC_64bit-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/UWE/zj/Qt/Project/build-test-ZJ-Desktop_Qt_5_12_2_GCC_64bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -293,10 +293,10 @@
</valuelist> </valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">test-JHQ</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">test-ZJ</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/UWE/jhq/Qt/Project/UWE/test-JHQ.pro</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/UWE/zj/Qt/Project/UWE/test-ZJ.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">test-JHQ.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">test-ZJ.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value> <value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
@ -306,7 +306,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value> <value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/UWE/jhq/Qt/Project/build-test-JHQ-Desktop_Qt_5_12_2_GCC_64bit-Debug</value> <value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/UWE/zj/Qt/Project/build-test-ZJ-Desktop_Qt_5_12_2_GCC_64bit-Debug</value>
</valuemap> </valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap> </valuemap>

@ -0,0 +1,53 @@
#ifndef _FINDDIALOG_H_
#define _FINDDIALOG_H_
#include <QDialog>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QCheckBox>
#include <QGroupBox>
#include <QPlainTextEdit>
#include <QPointer>
class FindDialog : public QDialog
{
Q_OBJECT
protected:
QGroupBox m_radioGrpBx;
QGridLayout m_layout;
QHBoxLayout m_hbLayout;
QLabel m_findLbl;
QLineEdit m_findEdit;
QPushButton m_findBtn;
QPushButton m_closeBtn;
QCheckBox m_matchChkBx;
QRadioButton m_forwardBtn;
QRadioButton m_backwardBtn;
QPointer<QPlainTextEdit> m_pText; // FindDialog ¾ÛºÏʹÓà QPlainTextEdit
QSharedPointer<FindDialog> m_pFindDlg;
QTextCharFormat m_format;
void initControl();
void connectSlot();
protected slots:
void onFindClicked();
void onCloseClicked();
public:
explicit FindDialog(QWidget* parent = 0, QPlainTextEdit* pText = 0);
void setPlainTextEdit(QPlainTextEdit* pText);
void highlightText(QPlainTextEdit* pText);
QPlainTextEdit* getPlainTextEdit();
bool event(QEvent* evt);
};
#endif // _FINDDIALOG_H_

@ -0,0 +1,11 @@
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
class finddialog
{
public:
finddialog();
};
#endif // FINDDIALOG_H

@ -0,0 +1,94 @@
#include "highlighter.h"
normol_HighLighter::normol_HighLighter(QTextDocument *parent) :
QSyntaxHighlighter(parent)
{
/*m_moduleFormat.setForeground(Qt::blue);
m_taskFormat.setForeground(Qt::red);
m_functionFormat.setForeground(Qt::darkGreen);
m_assertFormat.setForeground(Qt::magenta);*/
// HighlightRule num_rule;
// num_rule.pattern.setPattern("[0-9]{1,1}");
// num_rule.format.setForeground(QColor(144,238,144));
// highlightrules.append(num_rule);
normol_HighLighteRule key_rule;
key_rule.pattern.setPattern("\\b(char|string|int|double|bool|void|true|false)\\b");
key_rule.format.setForeground(QColor(30,144,255));
highlightrules.append(key_rule);
normol_HighLighteRule code_rule;
code_rule.pattern.setPattern("\\b(if|while|for|else|break|return|switch|case)\\b");
code_rule.format.setForeground(QColor(186,85,211));
highlightrules.append(code_rule);
}
/*void normol_HighLighter::setVerilogKeywordFormat(QStringList keywordList, QTextCharFormat format)
{
foreach (const QString &keyword, keywordList) {
QRegularExpression expression("\\b" + keyword + "\\b");
QRegularExpressionMatchIterator itr = expression.globalMatch(currentBlock().text());
while (itr.hasNext()) {
QRegularExpressionMatch match = itr.next();
setFormat(match.capturedStart(), match.capturedLength(), format);
}
}
}*/
void normol_HighLighter::highlightBlock(const QString &text)
{
for(const normol_HighLighteRule &rule : highlightrules){
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
while(index>=0){
int length = expression.matchedLength();
setFormat(index,length,rule.format);
index = expression.indexIn(text,index+length);}
}
}
///////////////////////////////////
SV_HighLighter::SV_HighLighter(QTextDocument *parent) :
QSyntaxHighlighter(parent)
{
SV_HighLighteRule key_rule;
key_rule.pattern.setPattern("\\b(class|virtual|function|typedef|interface|modport|new|this|override|final)\\b");
key_rule.format.setForeground(QColor(30,144,255));
highlightrules.append(key_rule);
}
void SV_HighLighter::highlightBlock(const QString &text)
{
for(const SV_HighLighteRule &rule : highlightrules){
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
while(index>=0){
int length = expression.matchedLength();
setFormat(index,length,rule.format);
index = expression.indexIn(text,index+length);}
}
}
////////////////////////////////////
V_HighLighter::V_HighLighter(QTextDocument *parent) :
QSyntaxHighlighter(parent)
{
V_HighLighteRule key_rule;
key_rule.pattern.setPattern("\\b(module|endmodule|input|output|wire|reg|assign|always|initial|if|else)\\b");
key_rule.format.setForeground(QColor(30,144,255));
highlightrules.append(key_rule);
}
void V_HighLighter::highlightBlock(const QString &text)
{
for(const V_HighLighteRule &rule : highlightrules){
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
while(index>=0){
int length = expression.matchedLength();
setFormat(index,length,rule.format);
index = expression.indexIn(text,index+length);}
}
}

@ -0,0 +1,58 @@
#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H
#include<QSyntaxHighlighter>
#include<QTextCharFormat>
#include<QTextDocument>
#include<QRegularExpression>
class normol_HighLighter :public QSyntaxHighlighter{
Q_OBJECT
public:
explicit normol_HighLighter(QTextDocument *parent=0);
protected:
void highlightBlock(const QString &text);
private:
/*void setVerilogKeywordFormat(QStringList keywordList, QTextCharFormat format);
QTextCharFormat m_moduleFormat;
QTextCharFormat m_taskFormat;
QTextCharFormat m_functionFormat;
QTextCharFormat m_assertFormat;*/
struct normol_HighLighteRule{
QRegExp pattern;
QTextCharFormat format;
};
QVector<normol_HighLighteRule> highlightrules;
};
class SV_HighLighter : public QSyntaxHighlighter{
Q_OBJECT
public:
explicit SV_HighLighter(QTextDocument *parent=0);
protected:
void highlightBlock(const QString &text);
private:
struct SV_HighLighteRule{
QRegExp pattern;
QTextCharFormat format;
};
QVector<SV_HighLighteRule> highlightrules;
};
class V_HighLighter : public QSyntaxHighlighter{
Q_OBJECT
public:
explicit V_HighLighter(QTextDocument *parent=0);
protected:
void highlightBlock(const QString &text);
private:
struct V_HighLighteRule{
QRegExp pattern;
QTextCharFormat format;
};
QVector<V_HighLighteRule> highlightrules;
};
#endif // HIGHLIGHTER_H

@ -1,4 +1,4 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QPushButton> #include <QPushButton>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,237 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMenuBar>
#include <QDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QFileSystemModel>
#include <QProcess>
#include <map>
#include <string>
#include <fstream>
#include <QObject>
#include <QTextEdit>
#include <QTreeView>
#include <QStandardItemModel>
#include <QTableView>
using namespace std;
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class Variate_Map;
class Work_Project;
class KTextEdit;
class normol_HighLighter;
class SV_HighLighter;
class V_HighLighter;
//
class MainWindow : public QMainWindow
{
Q_OBJECT
private:
normol_HighLighter *n_highlighter;
SV_HighLighter *sv_highlighter;
V_HighLighter *v_highlighter;
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void String_Replace(string& str, string variate);
void keyPressEvent(QKeyEvent *k);
void New_Project();
// 菜单栏
QMenuBar *pMenuBar;
QMenu *pMenu1;
QMenu *pMenu2;
QMenu *pMenu3;
QMenu *pMenu4;
QMenu *pMenu5;
//pmenu1
QAction *pAction_newproject;
QAction *pAction_openproject;
QAction *pAction_save;
QAction *pAction_openrecentproject;
QAction *pAction_print;
QAction *pAction_exit;
//pmenu2
QAction *pAction_parameter_config;
QAction *pAction_startdebug;
QAction *pAction_stopdebug;
QAction *pAction_restartdebug;
QAction *pAction_skip;
QAction *pAction_continue;
QAction *pAction_syn;
//pmenu3
QAction *pAction_revoke;
QAction *pAction_restore;
QAction *pAction_shear;
QAction *pAction_copy;
QAction *pAction_paste;
QAction *pAction_seek;
QAction *pAction_replace;
//pmenu4
QAction *pAction_changeappearance;
QAction *pAction_reportdata;
QAction *pAction_error;
QAction *pAction_control;
//pmeun5
QAction *pAction_alltutorial;
QAction *pAction_fasttutorial;
QAction *pAction_about;
QAction *pAction_search;
QFileSystemModel *model_file;
Ui::MainWindow *ui;
// bash窗口
QProcess *m_process_bash[4];
Variate_Map *variate_map;
QDockWidget *dockWidget_report_check, *dockWidget_module;
KTextEdit *ktextEdit;
// flow界面窗口
QMainWindow *qmainwindow_precheck, *qmainwindow_syn, *qmainwindow_pt, *qmainwindow_fm, *qmainwindow_design_check;
// flag set
bool ready_syn, ready_r0_result, ready_setup, ready_prepare;
// 工作项目
Work_Project *work_project;
// 存储work_flow对象的列表
QTabWidget *tabwidget_flow_src_list[4];
QDockWidget *dockwidget_flow_src_list[4];
public slots:
//????????
//????????
void OpenProject();
void TreeClicked(const QModelIndex &index);
void readBashStandardOutputInfo_precheck();
void readBashStandardErrorInfo_precheck();
void readBashStandardOutputInfo_syn();
void readBashStandardErrorInfo_syn();
void readBashStandardOutputInfo_pt();
void readBashStandardErrorInfo_pt();
void readBashStandardOutputInfo_fm();
void readBashStandardErrorInfo_fm();
// void Parameter_Config();
private slots:
void find();
void on_buttonBox_Save_accepted();
void on_pushButton_runsyn_clicked();
void on_pushButton_result_clicked();
// void on_pushButton_run_cmd_clicked();
// void on_treeView_module_clicked(const QModelIndex &index);
void on_pushButton_code_check_clicked();
void on_pushButton_run_cmd_syn_clicked();
// void on_tabWidget_src_syn_tabCloseRequested(int index);
void on_pushButton_run_cmd_pt_clicked();
// void on_tabWidget_src_pt_tabCloseRequested(int index);
void on_buttonBox_Save_pt_accepted();
void on_pushButton_runpt_clicked();
void on_pushButton_runformality_clicked();
void on_pushButton_run_cmd_fm_clicked();
void on_tabWidget_src_tabCloseRequested(int index);
void on_pushButton_run_cmd_precheck_clicked();
void on_pushButton_result_design_check_clicked();
void on_pushButton_sg_clicked();
};
//????map?
class Variate_Map
{
public:
Variate_Map(){}
~Variate_Map(){}
string get_value(string str){return mapper[str];}
int add_variate(string key, string value){mapper[key] = value;}
bool alter_variate(string key, string value)
{
if (mapper.find(key) == mapper.end())
return false;
else{
mapper[key] = value;
return true;
}
}
void Generate_Parameter_File();
private:
map<string, string> mapper;
};
// 工作项目类
class Work_Project : public QObject
{
Q_OBJECT
public:
MainWindow *father;
QLineEdit *edit_uwe_project_path, *edit_uwe_project_name,
*edit_src_project_path, *edit_src_path, *edit_module_name;
QLineEdit *edit_designer, *edit_company, *edit_synthetic_library,
*edit_target_library, *edit_link_library, *edit_symbol_library, *edit_cache_write,
*edit_cache_read, *edit_my_lib_path, *edit_search_path,
*edit_suppress_message, *edit_define_design_lib , *edit_view_script_submenu_items;
// 判断信号
bool bool_Current_Design_ready;
// 需要存储的变量
QString uwe_project_path, uwe_project_name, src_project_path, src_path, current_module_name;
QList<QString> list_lib_path, list_lib, list_target_lib_selected, list_link_lib_selected;
// int current_module_row;
Work_Project(){}
~Work_Project(){}
void Generate_UWE_Project_config();
void Get_UWE_Project_config();
void Extract_lib();
void Module_Set();
QTableView* Show_lib(QList<QString>& list_lib, QStandardItemModel *model);
public slots:
void New_Project_1();
void New_Project_2();
void New_setup_lib_path();
void New_setup_target_library();
void New_setup_link_library();
void Src_Project_Environment_set();
void Src_Project_Environment_set_Determine();
void Generate_Setup_File();
};
class KTextEdit : public QTextEdit
{
Q_OBJECT
public:
KTextEdit(QWidget *parent = nullptr);
void SetText(const QString &text);
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
QList<QString> clickable_text_list;
QString error_type;
QProcess *m_process_report_man;
QByteArray man_out;
public slots:
void OnCursorMove();
void readBash_manOutputInfo();
};
#endif // MAINWINDOW_H

File diff suppressed because it is too large Load Diff

@ -0,0 +1,236 @@
#include "mytreeview.h"
#include "ui_mainwindow.h"
#include <iostream>
#include <QStandardItemModel>
#include <QDockWidget>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QPushButton>
#include <QDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <iostream>
#include <QMainWindow>
#include "ui_mainwindow.h"
MyTreeView::MyTreeView(QWidget *parent)
: QTreeView(parent)
{
// 初始化
this->model_module = new QStandardItemModel;
cnt_module = 0;
list_actionof_modules = new QList<QAction*>();
map_name_2_item = new std::map<QString, QStandardItem*>();
model_module->setHorizontalHeaderLabels(QStringList()<<"module name"<<"state");
setModel(model_module);
setColumnWidth(0, 200);
setColumnWidth(1, 50);
setContextMenuPolicy(Qt::CustomContextMenu);
setSelectionMode(QAbstractItemView::SingleSelection);
// actions
action_new_module1 = new QAction("new module", this);
action_new_module2 = new QAction("new module", this);
action_del_module = new QAction("del module", this);
// menu_module_blank
menu_module_blank = new QMenu(this);
menu_module_blank->addAction(action_new_module1);
// menu_module_withmodule
menu_module_withmodule = new QMenu(this);
menu_module_withmodule->addAction(action_new_module2);
menu_module_move = menu_module_withmodule->addMenu(tr("move to")); menu_module_move->addAction(new QAction("顶层"));
menu_module_withmodule->addAction(action_del_module);
// 空白处菜单new module信号槽
connect(action_new_module1, &QAction::triggered, this, [=]() {
New_Module(nullptr);
});
// 有module处菜单new module信号槽
connect(action_new_module2, &QAction::triggered, this, [this](){
New_Module(selecteditem);
});
// 有module处菜单move to信号槽
connect(menu_module_move, &QMenu::triggered, this, &MyTreeView::on_MoveMenu_Triggered);
// del module信号槽
connect(action_del_module, &QAction::triggered, this, [this](){
Del_Module(selecteditem);
});
}
// 鼠标点击treeview响应函数
void MyTreeView::mousePressEvent(QMouseEvent *event)
{
QPoint p = event->pos();
QModelIndex index = indexAt(p);
QStandardItemModel *model;
if (event->buttons() & Qt::RightButton){ // 鼠标右键点击
if (!index.isValid()){ // 点击空白处
menu_module_blank->popup(viewport()->mapToGlobal(p));
}
else { // 点击有module处
menu_module_withmodule->popup(viewport()->mapToGlobal(p));
model = qobject_cast<QStandardItemModel *>(this->model());
selecteditem = model->itemFromIndex(index);
}
}
if(!index.isValid())
{
clearSelection(); //实现点空白处取消选择
// if (father->ui->treeView_module->selectionModel())
// father->ui->treeView_module->selectionModel()->clear();
// emit sigPressEmpty();
// return;
}
QTreeView::mousePressEvent(event);
}
// new module响应槽函数
void MyTreeView::New_Module(QStandardItem* selecteditem)
{
QDialog *qdialog = new QDialog;
qdialog->setWindowTitle("module name");
qdialog->setFixedSize(500, 50);
QFormLayout *layout = new QFormLayout;
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
QLineEdit *edit_module_name = new QLineEdit;
layout->addRow("module name:", edit_module_name);
qdialog->setLayout(layout);
QPushButton *button_determine = new QPushButton("确定", qdialog);
button_determine->move(300, 100);
connect(button_determine, &QPushButton::clicked, qdialog, &QDialog::close);
connect(button_determine, &QPushButton::clicked, this, [=]{
QString module_name = edit_module_name->text();
QStandardItem *item_new = new QStandardItem(module_name);
QStandardItem *Item_state = new QStandardItem();
Item_state->setIcon(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
// 直接创建new module
if (selecteditem == nullptr){
QList<QStandardItem *> items;
items.append(item_new);
items.append(Item_state);
model_module->appendRow(items);
}
// 创建子module
else{
int row = selecteditem->rowCount();
selecteditem->setChild(row, 0, item_new);
selecteditem->setChild(row, 1, Item_state);
}
// 添加module信息
map_name_2_item->insert(std::pair<QString, QStandardItem*>(module_name, item_new));
QAction *action_tmp = new QAction(module_name, this); list_actionof_modules->append(action_tmp);
cnt_module++;
// 更新MoveMenu菜单信息
menu_module_move->addAction(action_tmp);
});
qdialog->exec();
}
//
QStandardItem* MyTreeView::Name_get_Item(QString name_module)
{
std::map<QString,QStandardItem*>::iterator it = map_name_2_item->find(name_module);
if (it != map_name_2_item->end()) // 找到
return it->second;
else // 没找到
std::cout << "map中不存在该元素\n";
return nullptr;
}
// move_to菜单列表点击action响应函数 目前还存在的bug父项移到子项下寄
void MyTreeView::on_MoveMenu_Triggered(QAction* action)
{
if (action){
QString father_item_name = action->text();
QString selected_item_name = selecteditem->text();
if (father_item_name == "顶层"){ // 如果移动到顶层
if (selecteditem->parent() == nullptr) // 选中item没有父项
return;
else{ //选中item有原父项
QStandardItem *old_father_item = selecteditem->parent();
QString old_father_item_name = old_father_item->text();
// 移动(重新添加)
model_module->appendRow(old_father_item->takeRow(selecteditem->row()));
}
}
else{ // 不是移动到顶层
// 获取父项item
QStandardItem *fatherItem = Name_get_Item(father_item_name);
if (father_item_name == selected_item_name)
return;
else{
if (selecteditem->parent() == nullptr){ // 选中item没有父项
// 移动(重新添加)
fatherItem->appendRow(model_module->takeRow(selecteditem->row()));
}
else{ //选中item有原父项
QStandardItem *old_father_item = selecteditem->parent();
QString old_father_item_name = old_father_item->text();
if (old_father_item_name == father_item_name) // 新旧父项相同
return;
// 移动(重新添加)
fatherItem->appendRow(old_father_item->takeRow(selecteditem->row()));
}
}
}
}
}
//
void MyTreeView::Add_Module(QString module_name, QStandardItem* father)
{
// 图标item
QStandardItem *Item_state = new QStandardItem();
Item_state->setIcon(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
if (father){
father->setChild(father->rowCount(), 0, new QStandardItem(module_name));
father->setChild(father->rowCount(), 1, Item_state);
}
else {
QList<QStandardItem*> item_row;
item_row.append(new QStandardItem(module_name));
item_row.append(Item_state);
model_module->appendRow(item_row);
}
}
// del module响应函数
void MyTreeView::Del_Module(QStandardItem* selecteditem)
{
// 在model中删除
QStandardItem* parentItem = selecteditem->parent();
if (parentItem){
parentItem->removeRow(selecteditem->row());
}
else{
model_module->removeRow(selecteditem->row());
}
// 获取当前model所有module name将不在其中的action对象删除
QList<QString> list_del_module;
for (int i = 0; i < model_module->rowCount(); ++i) {
QStandardItem* item = model_module->item(i, 0);
if (item) {
QString text = item->text();
list_del_module.append(text);
}
}
foreach(QAction* action, menu_module_move->actions()){
if (!list_del_module.contains(action->text()) && action->text() != "顶层") {
menu_module_move->removeAction(action);
action->deleteLater(); // 删除该QAction对象并释放内存
}
}
}

@ -0,0 +1,47 @@
#ifndef MYTREEVIEW_H
#define MYTREEVIEW_H
#include <QTreeView>
#include <QMouseEvent>
#include "mainwindow.h"
#include <map>
#include <QStandardItem>
//改造QTreeView实现点击空白处时取消选择
class MyTreeView : public QTreeView
{
Q_OBJECT
public:
MainWindow* father = nullptr;
QStandardItemModel* model_module; // module数据模型
QMenu *menu_module_blank, *menu_module_withmodule; // 右键菜单选项
QAction *action_new_module1, *action_new_module2, *action_del_module, *action_move_module; // 动作
// 数据结构
std::map<QString, QStandardItem*> *map_name_2_item; // module名和item对应表
QStandardItem *selecteditem = nullptr; // 当前鼠标选中的item对象
QList<QAction*> *list_actionof_modules; // module对应action列表
int cnt_module; // module计数
QMenu *menu_module_move; // move to菜单
//
MyTreeView(QWidget *parent = Q_NULLPTR);
QStandardItem* Name_get_Item(QString);
void Add_Module(QString, QStandardItem*);
public slots:
void New_Module(QStandardItem*);
void Del_Module(QStandardItem*);
void on_MoveMenu_Triggered(QAction*); // menu按键响应槽函数
signals:
void sigPressEmpty();
protected:
void mousePressEvent ( QMouseEvent * event ) ;
};
#endif

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2023-03-08T20:16:25. --> <!-- Written by QtCreator 4.8.2, 2023-03-10T11:02:24. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@ -295,7 +295,7 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">test</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">test</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">test2</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">test2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/UWE/lky (copy)/Qt/Project/UWE/test.pro</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/UWE/zj/Qt/Project/UWE/test.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">test.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">test.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value> <value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
Loading…
Cancel
Save