This commit is contained in:
2024-09-12 17:31:39 +08:00
commit 64cd67ecf6
14 changed files with 1517 additions and 0 deletions

13
gloab.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "gloab.h"
QString Gloab::fileName="";
QVector<QMap<QString,QString>> Gloab::g_param[4];
QMap<QString,QString> Gloab::temData;
QMap<QString,bool> Gloab::namelist;
QList<QtCharts::QChartView*> Gloab::m_chartViews;
QWidget * Gloab::widget;
QVector<QString> Gloab::rule;
QFile Gloab::file;
qint64 Gloab::fileSize;
qint64 Gloab::bytesRead;
QCompleter *Gloab::completer;

33
gloab.h Normal file
View File

@ -0,0 +1,33 @@
//
// Created by Sherlock on 2024/8/12.
//
#ifndef GLOAB_H
#define GLOAB_H
#include <QChartView>
#include <QMap>
#include <QVector>
#include <QString>
#include <QList>
#include <QWidget>
#include <QFile>
#include <QLineSeries>
#include <QCompleter>
class Gloab{
public:
static QString fileName;
static QVector<QMap<QString,QString>> g_param[4];
static QMap<QString,QString> temData;
static QMap<QString,bool> namelist;
static QList<QtCharts::QChartView*> m_chartViews;
static QWidget *widget;
static QVector<QString> rule;
static QFile file;
static qint64 fileSize;
static qint64 bytesRead;
static QCompleter *completer;
};
#endif //GLOAB_H

32
log7.pro Normal file
View File

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

275
log7.pro.user Normal file
View File

@ -0,0 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 12.0.2, 2024-09-12T17:28:53. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{212c491d-8228-40db-8cc9-f183f9b9d8d0}</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>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="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">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<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">6</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="ClangdSettings">
<value type="bool" key="blockIndexing">false</value>
<value type="bool" key="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">Qt 5.12.0 (mingw73_64)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.12.0 (mingw73_64)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{edc54fcd-f681-4a0a-ba77-11a1a5c94a66}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</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">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Work\CQT\Test_01\build-log7-Qt_5_12_0_mingw73_64-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-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">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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:\Work\CQT\Test_01\build-log7-Qt_5_12_0_mingw73_64-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-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">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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:\Work\CQT\Test_01\build-log7-Qt_5_12_0_mingw73_64-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</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>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></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="ProjectExplorer.ProjectConfiguration.DisplayName">log72</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Work/QT/ReadLog/log7/log7.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Work/QT/ReadLog/log7/log7.pro</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</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:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Debug</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>

15
main.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "mainwindow.h"
#include <QApplication>
#include <QTextCodec>
int main(int argc, char *argv[])
{
// qputenv("QT_SCALE_FACTOR", "2.0");
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

373
mainwindow.cpp Normal file
View File

@ -0,0 +1,373 @@
#include "mainwindow.h"
#include <QMessageBox>
#include "./ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
, thread_read(new threadRead), thread_chart(new ThreadChart),thread_polt(new threadPoltChart){
ui->setupUi(this);
this->setWindowTitle("日志查询工具");
// 创建版本号标签
m_versionLabel = new QLabel(tr("v1.1.0"), this);
// 将标签添加到状态栏的右端
ui->statusbar->addPermanentWidget(m_versionLabel);
connect(thread_read, &threadRead::clearCombo, this, &MainWindow::clearCombo);
connect(thread_read, &threadRead::showStatusbar, this, &MainWindow::showStatusbar);
connect(thread_read, &threadRead::setBeginTime, this, &MainWindow::setBeginTime);
connect(thread_read, &threadRead::setEndTime, this, &MainWindow::setEndTime);
connect(thread_read, &threadRead::addCombo, this, &MainWindow::addCombo);
connect(thread_read, &threadRead::setProgressBar, this, &MainWindow::setProgressBar);
connect(thread_read, &threadRead::closeProg, this, &MainWindow::closeProg);
//chart
connect(thread_chart, &ThreadChart::newCandS, this, &MainWindow::newCandS);
connect(thread_chart, &ThreadChart::appSeries, this, &MainWindow::appSeries);
connect(thread_chart, &ThreadChart::setChartView, this, &MainWindow::setChartView);
connect(thread_chart, &ThreadChart::setWidget, this, &MainWindow::setWidget);
connect(thread_chart, &ThreadChart::setProgressBar, this, &MainWindow::setProgressBar);
//plot
connect(thread_polt, &threadPoltChart::newCandS, this, &MainWindow::newPlotCandS);
connect(thread_polt, &threadPoltChart::appSeries, this, &MainWindow::appSeries);
connect(thread_polt, &threadPoltChart::setChartView, this, &MainWindow::setPlotChartView);
connect(thread_polt, &threadPoltChart::setWidget, this, &MainWindow::setWidget);
connect(thread_polt, &threadPoltChart::setProgressBar, this, &MainWindow::setProgressBar);
}
MainWindow::~MainWindow() {
delete ui;
}
void MainWindow::on_openFileBtn_clicked() {
Gloab::fileName = QFileDialog::getOpenFileName();
//打开文件
Gloab::file.setFileName(Gloab::fileName);
if (!Gloab::file.open(QIODevice::ReadOnly)) {
// 打开失败时弹窗
QString dlgTitle = "错误";
QString strInfo = "文件打开失败";
QMessageBox::warning(this, dlgTitle, strInfo);
//退出
return;
}
//设置进度条
layout = new QVBoxLayout(ui->widget);
progressBar = new QProgressBar(ui->widget);
layout->addWidget(progressBar);
ui->widget->show();
// 获取文件大小
Gloab::fileSize = Gloab::file.size();
Gloab::bytesRead = 0;
thread_read->start();
}
void MainWindow::clearCombo() {
ui->comboBox->clear();
}
void MainWindow::showStatusbar(const QString &message) {
ui->statusbar->showMessage(message);
}
void MainWindow::setBeginTime(const QDateTime &begin) {
ui->beginTime->setDateTime(begin);
}
void MainWindow::setEndTime(const QDateTime &begin) {
ui->endTime->setDateTime(begin);
}
void MainWindow::addCombo(const QStringList &list) {
ui->comboBox->addItems(list);
//根据输入匹配下拉框
Gloab::completer = new QCompleter(list);
ui->comboBox->setCompleter(Gloab::completer);
}
void MainWindow::setProgressBar(int percent) {
progressBar->setValue(percent);
// qApp->processEvents(); // 更新UI
}
void MainWindow::closeProg() {
layout->deleteLater();
progressBar->deleteLater();
ui->widget->close();
}
void MainWindow::newCandS() {
chart = new QChart;
series = new QLineSeries;
// series->setPointsVisible();
}
void MainWindow::appSeries(qreal A, qreal B) {
series->append(A, B);
}
void MainWindow::setChartView(int jd, bool isEnum) {
// 设置图表标题
chart->setTitle(QString("基带 %1").arg(jd+1));
chart->addSeries(series);
if (isEnum) {
chart->createDefaultAxes();
// 获取X轴
QList<QAbstractAxis *> xAxes = chart->axes(Qt::Horizontal);
// 断开所有与该轴关联的系列
series->detachAxis(xAxes[0]);
// 从图表中移除轴
chart->removeAxis(xAxes[0]);
} else {
// 创建类别Y轴
QCategoryAxis *axisY = new QCategoryAxis();
for (int var = 1; var < Gloab::rule.size(); ++var) {
axisY->append(Gloab::rule[var], var);
}
//刻度线和刻度的label对齐
axisY->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);
axisY->setRange(0, Gloab::rule.size() + 1);
chart->setAxisY(axisY, series);
// series->attachAxis(axisY);
}
// 创建一个时间轴
QDateTimeAxis *axisX = new QDateTimeAxis;
axisX->setTickCount(10);
axisX->setFormat("HH:mm"); // 设置时间格式
chart->addAxis(axisX, Qt::AlignBottom);
series->attachAxis(axisX);
// 创建QChartView
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
// 将chartView添加到容器中
Gloab::m_chartViews.append(chartView);
}
void MainWindow::setWidget() {
// 设置布局
int wide = 850;
int hight = 600;
if (Gloab::m_chartViews.size() > 1) {
wide = 1800;
}
QGridLayout *gridLayout = new QGridLayout(Gloab::widget);
for (int i = 0, j = 0; i < Gloab::m_chartViews.size(); i++) {
if (i != 0 && i % 2 == 0) {
j++;
hight += 350;
}
gridLayout->addWidget(Gloab::m_chartViews[i], j, i - 2 * j);
}
Gloab::widget->resize(wide, hight);
// Gloab::widget->setMaximumHeight(950);
Gloab::widget->move(70, 20);
Gloab::widget->show();
layout->deleteLater();
progressBar->deleteLater();
ui->widget->close();
}
void MainWindow::newPlotCandS() {
chart = new QChart;
series = new QLineSeries;
// series->setPointsVisible();
}
void MainWindow::setPlotChartView(int jd, bool isEnum) {
// 设置图表标题
chart->setTitle(QString("基带 %1").arg(jd+1));
chart->addSeries(series);
if (isEnum) {
chart->createDefaultAxes();
} else {
//创建默认XY轴
chart->createDefaultAxes();
//删除Y轴
// 获取Y轴
QList<QAbstractAxis *> yAxes = chart->axes(Qt::Vertical);
// 断开所有与该轴关联的系列
series->detachAxis(yAxes[0]);
// 从图表中移除轴
chart->removeAxis(yAxes[0]);
// 创建类别Y轴
QCategoryAxis *axisY = new QCategoryAxis();
for (int var = 1; var < Gloab::rule.size(); ++var) {
axisY->append(Gloab::rule[var], var);
}
//刻度线和刻度的label对齐
axisY->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);
axisY->setRange(0, Gloab::rule.size() + 1);
chart->setAxisY(axisY, series);
// plotSeries->attachAxis(axisY);
}
// 创建QChartView
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
// 将chartView添加到容器中
Gloab::m_chartViews.append(chartView);
}
void MainWindow::on_lineChart_clicked() {
if (Gloab::fileName.isEmpty()) {
QMessageBox::warning(this, "警告", "请先打开一个日志");
return;
}
//关闭打开的窗口
if (Gloab::widget) {
Gloab::widget->close();
delete Gloab::widget;
Gloab::widget = nullptr;
}
//获取基带id
QVector<int> jd;
if (ui->jd1->isChecked()) {
jd.append(0);
}
if (ui->jd2->isChecked()) {
jd.append(1);
}
if (ui->jd3->isChecked()) {
jd.append(2);
}
if (ui->jd4->isChecked()) {
jd.append(3);
}
if (jd.isEmpty()) {
QMessageBox::warning(this, "警告", "请至少选择一个基带");
return;
}
//获取时间
QDateTime beginTime = ui->beginTime->dateTime();
QDateTime endTime = ui->endTime->dateTime();
if (beginTime>endTime) {
QMessageBox::warning(this, "警告", "请选择正确的时间段");
return;
}
//获取参数名
QString dataName = ui->comboBox->currentText();
if (!Gloab::namelist.keys().contains(dataName)) {
QMessageBox::warning(this, "警告", "未找到该数据");
return;
}
//传入数据绘图
thread_chart->setValue(jd, dataName, beginTime, endTime);
Gloab::widget = new QWidget();
Gloab::widget->setWindowTitle(dataName);
//设置进度条
layout = new QVBoxLayout(ui->widget);
progressBar = new QProgressBar(ui->widget);
layout->addWidget(progressBar);
ui->widget->show();
// 获取文件大小
Gloab::fileSize=0;
for (int i = 0; i < jd.size(); ++i) {
Gloab::fileSize+=Gloab::g_param[jd[i]].size();
}
Gloab::bytesRead = 0;
thread_chart->start();
}
bool MainWindow::isNumeric(const QString &str) {
// 正则表达式匹配数字和可选的正负号
QRegularExpression pattern("^[+-]?([1-9][0-9]*|0)[.]?[0-9]*$");
QRegularExpressionMatch patternMatch = pattern.match(str);
// 使用std::regex_match来检查字符串是否完全匹配模式
return patternMatch.hasMatch();
}
void MainWindow::on_plotChart_clicked()
{
if (Gloab::fileName.isEmpty()) {
QMessageBox::warning(this, "警告", "请先打开一个日志");
return;
}
//关闭打开的窗口
if (Gloab::widget) {
Gloab::widget->close();
delete Gloab::widget;
Gloab::widget = nullptr;
}
//获取基带id
QVector<int> jd;
if (ui->jd1->isChecked()) {
jd.append(0);
}
if (ui->jd2->isChecked()) {
jd.append(1);
}
if (ui->jd3->isChecked()) {
jd.append(2);
}
if (ui->jd4->isChecked()) {
jd.append(3);
}
if (jd.isEmpty()) {
QMessageBox::warning(this, "警告", "请至少选择一个基带");
return;
}
//获取时间
QDateTime beginTime = ui->beginTime->dateTime();
QDateTime endTime = ui->endTime->dateTime();
if (beginTime>endTime) {
QMessageBox::warning(this, "警告", "请选择正确的时间段");
return;
}
//获取参数名
QString dataName = ui->comboBox->currentText();
if (!Gloab::namelist.keys().contains(dataName)) {
QMessageBox::warning(this, "警告", "未找到该数据");
return;
}
//传入数据绘图
thread_polt->setValue(jd, dataName, beginTime, endTime);
Gloab::widget = new QWidget();
Gloab::widget->setWindowTitle(dataName);
//设置进度条
layout = new QVBoxLayout(ui->widget);
progressBar = new QProgressBar(ui->widget);
layout->addWidget(progressBar);
ui->widget->show();
// 获取文件大小
Gloab::fileSize=0;
for (int i = 0; i < jd.size(); ++i) {
Gloab::fileSize+=Gloab::g_param[jd[i]].size();
}
Gloab::bytesRead = 0;
thread_polt->start();
}

68
mainwindow.h Normal file
View File

@ -0,0 +1,68 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "gloab.h"
#include "threadread.h"
#include <QMainWindow>
#include <QString>
#include <QDialog>
#include <QVBoxLayout>
#include <QProgressBar>
#include "threadchart.h"
#include "threadpoltchart.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_openFileBtn_clicked();
void clearCombo();
void showStatusbar(const QString &message);
void setBeginTime(const QDateTime &begin);
void setEndTime(const QDateTime &begin);
void addCombo(const QStringList &list);
void setProgressBar(int percent);
void closeProg();
void newCandS();
void appSeries(qreal A,qreal B);
void setChartView(int jd,bool isEnum);
void setWidget();
void newPlotCandS();
void setPlotChartView(int jd,bool isEnum);
void on_lineChart_clicked();
bool isNumeric(const QString &str);
void on_plotChart_clicked();
private:
Ui::MainWindow *ui;
QLabel *m_versionLabel;
threadRead *thread_read;
ThreadChart *thread_chart;
threadPoltChart *thread_polt;
QProgressBar *progressBar;
QVBoxLayout *layout;
QChart *chart;
QLineSeries *series;
};
#endif // MAINWINDOW_H

294
mainwindow.ui Normal file
View File

@ -0,0 +1,294 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_5">
<item row="9" column="0">
<widget class="QPushButton" name="lineChart">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>时间图</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>开始时间</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QDateTimeEdit" name="beginTime">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="displayFormat">
<string>yyyy/MM/dd HH:mm:ss</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="10" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" rowspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>选择基带</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="jd1">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>基带1</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="jd4">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>基带4</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="jd3">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>基带3</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="jd2">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>基带2</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>数据</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QComboBox" name="comboBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>结束时间</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QDateTimeEdit" name="endTime">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="displayFormat">
<string>yyyy/MM/dd HH:mm:ss</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="10" column="1">
<widget class="QWidget" name="widget" native="true"/>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="plotChart">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>数据变化图</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="openFileBtn">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>打开文件</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

82
threadchart.cpp Normal file
View File

@ -0,0 +1,82 @@
#include "threadchart.h"
#include <QDebug>
ThreadChart::ThreadChart(QObject *parent)
: QThread{parent} {
}
void ThreadChart::setValue(QVector<int> jd, QString dataName, QDateTime beginTime, QDateTime endTime) {
this->jd = jd;
this->dataName = dataName;
this->beginTime = beginTime;
this->endTime = endTime;
}
void ThreadChart::run() {
Gloab::m_chartViews.clear();
Gloab::rule.clear();
Gloab::rule.append("状态");
//判断右侧数据是否为数字型
bool isEnum = Gloab::namelist[dataName];
for (int i = 0; i < jd.size(); ++i) {
emit newCandS();
qreal y = 114.514;
QString tem1 = "无数据";
// 为每个图表添加数据
if (isEnum) {
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
//更新进度条
Gloab::bytesRead++;
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
emit setProgressBar(percent);
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
if (temTime >= beginTime && temTime < endTime) {
if (!Gloab::g_param[jd[i]][j].contains(dataName)) {
if (y != 114.514) {
emit appSeries(temTime.toMSecsSinceEpoch(), y);
}
} else {
if (Gloab::g_param[jd[i]][j][dataName].contains(".")) {
y = Gloab::g_param[jd[i]][j][dataName].toDouble();
emit appSeries(temTime.toMSecsSinceEpoch(), y);
} else {
y = Gloab::g_param[jd[i]][j][dataName].toLongLong();
emit appSeries(temTime.toMSecsSinceEpoch(), y);
}
}
}
}
} else {
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
//更新进度条
Gloab::bytesRead++;
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
emit setProgressBar(percent);
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
if (temTime >= beginTime && temTime < endTime) {
if (!Gloab::g_param[jd[i]][j].contains(dataName)) {
if (tem1 != "无数据") {
if (!Gloab::rule.contains(tem1)) {
Gloab::rule.append(tem1);
}
emit appSeries(temTime.toMSecsSinceEpoch(), Gloab::rule.indexOf(tem1));
}
} else {
tem1 = Gloab::g_param[jd[i]][j][dataName];
if (!Gloab::rule.contains(tem1)) {
Gloab::rule.append(tem1);
}
emit appSeries(temTime.toMSecsSinceEpoch(), Gloab::rule.indexOf(tem1));
}
}
}
}
emit setChartView(jd[i], isEnum);
}
emit setWidget();
quit();
}

44
threadchart.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef THREADCHART_H
#define THREADCHART_H
#include <QThread>
#include <QDateTime>
#include <QDialog>
#include <QChart>
using namespace QtCharts;
#include <QLineSeries>
#include <QRegularExpression>
#include <QCategoryAxis>
#include <QDateTimeAxis>
#include <QGridLayout>
#include "gloab.h"
class ThreadChart : public QThread {
Q_OBJECT
public:
explicit ThreadChart(QObject *parent = nullptr);
void setValue(QVector<int> jd, QString dataName, QDateTime beginTime, QDateTime endTime);
signals:
void newCandS();
void appSeries(qreal A,qreal B);
void setChartView(int jd,bool isEnum);
void setWidget();
void setProgressBar(int percent);
protected:
void run() override;
private:
QVector<int> jd;
QDateTime beginTime;
QDateTime endTime;
QString dataName;
};
#endif // THREADCHART_H

87
threadpoltchart.cpp Normal file
View File

@ -0,0 +1,87 @@
#include "threadpoltchart.h"
#include <QDebug>
threadPoltChart::threadPoltChart(QObject *parent)
: QThread{parent} {
}
void threadPoltChart::setValue(QVector<int> jd, QString dataName, QDateTime beginTime, QDateTime endTime) {
this->jd = jd;
this->dataName = dataName;
this->beginTime = beginTime;
this->endTime = endTime;
}
void threadPoltChart::run() {
Gloab::m_chartViews.clear();
Gloab::rule.clear();
Gloab::rule.append("状态");
for (int i = 0; i < jd.size(); ++i) {
int X = 1;
emit newCandS();
// 为每个图表添加数据
//判断右侧数据是否为数字型
bool isEnum = Gloab::namelist[dataName];
if (dataName.contains("版本号")) {
isEnum = false;
}
if (isEnum) {
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
//更新进度条
Gloab::bytesRead++;
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
emit setProgressBar(percent);
if (Gloab::g_param[jd[i]][j].keys().size()<=deleteName.size()) {
bool f=true;
for(auto key : Gloab::g_param[jd[i]][j].keys()) {
if (!deleteName.contains(key)) {
f=false;
break;
}
}
if (f) {
continue;
}
}
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
if (temTime >= beginTime && temTime < endTime) {
if (Gloab::g_param[jd[i]][j].contains(dataName)) {
if (Gloab::g_param[jd[i]][j][dataName].contains(".")) {
emit appSeries(X++, Gloab::g_param[jd[i]][j][dataName].toDouble());
} else {
emit appSeries(X++, Gloab::g_param[jd[i]][j][dataName].toLongLong());
}
}
}
}
} else {
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
//更新进度条
Gloab::bytesRead++;
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
emit setProgressBar(percent);
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
if (temTime >= beginTime && temTime < endTime) {
if (Gloab::g_param[jd[i]][j].contains(dataName)) {
QString tem1 = Gloab::g_param[jd[i]][j][dataName];
if (!Gloab::rule.contains(tem1)) {
Gloab::rule.append(tem1);
}
emit appSeries(X++, Gloab::rule.indexOf(tem1));
}
}
}
}
emit setChartView(jd[i], isEnum);
}
emit setWidget();
quit();
}

49
threadpoltchart.h Normal file
View File

@ -0,0 +1,49 @@
#ifndef THREADPOLTCHART_H
#define THREADPOLTCHART_H
#include <QThread>
#include <QDateTime>
#include <QDialog>
#include <QChart>
using namespace QtCharts;
#include <QLineSeries>
#include <QRegularExpression>
#include <QCategoryAxis>
#include <QDateTimeAxis>
#include <QGridLayout>
#include "gloab.h"
class threadPoltChart : public QThread {
Q_OBJECT
public:
explicit threadPoltChart(QObject *parent = nullptr);
void setValue(QVector<int> jd, QString dataName, QDateTime beginTime, QDateTime endTime );
signals:
void newCandS();
void appSeries(qreal A, qreal B);
void setChartView(int jd, bool isEnum);
void setWidget();
void setProgressBar(int percent);
protected:
void run() override;
private:
QVector<int> jd;
QDateTime beginTime;
QDateTime endTime;
QString dataName;
QStringList deleteName;
};
#endif // THREADPOLTCHART_H

121
threadread.cpp Normal file
View File

@ -0,0 +1,121 @@
#include "threadread.h"
threadRead::threadRead(QObject *parent)
: QThread{parent} {
}
bool threadRead::isNumeric(QString data) {
// 正则表达式匹配数字和可选的正负号
QRegularExpression pattern("^[+-]?([1-9][0-9]*|0)[.]?[0-9]*$");
QRegularExpressionMatch patternMatch =pattern.match(data);
// 使用std::regex_match来检查字符串是否完全匹配模式
return patternMatch.hasMatch();
}
void threadRead::run() {
//正则表达式
//时间
QRegularExpression dateTimeRegex("([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}:[0-9]{3})");
QRegularExpressionMatch matchDateTime;
//基带
QRegularExpression jdRegex("\\[.*(\\d)\\]");
QRegularExpressionMatch matchLogLevel;
//初始化数据
for (auto &i: Gloab::g_param) {
i.clear();
}
//清除下拉框数据
emit clearCombo();
if(!Gloab::namelist.empty()){
Gloab::namelist.clear();
Gloab::completer->deleteLater();
}
//设置状态栏
emit showStatusbar("正在打开文件");
//读取文件
QTextStream in(&Gloab::file);
while (!in.atEnd()) {
//读取一行
QString line = in.readLine();
//更新进度条
Gloab::bytesRead += line.size();
int percent = Gloab::bytesRead * 150 / Gloab::fileSize;
emit setProgressBar(percent);
/* 匹配数据 */
//匹配日期时间
QMap<QString, QString> temMap;
int JD;
QString temtime;
QString temjd;
matchDateTime = dateTimeRegex.match(line);
if (matchDateTime.hasMatch()) {
temtime = matchDateTime.captured(1);
temMap["时间"] = temtime;
} else {
continue;
}
//匹配基带
matchLogLevel = jdRegex.match(line);
if (matchLogLevel.hasMatch()) {
temjd = matchLogLevel.captured(1);
temMap["基带"] = temjd;
JD = temjd.toInt() - 1;
} else {
continue;
}
//设置开始时间
if (Gloab::temData.isEmpty()) {
emit setBeginTime(QDateTime::fromString(temtime, "yyyy-MM-dd hh:mm:ss:zzz"));
}
Gloab::temData.clear();
Gloab::temData["时间"] = temtime;
//将左右拆分
QStringList dataParts = line.split(']');
//判断右侧是否有数据
if (dataParts[1].isEmpty()) {
continue;
}
//将右侧数据拆分
QStringList data = dataParts[1].split(',');
for (int i = 0; i < data.size(); i++) {
//将每一条数据拆为数据名和值
QStringList tem = data[i].split('=');
if (tem.size() < 2) {
continue;
}
if (!Gloab::namelist.contains(tem[0])) {
Gloab::namelist[tem[0]]=isNumeric(tem[1]);
if (tem[0].contains("版本号")) {
Gloab::namelist[tem[0]] = false;
}
}
Gloab::temData[tem[0]] = tem[1];
}
//记录数据
Gloab::g_param[JD].append(Gloab::temData);
}
//设置结束时间
emit setEndTime(QDateTime::fromString(Gloab::temData["时间"], "yyyy-MM-dd hh:mm:ss:zzz"));
//设置状态栏
emit showStatusbar("打开成功:" + Gloab::fileName);
//添加下拉框数据
emit addCombo(Gloab::namelist.keys());
//关闭
emit closeProg();
Gloab::file.close();
Gloab::temData.clear();
quit();
}

31
threadread.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef THREADREAD_H
#define THREADREAD_H
#include "gloab.h"
#include <QtCharts>
class threadRead : public QThread {
Q_OBJECT
public:
explicit threadRead(QObject *parent = nullptr);
bool isNumeric(QString data);
signals:
void clearCombo();
void showStatusbar(QString message);
void setBeginTime(QDateTime begin);
void setEndTime(QDateTime begin);
void addCombo(QStringList list);
void setProgressBar(int percent);
void closeProg();
private:
protected:
void run() Q_DECL_OVERRIDE;
};
#endif // THREADREAD_H