Compare commits
No commits in common. "V1.0" and "main2" have entirely different histories.
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/build/*
|
|
||||||
48
Hexes.pro
48
Hexes.pro
@ -1,48 +0,0 @@
|
|||||||
QT += core gui testlib
|
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|
||||||
|
|
||||||
CONFIG += c++17
|
|
||||||
|
|
||||||
# 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 += \
|
|
||||||
blockvalue.cpp \
|
|
||||||
deleteruledialog.cpp \
|
|
||||||
hexeslogger.cpp \
|
|
||||||
hexstream.cpp \
|
|
||||||
hexviewer.cpp \
|
|
||||||
main.cpp \
|
|
||||||
mainwindow.cpp \
|
|
||||||
rule.cpp \
|
|
||||||
ruledialog.cpp \
|
|
||||||
rulepreview.cpp \
|
|
||||||
testhexviewer.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
blockvalue.h \
|
|
||||||
deleteruledialog.h \
|
|
||||||
hexeslogger.h \
|
|
||||||
hexstream.h \
|
|
||||||
hexviewer.h \
|
|
||||||
mainwindow.h \
|
|
||||||
rule.h \
|
|
||||||
ruledialog.h \
|
|
||||||
rulepreview.h \
|
|
||||||
testhexviewer.h
|
|
||||||
|
|
||||||
FORMS += \
|
|
||||||
deleteruledialog.ui \
|
|
||||||
mainwindow.ui \
|
|
||||||
ruledialog.ui \
|
|
||||||
rulepreview.ui
|
|
||||||
|
|
||||||
# Default rules for deployment.
|
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
|
||||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|
||||||
!isEmpty(target.path): INSTALLS += target
|
|
||||||
|
|
||||||
RESOURCES += \
|
|
||||||
Resources.qrc
|
|
||||||
252
Hexes.pro.user
252
Hexes.pro.user
@ -1,252 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE QtCreatorProject>
|
|
||||||
<!-- Written by QtCreator 14.0.0, 2024-10-30T21:06:26. -->
|
|
||||||
<qtcreator>
|
|
||||||
<data>
|
|
||||||
<variable>EnvironmentId</variable>
|
|
||||||
<value type="QByteArray">{199ac760-f7e3-4183-8af2-8f4816c5a2b4}</value>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
|
||||||
<value type="qlonglong">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>
|
|
||||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">1</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="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</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">2</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>
|
|
||||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
|
||||||
<valuemap type="QVariantMap">
|
|
||||||
<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>
|
|
||||||
<value type="bool" key="ClangTools.PreferConfigFile">true</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 6.7.2 MSVC2019 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.7.2 MSVC2019 64bit</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.672.win64_msvc2019_64_kit</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
|
||||||
<value type="int" key="EnableQmlDebugging">1</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Ext\Projects\Qt\Hexes\build\Desktop_Qt_6_7_2_MSVC2019_64bit-Debug</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Ext/Projects/Qt/Hexes/build/Desktop_Qt_6_7_2_MSVC2019_64bit-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="qlonglong" 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="qlonglong" 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"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<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">C:\Ext\Projects\Qt\Hexes\build\Desktop_Qt_6_7_2_MSVC2019_64bit-Release</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Ext/Projects/Qt/Hexes/build/Desktop_Qt_6_7_2_MSVC2019_64bit-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="qlonglong" 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="qlonglong" 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"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<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">C:\Ext\Projects\Qt\Hexes\build\Desktop_Qt_6_7_2_MSVC2019_64bit-Profile</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Ext/Projects/Qt/Hexes/build/Desktop_Qt_6_7_2_MSVC2019_64bit-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">true</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="qlonglong" 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="qlonglong" 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"/>
|
|
||||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
|
||||||
<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="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
|
||||||
<value type="qlonglong" 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="qlonglong" 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>
|
|
||||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
|
||||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
|
||||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
|
||||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
|
||||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph "dwarf,4096" -F 250</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
|
||||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Ext/Projects/Qt/Hexes/Hexes.pro</value>
|
|
||||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Ext/Projects/Qt/Hexes/Hexes.pro</value>
|
|
||||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
|
||||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
|
||||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Ext/Projects/Qt/Hexes/build/Desktop_Qt_6_7_2_MSVC2019_64bit-Release</value>
|
|
||||||
</valuemap>
|
|
||||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
|
||||||
</valuemap>
|
|
||||||
</data>
|
|
||||||
<data>
|
|
||||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
|
||||||
<value type="qlonglong">1</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>
|
|
||||||
674
LICENSE
Normal file
674
LICENSE
Normal file
@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Hexes
|
||||||
|
Hex Editor with rule-based hightlight and parsing for file reverse engineering.
|
||||||
@ -1,11 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/tests">
|
|
||||||
<file>test.zone</file>
|
|
||||||
</qresource>
|
|
||||||
<qresource prefix="/icons">
|
|
||||||
<file>delete.png</file>
|
|
||||||
<file>skip.png</file>
|
|
||||||
<file>general.png</file>
|
|
||||||
<file>repeat.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
190
blockvalue.cpp
190
blockvalue.cpp
@ -1,190 +0,0 @@
|
|||||||
#include "blockvalue.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value default constructor
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue() {
|
|
||||||
pName = "";
|
|
||||||
pBlockType = BLOCK_TYPE_NONE;
|
|
||||||
pData = QVariant::fromValue(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value copy constructor
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const BlockValue &aBlockVal) {
|
|
||||||
pName = aBlockVal.Name();
|
|
||||||
pBlockType = aBlockVal.BlockType();
|
|
||||||
pData = aBlockVal.ToVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_NONE;
|
|
||||||
pData = QVariant::fromValue(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & int8
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, qint8 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_INT8;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & uint8
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, quint8 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_UINT8;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & int16
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, qint16 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_INT16;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & uint16
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, quint16 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_UINT16;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & int32
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, qint32 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_INT32;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & uint32
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, quint32 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_UINT32;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & int64
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, qint64 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_INT64;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value constructor w/ name & uint64
|
|
||||||
*/
|
|
||||||
BlockValue::BlockValue(const QString aName, quint64 aVal) {
|
|
||||||
pName = aName;
|
|
||||||
pBlockType = BLOCK_TYPE_UINT64;
|
|
||||||
pData = QVariant::fromValue(aVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block Value = operator implementation
|
|
||||||
*/
|
|
||||||
BlockValue &BlockValue::operator=(const BlockValue &aBlockVal) {
|
|
||||||
if (this == &aBlockVal) {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBlockType = aBlockVal.BlockType();
|
|
||||||
pName = aBlockVal.Name();
|
|
||||||
pData = aBlockVal.ToVariant();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return Block Value as an integer
|
|
||||||
*/
|
|
||||||
int BlockValue::ToInt() const {
|
|
||||||
switch ((int)pBlockType) {
|
|
||||||
case 0: // BLOCK_TYPE_INT8
|
|
||||||
return static_cast<int>(pData.value<qint8>());
|
|
||||||
break;
|
|
||||||
case 1: // BLOCK_TYPE_UINT8
|
|
||||||
return static_cast<int>(pData.value<quint8>());
|
|
||||||
break;
|
|
||||||
case 2: // BLOCK_TYPE_INT16
|
|
||||||
return static_cast<int>(pData.value<qint16>());
|
|
||||||
break;
|
|
||||||
case 3: // BLOCK_TYPE_UINT16
|
|
||||||
return static_cast<int>(pData.value<quint16>());
|
|
||||||
break;
|
|
||||||
case 4: // BLOCK_TYPE_INT32
|
|
||||||
return static_cast<int>(pData.value<qint32>());
|
|
||||||
break;
|
|
||||||
case 5: // BLOCK_TYPE_UINT32
|
|
||||||
return static_cast<int>(pData.value<quint32>());
|
|
||||||
break;
|
|
||||||
case 6: // BLOCK_TYPE_INT64
|
|
||||||
return static_cast<int>(pData.value<qint64>());
|
|
||||||
break;
|
|
||||||
case 7: // BLOCK_TYPE_UINT64
|
|
||||||
return static_cast<int>(pData.value<quint64>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return Block Value as a string
|
|
||||||
*/
|
|
||||||
QString BlockValue::ToString() const {
|
|
||||||
return QString::number(ToInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set Block Value type (uint8, int16, etc)
|
|
||||||
*/
|
|
||||||
QVariant BlockValue::ToVariant() const {
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set Block Value's name
|
|
||||||
*/
|
|
||||||
void BlockValue::SetName(const QString aName) {
|
|
||||||
pName = aName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns Block Value's name
|
|
||||||
*/
|
|
||||||
QString BlockValue::Name() const {
|
|
||||||
return pName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set Block Balue type (uint8, int16, etc)
|
|
||||||
*/
|
|
||||||
void BlockValue::SetBlockType(BLOCK_TYPE aBlockType) {
|
|
||||||
pBlockType = aBlockType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get Block Balue type (uint8, int16, etc)
|
|
||||||
*/
|
|
||||||
BLOCK_TYPE BlockValue::BlockType() const {
|
|
||||||
return pBlockType;
|
|
||||||
}
|
|
||||||
71
blockvalue.h
71
blockvalue.h
@ -1,71 +0,0 @@
|
|||||||
#ifndef BLOCKVALUE_H
|
|
||||||
#define BLOCKVALUE_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BLOCK_TYPE enum
|
|
||||||
*
|
|
||||||
* Value types that the BlockVlaue class can
|
|
||||||
* ingest and convert to/from.
|
|
||||||
*/
|
|
||||||
enum BLOCK_TYPE {
|
|
||||||
BLOCK_TYPE_NONE = 0,
|
|
||||||
BLOCK_TYPE_INT8 = 1,
|
|
||||||
BLOCK_TYPE_UINT8 = 2,
|
|
||||||
BLOCK_TYPE_INT16 = 3,
|
|
||||||
BLOCK_TYPE_UINT16 = 4,
|
|
||||||
BLOCK_TYPE_INT32 = 5,
|
|
||||||
BLOCK_TYPE_UINT32 = 6,
|
|
||||||
BLOCK_TYPE_INT64 = 7,
|
|
||||||
BLOCK_TYPE_UINT64 = 8,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BlockValue class
|
|
||||||
*
|
|
||||||
* Represents a variable value resulting from
|
|
||||||
* parsing a block of data from the input.
|
|
||||||
*
|
|
||||||
* Constructed preferrably with a name and value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class BlockValue
|
|
||||||
{
|
|
||||||
|
|
||||||
public: /*** PUBLIC MEMBERS ***/
|
|
||||||
/* Block Value Constructors */
|
|
||||||
BlockValue(); // Default
|
|
||||||
BlockValue(const BlockValue &aBlockVal); // Copy
|
|
||||||
BlockValue(const QString aName); // Name
|
|
||||||
BlockValue(const QString aName, qint8 aVal); // Name + int8
|
|
||||||
BlockValue(const QString aName, quint8 aVal); // Name + uint8
|
|
||||||
BlockValue(const QString aName, qint16 aVal); // Name + int16
|
|
||||||
BlockValue(const QString aName, quint16 aVal); // Name + uint16
|
|
||||||
BlockValue(const QString aName, qint32 aVal); // Name + int32
|
|
||||||
BlockValue(const QString aName, quint32 aVal); // Name + uint32
|
|
||||||
BlockValue(const QString aName, qint64 aVal); // Name + int64
|
|
||||||
BlockValue(const QString aName, quint64 aVal); // Name + uint64
|
|
||||||
|
|
||||||
/* Block Value Operators */
|
|
||||||
BlockValue &operator=(const BlockValue &aBlockVal); // = operator
|
|
||||||
|
|
||||||
/* Setters and Getters */
|
|
||||||
void SetName(const QString aName); // Set Name
|
|
||||||
QString Name() const; // Get Name
|
|
||||||
void SetBlockType(BLOCK_TYPE aBlockType); // Set Block Value Type
|
|
||||||
BLOCK_TYPE BlockType() const; // Get Block Value Type
|
|
||||||
|
|
||||||
/* Data Access Methods */
|
|
||||||
int ToInt() const; // Convert to integer
|
|
||||||
QString ToString() const; // Convert to string
|
|
||||||
QVariant ToVariant() const; // Return as raw data
|
|
||||||
|
|
||||||
private: /*** PRIVATE MEMBERS ***/
|
|
||||||
QString pName;
|
|
||||||
BLOCK_TYPE pBlockType;
|
|
||||||
QVariant pData;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // BLOCKVALUE_H
|
|
||||||
BIN
delete.png
BIN
delete.png
Binary file not shown.
|
Before Width: | Height: | Size: 793 B |
@ -1,39 +0,0 @@
|
|||||||
#include "deleteruledialog.h"
|
|
||||||
#include "ui_deleteruledialog.h"
|
|
||||||
|
|
||||||
DeleteRuleDialog::DeleteRuleDialog(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::DeleteRuleDialog) {
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
pRuleNames = QStringList();
|
|
||||||
|
|
||||||
connect(ui->pushButton_Delete, &QPushButton::clicked, this, &DeleteRuleDialog::DeleteRule);
|
|
||||||
connect(ui->pushButton_Cancel, &QPushButton::clicked, this, &DeleteRuleDialog::Cancel);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteRuleDialog::~DeleteRuleDialog() {
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeleteRuleDialog::SetRuleNames(QStringList ruleNames) {
|
|
||||||
ui->listWidget_Rules->clear();
|
|
||||||
foreach (QString ruleName, ruleNames) {
|
|
||||||
ui->listWidget_Rules->addItem(ruleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeleteRuleDialog::DeleteRule() {
|
|
||||||
QList<QListWidgetItem *> items = ui->listWidget_Rules->selectedItems();
|
|
||||||
if (items.count() == 0) { return; }
|
|
||||||
|
|
||||||
foreach (QListWidgetItem *item, items) {
|
|
||||||
emit RuleDeleted(item->text());
|
|
||||||
}
|
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeleteRuleDialog::Cancel() {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#ifndef DELETERULEDIALOG_H
|
|
||||||
#define DELETERULEDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class DeleteRuleDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class DeleteRuleDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit DeleteRuleDialog(QWidget *parent = nullptr);
|
|
||||||
~DeleteRuleDialog();
|
|
||||||
|
|
||||||
void SetRuleNames(QStringList ruleNames);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void DeleteRule();
|
|
||||||
void Cancel();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void RuleDeleted(QString ruleName);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::DeleteRuleDialog *ui;
|
|
||||||
QStringList pRuleNames;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DELETERULEDIALOG_H
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>DeleteRuleDialog</class>
|
|
||||||
<widget class="QDialog" name="DeleteRuleDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>192</width>
|
|
||||||
<height>176</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>192</width>
|
|
||||||
<height>176</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>328</width>
|
|
||||||
<height>310</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Select a rule to delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="listWidget_Rules">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_Delete">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_Cancel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
BIN
general.png
BIN
general.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB |
@ -1,43 +0,0 @@
|
|||||||
#include "hexeslogger.h"
|
|
||||||
|
|
||||||
HexesLogger *HexesLogger::pInstance = nullptr;
|
|
||||||
QWidget *HexesLogger::pParent = nullptr;
|
|
||||||
|
|
||||||
void HexesLogger::MakeInstance(QWidget *aParent) {
|
|
||||||
pInstance = new HexesLogger(aParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexesLogger::HexesInfo(const QString pInfoMsg) {
|
|
||||||
QMessageBox::information(pParent,
|
|
||||||
HEXES_INFO_TITLE,
|
|
||||||
QString(HEXES_INFO_TEMPLATE).arg(pInfoMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexesLogger::HexesError(int pErrorId, const QString pErrorMsg) {
|
|
||||||
QString errorIdString = QString::number(pErrorId);
|
|
||||||
QMessageBox::warning(pParent,
|
|
||||||
HEXES_ERROR_TITLE,
|
|
||||||
QString(HEXES_ERROR_TEMPLATE).arg(errorIdString, pErrorMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexesLogger::HexesFatal(int pFatalId, const QString pFatalMsg) {
|
|
||||||
QString fatalIdString = QString::number(pFatalId);
|
|
||||||
QMessageBox::critical(pParent,
|
|
||||||
HEXES_FATAL_TITLE,
|
|
||||||
QString(HEXES_FATAL_TEMPLATE).arg(fatalIdString, pFatalMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexesLogger::DeleteInstance() {
|
|
||||||
delete pInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
HexesLogger::HexesLogger(QWidget *aParent) {
|
|
||||||
pParent = aParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
HexesLogger* HexesLogger::Instance() {
|
|
||||||
if (!pInstance) {
|
|
||||||
MakeInstance();
|
|
||||||
}
|
|
||||||
return pInstance;
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#ifndef HEXESLOGGER_H
|
|
||||||
#define HEXESLOGGER_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
const QString HEXES_INFO_TITLE = "Hexes Info Message";
|
|
||||||
const QString HEXES_ERROR_TITLE = "Hexes Error Message";
|
|
||||||
const QString HEXES_FATAL_TITLE = "Hexes Fatal Message";
|
|
||||||
const QString HEXES_INFO_TEMPLATE = "Hexes Info: %1";
|
|
||||||
const QString HEXES_ERROR_TEMPLATE = "Hexes Error [%1]: %2";
|
|
||||||
const QString HEXES_FATAL_TEMPLATE = "Hexes Fatal [%1]: %2";
|
|
||||||
|
|
||||||
class HexesLogger
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static HexesLogger* Instance();
|
|
||||||
static void DeleteInstance();
|
|
||||||
static void MakeInstance(QWidget *aParent = nullptr);
|
|
||||||
|
|
||||||
static void HexesInfo(const QString pInfoMsg);
|
|
||||||
static void HexesError(int pErrorId, const QString pErrorMsg);
|
|
||||||
static void HexesFatal(int pFatalId, const QString pFatalMsg);
|
|
||||||
|
|
||||||
private:
|
|
||||||
HexesLogger(QWidget *aParent = nullptr);
|
|
||||||
|
|
||||||
static QWidget *pParent;
|
|
||||||
static HexesLogger *pInstance;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // HEXESLOGGER_H
|
|
||||||
142
hexstream.cpp
142
hexstream.cpp
@ -1,142 +0,0 @@
|
|||||||
#include "hexstream.h"
|
|
||||||
|
|
||||||
HexStream::HexStream()
|
|
||||||
: QDataStream() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
HexStream::HexStream(QIODevice *aIODevice)
|
|
||||||
: QDataStream(aIODevice) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
HexStream::HexStream(QByteArray *aData, OpenMode aFlags)
|
|
||||||
: QDataStream(aData, aFlags) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
HexStream::HexStream(const QByteArray &aData)
|
|
||||||
: QDataStream(aData) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
HexStream::~HexStream() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexStream::SetHexByteOrder(BYTE_ORDER aByteOrder) {
|
|
||||||
pByteOrder = aByteOrder;
|
|
||||||
if (aByteOrder == BYTE_ORDER_BE) {
|
|
||||||
setByteOrder(BigEndian);
|
|
||||||
} else {
|
|
||||||
setByteOrder(BigEndian);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BYTE_ORDER HexStream::HexByteOrder() {
|
|
||||||
return pByteOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexStream::ParseSkip(const Rule &aRule) {
|
|
||||||
// Skip hex bytes if valid
|
|
||||||
skipRawData(aRule.Length());
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexStream::ParseSkip(int aSkipLen) {
|
|
||||||
// Skip hex 'aSkipLen' bytes
|
|
||||||
skipRawData(aSkipLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseInt8(const Rule &aRule) {
|
|
||||||
qint8 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseUInt8(const Rule &aRule) {
|
|
||||||
quint8 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseInt16(const Rule &aRule) {
|
|
||||||
qint16 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseUInt16(const Rule &aRule) {
|
|
||||||
quint16 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseInt32(const Rule &aRule) {
|
|
||||||
qint32 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseUInt32(const Rule &aRule) {
|
|
||||||
quint32 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseInt64(const Rule &aRule) {
|
|
||||||
qint64 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseUInt64(const Rule &aRule) {
|
|
||||||
quint64 val;
|
|
||||||
operator >>(val);
|
|
||||||
return BlockValue(aRule.Name(), val);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockValue HexStream::ParseRule(const Rule &aRule) {
|
|
||||||
if (!aRule) {
|
|
||||||
HexesLogger::HexesError(50, "Attempted to parse null rule!");
|
|
||||||
return BlockValue("INVALID");
|
|
||||||
}
|
|
||||||
if (aRule.Name().isEmpty()) {
|
|
||||||
HexesLogger::HexesError(55, "Attempted to parse rule w/ null name!");
|
|
||||||
return BlockValue("INVALID");
|
|
||||||
}
|
|
||||||
if (aRule.Length() < 0) {
|
|
||||||
HexesLogger::HexesError(60, "Attempted to rule w/ invalid length!");
|
|
||||||
return BlockValue(aRule.Name());
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ((int)aRule.Type()) {
|
|
||||||
case 1: // Skip
|
|
||||||
ParseSkip(aRule);
|
|
||||||
break;
|
|
||||||
case 2: // int8
|
|
||||||
return ParseInt8(aRule);
|
|
||||||
break;
|
|
||||||
case 3: // uint8
|
|
||||||
return ParseUInt8(aRule);
|
|
||||||
break;
|
|
||||||
case 4: // int16
|
|
||||||
return ParseInt16(aRule);
|
|
||||||
break;
|
|
||||||
case 5: // uint16
|
|
||||||
return ParseUInt16(aRule);
|
|
||||||
break;
|
|
||||||
case 6: // int32
|
|
||||||
return ParseInt32(aRule);
|
|
||||||
break;
|
|
||||||
case 7: // uint32
|
|
||||||
return ParseUInt32(aRule);
|
|
||||||
break;
|
|
||||||
case 8: // int64
|
|
||||||
return ParseInt64(aRule);
|
|
||||||
break;
|
|
||||||
case 9: // uint64
|
|
||||||
return ParseUInt64(aRule);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return BlockValue(aRule.Name());
|
|
||||||
}
|
|
||||||
38
hexstream.h
38
hexstream.h
@ -1,38 +0,0 @@
|
|||||||
#ifndef HEXSTREAM_H
|
|
||||||
#define HEXSTREAM_H
|
|
||||||
|
|
||||||
#include "rule.h"
|
|
||||||
#include "blockvalue.h"
|
|
||||||
#include "hexeslogger.h"
|
|
||||||
|
|
||||||
#include <QDataStream>
|
|
||||||
|
|
||||||
class HexStream : public QDataStream
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HexStream();
|
|
||||||
explicit HexStream(QIODevice *aIODevice);
|
|
||||||
HexStream(QByteArray *aData, OpenMode aFlags);
|
|
||||||
HexStream(const QByteArray &aData);
|
|
||||||
~HexStream();
|
|
||||||
|
|
||||||
void SetHexByteOrder(BYTE_ORDER aByteOrder);
|
|
||||||
BYTE_ORDER HexByteOrder();
|
|
||||||
|
|
||||||
void ParseSkip(const Rule &aRule);
|
|
||||||
void ParseSkip(int aSkipLen);
|
|
||||||
BlockValue ParseInt8(const Rule &aRule);
|
|
||||||
BlockValue ParseUInt8(const Rule &aRule);
|
|
||||||
BlockValue ParseInt16(const Rule &aRule);
|
|
||||||
BlockValue ParseUInt16(const Rule &aRule);
|
|
||||||
BlockValue ParseInt32(const Rule &aRule);
|
|
||||||
BlockValue ParseUInt32(const Rule &aRule);
|
|
||||||
BlockValue ParseInt64(const Rule &aRule);
|
|
||||||
BlockValue ParseUInt64(const Rule &aRule);
|
|
||||||
BlockValue ParseRule(const Rule &aRule);
|
|
||||||
|
|
||||||
private:
|
|
||||||
BYTE_ORDER pByteOrder;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // HEXSTREAM_H
|
|
||||||
899
hexviewer.cpp
899
hexviewer.cpp
@ -1,899 +0,0 @@
|
|||||||
#include "hexviewer.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* HexViewer Constructor
|
|
||||||
*/
|
|
||||||
HexViewer::HexViewer(QWidget *parent)
|
|
||||||
: QAbstractScrollArea(parent)
|
|
||||||
, pText("")
|
|
||||||
, pHex("")
|
|
||||||
, pFileName("")
|
|
||||||
, pViewRect(0, 0, 800, 557)
|
|
||||||
, pBlinkTimer(new QTimer(this))
|
|
||||||
, pRules(QQueue<Rule>())
|
|
||||||
, pScrollValue(0)
|
|
||||||
, pVars(QMap<QString, BlockValue>())
|
|
||||||
, pFontMetrics(QFontMetrics(QFont("CommitMono", 10)))
|
|
||||||
, pFileDir("C:/"){
|
|
||||||
// Set font to monospaced option
|
|
||||||
setFont(QFont("CommitMono", 10));
|
|
||||||
// Initialize scroll bar and cursor timer
|
|
||||||
pInitScrollBar();
|
|
||||||
pInitCursorTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* HexViewer Destructor
|
|
||||||
*/
|
|
||||||
HexViewer::~HexViewer() {
|
|
||||||
delete pBlinkTimer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Scroll Bar Initialization
|
|
||||||
*/
|
|
||||||
void HexViewer::pInitScrollBar() {
|
|
||||||
verticalScrollBar()->setSingleStep(DEFAULT_SINGLE_STEP);
|
|
||||||
verticalScrollBar()->setPageStep(DEFAULT_PAGE_STEP);
|
|
||||||
connect(verticalScrollBar(), &QScrollBar::valueChanged,
|
|
||||||
this, &HexViewer::pScrollValueChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cursor Blink Timer Initialization
|
|
||||||
*/
|
|
||||||
void HexViewer::pInitCursorTimer() {
|
|
||||||
connect(pBlinkTimer, &QTimer::timeout,
|
|
||||||
this, &HexViewer::pBlinkCursor);
|
|
||||||
pBlinkTimer->start(500); // Blinking interval
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set filename of hex file we want to open
|
|
||||||
*/
|
|
||||||
void HexViewer::SetFileName(const QString fileName) {
|
|
||||||
if (fileName.isEmpty()) { return; }
|
|
||||||
// Set file name & open for read-only
|
|
||||||
pFile.setFileName(pFileName = fileName);
|
|
||||||
if (!pFile.open(QIODevice::ReadOnly)) {
|
|
||||||
const QString errorMsg("Failed to open " + pFileName);
|
|
||||||
HexesLogger::HexesError(20, errorMsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Re-search the file contents to display
|
|
||||||
pSeekFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add a rule to our local queue
|
|
||||||
*/
|
|
||||||
void HexViewer::AddRule(const Rule rule) {
|
|
||||||
pRules.enqueue(rule);
|
|
||||||
// Refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Adds multiple rules to our local queue
|
|
||||||
*/
|
|
||||||
void HexViewer::AddRules(const QVector<Rule> rules) {
|
|
||||||
if (rules.isEmpty()) { return; }
|
|
||||||
// Add rules from incoming queue
|
|
||||||
for (int i = 0; i < rules.size(); i++) {
|
|
||||||
pRules.enqueue(rules[i]);
|
|
||||||
}
|
|
||||||
// Refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove a rule from our local queue
|
|
||||||
*/
|
|
||||||
void HexViewer::DeleteRule(const Rule rule) {
|
|
||||||
if (!pRules.contains(rule)) { return; }
|
|
||||||
if (pRules.size() == 0) { return; }
|
|
||||||
// Search for and remove rule
|
|
||||||
for (int i = 0; i < pRules.size(); i++) {
|
|
||||||
Rule currentRule = pRules.dequeue();
|
|
||||||
if (currentRule != rule) {
|
|
||||||
pRules.enqueue(currentRule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove a rule, by name, from our local queue
|
|
||||||
*/
|
|
||||||
void HexViewer::DeleteRuleByName(const QString ruleName) {
|
|
||||||
if (pRules.size() == 0) { return; }
|
|
||||||
// Search for and remove rule
|
|
||||||
for (int i = 0; i < pRules.size(); i++) {
|
|
||||||
Rule currentRule = pRules.dequeue();
|
|
||||||
if (currentRule.Name() != ruleName) {
|
|
||||||
pRules.enqueue(currentRule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Pop/dequeue a rule from our local queue
|
|
||||||
*/
|
|
||||||
void HexViewer::PopRule() {
|
|
||||||
if (pRules.isEmpty()) { return; }
|
|
||||||
pRules.dequeue();
|
|
||||||
// Refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear all rules from our local queue
|
|
||||||
*/
|
|
||||||
void HexViewer::ClearRules() {
|
|
||||||
if (pRules.isEmpty()) { return; }
|
|
||||||
pRules.clear();
|
|
||||||
// Refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Save rules to a Hexes Rule File (.hrf)
|
|
||||||
*/
|
|
||||||
void HexViewer::SaveRules() {
|
|
||||||
// Have user choose where to save the .hrf
|
|
||||||
QString filePath = QFileDialog::getSaveFileName(this, "Save Hexes Rule File",
|
|
||||||
pFileDir, "Rule File (*.hrf);;All Files(*.*)");
|
|
||||||
QString tempFilePath = filePath;
|
|
||||||
pFileDir = tempFilePath.replace(tempFilePath.split('/').last(), "");
|
|
||||||
emit BaseDirChanged(pFileDir);
|
|
||||||
|
|
||||||
// Open rule file, or report error, then close
|
|
||||||
QFile ruleFile(filePath);
|
|
||||||
if (!ruleFile.open(QIODevice::WriteOnly)) {
|
|
||||||
HexesLogger::HexesError(25, "Failed to save rule file!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ruleFile.close();
|
|
||||||
// Write to rule file in ini format
|
|
||||||
QSettings ruleExport(filePath, QSettings::IniFormat);
|
|
||||||
ruleExport.setValue("rules", QVariant::fromValue(pRules));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open a Hexes Rule File (.hrf)
|
|
||||||
*/
|
|
||||||
void HexViewer::OpenRules() {
|
|
||||||
// Have user choose where to save the .hrf
|
|
||||||
QString filePath = QFileDialog::getOpenFileName(this, "Open Hexes Rule File",
|
|
||||||
pFileDir, "Rule File (*.hrf);;All Files(*.*)");
|
|
||||||
QString tempFilePath = filePath;
|
|
||||||
pFileDir = tempFilePath.replace(tempFilePath.split('/').last(), "");
|
|
||||||
emit BaseDirChanged(pFileDir);
|
|
||||||
|
|
||||||
// Open rule file, or report error, then close
|
|
||||||
QFile ruleFile(filePath);
|
|
||||||
if (!ruleFile.open(QIODevice::ReadOnly)) {
|
|
||||||
HexesLogger::HexesError(30, "Failed to open rule file!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ruleFile.close();
|
|
||||||
// Read from rule file in ini format
|
|
||||||
QSettings ruleExport(filePath, QSettings::IniFormat);
|
|
||||||
pRules = ruleExport.value("rules").value<QQueue<Rule>>();
|
|
||||||
// Notify & refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
emit FileOpened(filePath.split('/').last());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open a binary input file
|
|
||||||
*/
|
|
||||||
void HexViewer::OpenFile() {
|
|
||||||
// Have user choose where to save the .hrf
|
|
||||||
QString filePath = QFileDialog::getOpenFileName(this, "Open Input File",
|
|
||||||
pFileDir, "All Files(*.*)");
|
|
||||||
|
|
||||||
QString tempFilePath = filePath;
|
|
||||||
pFileDir = tempFilePath.replace(tempFilePath.split('/').last(), "");
|
|
||||||
emit BaseDirChanged(pFileDir);
|
|
||||||
|
|
||||||
SetFileName(filePath);
|
|
||||||
// Notify & refresh rules and view
|
|
||||||
pRefreshRules();
|
|
||||||
emit FileOpened(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get a list of rule names from local queue
|
|
||||||
*/
|
|
||||||
QStringList HexViewer::RuleNames() {
|
|
||||||
if (pRules.isEmpty()) { return QStringList(); }
|
|
||||||
// Create and return name list
|
|
||||||
QStringList ruleNames;
|
|
||||||
foreach (Rule rule, pRules) {
|
|
||||||
ruleNames.append(rule.Name());
|
|
||||||
}
|
|
||||||
return ruleNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Re-parse rules and update the variables' values
|
|
||||||
*/
|
|
||||||
void HexViewer::ParseRules() {
|
|
||||||
// Read in hex data as a byte-stream
|
|
||||||
HexStream hexStream(QByteArray::fromHex(pHex.toUtf8()));
|
|
||||||
// Iterate through local rules
|
|
||||||
for (int i = 0; i < pRules.size(); i++) {
|
|
||||||
Rule &rule = pRules[i]; // Current rule
|
|
||||||
qDebug() << rule.Name();
|
|
||||||
if ((rule.Type() == TYPE_NONE) || (rule.Type() == TYPE_SKIP)) {
|
|
||||||
hexStream.ParseSkip(rule.Length() + rule.SkipOffset());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Repeat rule per defined repeat count
|
|
||||||
for (int j = 0; j <= rule.RepeatCount() + rule.RepeatOffset(); j++) {
|
|
||||||
// Set byte order and execute pre-skip
|
|
||||||
hexStream.SetHexByteOrder(rule.ByteOrder());
|
|
||||||
hexStream.ParseSkip(rule.PreSkipCount() + rule.PreSkipOffset());
|
|
||||||
|
|
||||||
// Create parse block to get value for variable
|
|
||||||
BlockValue val = hexStream.ParseRule(rule);
|
|
||||||
rule.SetValue(val.ToString());
|
|
||||||
|
|
||||||
// Execute post-skip
|
|
||||||
hexStream.ParseSkip(rule.PostSkipCount() + rule.PostSkipOffset());
|
|
||||||
|
|
||||||
// Add a var suffix (index) if repeating
|
|
||||||
if (rule.RepeatCount() > 0) {
|
|
||||||
pVars[rule.Name() + QString(" %1").arg(j)] = val;
|
|
||||||
} else {
|
|
||||||
pVars[rule.Name()] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit VarsChanged(pVars);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the local variable map
|
|
||||||
* - Note: May not be populated
|
|
||||||
*/
|
|
||||||
QMap<QString, BlockValue> HexViewer::GetVars() {
|
|
||||||
return pVars;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::SetBaseDir(QString dir) {
|
|
||||||
pFileDir = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the text representation of the data
|
|
||||||
*/
|
|
||||||
QString HexViewer::Text() {
|
|
||||||
return pText;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get the hex representation of the data
|
|
||||||
*/
|
|
||||||
QString HexViewer::Hex() {
|
|
||||||
return pHex;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString HexViewer::pFormatValuesGrid(const QVector<int> &values, int width, const QFont &font, int bitSize, int& textHeight) {
|
|
||||||
if (values.isEmpty()) return "";
|
|
||||||
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
QString result;
|
|
||||||
|
|
||||||
// Determine the width for the index based on the number of digits in the largest index
|
|
||||||
int maxIndexDigits = QString::number(values.size()).length();
|
|
||||||
|
|
||||||
// Determine padding width for values based on bit size (minimal necessary width)
|
|
||||||
int valuePaddingWidth = 0;
|
|
||||||
switch (bitSize) {
|
|
||||||
case 8: valuePaddingWidth = 3; break; // int8 max is 255
|
|
||||||
case 16: valuePaddingWidth = 5; break; // int16 max is 65535
|
|
||||||
case 32: valuePaddingWidth = 10; break; // int32 max is 4294967295
|
|
||||||
case 64: valuePaddingWidth = 20; break; // int64 max is very large
|
|
||||||
default: valuePaddingWidth = 10; break; // Default to int32-like width
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate a compact maximum entry width (index + value) with minimal padding
|
|
||||||
int maxEntryWidth = fm.horizontalAdvance(QString("%1=%2 ")
|
|
||||||
.arg(values.size(), maxIndexDigits)
|
|
||||||
.arg(0, valuePaddingWidth, 10, QChar('0')));
|
|
||||||
|
|
||||||
// Determine the optimal number of entries per line based on available width
|
|
||||||
int entriesPerLine = std::max(1, width / maxEntryWidth);
|
|
||||||
|
|
||||||
// Build the grid-like output
|
|
||||||
int lineCount = 0;
|
|
||||||
for (int i = 0; i < values.size(); ++i) {
|
|
||||||
if (i > 0 && i % entriesPerLine == 0) {
|
|
||||||
result += "\n";
|
|
||||||
lineCount++;
|
|
||||||
} else if (i > 0) {
|
|
||||||
result += ", "; // Minimal spacing between entries
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format each entry with a left-aligned index and right-aligned value
|
|
||||||
result += QString("%1=%2")
|
|
||||||
.arg(i + 1, maxIndexDigits, 10, QChar(' ')) // Left-pad index minimally
|
|
||||||
.arg(values[i], -valuePaddingWidth, 10, QChar(' ')); // Right-pad value minimally
|
|
||||||
}
|
|
||||||
|
|
||||||
// Account for the final line
|
|
||||||
lineCount++;
|
|
||||||
|
|
||||||
// Calculate the height of the text block
|
|
||||||
textHeight = lineCount * fm.height();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the hex header rectangle
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcHexHeaderRect() const {
|
|
||||||
qreal columnWidth = viewport()->width()
|
|
||||||
- (OFFSET_HEADER_WIDTH + (3 * MAX_PADDING));
|
|
||||||
qreal hexColumnWidth = (columnWidth / 5 * 3) - 2 * MAX_PADDING;
|
|
||||||
|
|
||||||
return QRectF(OFFSET_HEADER_WIDTH + MAX_PADDING, MIN_PADDING,
|
|
||||||
hexColumnWidth, HEADER_HEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the text header rectangle
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcTextHeaderRect() const {
|
|
||||||
qreal columnWidth = viewport()->width()
|
|
||||||
- (OFFSET_HEADER_WIDTH + (3 * MAX_PADDING));
|
|
||||||
qreal hexColumnWidth = (columnWidth / 5 * 3) - MAX_PADDING;
|
|
||||||
qreal textColumnWidth = (columnWidth / 5) + MAX_PADDING;
|
|
||||||
|
|
||||||
return QRectF(OFFSET_HEADER_WIDTH + hexColumnWidth + MAX_PADDING, MIN_PADDING,
|
|
||||||
textColumnWidth - 2 * MAX_PADDING, MAX_PADDING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the rule header rectangle
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcRuleHeaderRect() const {
|
|
||||||
qreal columnWidth = viewport()->width()
|
|
||||||
- (OFFSET_HEADER_WIDTH + (3 * MAX_PADDING));
|
|
||||||
qreal hexColumnWidth = (columnWidth / 5 * 3);
|
|
||||||
qreal textColumnWidth = (columnWidth / 5) + MAX_PADDING;
|
|
||||||
qreal ruleColumnWidth = (columnWidth / 5) + MAX_PADDING;
|
|
||||||
|
|
||||||
return QRectF(OFFSET_HEADER_WIDTH + hexColumnWidth + textColumnWidth, MIN_PADDING,
|
|
||||||
ruleColumnWidth - MAX_PADDING, MAX_PADDING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the offset header rectangle
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcOffsetHeaderRect() const {
|
|
||||||
return QRectF(MIN_PADDING, MIN_PADDING,
|
|
||||||
OFFSET_HEADER_WIDTH, HEADER_HEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the offset column rectangle
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcOffsetColumnRect() const {
|
|
||||||
return QRectF(MIN_PADDING, FONT_HEIGHT + HEADER_HEIGHT,
|
|
||||||
OFFSET_HEADER_WIDTH, height() - STATUS_BAR_HEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Paint the offset column
|
|
||||||
*/
|
|
||||||
void HexViewer::pPaintOffsetColumn(QPainter &painter) {
|
|
||||||
QRectF offSetColumnRect = pCalcOffsetColumnRect();
|
|
||||||
QRectF hexRect = pCalcHexRect();
|
|
||||||
|
|
||||||
QString offset = "";
|
|
||||||
int nextOffset = verticalScrollBar()->value();
|
|
||||||
for (int i = 0; i < qCeil(hexRect.height() / fontMetrics().height()); i++) {
|
|
||||||
offset += QString::number(nextOffset).rightJustified(8, '0') + " ";
|
|
||||||
nextOffset += pCalcCharCount();
|
|
||||||
}
|
|
||||||
offset = offset.trimmed();
|
|
||||||
|
|
||||||
painter.setPen(Qt::blue);
|
|
||||||
painter.drawText(offSetColumnRect, Qt::TextWordWrap | Qt::AlignHCenter, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the hex content rectangle
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcHexRect() const {
|
|
||||||
qreal columnWidth = viewport()->width()
|
|
||||||
- (OFFSET_HEADER_WIDTH + (3 * MAX_PADDING));
|
|
||||||
qreal hexColumnWidth = (columnWidth / 5 * 3) - 2 * MAX_PADDING;
|
|
||||||
|
|
||||||
return QRectF(OFFSET_HEADER_WIDTH + MAX_PADDING, HEADER_HEIGHT + FONT_HEIGHT,
|
|
||||||
hexColumnWidth, viewport()->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Paint the hex content
|
|
||||||
*/
|
|
||||||
void HexViewer::pPaintHex(QPainter &painter) {
|
|
||||||
QRectF hexRect = pCalcHexRect();
|
|
||||||
|
|
||||||
painter.setPen(Qt::black);
|
|
||||||
painter.drawText(hexRect, Qt::TextWordWrap, pHex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the text content rect
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcTextRect() const {
|
|
||||||
qreal columnWidth = viewport()->width()
|
|
||||||
- (OFFSET_HEADER_WIDTH + (3 * MAX_PADDING));
|
|
||||||
qreal hexColumnWidth = (columnWidth / 5 * 3);
|
|
||||||
qreal textColumnWidth = (columnWidth / 5) - MAX_PADDING / 2;
|
|
||||||
|
|
||||||
return QRectF(OFFSET_HEADER_WIDTH + hexColumnWidth, HEADER_HEIGHT + FONT_HEIGHT,
|
|
||||||
textColumnWidth, viewport()->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate rule sidebar rectangle
|
|
||||||
*/
|
|
||||||
QRectF HexViewer::pCalcRuleRect() const {
|
|
||||||
qreal columnWidth = viewport()->width()
|
|
||||||
- (OFFSET_HEADER_WIDTH + (3 * MAX_PADDING));
|
|
||||||
qreal hexColumnWidth = (columnWidth / 5 * 3);
|
|
||||||
qreal textColumnWidth = (columnWidth / 5) + MAX_PADDING;
|
|
||||||
qreal ruleColumnWidth = (columnWidth / 5) + MAX_PADDING;
|
|
||||||
|
|
||||||
return QRectF(OFFSET_HEADER_WIDTH + hexColumnWidth + textColumnWidth, HEADER_HEIGHT + FONT_HEIGHT,
|
|
||||||
ruleColumnWidth, viewport()->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Paint the text content
|
|
||||||
*/
|
|
||||||
void HexViewer::pPaintText(QPainter &painter) {
|
|
||||||
QRectF textRect = pCalcTextRect();
|
|
||||||
|
|
||||||
painter.setPen(Qt::black);
|
|
||||||
painter.drawText(textRect, Qt::TextWrapAnywhere, pText);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Paint a hex rule over the content
|
|
||||||
*/
|
|
||||||
void HexViewer::pPaintHexRule(QPainter &painter, int ¤tXPos,
|
|
||||||
int ¤tYPos, int ruleLen, bool skip) {
|
|
||||||
int charWidth = fontMetrics().horizontalAdvance("F");
|
|
||||||
int charPerLine = pCalcCharCount();
|
|
||||||
QRectF hexRect = pCalcHexRect();
|
|
||||||
int scrollHeight = verticalScrollBar()->value();
|
|
||||||
int adjustedYPos = currentYPos - scrollHeight; // Apply scroll offset
|
|
||||||
|
|
||||||
while (ruleLen > 0) {
|
|
||||||
int remainingCharsOnLine = charPerLine - ((currentXPos - hexRect.left()) / (3 * charWidth));
|
|
||||||
int charsToDraw = qMin(remainingCharsOnLine, ruleLen);
|
|
||||||
int rectWidth = charsToDraw * 3 * charWidth;
|
|
||||||
|
|
||||||
// Only draw if within the visible area vertically
|
|
||||||
if (adjustedYPos >= hexRect.top() &&
|
|
||||||
adjustedYPos <= (hexRect.bottom() - fontMetrics().height())) {
|
|
||||||
|
|
||||||
QRectF skipRect(QPointF(currentXPos, adjustedYPos + 1),
|
|
||||||
QSizeF(rectWidth - charWidth, fontMetrics().height() - 2));
|
|
||||||
painter.drawRect(skipRect);
|
|
||||||
if (skip) {
|
|
||||||
painter.drawLine(skipRect.topLeft(), skipRect.bottomRight());
|
|
||||||
painter.drawLine(skipRect.topRight(), skipRect.bottomLeft());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
currentXPos += rectWidth;
|
|
||||||
ruleLen -= charsToDraw;
|
|
||||||
|
|
||||||
// Move to the next line if the current position exceeds the line width
|
|
||||||
if (currentXPos >= hexRect.left() + charPerLine * 3 * charWidth) {
|
|
||||||
currentXPos = hexRect.left();
|
|
||||||
adjustedYPos += fontMetrics().height();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore the Y position accounting for scroll offset
|
|
||||||
currentYPos = adjustedYPos + scrollHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Paint a text rule over the content
|
|
||||||
*/
|
|
||||||
void HexViewer::pPaintTextRule(QPainter &painter, int ¤tXPos,
|
|
||||||
int ¤tYPos, int ruleLen, bool skip) {
|
|
||||||
int charWidth = fontMetrics().horizontalAdvance("F");
|
|
||||||
int charPerLine = pCalcCharCount();
|
|
||||||
QRectF textRect = pCalcTextRect();
|
|
||||||
int scrollHeight = verticalScrollBar()->value();
|
|
||||||
int adjustedYPos = currentYPos - scrollHeight; // Apply scroll offset
|
|
||||||
|
|
||||||
while (ruleLen > 0) {
|
|
||||||
int remainingCharsOnLine = charPerLine - ((currentXPos - textRect.left()) / charWidth);
|
|
||||||
|
|
||||||
// Ensure we do not run into a situation where remainingCharsOnLine becomes zero or negative
|
|
||||||
if (remainingCharsOnLine <= 0) {
|
|
||||||
currentXPos = textRect.left();
|
|
||||||
adjustedYPos += fontMetrics().height();
|
|
||||||
remainingCharsOnLine = charPerLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
int charsToDraw = qMin(remainingCharsOnLine, ruleLen);
|
|
||||||
|
|
||||||
// If charsToDraw is still 0, break out to avoid an infinite loop
|
|
||||||
if (charsToDraw <= 0) break;
|
|
||||||
|
|
||||||
int rectWidth = charsToDraw * charWidth;
|
|
||||||
|
|
||||||
// Only draw if within the visible area vertically
|
|
||||||
if (adjustedYPos >= textRect.top() &&
|
|
||||||
adjustedYPos <= textRect.bottom()) {
|
|
||||||
|
|
||||||
QRectF skipRect(QPointF(currentXPos, adjustedYPos + 1),
|
|
||||||
QSizeF(rectWidth, fontMetrics().height() - 2));
|
|
||||||
painter.drawRect(skipRect);
|
|
||||||
if (skip) {
|
|
||||||
painter.drawLine(skipRect.topLeft(), skipRect.bottomRight());
|
|
||||||
painter.drawLine(skipRect.topRight(), skipRect.bottomLeft());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
currentXPos += rectWidth;
|
|
||||||
ruleLen -= charsToDraw;
|
|
||||||
|
|
||||||
// Move to the next line if the current position exceeds the line width
|
|
||||||
if (currentXPos >= textRect.left() + charPerLine * charWidth) {
|
|
||||||
currentXPos = textRect.left();
|
|
||||||
adjustedYPos += fontMetrics().height();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore the Y position accounting for scroll offset
|
|
||||||
currentYPos = adjustedYPos + scrollHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Seek to a new file location, process
|
|
||||||
* the contents, and update the view.
|
|
||||||
*/
|
|
||||||
void HexViewer::pSeekFile() {
|
|
||||||
QRectF hexRect(pCalcHexRect());
|
|
||||||
int dataLength = (hexRect.height() / fontMetrics().height()) * pCalcCharCount();
|
|
||||||
|
|
||||||
if (dataLength < 0) {
|
|
||||||
return;
|
|
||||||
} else if (pFile.isOpen()) {
|
|
||||||
pFile.seek(verticalScrollBar()->value());
|
|
||||||
QByteArray data = pFile.read(dataLength + 2);
|
|
||||||
pHex = pCleanHex(data.toHex());
|
|
||||||
pText = QString::fromLocal8Bit(data).replace('\0', '.');//, pCalcCharCount());
|
|
||||||
} else {
|
|
||||||
//HexesLogger::HexesError(35, QString("File '%1' not open...").arg(pFile.fileName()));
|
|
||||||
//return;
|
|
||||||
}
|
|
||||||
pUpdateScrollBar();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* void pRefreshRules()
|
|
||||||
*
|
|
||||||
* Notify rules have changed and update view
|
|
||||||
*/
|
|
||||||
void HexViewer::pRefreshRules() {
|
|
||||||
// Notify current rules have changed
|
|
||||||
emit RuleNamesChanged(RuleNames());
|
|
||||||
// Parse new vars and values
|
|
||||||
ParseRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* void pPaintRules(QPainter &painter)
|
|
||||||
*
|
|
||||||
* Paint the hex rules to the sidebar
|
|
||||||
*/
|
|
||||||
void HexViewer::pPaintRules(QPainter &painter) {
|
|
||||||
int ruleIndex = 1;
|
|
||||||
bool isSkip = false;
|
|
||||||
qreal fontHeight = QFontMetrics(painter.font()).height();
|
|
||||||
QRectF rulesRect = pCalcRuleRect();
|
|
||||||
|
|
||||||
painter.save();
|
|
||||||
painter.setFont(QFont("CommitMono", 7));
|
|
||||||
|
|
||||||
QRectF hexRect(pCalcHexRect());
|
|
||||||
int hexXPos = hexRect.left();
|
|
||||||
int hexYPos = hexRect.top();
|
|
||||||
|
|
||||||
QRectF textRect(pCalcTextRect());
|
|
||||||
int textXPos = textRect.left();
|
|
||||||
int textYPos = textRect.top();
|
|
||||||
|
|
||||||
int currY = 0;
|
|
||||||
|
|
||||||
foreach (Rule rule, pRules) {
|
|
||||||
QString typeText = "";
|
|
||||||
QString valueText = "";
|
|
||||||
int preSkipCount = rule.PreSkipCount();
|
|
||||||
int postSkipCount = rule.PostSkipCount();
|
|
||||||
QVector<int> repeatVals = QVector<int>();
|
|
||||||
|
|
||||||
QString ruleName = rule.Name();
|
|
||||||
|
|
||||||
QColor ruleBackground(rule.Color());
|
|
||||||
ruleBackground.setAlpha(75);
|
|
||||||
painter.setPen(Qt::black);
|
|
||||||
painter.setBrush(ruleBackground);
|
|
||||||
|
|
||||||
valueText.clear();
|
|
||||||
for (int i = 0; i <= rule.RepeatCount(); i++) {
|
|
||||||
QString formattedName = rule.Name();
|
|
||||||
if (rule.RepeatCount() > 0) {
|
|
||||||
formattedName = QString(rule.Name() + " %1").arg(i + 1);
|
|
||||||
}
|
|
||||||
// Paint pre-skip
|
|
||||||
if (preSkipCount > 0) {
|
|
||||||
pPaintHexRule(painter, hexXPos, hexYPos, preSkipCount, true);
|
|
||||||
pPaintTextRule(painter, textXPos, textYPos, preSkipCount, true);
|
|
||||||
}
|
|
||||||
// Paint skip or int
|
|
||||||
if (rule.Type() == TYPE_SKIP) {
|
|
||||||
pPaintHexRule(painter, hexXPos, hexYPos, rule.Length(), true);
|
|
||||||
pPaintTextRule(painter, textXPos, textYPos, rule.Length(), true);
|
|
||||||
isSkip = true;
|
|
||||||
} else {
|
|
||||||
typeText = QString("%1-BIT %2 INTEGER").arg(rule.Length() * 8)
|
|
||||||
.arg(rule.Type() % 2 == 0 ? "" : "US");
|
|
||||||
valueText += pVars[formattedName].ToString() + "\n";
|
|
||||||
if (rule.RepeatCount() > 0) {
|
|
||||||
repeatVals.push_back(pVars[formattedName].ToInt());
|
|
||||||
}
|
|
||||||
pPaintHexRule(painter, hexXPos, hexYPos, rule.Length());
|
|
||||||
pPaintTextRule(painter, textXPos, textYPos, rule.Length());
|
|
||||||
}
|
|
||||||
// Paint post-skip
|
|
||||||
if (postSkipCount > 0) {
|
|
||||||
pPaintHexRule(painter, hexXPos, hexYPos, postSkipCount, true);
|
|
||||||
pPaintTextRule(painter, textXPos, textYPos, postSkipCount, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isSkip) {
|
|
||||||
int blockHeight;
|
|
||||||
if (repeatVals.size() > 0) {
|
|
||||||
valueText = pFormatValuesGrid(repeatVals, rulesRect.width(), painter.font(), rule.Length() * 8, blockHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal ruleHeight;
|
|
||||||
if (rule.RepeatCount() == 0) {
|
|
||||||
ruleHeight = fontHeight * 2;
|
|
||||||
} else {
|
|
||||||
ruleHeight = fontHeight * 2 + blockHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF ruleRect(rulesRect.left() + 1, -verticalScrollBar()->value() + rulesRect.top() + 2 + currY,
|
|
||||||
rulesRect.width() - 2, ruleHeight);
|
|
||||||
QString paddedIndex = QString::number(ruleIndex).rightJustified(2, '0');
|
|
||||||
QString ruleText = QString("%1. %2\n%3\n%4\n").arg(paddedIndex, ruleName,
|
|
||||||
typeText, valueText);
|
|
||||||
QString ruleByteOrder = QString(rule.ByteOrder() == BYTE_ORDER_BE ? "BE" : "LE") + "\n\n";
|
|
||||||
painter.drawText(ruleRect, Qt::TextWrapAnywhere, ruleText);
|
|
||||||
painter.drawText(ruleRect, Qt::AlignRight, ruleByteOrder);
|
|
||||||
|
|
||||||
QRectF ruleBackgroundRect(rulesRect.left(), -verticalScrollBar()->value() + rulesRect.top() + 1 + currY,
|
|
||||||
rulesRect.width(), ruleHeight);
|
|
||||||
|
|
||||||
painter.drawRect(ruleBackgroundRect);
|
|
||||||
ruleIndex++;
|
|
||||||
currY += ruleHeight;
|
|
||||||
}
|
|
||||||
isSkip = false;
|
|
||||||
}
|
|
||||||
painter.restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::pPaintHeaders(QPainter &painter) {
|
|
||||||
QRectF offSetHeaderRect = pCalcOffsetHeaderRect();
|
|
||||||
|
|
||||||
painter.setPen(Qt::blue);
|
|
||||||
painter.drawText(offSetHeaderRect, Qt::AlignHCenter | Qt::AlignVCenter, "Offset (d)");
|
|
||||||
|
|
||||||
QRectF hexHeaderRect = pCalcHexHeaderRect();
|
|
||||||
|
|
||||||
int charWidth = fontMetrics().horizontalAdvance('F');
|
|
||||||
int hexCharsPerLine = qCeil(hexHeaderRect.width() / charWidth) / 3;
|
|
||||||
QString hexHeader = "";
|
|
||||||
for (int i = 0; i < hexCharsPerLine; i++) {
|
|
||||||
hexHeader += QString::number(i).rightJustified(2, '0') + " ";
|
|
||||||
}
|
|
||||||
hexHeader = hexHeader.trimmed();
|
|
||||||
|
|
||||||
painter.setPen(Qt::blue);
|
|
||||||
painter.drawText(hexHeaderRect, Qt::AlignVCenter, hexHeader);
|
|
||||||
|
|
||||||
QRectF textHeaderRect = pCalcTextHeaderRect();
|
|
||||||
|
|
||||||
painter.setPen(Qt::blue);
|
|
||||||
painter.drawText(textHeaderRect, Qt::AlignVCenter, "Decoded Text");
|
|
||||||
|
|
||||||
QRectF stackHeaderRect = pCalcRuleHeaderRect();
|
|
||||||
|
|
||||||
painter.setPen(Qt::blue);
|
|
||||||
painter.drawText(stackHeaderRect, Qt::AlignVCenter, "Rule Stack");
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::paintEvent(QPaintEvent *event) {
|
|
||||||
QPainter painter(viewport());
|
|
||||||
if (!painter.isActive()) {
|
|
||||||
HexesLogger::HexesError(45, "QPainter is not active!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event->rect().isEmpty()) { return; }
|
|
||||||
painter.fillRect(pViewRect, Qt::white);
|
|
||||||
|
|
||||||
pPaintHeaders(painter);
|
|
||||||
pPaintOffsetColumn(painter);
|
|
||||||
pPaintHex(painter);
|
|
||||||
pPaintText(painter);
|
|
||||||
pPaintRules(painter);
|
|
||||||
|
|
||||||
// if (pCursorVisible) {
|
|
||||||
// QPoint cursorPos = pCalcCursorPosition();
|
|
||||||
|
|
||||||
// int cursorHeight = pFontMetrics.height();
|
|
||||||
|
|
||||||
// painter.drawLine(cursorPos.x(), cursorPos.y(), cursorPos.x(), cursorPos.y() + cursorHeight);
|
|
||||||
// }
|
|
||||||
// if (pSelectionStart >= 0 && pSelectionEnd >= pSelectionStart) {
|
|
||||||
// if (pSelectionStart >= 0 && pSelectionEnd >= pSelectionStart) {
|
|
||||||
// int startX = pFontMetrics.horizontalAdvance(pText.left(pSelectionStart));
|
|
||||||
// int endX = pFontMetrics.horizontalAdvance(pText.left(pSelectionEnd));
|
|
||||||
// int height = pFontMetrics.height();
|
|
||||||
|
|
||||||
// painter.fillRect(QRect(startX, 0, endX - startX, height), QColor(0, 120, 215, 100)); // Semi-transparent blue
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::showEvent(QShowEvent *event) {
|
|
||||||
pUpdateScrollBar();
|
|
||||||
pSeekFile();
|
|
||||||
QAbstractScrollArea::showEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize HexViewer::sizeHint() const {
|
|
||||||
return pCalcPaintRect().size().toSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::pScrollValueChanged(int value) {
|
|
||||||
pScrollValue = value;
|
|
||||||
pSeekFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::pBlinkCursor() {
|
|
||||||
pCursorVisible = !pCursorVisible;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::resizeEvent(QResizeEvent *event) {
|
|
||||||
QAbstractScrollArea::resizeEvent(event);
|
|
||||||
|
|
||||||
pViewRect = QRectF(QPoint(0, 0), event->size());
|
|
||||||
pSeekFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::keyPressEvent(QKeyEvent *event) {
|
|
||||||
if (event->key() == Qt::Key_Left) {
|
|
||||||
pCursorPosition = qMax(0, pCursorPosition - 1);
|
|
||||||
} else if (event->key() == Qt::Key_Right) {
|
|
||||||
pCursorPosition = qMin(pText.length(), pCursorPosition + 1);
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::mousePressEvent(QMouseEvent *event) {
|
|
||||||
QFontMetrics fm(font());
|
|
||||||
int pos = event->pos().x() / fm.averageCharWidth();
|
|
||||||
pCursorPosition = qMin(pos, pText.length());
|
|
||||||
pSelectionStart = pCursorPosition;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::mouseMoveEvent(QMouseEvent *event) {
|
|
||||||
QFontMetrics fm(font());
|
|
||||||
int pos = event->pos().x() / fm.averageCharWidth();
|
|
||||||
pSelectionEnd = qMin(pos, pText.length());
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString HexViewer::pCleanHex(const QString &text) {
|
|
||||||
QString result;
|
|
||||||
for (int i = 0; i < text.length(); i += 2) {
|
|
||||||
result.append(text.mid(i, 2)); // Get two characters at a time
|
|
||||||
if (i + 2 < text.length()) {
|
|
||||||
result.append(" "); // Add a space after every two characters
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toUpper();
|
|
||||||
}
|
|
||||||
|
|
||||||
int HexViewer::pCalcContentHeight() const {
|
|
||||||
int numLines = pHex.length() / pCalcCharCount();
|
|
||||||
return numLines * fontMetrics().height();
|
|
||||||
}
|
|
||||||
|
|
||||||
int HexViewer::pCalcCharCount() const {
|
|
||||||
int charWidth = fontMetrics().horizontalAdvance("F");
|
|
||||||
QRectF hexHeaderRect(pCalcHexHeaderRect());
|
|
||||||
return qCeil(hexHeaderRect.width() / charWidth) / 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
int HexViewer::pCalcLineCount() const {
|
|
||||||
return pText.length() / pCalcCharCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
QPoint HexViewer::pCalcCursorPosition() const {
|
|
||||||
int lineHeight = fontMetrics().height();
|
|
||||||
|
|
||||||
int line = pCalcCursorLine();
|
|
||||||
|
|
||||||
int lineStart = 0;
|
|
||||||
for (int i = 0; i < line; ++i) {
|
|
||||||
lineStart += rect().width() / fontMetrics().averageCharWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
int cursorX = fontMetrics().horizontalAdvance(pText.mid(lineStart, pCursorPosition - lineStart));
|
|
||||||
int cursorY = line * lineHeight;
|
|
||||||
|
|
||||||
return QPoint(cursorX, cursorY);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF HexViewer::pCalcPaintRect() const {
|
|
||||||
return pViewRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
int HexViewer::pCalcCursorLine() const {
|
|
||||||
qreal columnWidth = rect().right() - 90 - verticalScrollBar()->width();
|
|
||||||
qreal scrollHeight = verticalScrollBar()->height();
|
|
||||||
qreal hexColumnWidth = (columnWidth / 4 * 3) - 15;
|
|
||||||
QRectF hexRect(95, 30, hexColumnWidth - 10, scrollHeight - 35);
|
|
||||||
|
|
||||||
int charsPerLine = hexRect.width() / fontMetrics().averageCharWidth();
|
|
||||||
|
|
||||||
return pCursorPosition / charsPerLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::pPaintCursor(QPainter &painter) {
|
|
||||||
Q_UNUSED(painter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::pPaintSelection(QPainter &painter) {
|
|
||||||
Q_UNUSED(painter);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString HexViewer::pStringToHex(const QString &text) {
|
|
||||||
return text.toUtf8().toHex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HexViewer::pUpdateScrollBar() {
|
|
||||||
verticalScrollBar()->setRange(0, pFile.size());
|
|
||||||
verticalScrollBar()->setPageStep(pCalcCharCount());
|
|
||||||
verticalScrollBar()->setSingleStep(pCalcCharCount());
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
157
hexviewer.h
157
hexviewer.h
@ -1,157 +0,0 @@
|
|||||||
#ifndef HEXVIEWER_H
|
|
||||||
#define HEXVIEWER_H
|
|
||||||
|
|
||||||
#include "rule.h"
|
|
||||||
#include "blockvalue.h"
|
|
||||||
#include "hexstream.h"
|
|
||||||
#include "hexeslogger.h"
|
|
||||||
|
|
||||||
#include <QAbstractScrollArea>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QScrollBar>
|
|
||||||
#include <QPaintEvent>
|
|
||||||
#include <QResizeEvent>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QQueue>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
const int DEFAULT_SINGLE_STEP = 45;
|
|
||||||
const int DEFAULT_PAGE_STEP = 45;
|
|
||||||
|
|
||||||
const int OFFSET_HEADER_WIDTH = 80;
|
|
||||||
const int MIN_PADDING = 5;
|
|
||||||
const int MAX_PADDING = 15;
|
|
||||||
const int HEADER_HEIGHT = 15;
|
|
||||||
const int STATUS_BAR_HEIGHT = 35;
|
|
||||||
const int FONT_HEIGHT = 15;
|
|
||||||
|
|
||||||
class HexViewer : public QAbstractScrollArea
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit HexViewer(QWidget *parent = nullptr);
|
|
||||||
~HexViewer();
|
|
||||||
|
|
||||||
void SetFileName(const QString fileName);
|
|
||||||
|
|
||||||
QStringList RuleNames();
|
|
||||||
void ParseRules();
|
|
||||||
|
|
||||||
void DeclareVar();
|
|
||||||
void SetVar(QString varName, QVariant value);
|
|
||||||
QVariant GetVar(QString varName);
|
|
||||||
QMap<QString, BlockValue> GetVars();
|
|
||||||
|
|
||||||
void SetBaseDir(QString dir);
|
|
||||||
|
|
||||||
QString Text();
|
|
||||||
QString Hex();
|
|
||||||
|
|
||||||
QString pFormatValuesGrid(const QVector<int>& values, int width, const QFont& font, int bitSize, int &textHeight);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void AddRule(const Rule rule);
|
|
||||||
void AddRules(const QVector<Rule> rules);
|
|
||||||
void DeleteRule(const Rule rule);
|
|
||||||
void DeleteRuleByName(const QString ruleName);
|
|
||||||
void PopRule();
|
|
||||||
void ClearRules();
|
|
||||||
|
|
||||||
void SaveRules();
|
|
||||||
void OpenRules();
|
|
||||||
void OpenFile();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
|
||||||
void paintEvent(QPaintEvent *event) override;
|
|
||||||
void showEvent(QShowEvent *event) override;
|
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void pScrollValueChanged(int value);
|
|
||||||
void pBlinkCursor();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void RuleNamesChanged(QStringList ruleNames);
|
|
||||||
void VarsChanged(QMap<QString, BlockValue> vars);
|
|
||||||
void FileOpened(const QString aFileName);
|
|
||||||
void BaseDirChanged(QString dir);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString pFileName;
|
|
||||||
QString pHex;
|
|
||||||
QString pText;
|
|
||||||
QRectF pViewRect;
|
|
||||||
QFile pFile;
|
|
||||||
QMap<QString, BlockValue> pVars;
|
|
||||||
QFontMetrics pFontMetrics;
|
|
||||||
QString pFileDir;
|
|
||||||
|
|
||||||
int pScrollValue;
|
|
||||||
int pCursorPosition; // Cursor position in the text
|
|
||||||
bool pCursorVisible; // Flag for cursor blinking
|
|
||||||
int pSelectionStart; // Selection start index
|
|
||||||
int pSelectionEnd; // Selection end index
|
|
||||||
QTimer *pBlinkTimer; // Timer for blinking cursor
|
|
||||||
QQueue<Rule> pRules;
|
|
||||||
|
|
||||||
// Init, update, & utility functions
|
|
||||||
void pInitCursorTimer();
|
|
||||||
void pInitScrollBar();
|
|
||||||
void pUpdateScrollBar();
|
|
||||||
QString pCleanHex(const QString &text);
|
|
||||||
QString pStringToHex(const QString &text);
|
|
||||||
void pSeekFile();
|
|
||||||
void pRefreshRules();
|
|
||||||
|
|
||||||
// Cursor functions
|
|
||||||
void pPaintCursor(QPainter &painter);
|
|
||||||
int pCalcCursorLine() const;
|
|
||||||
QPoint pCalcCursorPosition() const;
|
|
||||||
|
|
||||||
// Selection functions
|
|
||||||
void pPaintSelection(QPainter &painter);
|
|
||||||
|
|
||||||
// Header functions
|
|
||||||
void pPaintHeaders(QPainter &painter);
|
|
||||||
QRectF pCalcHexHeaderRect() const;
|
|
||||||
QRectF pCalcOffsetHeaderRect() const;
|
|
||||||
QRectF pCalcRuleHeaderRect() const;
|
|
||||||
QRectF pCalcTextHeaderRect() const;
|
|
||||||
|
|
||||||
// Hex content functions
|
|
||||||
void pPaintHex(QPainter &painter);
|
|
||||||
QRectF pCalcHexRect() const;
|
|
||||||
|
|
||||||
// Text content functions
|
|
||||||
void pPaintText(QPainter &painter);
|
|
||||||
QRectF pCalcTextRect() const;
|
|
||||||
|
|
||||||
// Offset functions
|
|
||||||
void pPaintOffsetColumn(QPainter &painter);
|
|
||||||
QRectF pCalcOffsetColumnRect() const;
|
|
||||||
|
|
||||||
// Rule functions
|
|
||||||
void pPaintRules(QPainter &painter);
|
|
||||||
QRectF pCalcRuleRect() const;
|
|
||||||
void pPaintHexRule(QPainter &painter, int ¤tXPos,
|
|
||||||
int ¤tYPos, int ruleLen, bool skip = false);
|
|
||||||
void pPaintTextRule(QPainter &painter, int ¤tXPos,
|
|
||||||
int ¤tYPos, int ruleLen, bool skip = false);
|
|
||||||
|
|
||||||
// Other calculations
|
|
||||||
QRectF pCalcPaintRect() const;
|
|
||||||
int pCalcContentHeight() const;
|
|
||||||
int pCalcCharCount() const;
|
|
||||||
int pCalcLineCount() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // HEXVIEWER_H
|
|
||||||
40
main.cpp
40
main.cpp
@ -1,40 +0,0 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
class Rule;
|
|
||||||
|
|
||||||
void HexesLogOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
||||||
{
|
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
|
||||||
switch (type) {
|
|
||||||
case QtDebugMsg:
|
|
||||||
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
||||||
break;
|
|
||||||
case QtInfoMsg:
|
|
||||||
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
||||||
break;
|
|
||||||
case QtWarningMsg:
|
|
||||||
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
||||||
break;
|
|
||||||
case QtCriticalMsg:
|
|
||||||
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
||||||
break;
|
|
||||||
case QtFatalMsg:
|
|
||||||
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
qInstallMessageHandler(HexesLogOutput);
|
|
||||||
QApplication a(argc, argv);
|
|
||||||
|
|
||||||
qRegisterMetaType<Rule>("Rule");
|
|
||||||
qRegisterMetaType<QQueue<Rule>>("QQueue<Rule>");
|
|
||||||
|
|
||||||
MainWindow w;
|
|
||||||
w.show();
|
|
||||||
return a.exec();
|
|
||||||
}
|
|
||||||
140
mainwindow.cpp
140
mainwindow.cpp
@ -1,140 +0,0 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
#include "ui_mainwindow.h"
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
|
||||||
: QMainWindow(parent)
|
|
||||||
, ui(new Ui::MainWindow) {
|
|
||||||
HexesLogger::MakeInstance(this);
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
pSettingsName = "mainwindow.ini";
|
|
||||||
pRecentFiles = QStringList();
|
|
||||||
pActions = QVector<QAction*>();
|
|
||||||
pBaseDir = "C:/";
|
|
||||||
|
|
||||||
pViewer = new HexViewer(this);
|
|
||||||
setCentralWidget(pViewer);
|
|
||||||
//pViewer->SetFileName("C:/Ext/Projects/Qt/Hexes/nazi_zombie_factory_patch.zone");
|
|
||||||
|
|
||||||
//ui->statusbar->showMessage(QString("File Size: %1 bytes").arg(data.size()));
|
|
||||||
|
|
||||||
pRuleDialog = new RuleDialog(this);
|
|
||||||
pRuleDialog->SetRuleNames(pViewer->RuleNames());
|
|
||||||
connect(ui->actionAdd_Rule, &QAction::triggered, pRuleDialog, &RuleDialog::exec);
|
|
||||||
connect(pRuleDialog, &RuleDialog::RuleChanged, pViewer, &HexViewer::AddRule);
|
|
||||||
connect(pRuleDialog, &RuleDialog::RulesChanged, pViewer, &HexViewer::AddRules);
|
|
||||||
connect(pViewer, &HexViewer::RuleNamesChanged, pRuleDialog, &RuleDialog::SetRuleNames);
|
|
||||||
connect(pViewer, &HexViewer::VarsChanged, pRuleDialog, &RuleDialog::SetVars);
|
|
||||||
|
|
||||||
connect(pViewer, &HexViewer::BaseDirChanged, pRuleDialog, &RuleDialog::SetBaseDir);
|
|
||||||
connect(pRuleDialog, &RuleDialog::BaseDirChanged, pViewer, &HexViewer::SetBaseDir);
|
|
||||||
connect(pViewer, &HexViewer::BaseDirChanged, this, &MainWindow::pSetBaseDir);
|
|
||||||
connect(pRuleDialog, &RuleDialog::BaseDirChanged, this, &MainWindow::pSetBaseDir);
|
|
||||||
|
|
||||||
pDelRuleDialog = new DeleteRuleDialog(this);
|
|
||||||
pDelRuleDialog->SetRuleNames(pViewer->RuleNames());
|
|
||||||
connect(pViewer, &HexViewer::RuleNamesChanged, pDelRuleDialog, &DeleteRuleDialog::SetRuleNames);
|
|
||||||
connect(ui->actionDelete_Rule, &QAction::triggered, pDelRuleDialog, &RuleDialog::exec);
|
|
||||||
connect(pDelRuleDialog, &DeleteRuleDialog::RuleDeleted, pViewer, &HexViewer::DeleteRuleByName);
|
|
||||||
|
|
||||||
connect(ui->actionClear_Rules, &QAction::triggered, pViewer, &HexViewer::ClearRules);
|
|
||||||
connect(ui->actionPop_Rule, &QAction::triggered, pViewer, &HexViewer::PopRule);
|
|
||||||
connect(ui->actionRun_Rules, &QAction::triggered, pViewer, &HexViewer::ParseRules);
|
|
||||||
connect(ui->actionOpen, &QAction::triggered, pViewer, &HexViewer::OpenFile);
|
|
||||||
connect(ui->actionSave_Rule_File, &QAction::triggered, pViewer, &HexViewer::SaveRules);
|
|
||||||
connect(ui->actionOpen_Rule_File, &QAction::triggered, pViewer, &HexViewer::OpenRules);
|
|
||||||
connect(pViewer, &HexViewer::FileOpened, this, &MainWindow::pAddRecentFile);
|
|
||||||
connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
|
||||||
|
|
||||||
QSettings HexesSettings(pSettingsName, QSettings::IniFormat);
|
|
||||||
if (HexesSettings.contains("file/basedir")) {
|
|
||||||
pBaseDir = HexesSettings.value("file/basedir").toString();
|
|
||||||
pViewer->SetBaseDir(pBaseDir);
|
|
||||||
pRuleDialog->SetBaseDir(pBaseDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::pClearActions() {
|
|
||||||
for (int i = 0; i < pActions.size(); i++) {
|
|
||||||
delete pActions[i];
|
|
||||||
}
|
|
||||||
pActions.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::pSetBaseDir(QString baseDir) {
|
|
||||||
pBaseDir = baseDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showEvent(QShowEvent *event) {
|
|
||||||
QMainWindow::showEvent(event);
|
|
||||||
|
|
||||||
pInitializeRecentFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::pClearRecentFiles() {
|
|
||||||
QMenu *recentFileMenu = ui->menuRecent_Files;
|
|
||||||
recentFileMenu->clear();
|
|
||||||
pRecentFiles.clear();
|
|
||||||
|
|
||||||
pClearActions();
|
|
||||||
|
|
||||||
pActions << new QAction("Clear Recents...", recentFileMenu);
|
|
||||||
recentFileMenu->addAction(pActions.last());
|
|
||||||
connect(pActions.last(), &QAction::triggered, this, &MainWindow::pClearRecentFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::pAddRecentFile(QString fileName) {
|
|
||||||
setWindowTitle(QString("Hexes - %1").arg(fileName));
|
|
||||||
|
|
||||||
QMenu *recentFileMenu = ui->menuRecent_Files;
|
|
||||||
recentFileMenu->clear();
|
|
||||||
|
|
||||||
pRecentFiles.push_back(fileName);
|
|
||||||
if (pRecentFiles.size() > 5) {
|
|
||||||
pRecentFiles.pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QAction*> pActions;
|
|
||||||
for (int i = 0; i < pRecentFiles.size(); i++) {
|
|
||||||
QString recentFileName = pRecentFiles[i];
|
|
||||||
pActions << new QAction(recentFileName, recentFileMenu);
|
|
||||||
}
|
|
||||||
recentFileMenu->addActions(pActions);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::pInitializeRecentFiles() {
|
|
||||||
pClearActions();
|
|
||||||
|
|
||||||
QMenu *recentFileMenu = ui->menuRecent_Files;
|
|
||||||
QSettings HexesSettings(pSettingsName, QSettings::IniFormat);
|
|
||||||
if (HexesSettings.contains("menu/recentfiles")) {
|
|
||||||
pRecentFiles = HexesSettings.value("menu/recentfiles").toStringList();
|
|
||||||
for (int i = 0; i < pRecentFiles.size(); i++) {
|
|
||||||
QString recentFileName = pRecentFiles[i];
|
|
||||||
pActions << new QAction(recentFileName, recentFileMenu);
|
|
||||||
recentFileMenu->addAction(pActions.last());
|
|
||||||
connect(pActions.last(), &QAction::triggered, this, [&]() {
|
|
||||||
pViewer->SetFileName(recentFileName);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
recentFileMenu->addSeparator();
|
|
||||||
pActions << new QAction("Clear Recents...", recentFileMenu);
|
|
||||||
recentFileMenu->addAction(pActions.last());
|
|
||||||
connect(pActions.last(), &QAction::triggered, this, &MainWindow::pClearRecentFiles);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
|
||||||
QSettings HexesSettings(pSettingsName, QSettings::IniFormat);
|
|
||||||
HexesSettings.setValue("menu/recentfiles", QVariant::fromValue(pRecentFiles));
|
|
||||||
HexesSettings.setValue("file/basedir", QVariant::fromValue(pBaseDir));
|
|
||||||
|
|
||||||
pClearActions();
|
|
||||||
HexesLogger::DeleteInstance();
|
|
||||||
|
|
||||||
delete ui;
|
|
||||||
delete pViewer;
|
|
||||||
delete pRuleDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
50
mainwindow.h
50
mainwindow.h
@ -1,50 +0,0 @@
|
|||||||
#ifndef MAINWINDOW_H
|
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include "hexviewer.h"
|
|
||||||
#include "ruledialog.h"
|
|
||||||
#include "deleteruledialog.h"
|
|
||||||
#include "hexeslogger.h"
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QDockWidget>
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
namespace Ui { class MainWindow; }
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MainWindow(QWidget *parent = nullptr);
|
|
||||||
~MainWindow();
|
|
||||||
|
|
||||||
void AddRecentFile(const QString fileName);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void pInitializeRecentFiles();
|
|
||||||
void pAddRecentFile(QString fileName);
|
|
||||||
void pClearRecentFiles();
|
|
||||||
void pClearActions();
|
|
||||||
void pSetBaseDir(QString baseDir);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void showEvent(QShowEvent* event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::MainWindow *ui;
|
|
||||||
HexViewer *pViewer;
|
|
||||||
RuleDialog *pRuleDialog;
|
|
||||||
DeleteRuleDialog *pDelRuleDialog;
|
|
||||||
QString pSettingsName;
|
|
||||||
QStringList pRecentFiles;
|
|
||||||
QVector<QAction*> pActions;
|
|
||||||
QString pBaseDir;
|
|
||||||
};
|
|
||||||
#endif // MAINWINDOW_H
|
|
||||||
281
mainwindow.ui
281
mainwindow.ui
@ -1,281 +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>800</width>
|
|
||||||
<height>600</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Hexes</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
|
||||||
<widget class="QMenuBar" name="menubar">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>800</width>
|
|
||||||
<height>20</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>10</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<widget class="QMenu" name="menuFile">
|
|
||||||
<property name="title">
|
|
||||||
<string>File</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QMenu" name="menuRecent_Files">
|
|
||||||
<property name="title">
|
|
||||||
<string>Recent Files</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionClear_Recents_2"/>
|
|
||||||
</widget>
|
|
||||||
<addaction name="actionNew"/>
|
|
||||||
<addaction name="actionOpen"/>
|
|
||||||
<addaction name="actionClose"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionSave_Rule_File"/>
|
|
||||||
<addaction name="actionSave_As"/>
|
|
||||||
<addaction name="actionOpen_Rule_File"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionSave_all"/>
|
|
||||||
<addaction name="actionClose_all"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="menuRecent_Files"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionExit"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menuRule">
|
|
||||||
<property name="title">
|
|
||||||
<string>Rule</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionAdd_Rule"/>
|
|
||||||
<addaction name="actionEdit_Rule"/>
|
|
||||||
<addaction name="actionPop_Rule"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionDelete_Rule"/>
|
|
||||||
<addaction name="actionClear_Rules"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionRun_Rules"/>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menuFile"/>
|
|
||||||
<addaction name="menuRule"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
|
||||||
<action name="actionAdd_Rule">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add Rule</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionEdit_Rule">
|
|
||||||
<property name="text">
|
|
||||||
<string>Edit Rule</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionDelete_Rule">
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete Rule</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionPop_Rule">
|
|
||||||
<property name="text">
|
|
||||||
<string>Pop Rule</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionRun_Rules">
|
|
||||||
<property name="text">
|
|
||||||
<string>Run Rules</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionNew">
|
|
||||||
<property name="text">
|
|
||||||
<string>New</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionOpen">
|
|
||||||
<property name="text">
|
|
||||||
<string>Open</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionClose">
|
|
||||||
<property name="text">
|
|
||||||
<string>Close</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSave">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSave_As">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save as...</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSave_all">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save all</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionClose_all">
|
|
||||||
<property name="text">
|
|
||||||
<string>Close all</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionExit">
|
|
||||||
<property name="text">
|
|
||||||
<string>Exit</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionClear_Rules">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear Rules</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionRecentFiles">
|
|
||||||
<property name="text">
|
|
||||||
<string>RecentFiles</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionClear_Recents">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear Recents</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>7</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionOpen_Rule_File">
|
|
||||||
<property name="text">
|
|
||||||
<string>Open Rule File</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSave_Rule_File">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save Rule File</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionClear_Recents_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear Recents</string>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>CommitMono</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
BIN
repeat.png
BIN
repeat.png
Binary file not shown.
|
Before Width: | Height: | Size: 954 B |
262
rule.cpp
262
rule.cpp
@ -1,262 +0,0 @@
|
|||||||
#include "rule.h"
|
|
||||||
|
|
||||||
Rule::Rule() {
|
|
||||||
pName = "";
|
|
||||||
pType = TYPE_NONE;
|
|
||||||
pProps = QVariantMap();
|
|
||||||
pColor = pGenerateColor();
|
|
||||||
pByteOrder = BYTE_ORDER_NONE;
|
|
||||||
pLength = -1;
|
|
||||||
pValue = "";
|
|
||||||
pRepeatCount = 0;
|
|
||||||
pPreSkipCount = 0;
|
|
||||||
pPostSkipCount = 0;
|
|
||||||
pRepeatOffset = 0;
|
|
||||||
pSkipOffset = 0;
|
|
||||||
pPreSkipOffset = 0;
|
|
||||||
pPostSkipOffset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rule::Rule(const Rule &rule) {
|
|
||||||
pName = rule.Name();
|
|
||||||
pType = rule.Type();
|
|
||||||
pProps = rule.Properties();
|
|
||||||
pColor = rule.Color();
|
|
||||||
pByteOrder = rule.ByteOrder();
|
|
||||||
pLength = rule.Length();
|
|
||||||
pValue = rule.Value();
|
|
||||||
pRepeatCount = rule.RepeatCount();
|
|
||||||
pPreSkipCount = rule.PreSkipCount();
|
|
||||||
pPostSkipCount = rule.PostSkipCount();
|
|
||||||
pRepeatOffset = rule.RepeatOffset();
|
|
||||||
pSkipOffset = rule.SkipOffset();
|
|
||||||
pPreSkipOffset = rule.PreSkipOffset();
|
|
||||||
pPostSkipOffset = rule.PostSkipOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
Rule &Rule::operator=(const Rule &rule) {
|
|
||||||
if (this == &rule) {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
pName = rule.Name();
|
|
||||||
pType = rule.Type();
|
|
||||||
pProps = rule.Properties();
|
|
||||||
pColor = rule.Color();
|
|
||||||
pByteOrder = rule.ByteOrder();
|
|
||||||
pLength = rule.Length();
|
|
||||||
pValue = rule.Value();
|
|
||||||
pRepeatCount = rule.RepeatCount();
|
|
||||||
pPreSkipCount = rule.PreSkipCount();
|
|
||||||
pPostSkipCount = rule.PostSkipCount();
|
|
||||||
pRepeatOffset = rule.RepeatOffset();
|
|
||||||
pSkipOffset = rule.SkipOffset();
|
|
||||||
pPreSkipOffset = rule.PreSkipOffset();
|
|
||||||
pPostSkipOffset = rule.PostSkipOffset();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Rule::operator!() const {
|
|
||||||
bool nameNull = pName.isEmpty();
|
|
||||||
bool typeNull = pType == TYPE_NONE;
|
|
||||||
bool propsNull = pProps.isEmpty();
|
|
||||||
bool byteOrderNull = pByteOrder == BYTE_ORDER_NONE;
|
|
||||||
bool lengthNull = pLength < 0;
|
|
||||||
bool valueNull = pValue.isLower() || pValue.isEmpty();
|
|
||||||
bool repeatNull = pRepeatCount < 0;
|
|
||||||
bool preSkipNull = pPreSkipCount < 0;
|
|
||||||
bool postSkipNull = pPostSkipCount < 0;
|
|
||||||
return nameNull && typeNull && propsNull &&
|
|
||||||
byteOrderNull && lengthNull && valueNull &&
|
|
||||||
repeatNull && preSkipNull && postSkipNull;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Rule::operator==(const Rule &rule) const {
|
|
||||||
bool nameMatch = pName == rule.Name();
|
|
||||||
bool typeMatch = pType == rule.Type();
|
|
||||||
bool propsMatch = pProps == rule.Properties();
|
|
||||||
bool byteOrderMatch = pByteOrder == rule.ByteOrder();
|
|
||||||
bool lengthMatch = pLength == rule.Length();
|
|
||||||
bool valueMatch = pValue == rule.Value();
|
|
||||||
bool repeatMatch = pRepeatCount == rule.RepeatCount();
|
|
||||||
bool preSkipMatch = pPreSkipCount == rule.PreSkipCount();
|
|
||||||
bool postSkipMatch = pPostSkipCount == rule.PostSkipCount();
|
|
||||||
return nameMatch && typeMatch && propsMatch &&
|
|
||||||
byteOrderMatch && lengthMatch && valueMatch &&
|
|
||||||
repeatMatch && preSkipMatch && postSkipMatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Rule::operator!=(const Rule &rule) const {
|
|
||||||
return !operator==(rule);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetName(const QString name) {
|
|
||||||
pName = name.toUpper();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Rule::Name() const {
|
|
||||||
return pName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetType(RULE_TYPE type) {
|
|
||||||
pType = type;
|
|
||||||
|
|
||||||
if (pLength == -1) {
|
|
||||||
pLength = pGetTypeLength(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RULE_TYPE Rule::Type() const {
|
|
||||||
return pType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetColor(const QColor color) {
|
|
||||||
pColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor Rule::Color() const {
|
|
||||||
return pColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetByteOrder(BYTE_ORDER byteOrder) {
|
|
||||||
pByteOrder = byteOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
BYTE_ORDER Rule::ByteOrder() const {
|
|
||||||
return pByteOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetLength(int length) {
|
|
||||||
pLength = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::Length() const {
|
|
||||||
return pLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetValue(QString value) {
|
|
||||||
pValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Rule::Value() const {
|
|
||||||
return pValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant Rule::GetProperty(QString propName) const {
|
|
||||||
return pProps[propName];
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetProperties(QVariantMap props) {
|
|
||||||
pProps = props;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap Rule::Properties() const {
|
|
||||||
return pProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetRepeatCount(int repeatCount) {
|
|
||||||
pRepeatCount = repeatCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::RepeatCount() const {
|
|
||||||
return pRepeatCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetPreSkipCount(int preSkipCount) {
|
|
||||||
if (pPreSkipCount < 0) { return; }
|
|
||||||
pPreSkipCount = preSkipCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::PreSkipCount() const {
|
|
||||||
return pPreSkipCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetPostSkipCount(int postSkipCount) {
|
|
||||||
pPostSkipCount = postSkipCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::PostSkipCount() const {
|
|
||||||
return pPostSkipCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetRepeatOffset(int repeatOffset) {
|
|
||||||
pRepeatOffset = repeatOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::RepeatOffset() const {
|
|
||||||
return pRepeatOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetSkipOffset(int skipOffset) {
|
|
||||||
pSkipOffset = skipOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::SkipOffset() const {
|
|
||||||
return pSkipOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetPreSkipOffset(int preSkipOffset) {
|
|
||||||
pPreSkipOffset = preSkipOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::PreSkipOffset() const {
|
|
||||||
return pPreSkipOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetPostSkipOffset(int postSkipOffset) {
|
|
||||||
pPostSkipOffset = postSkipOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::PostSkipOffset() const {
|
|
||||||
return pPostSkipOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor Rule::pGenerateColor() {
|
|
||||||
QRandomGenerator64 *globalRand = QRandomGenerator64::global();
|
|
||||||
double rRand = globalRand->generateDouble();
|
|
||||||
double gRand = globalRand->generateDouble();
|
|
||||||
double bRand = globalRand->generateDouble();
|
|
||||||
return QColor(rRand * 255, gRand * 255, bRand * 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Rule::pGetTypeLength(RULE_TYPE ruleType) {
|
|
||||||
int typeLength = 0;
|
|
||||||
switch ((int)ruleType) {
|
|
||||||
case 1: // TYPE_SKIP
|
|
||||||
typeLength = 0;
|
|
||||||
break;
|
|
||||||
case 2: // TYPE_INT_8
|
|
||||||
typeLength = 1;
|
|
||||||
break;
|
|
||||||
case 3: // TYPE_UINT_8
|
|
||||||
typeLength = 1;
|
|
||||||
break;
|
|
||||||
case 4: // TYPE_INT_16
|
|
||||||
typeLength = 2;
|
|
||||||
break;
|
|
||||||
case 5: // TYPE_UINT_16
|
|
||||||
typeLength = 2;
|
|
||||||
break;
|
|
||||||
case 6: // TYPE_INT_32
|
|
||||||
typeLength = 4;
|
|
||||||
break;
|
|
||||||
case 7: // TYPE_UINT_32
|
|
||||||
typeLength = 4;
|
|
||||||
break;
|
|
||||||
case 8: // TYPE_INT_64
|
|
||||||
typeLength = 8;
|
|
||||||
break;
|
|
||||||
case 9: // TYPE_UINT_64
|
|
||||||
typeLength = 8;
|
|
||||||
break;
|
|
||||||
default: // Unknown
|
|
||||||
typeLength = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return typeLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rule::SetProperty(QString propName, QVariant propData) {
|
|
||||||
pProps[propName] = propData;
|
|
||||||
}
|
|
||||||
202
rule.h
202
rule.h
@ -1,202 +0,0 @@
|
|||||||
#ifndef RULE_H
|
|
||||||
#define RULE_H
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QRandomGenerator64>
|
|
||||||
#include <QColor>
|
|
||||||
|
|
||||||
enum RULE_TYPE {
|
|
||||||
TYPE_NONE = 0,
|
|
||||||
TYPE_SKIP = 1,
|
|
||||||
TYPE_INT_8 = 2,
|
|
||||||
TYPE_UINT_8 = 3,
|
|
||||||
TYPE_INT_16 = 4,
|
|
||||||
TYPE_UINT_16 = 5,
|
|
||||||
TYPE_INT_32 = 6,
|
|
||||||
TYPE_UINT_32 = 7,
|
|
||||||
TYPE_INT_64 = 8,
|
|
||||||
TYPE_UINT_64 = 9
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BYTE_ORDER {
|
|
||||||
BYTE_ORDER_NONE = 0,
|
|
||||||
BYTE_ORDER_LE = 1,
|
|
||||||
BYTE_ORDER_BE = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
class Rule : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
Rule();
|
|
||||||
Rule(const Rule &rule);
|
|
||||||
|
|
||||||
Rule &operator=(const Rule &rule);
|
|
||||||
bool operator!() const;
|
|
||||||
bool operator==(const Rule& rule) const;
|
|
||||||
bool operator!=(const Rule& rule) const;
|
|
||||||
|
|
||||||
friend QDataStream &operator<<(QDataStream &arch, const Rule &rule) {
|
|
||||||
arch << rule.Name();
|
|
||||||
arch << rule.Type();
|
|
||||||
arch << rule.Properties();
|
|
||||||
arch << rule.Color();
|
|
||||||
arch << rule.ByteOrder();
|
|
||||||
arch << rule.Length();
|
|
||||||
arch << rule.Value();
|
|
||||||
arch << rule.PreSkipCount();
|
|
||||||
arch << rule.RepeatCount();
|
|
||||||
arch << rule.PostSkipCount();
|
|
||||||
arch << rule.SkipOffset();
|
|
||||||
arch << rule.RepeatOffset();
|
|
||||||
arch << rule.PreSkipOffset();
|
|
||||||
arch << rule.PostSkipOffset();
|
|
||||||
return arch;
|
|
||||||
}
|
|
||||||
friend QDataStream &operator>>(QDataStream &arch, Rule &rule) {
|
|
||||||
QString ruleName = "";
|
|
||||||
RULE_TYPE ruleType = TYPE_NONE;
|
|
||||||
QVariantMap ruleProps = QVariantMap();
|
|
||||||
QColor ruleColor = QColor();
|
|
||||||
BYTE_ORDER ruleByteOrder = BYTE_ORDER_NONE;
|
|
||||||
int ruleLength = 0;
|
|
||||||
QString ruleValue = "";
|
|
||||||
int preSkipCount = 0;
|
|
||||||
int repeatCount = 0;
|
|
||||||
int postSkipCount = 0;
|
|
||||||
int repeatOffset;
|
|
||||||
int skipOffset;
|
|
||||||
int preSkipOffset;
|
|
||||||
int postSkipOffset;
|
|
||||||
|
|
||||||
arch >> ruleName;
|
|
||||||
rule.SetName(ruleName);
|
|
||||||
arch >> ruleType;
|
|
||||||
rule.SetType(ruleType);
|
|
||||||
arch >> ruleProps;
|
|
||||||
rule.SetProperties(ruleProps);
|
|
||||||
arch >> ruleColor;
|
|
||||||
rule.SetColor(ruleColor);
|
|
||||||
arch >> ruleByteOrder;
|
|
||||||
rule.SetByteOrder(ruleByteOrder);
|
|
||||||
arch >> ruleLength;
|
|
||||||
rule.SetLength(ruleLength);
|
|
||||||
arch >> ruleValue;
|
|
||||||
rule.SetValue(ruleValue);
|
|
||||||
arch >> preSkipCount;
|
|
||||||
rule.SetPreSkipCount(preSkipCount);
|
|
||||||
arch >> repeatCount;
|
|
||||||
rule.SetRepeatCount(repeatCount);
|
|
||||||
arch >> postSkipCount;
|
|
||||||
rule.SetPostSkipCount(postSkipCount);
|
|
||||||
arch >> repeatOffset;
|
|
||||||
rule.SetRepeatOffset(repeatOffset);
|
|
||||||
arch >> skipOffset;
|
|
||||||
rule.SetSkipOffset(skipOffset);
|
|
||||||
arch >> preSkipOffset;
|
|
||||||
rule.SetPreSkipOffset(preSkipOffset);
|
|
||||||
arch >> postSkipOffset;
|
|
||||||
rule.SetPostSkipOffset(postSkipOffset);
|
|
||||||
|
|
||||||
return arch;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator QString() const {
|
|
||||||
return QString("Rule: %1\n"
|
|
||||||
"-Type: %2\n"
|
|
||||||
"-Color: %4\n"
|
|
||||||
"-ByteOrder: %5\n"
|
|
||||||
"-Length: %6\n"
|
|
||||||
"-Value: %7\n"
|
|
||||||
"-PreSkipCount: %8\n"
|
|
||||||
"-RepeatCount: %9\n"
|
|
||||||
"-PostSkipCount: %10\n"
|
|
||||||
"-SkipOffset: %11\n"
|
|
||||||
"-RepeatOffset: %12\n"
|
|
||||||
"-PreSkipOffset: %13\n"
|
|
||||||
"-PostSkipOffset: %14\n")
|
|
||||||
.arg(pName)
|
|
||||||
.arg(pType)
|
|
||||||
.arg(pColor.name())
|
|
||||||
.arg(pByteOrder)
|
|
||||||
.arg(pLength)
|
|
||||||
.arg(pValue)
|
|
||||||
.arg(pPreSkipCount)
|
|
||||||
.arg(pRepeatCount)
|
|
||||||
.arg(pPostSkipCount)
|
|
||||||
.arg(pSkipOffset)
|
|
||||||
.arg(pRepeatOffset)
|
|
||||||
.arg(pPreSkipOffset)
|
|
||||||
.arg(pPostSkipOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetName(const QString name);
|
|
||||||
QString Name() const;
|
|
||||||
|
|
||||||
void SetType(RULE_TYPE type);
|
|
||||||
RULE_TYPE Type() const;
|
|
||||||
|
|
||||||
void SetColor(const QColor color);
|
|
||||||
QColor Color() const;
|
|
||||||
|
|
||||||
void SetByteOrder(BYTE_ORDER byteOrder);
|
|
||||||
BYTE_ORDER ByteOrder() const;
|
|
||||||
|
|
||||||
void SetLength(int length);
|
|
||||||
int Length() const;
|
|
||||||
|
|
||||||
void SetValue(QString value);
|
|
||||||
QString Value() const;
|
|
||||||
|
|
||||||
void SetProperty(QString propName, QVariant propData);
|
|
||||||
QVariant GetProperty(QString propName) const;
|
|
||||||
|
|
||||||
void SetProperties(QVariantMap props);
|
|
||||||
QVariantMap Properties() const;
|
|
||||||
|
|
||||||
void SetRepeatCount(int repeatCount);
|
|
||||||
int RepeatCount() const;
|
|
||||||
|
|
||||||
void SetPreSkipCount(int preSkipCount);
|
|
||||||
int PreSkipCount() const;
|
|
||||||
|
|
||||||
void SetPostSkipCount(int postSkipCount);
|
|
||||||
int PostSkipCount() const;
|
|
||||||
|
|
||||||
void SetRepeatOffset(int repeatOffset);
|
|
||||||
int RepeatOffset() const;
|
|
||||||
|
|
||||||
void SetSkipOffset(int skipOffset);
|
|
||||||
int SkipOffset() const;
|
|
||||||
|
|
||||||
void SetPreSkipOffset(int preSkipOffset);
|
|
||||||
int PreSkipOffset() const;
|
|
||||||
|
|
||||||
void SetPostSkipOffset(int postSkipOffset);
|
|
||||||
int PostSkipOffset() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString pName;
|
|
||||||
RULE_TYPE pType;
|
|
||||||
QVariantMap pProps;
|
|
||||||
QColor pColor;
|
|
||||||
BYTE_ORDER pByteOrder;
|
|
||||||
int pLength;
|
|
||||||
QString pValue;
|
|
||||||
int pRepeatCount;
|
|
||||||
int pPreSkipCount;
|
|
||||||
int pPostSkipCount;
|
|
||||||
int pRepeatOffset;
|
|
||||||
int pSkipOffset;
|
|
||||||
int pPreSkipOffset;
|
|
||||||
int pPostSkipOffset;
|
|
||||||
|
|
||||||
QColor pGenerateColor();
|
|
||||||
int pGetTypeLength(RULE_TYPE ruleType);
|
|
||||||
};
|
|
||||||
Q_DECLARE_METATYPE(Rule)
|
|
||||||
|
|
||||||
#endif // RULE_H
|
|
||||||
443
ruledialog.cpp
443
ruledialog.cpp
@ -1,443 +0,0 @@
|
|||||||
#include "ruledialog.h"
|
|
||||||
#include "ui_ruledialog.h"
|
|
||||||
|
|
||||||
RuleDialog::RuleDialog(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::RuleDialog) {
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
pRuleNames = QStringList();
|
|
||||||
pVars = QMap<QString, BlockValue>();
|
|
||||||
pDefaultRuleCount = 1;
|
|
||||||
pRules = QQueue<Rule>();
|
|
||||||
pSnippetDir = "C:/";
|
|
||||||
|
|
||||||
ui->toolBox->setCurrentIndex(0);
|
|
||||||
|
|
||||||
ui->groupBox_SkipOptions->hide();
|
|
||||||
pHideLayout(ui->layout_ByteOrder);
|
|
||||||
|
|
||||||
ui->label_Pre_SkipOffset->hide();
|
|
||||||
ui->spinBox_Pre_Offset->hide();
|
|
||||||
|
|
||||||
ui->label_SkipOffset->hide();
|
|
||||||
ui->spinBox_Skip_Offset->hide();
|
|
||||||
|
|
||||||
ui->label_Post_SkipOffset->hide();
|
|
||||||
ui->spinBox_Post_Offset->hide();
|
|
||||||
|
|
||||||
ui->label_RepeatOffset->hide();
|
|
||||||
ui->spinBox_Repeat_Offset->hide();
|
|
||||||
|
|
||||||
connect(ui->checkBox_PreSkip_Offset, &QCheckBox::toggled, this, [this](bool toggled) {
|
|
||||||
ui->label_Pre_SkipOffset->setVisible(toggled);
|
|
||||||
ui->spinBox_Pre_Offset->setVisible(toggled);
|
|
||||||
});
|
|
||||||
connect(ui->checkBox_Skip_Offset, &QCheckBox::toggled, this, [this](bool toggled) {
|
|
||||||
ui->label_SkipOffset->setVisible(toggled);
|
|
||||||
ui->spinBox_Skip_Offset->setVisible(toggled);
|
|
||||||
});
|
|
||||||
connect(ui->checkBox_PostSkip_Offset, &QCheckBox::toggled, this, [this](bool toggled) {
|
|
||||||
ui->label_Post_SkipOffset->setVisible(toggled);
|
|
||||||
ui->spinBox_Post_Offset->setVisible(toggled);
|
|
||||||
});
|
|
||||||
connect(ui->checkBox_Repeat_Offset, &QCheckBox::toggled, this, [this](bool toggled) {
|
|
||||||
ui->label_RepeatOffset->setVisible(toggled);
|
|
||||||
ui->spinBox_Repeat_Offset->setVisible(toggled);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(ui->verticalScrollBar, &QScrollBar::valueChanged, ui->widget_RulePreview, &RulePreview::SetScrollValue);
|
|
||||||
connect(ui->widget_RulePreview, &RulePreview::ScrollMaxChanged, ui->verticalScrollBar, &QScrollBar::setMaximum);
|
|
||||||
|
|
||||||
connect(ui->pushButton_QueueRule, &QPushButton::clicked, this, &RuleDialog::pQueueRule);
|
|
||||||
connect(ui->pushButton_Cancel, &QPushButton::clicked, this, &RuleDialog::pCancelDialog);
|
|
||||||
connect(ui->pushButton_Clear, &QPushButton::clicked, this, &RuleDialog::pClearRules);
|
|
||||||
connect(ui->pushButton_PopFirstRule, &QPushButton::clicked, this, &RuleDialog::pPopFirstRule);
|
|
||||||
connect(ui->pushButton_PopLastRule, &QPushButton::clicked, this, &RuleDialog::pPopLastRule);
|
|
||||||
connect(ui->pushButton_Save, &QPushButton::clicked, this, &RuleDialog::pSaveRules);
|
|
||||||
connect(ui->comboBox_Type, &QComboBox::currentIndexChanged, this, &RuleDialog::pTypeChanged);
|
|
||||||
|
|
||||||
connect(ui->pushButton_Import, &QPushButton::clicked, this, &RuleDialog::pImportSnippet);
|
|
||||||
connect(ui->pushButton_Export, &QPushButton::clicked, this, &RuleDialog::pExportSnippet);
|
|
||||||
|
|
||||||
connect(this, &RuleDialog::RulesChanged, ui->widget_RulePreview, &RulePreview::SetRules);
|
|
||||||
|
|
||||||
ui->comboBox_Repeat_Vars->hide();
|
|
||||||
connect(ui->radioButton_Repeat_PrevVar, &QRadioButton::toggled, this, &RuleDialog::pRepeat_PrevVarToggled);
|
|
||||||
connect(ui->radioButton_Repeat_StaticVal, &QRadioButton::toggled, this, &RuleDialog::pRepeat_StaticValToggled);
|
|
||||||
|
|
||||||
ui->comboBox_Skip_Vars->hide();
|
|
||||||
connect(ui->radioButton_Skip_PrevVar, &QRadioButton::toggled, this, &RuleDialog::pSkip_PrevVarToggled);
|
|
||||||
connect(ui->radioButton_Skip_StaticVal, &QRadioButton::toggled, this, &RuleDialog::pSkip_StaticValToggled);
|
|
||||||
|
|
||||||
ui->comboBox_Pre_Vars->hide();
|
|
||||||
connect(ui->radioButton_Pre_StaticVal, &QRadioButton::toggled, this, &RuleDialog::pPre_StaticValToggled);
|
|
||||||
connect(ui->radioButton_Pre_PrevVar, &QRadioButton::toggled, this, &RuleDialog::pPre_PrevVarToggled);
|
|
||||||
|
|
||||||
ui->comboBox_Post_Vars->hide();
|
|
||||||
connect(ui->radioButton_Post_StaticVal, &QRadioButton::toggled, this, &RuleDialog::pPost_StaticValToggled);
|
|
||||||
connect(ui->radioButton_Post_PrevVar, &QRadioButton::toggled, this, &RuleDialog::pPost_PrevVarToggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
RuleDialog::~RuleDialog() {
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pQueueRule() {
|
|
||||||
QString name = ui->lineEdit_Name->text();
|
|
||||||
if (name == "") { return; }
|
|
||||||
|
|
||||||
RULE_TYPE type = (RULE_TYPE)ui->comboBox_Type->currentIndex();
|
|
||||||
|
|
||||||
Rule rule;
|
|
||||||
rule.SetName(name);
|
|
||||||
rule.SetType(type);
|
|
||||||
|
|
||||||
if (type == TYPE_NONE) {
|
|
||||||
return;
|
|
||||||
} else if (type == TYPE_SKIP) {
|
|
||||||
if (ui->radioButton_Skip_PrevVar->isChecked()) {
|
|
||||||
QString itemText = ui->comboBox_Skip_Vars->currentText();
|
|
||||||
const QString leadingNumber = itemText.split('.').first() + ".";
|
|
||||||
const QString varText = itemText.replace(leadingNumber, "")
|
|
||||||
.split('(').first().trimmed();
|
|
||||||
BlockValue blockVal = pVars[varText];
|
|
||||||
rule.SetLength(blockVal.ToInt());
|
|
||||||
} else if (ui->radioButton_Skip_StaticVal->isChecked()) {
|
|
||||||
rule.SetLength(ui->spinBox_Skip_StaticVal->value());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ui->radioButton_Repeat_StaticVal->isChecked()) {
|
|
||||||
rule.SetRepeatCount(ui->spinBox_Repeat_StaticVal->value());
|
|
||||||
} else {
|
|
||||||
QString itemText = ui->comboBox_Repeat_Vars->currentText();
|
|
||||||
const QString leadingNumber = itemText.split('.').first() + ".";
|
|
||||||
const QString varText = itemText.replace(leadingNumber, "")
|
|
||||||
.split('(').first().trimmed();
|
|
||||||
BlockValue blockVal = pVars[varText];
|
|
||||||
rule.SetRepeatCount(blockVal.ToInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ui->groupBox_PreSkip->isChecked()) {
|
|
||||||
if (ui->radioButton_Pre_StaticVal->isChecked()) {
|
|
||||||
rule.SetPreSkipCount(ui->spinBox_Pre_StaticVal->value());
|
|
||||||
} else {
|
|
||||||
QString itemText = ui->comboBox_Pre_Vars->currentText();
|
|
||||||
const QString leadingNumber = itemText.split('.').first() + ".";
|
|
||||||
const QString varText = itemText.replace(leadingNumber, "")
|
|
||||||
.split('(').first().trimmed();
|
|
||||||
BlockValue blockVal = pVars[varText];
|
|
||||||
rule.SetPreSkipCount(blockVal.ToInt());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ui->groupBox_PostSkip->isChecked()) {
|
|
||||||
if (ui->radioButton_Post_StaticVal->isChecked()) {
|
|
||||||
rule.SetPostSkipCount(ui->spinBox_Post_StaticVal->value());
|
|
||||||
} else {
|
|
||||||
QString itemText = ui->comboBox_Post_Vars->currentText();
|
|
||||||
const QString leadingNumber = itemText.split('.').first() + ".";
|
|
||||||
const QString varText = itemText.replace(leadingNumber, "")
|
|
||||||
.split('(').first().trimmed();
|
|
||||||
BlockValue blockVal = pVars[varText];
|
|
||||||
rule.SetPostSkipCount(blockVal.ToInt());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ui->radioButton_BE->isChecked()) {
|
|
||||||
rule.SetByteOrder(BYTE_ORDER_BE);
|
|
||||||
} else {
|
|
||||||
rule.SetByteOrder(BYTE_ORDER_LE);
|
|
||||||
}
|
|
||||||
|
|
||||||
rule.SetSkipOffset(ui->spinBox_Skip_Offset->value());
|
|
||||||
rule.SetPreSkipOffset(ui->spinBox_Pre_Offset->value());
|
|
||||||
rule.SetPostSkipOffset(ui->spinBox_Post_Offset->value());
|
|
||||||
rule.SetRepeatOffset(ui->spinBox_Repeat_Offset->value());
|
|
||||||
|
|
||||||
pRules.enqueue(rule);
|
|
||||||
ui->widget_RulePreview->SetRules(pRules.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pSaveRules() {
|
|
||||||
emit RulesChanged(pRules.toList());
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pClearRules() {
|
|
||||||
pRules.clear();
|
|
||||||
ui->widget_RulePreview->SetRules(pRules.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pPopFirstRule() {
|
|
||||||
pRules.pop_front();
|
|
||||||
ui->widget_RulePreview->SetRules(pRules.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pPopLastRule() {
|
|
||||||
pRules.pop_back();
|
|
||||||
ui->widget_RulePreview->SetRules(pRules.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pCancelDialog() {
|
|
||||||
pDefaultRuleCount--;
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pImportSnippet() {
|
|
||||||
QStringList filters;
|
|
||||||
filters.append("Rule File (*.hrs)");
|
|
||||||
filters.append("All Files(*.*)");
|
|
||||||
|
|
||||||
QFileDialog importDialog(this);
|
|
||||||
importDialog.setWindowTitle("Open Hexes Rule Snippet");
|
|
||||||
importDialog.setFileMode(QFileDialog::ExistingFile);
|
|
||||||
importDialog.setDirectory(pSnippetDir);
|
|
||||||
importDialog.setAcceptMode(QFileDialog::AcceptOpen);
|
|
||||||
importDialog.setNameFilters(filters);
|
|
||||||
if (importDialog.exec() != QDialog::Accepted) {
|
|
||||||
qDebug() << "Open snippet dialog was not accepted!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString snippetPath = importDialog.selectedFiles().first();
|
|
||||||
QString tempSnippetPath = snippetPath;
|
|
||||||
pSnippetDir = tempSnippetPath.replace(tempSnippetPath.split('/').last(), "");
|
|
||||||
emit BaseDirChanged(pSnippetDir);
|
|
||||||
|
|
||||||
QFile snippetFile(snippetPath);
|
|
||||||
if (!snippetFile.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "Failed to open snippet file!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
snippetFile.close();
|
|
||||||
|
|
||||||
QSettings snippetImport(snippetPath, QSettings::IniFormat);
|
|
||||||
pRules = snippetImport.value("rules").value<QQueue<Rule>>();
|
|
||||||
ui->widget_RulePreview->SetRules(pRules.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pExportSnippet() {
|
|
||||||
QStringList filters;
|
|
||||||
filters.append("Rule File (*.hrs)");
|
|
||||||
filters.append("All Files(*.*)");
|
|
||||||
|
|
||||||
QFileDialog exportDialog(this);
|
|
||||||
exportDialog.setWindowTitle("Save Hexes Rule Snippet");
|
|
||||||
exportDialog.setDirectory(pSnippetDir);
|
|
||||||
exportDialog.setAcceptMode(QFileDialog::AcceptSave);
|
|
||||||
exportDialog.setNameFilters(filters);
|
|
||||||
if (exportDialog.exec() != QDialog::Accepted) {
|
|
||||||
qDebug() << "Save snippet dialog was not accepted!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString snippetPath = exportDialog.selectedFiles().first();
|
|
||||||
QString tempSnippetPath = snippetPath;
|
|
||||||
pSnippetDir = tempSnippetPath.replace(tempSnippetPath.split('/').last(), "");
|
|
||||||
emit BaseDirChanged(pSnippetDir);
|
|
||||||
|
|
||||||
QFile snippetFile(snippetPath);
|
|
||||||
if (!snippetFile.open(QIODevice::WriteOnly)) {
|
|
||||||
qDebug() << "Failed to save snippet file!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
snippetFile.close();
|
|
||||||
|
|
||||||
QSettings snippetExport(snippetPath, QSettings::IniFormat);
|
|
||||||
snippetExport.setValue("rules", QVariant::fromValue(pRules));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pHideLayout(QLayout* layout) {
|
|
||||||
if (!layout)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < layout->count(); ++i) {
|
|
||||||
QWidget *widget = layout->itemAt(i)->widget();
|
|
||||||
if (widget) {
|
|
||||||
widget->hide(); // Hide each widget in the layout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pShowLayout(QLayout* layout) {
|
|
||||||
if (!layout)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < layout->count(); ++i) {
|
|
||||||
QWidget *widget = layout->itemAt(i)->widget();
|
|
||||||
if (widget) {
|
|
||||||
widget->show(); // Hide each widget in the layout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pTypeChanged(int index) {
|
|
||||||
ui->groupBox_SkipOptions->hide();
|
|
||||||
pShowLayout(ui->layout_ByteOrder);
|
|
||||||
|
|
||||||
switch (index) {
|
|
||||||
case 0: // none
|
|
||||||
ui->groupBox_SkipOptions->hide();
|
|
||||||
pHideLayout(ui->layout_ByteOrder);
|
|
||||||
break;
|
|
||||||
case 1: // skip
|
|
||||||
ui->groupBox_SkipOptions->show();
|
|
||||||
pHideLayout(ui->layout_ByteOrder);
|
|
||||||
break;
|
|
||||||
case 2: // int8 [1]
|
|
||||||
break;
|
|
||||||
case 3: // uint8 [1]
|
|
||||||
break;
|
|
||||||
case 4: // int16 [2]
|
|
||||||
break;
|
|
||||||
case 5: // uint16 [2]
|
|
||||||
break;
|
|
||||||
case 6: // int32 [3]
|
|
||||||
break;
|
|
||||||
case 7: // uint32 [3]
|
|
||||||
break;
|
|
||||||
case 8: // int64 [4]
|
|
||||||
break;
|
|
||||||
case 9: // uint64 [4]
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pSkip_PrevVarToggled(bool toggled) {
|
|
||||||
ui->comboBox_Skip_Vars->setVisible(toggled);
|
|
||||||
ui->spinBox_Skip_StaticVal->setVisible(!toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pSkip_StaticValToggled(bool toggled) {
|
|
||||||
ui->comboBox_Skip_Vars->setVisible(!toggled);
|
|
||||||
ui->spinBox_Skip_StaticVal->setVisible(toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pRepeat_PrevVarToggled(bool toggled) {
|
|
||||||
ui->comboBox_Repeat_Vars->setVisible(toggled);
|
|
||||||
ui->spinBox_Repeat_StaticVal->setVisible(!toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pRepeat_StaticValToggled(bool toggled) {
|
|
||||||
ui->comboBox_Repeat_Vars->setVisible(!toggled);
|
|
||||||
ui->spinBox_Repeat_StaticVal->setVisible(toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pPre_PrevVarToggled(bool toggled) {
|
|
||||||
ui->comboBox_Pre_Vars->setVisible(toggled);
|
|
||||||
ui->spinBox_Pre_StaticVal->setVisible(!toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pPre_StaticValToggled(bool toggled) {
|
|
||||||
ui->comboBox_Pre_Vars->setVisible(!toggled);
|
|
||||||
ui->spinBox_Pre_StaticVal->setVisible(toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pPost_PrevVarToggled(bool toggled) {
|
|
||||||
ui->comboBox_Post_Vars->setVisible(toggled);
|
|
||||||
ui->spinBox_Post_StaticVal->setVisible(!toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::pPost_StaticValToggled(bool toggled) {
|
|
||||||
ui->comboBox_Post_Vars->setVisible(!toggled);
|
|
||||||
ui->spinBox_Post_StaticVal->setVisible(toggled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::closeEvent(QCloseEvent *event) {
|
|
||||||
ui->toolBox->setCurrentIndex(0);
|
|
||||||
|
|
||||||
if (pRuleNames.contains(QString("RULE %1").arg(pDefaultRuleCount))) {
|
|
||||||
pDefaultRuleCount++;
|
|
||||||
}
|
|
||||||
const QString defaultName = QString("RULE %1").arg(pDefaultRuleCount);
|
|
||||||
ui->lineEdit_Name->setText(defaultName);
|
|
||||||
|
|
||||||
ui->comboBox_Type->setCurrentIndex(0);
|
|
||||||
|
|
||||||
ui->radioButton_LE->setChecked(true);
|
|
||||||
|
|
||||||
ui->spinBox_Skip_StaticVal->setValue(1);
|
|
||||||
ui->checkBox_Skip_Offset->setChecked(false);
|
|
||||||
ui->label_SkipOffset->hide();
|
|
||||||
ui->spinBox_Skip_Offset->hide();
|
|
||||||
ui->radioButton_Skip_StaticVal->setChecked(true);
|
|
||||||
ui->spinBox_Skip_StaticVal->setValue(0);
|
|
||||||
ui->comboBox_Skip_Vars->setCurrentIndex(0);
|
|
||||||
|
|
||||||
ui->groupBox_PreSkip->setChecked(false);
|
|
||||||
ui->checkBox_PreSkip_Offset->setChecked(false);
|
|
||||||
ui->radioButton_Pre_StaticVal->setChecked(true);
|
|
||||||
ui->spinBox_Pre_StaticVal->show();
|
|
||||||
ui->comboBox_Pre_Vars->hide();
|
|
||||||
ui->spinBox_Pre_Offset->setValue(0);
|
|
||||||
ui->spinBox_Pre_StaticVal->setValue(0);
|
|
||||||
|
|
||||||
ui->groupBox_PostSkip->setChecked(false);
|
|
||||||
ui->checkBox_PostSkip_Offset->setChecked(false);
|
|
||||||
ui->radioButton_Post_StaticVal->setChecked(true);
|
|
||||||
ui->spinBox_Post_StaticVal->show();
|
|
||||||
ui->comboBox_Post_Vars->hide();
|
|
||||||
ui->spinBox_Post_Offset->setValue(0);
|
|
||||||
ui->spinBox_Post_StaticVal->setValue(0);
|
|
||||||
|
|
||||||
ui->radioButton_Repeat_StaticVal->setChecked(true);
|
|
||||||
ui->checkBox_Repeat_Offset->setChecked(false);
|
|
||||||
ui->label_RepeatOffset->hide();
|
|
||||||
ui->spinBox_Repeat_Offset->hide();
|
|
||||||
ui->spinBox_Repeat_StaticVal->setValue(0);
|
|
||||||
|
|
||||||
pRules.clear();
|
|
||||||
ui->widget_RulePreview->SetRules(pRules.toList());
|
|
||||||
|
|
||||||
QDialog::closeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
Rule RuleDialog::GetRule() {
|
|
||||||
return pRule;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::SetRule(const Rule rule) {
|
|
||||||
ui->lineEdit_Name->setText(rule.Name());
|
|
||||||
|
|
||||||
if (rule.Type() == TYPE_SKIP) {
|
|
||||||
ui->spinBox_Skip_StaticVal->setValue(rule.Length());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::SetBaseDir(QString dir) {
|
|
||||||
pSnippetDir = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::SetRuleNames(QStringList ruleNames) {
|
|
||||||
pRuleNames = ruleNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuleDialog::SetVars(QMap<QString, BlockValue> vars) {
|
|
||||||
ui->comboBox_Repeat_Vars->clear();
|
|
||||||
ui->comboBox_Repeat_Vars->addItem("Select Variable");
|
|
||||||
|
|
||||||
ui->comboBox_Skip_Vars->clear();
|
|
||||||
ui->comboBox_Skip_Vars->addItem("Select Variable");
|
|
||||||
|
|
||||||
ui->comboBox_Pre_Vars->clear();
|
|
||||||
ui->comboBox_Pre_Vars->addItem("Select Variable");
|
|
||||||
|
|
||||||
ui->comboBox_Post_Vars->clear();
|
|
||||||
ui->comboBox_Post_Vars->addItem("Select Variable");
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (auto [key, value] : vars.asKeyValueRange()) {
|
|
||||||
i++;
|
|
||||||
QString varName = (QString)key;
|
|
||||||
BlockValue varVal = (BlockValue)value;
|
|
||||||
QString itemName = QString("%1. %2 (%3)")
|
|
||||||
.arg(QString::number(i), varName, varVal.ToVariant().toString());
|
|
||||||
ui->comboBox_Repeat_Vars->addItem(itemName);
|
|
||||||
ui->comboBox_Skip_Vars->addItem(itemName);
|
|
||||||
ui->comboBox_Pre_Vars->addItem(itemName);
|
|
||||||
ui->comboBox_Post_Vars->addItem(itemName);
|
|
||||||
}
|
|
||||||
pVars = vars;
|
|
||||||
}
|
|
||||||
71
ruledialog.h
71
ruledialog.h
@ -1,71 +0,0 @@
|
|||||||
#ifndef RULEDIALOG_H
|
|
||||||
#define RULEDIALOG_H
|
|
||||||
|
|
||||||
#include "rule.h"
|
|
||||||
#include "blockvalue.h"
|
|
||||||
#include "rulepreview.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QQueue>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class RuleDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RuleDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit RuleDialog(QWidget *parent = nullptr);
|
|
||||||
~RuleDialog();
|
|
||||||
|
|
||||||
Rule GetRule();
|
|
||||||
void SetRule(const Rule rule);
|
|
||||||
|
|
||||||
void SetBaseDir(QString dir);
|
|
||||||
|
|
||||||
void SetRuleNames(QStringList ruleNames);
|
|
||||||
void SetVars(QMap<QString, BlockValue> vars);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void pQueueRule();
|
|
||||||
void pClearRules();
|
|
||||||
void pSaveRules();
|
|
||||||
void pPopFirstRule();
|
|
||||||
void pPopLastRule();
|
|
||||||
void pCancelDialog();
|
|
||||||
void pImportSnippet();
|
|
||||||
void pExportSnippet();
|
|
||||||
void pTypeChanged(int index);
|
|
||||||
void pSkip_PrevVarToggled(bool toggled);
|
|
||||||
void pSkip_StaticValToggled(bool toggled);
|
|
||||||
void pPre_PrevVarToggled(bool toggled);
|
|
||||||
void pPre_StaticValToggled(bool toggled);
|
|
||||||
void pPost_PrevVarToggled(bool toggled);
|
|
||||||
void pPost_StaticValToggled(bool toggled);
|
|
||||||
void pRepeat_PrevVarToggled(bool toggled);
|
|
||||||
void pRepeat_StaticValToggled(bool toggled);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void RuleChanged(Rule rule);
|
|
||||||
void RulesChanged(QVector<Rule> rules);
|
|
||||||
void BaseDirChanged(QString dir);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void closeEvent(QCloseEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::RuleDialog *ui;
|
|
||||||
Rule pRule;
|
|
||||||
QStringList pRuleNames;
|
|
||||||
QMap<QString, BlockValue> pVars;
|
|
||||||
int pDefaultRuleCount;
|
|
||||||
QQueue<Rule> pRules;
|
|
||||||
QString pSnippetDir;
|
|
||||||
|
|
||||||
void pHideLayout(QLayout *layout);
|
|
||||||
void pShowLayout(QLayout *layout);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // RULEDIALOG_H
|
|
||||||
1415
ruledialog.ui
1415
ruledialog.ui
File diff suppressed because it is too large
Load Diff
141
rulepreview.cpp
141
rulepreview.cpp
@ -1,141 +0,0 @@
|
|||||||
#include "rulepreview.h"
|
|
||||||
#include "ui_rulepreview.h"
|
|
||||||
|
|
||||||
RulePreview::RulePreview(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::RulePreview)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
pRules = QQueue<Rule>();
|
|
||||||
pScrollValue = 0;
|
|
||||||
pScrollMax = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
RulePreview::~RulePreview() {
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RulePreview::AddRule(const Rule rule) {
|
|
||||||
pRules.enqueue(rule);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RulePreview::AddRules(const QVector<Rule> rules) {
|
|
||||||
for (int i = 0; i < rules.size(); i++) {
|
|
||||||
pRules.enqueue(rules[i]);
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RulePreview::DeleteRule(const Rule rule) {
|
|
||||||
if (!pRules.contains(rule)) { return; }
|
|
||||||
if (pRules.size() == 0) { return; }
|
|
||||||
|
|
||||||
for (int i = 0; i < pRules.size(); i++) {
|
|
||||||
Rule currentRule = pRules.dequeue();
|
|
||||||
|
|
||||||
if (currentRule != rule) {
|
|
||||||
pRules.enqueue(currentRule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RulePreview::DeleteRuleByName(const QString ruleName) {
|
|
||||||
if (pRules.size() == 0) { return; }
|
|
||||||
|
|
||||||
for (int i = 0; i < pRules.size(); i++) {
|
|
||||||
Rule currentRule = pRules.dequeue();
|
|
||||||
|
|
||||||
if (currentRule.Name() != ruleName) {
|
|
||||||
pRules.enqueue(currentRule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RulePreview::SetRules(const QVector<Rule> rules) {
|
|
||||||
pRules.clear();
|
|
||||||
AddRules(rules);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RulePreview::SetScrollValue(int scrollValue) {
|
|
||||||
pScrollValue = scrollValue;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RulePreview::paintEvent(QPaintEvent *event) {
|
|
||||||
Q_UNUSED(event);
|
|
||||||
|
|
||||||
QPainter painter(this);
|
|
||||||
|
|
||||||
int ruleIndex = 1;
|
|
||||||
QRectF rulesRect = event->rect();
|
|
||||||
painter.setBrush(QColor(45, 45, 45));
|
|
||||||
painter.setPen(QPen(QColor(60, 60, 60), 2));
|
|
||||||
painter.drawRoundedRect(rulesRect, 8, 8);
|
|
||||||
|
|
||||||
painter.setFont(QFont("CommitMono", 7));
|
|
||||||
|
|
||||||
QRectF clipRect(0, rulesRect.top(), width(), rulesRect.height());
|
|
||||||
painter.setClipRect(clipRect);
|
|
||||||
|
|
||||||
foreach (Rule rule, pRules) {
|
|
||||||
painter.setPen(QPen(rule.Color(), 1));
|
|
||||||
|
|
||||||
QString typeText = "";
|
|
||||||
|
|
||||||
QColor ruleBackground(rule.Color());
|
|
||||||
ruleBackground.setAlpha(75);
|
|
||||||
painter.setBrush(ruleBackground);
|
|
||||||
int offset = ruleIndex * 5;
|
|
||||||
|
|
||||||
// Draw the rule information in the rule stack on the right side
|
|
||||||
QRectF ruleBackgroundRect(rulesRect.left() + 10, offset - pScrollValue + rulesRect.top() + 11 + (QFontMetrics(painter.font()).height() * 3) * (ruleIndex - 1),
|
|
||||||
rulesRect.width() - 20, QFontMetrics(painter.font()).height() * 3);
|
|
||||||
QRectF ruleRect(rulesRect.left() + 11, offset - pScrollValue + rulesRect.top() + 12 + (QFontMetrics(painter.font()).height() * 3) * (ruleIndex - 1),
|
|
||||||
rulesRect.width() - 22, QFontMetrics(painter.font()).height() * 3);
|
|
||||||
painter.drawRect(ruleBackgroundRect);
|
|
||||||
|
|
||||||
pScrollMax = qMax(pScrollMax, (int)ruleRect.bottom());
|
|
||||||
|
|
||||||
bool isSkip = false;
|
|
||||||
switch ((int)rule.Type()) {
|
|
||||||
case 1: // TYPE_SKIP
|
|
||||||
typeText = QString("Skip %1 byte(s)").arg(rule.Length());
|
|
||||||
isSkip = true;
|
|
||||||
break;
|
|
||||||
case 2: // TYPE_INT_8
|
|
||||||
case 3: // TYPE_UINT_8
|
|
||||||
case 4: // TYPE_INT_16
|
|
||||||
case 5: // TYPE_UINT_16
|
|
||||||
case 6: // TYPE_INT_32
|
|
||||||
case 7: // TYPE_UINT_32
|
|
||||||
case 8: // TYPE_INT_64
|
|
||||||
case 9: // TYPE_UINT_64
|
|
||||||
typeText = QString("%1-BIT %2 INTEGER").arg(rule.Length() * 8).arg(rule.Type() % 2 == 0 ? "" : "US");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
typeText = "UH-OH";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
painter.setPen(Qt::white);
|
|
||||||
QString paddedIndex = QString::number(ruleIndex).rightJustified(2, '0');
|
|
||||||
QString ruleName = rule.Name().toUpper();
|
|
||||||
|
|
||||||
QString ruleText = QString("%1. %2\n%3\nN/A\n").arg(paddedIndex, ruleName, typeText);
|
|
||||||
painter.drawText(ruleRect, Qt::TextWrapAnywhere, ruleText);
|
|
||||||
QString ruleByteOrder = QString(rule.ByteOrder() == BYTE_ORDER_BE ? "BE" : "LE") + "\n\n";
|
|
||||||
if (!isSkip) {
|
|
||||||
painter.drawText(ruleRect, Qt::AlignRight, ruleByteOrder);
|
|
||||||
}
|
|
||||||
ruleIndex++;
|
|
||||||
}
|
|
||||||
emit ScrollMaxChanged(qMax(0, static_cast<int>(pScrollMax - rulesRect.height())));
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize RulePreview::sizeHint() const {
|
|
||||||
return parentWidget()->size();
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
#ifndef RULEPREVIEW_H
|
|
||||||
#define RULEPREVIEW_H
|
|
||||||
|
|
||||||
#include "rule.h"
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QPaintEvent>
|
|
||||||
#include <QScrollBar>
|
|
||||||
#include <QQueue>
|
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class RulePreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RuleDialog;
|
|
||||||
|
|
||||||
class RulePreview : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit RulePreview(QWidget *parent = nullptr);
|
|
||||||
~RulePreview();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void AddRule(const Rule rule);
|
|
||||||
void AddRules(const QVector<Rule> rules);
|
|
||||||
void DeleteRule(const Rule rule);
|
|
||||||
void DeleteRuleByName(const QString ruleName);
|
|
||||||
void SetRules(const QVector<Rule> rules);
|
|
||||||
|
|
||||||
void SetScrollValue(int scrollValue);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void ScrollMaxChanged(int scrollMax);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *event) override;
|
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::RulePreview *ui;
|
|
||||||
QQueue<Rule> pRules;
|
|
||||||
int pScrollValue;
|
|
||||||
int pScrollMax;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // RULEPREVIEW_H
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>RulePreview</class>
|
|
||||||
<widget class="QWidget" name="RulePreview">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
#include "testhexviewer.h"
|
|
||||||
|
|
||||||
void TestQString::pCalcCharCount() {
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
#ifndef TESTHEXVIEWER_H
|
|
||||||
#define TESTHEXVIEWER_H
|
|
||||||
|
|
||||||
#include "hexviewer.h"
|
|
||||||
|
|
||||||
#include <QTest>
|
|
||||||
|
|
||||||
class TestQString: public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void pCalcCharCount();
|
|
||||||
|
|
||||||
private:
|
|
||||||
HexViewer *pHexViewer;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // TESTHEXVIEWER_H
|
|
||||||
Loading…
x
Reference in New Issue
Block a user