hlp:桂林国际齿轮泵代码

This commit is contained in:
kite_lucs
2026-10-09 10:25:24 +08:00
commit fd606b3c81
2447 changed files with 999531 additions and 0 deletions
File diff suppressed because one or more lines are too long
@@ -0,0 +1,612 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogInsertVari</class>
<widget class="QDialog" name="DialogInsertVari">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>395</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>变量类型</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0" rowspan="2">
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="3" column="0">
<widget class="QRadioButton" name="radioButtonCurDate">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>生产日期</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="radioButtonYear">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>年</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radioButtonVar1">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>计数器1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="radioButtonVar2">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>计数器2</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButtonHour">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>时</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QRadioButton" name="radioButtonWeek">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>周</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QRadioButton" name="radioButtonVarRandom">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>随机码1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioButtonMonth">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>月</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QRadioButton" name="radioButtonDataMatrix">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>DataMatrix</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QRadioButton" name="radioButtonQRCode">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>QRCode</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="radioButtonExpiry">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>有效日期</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QRadioButton" name="radioButtonClass">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>Class</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="radioButtonSecond">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>秒</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="radioButtonDay">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>日</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radioButtonMinute">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>分</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QRadioButton" name="radioButtonBarCode">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>BarCode128</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QRadioButton" name="radioButtonCNT3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>计数器3</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="radioButtonXDay">
<property name="text">
<string>第XXX天</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QRadioButton" name="radioButtonCNT4">
<property name="text">
<string>隐藏变量</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>数字个数</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QRadioButton" name="radioButtonDigital9">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>9个</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QRadioButton" name="radioButtonDigitalB">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>11个</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="radioButtonDigitalA">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>10个</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioButtonDigital2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>2个</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="radioButtonDigital1">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>1个</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="radioButtonDigital3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>3个</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QRadioButton" name="radioButtonDigital4">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>4个</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButtonDigital5">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>5个</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="radioButtonDigital6">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>6个</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="radioButtonDigital7">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>7个</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QRadioButton" name="radioButtonDigital8">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>8个</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QRadioButton" name="radioButtonDigitalC">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>12个</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="radioButtonDigitalD">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>13个</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="radioButtonDigitalE">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>14个</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QRadioButton" name="radioButtonDigitalF">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>15个</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="image.qrc">:/80/image/expiryDate8.bmp</pixmap>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="image.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogInsertVari</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogInsertVari</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
File diff suppressed because one or more lines are too long
@@ -0,0 +1,391 @@
#include "LogInfo.h"
#include "ui_loginfo.h"
#include <QTime>
#include <QDir>
#include <QDebug>
#include <QFile>
#include <QIODevice>
#include <QTextDocumentWriter>
#include <QMessageBox>
#include "DevOp.h"
#include <stdio.h>
#include "myinclude.h"
#include <QScrollBar>
#ifndef LOGINFOFILE_DIR
#define LOGINFOFILE_DIR "/home/plg/loginfo/"
#endif
#define UDISK_LOGINFO_ROOT_DIR "/udisk/log/"
LogInfo::LogInfo(QWidget *parent) :
QWidget(parent),
ui(new Ui::LogInfo)
{
ui->setupUi(this);
ui->textEditRunStatus->setReadOnly(true);
ui->textEditRunStatus_2->setReadOnly(true);
textEdit = ui->textEditRunStatus;
textEdit->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 40px; }");
textEdit2 = ui->textEditRunStatus_2;
//textEdit2->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 40px; }");
textEdit2->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 40px; }");
textEditMachInfo = ui->machinInformation;
runStatusTextIndex = 0;
openFileName ="";
ui->labelPreFileName->setText("");
//currenDate="";
//r_CurrentDate=QDate::currentDate().toString("yyyyMMdd");
textEdit2->append(tr("请先打开历史状态文件!"));
if(!QDir("/home/plg").exists())
QDir("/home/plg").mkdir("/home/plg");
readRunStatusText();
runStatusTextIndex = textEdit->document()->lineCount();
//ui->pushButtonClear->hide();
fileDialog=0; // 先初始化为0 ,否则会死机
// LOGINFOFILE_DIR "/home/plg/loginfo/"
#ifdef DEBUG1
;
#else
QFile file(SYS_ROOT_DIR"UseEn");
if(file.exists()) //ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tab_3));
;
else {
//ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tab_3));
onReadRecorder( );
}
#endif
//ui->textEditRunStatus_3->setText(tr("测试变量加粗,可能会影响其它内容"));
//showMachineInformation(" "," "," "," ");
}
LogInfo::~LogInfo()
{
textEdit = 0;
textEdit2 = 0;
textEditMachInfo = 0;
if(fileDialog)
delete fileDialog;
delete ui;
}
QTextEdit *LogInfo::textEdit = 0;
QTextEdit *LogInfo::textEdit2 = 0;
QTextEdit *LogInfo::textEditMachInfo = 0;
int LogInfo::runStatusTextIndex = 0;
void LogInfo::showMachineInformation(QString Mac,QString SerialNum, QString VernonBachVer, QString FpgaVer)
{
QString machInfo;
machInfo = "Mac:" + Mac + "\n";
machInfo += "Serial Number:" + SerialNum + "\n";
machInfo += "VernonBach Ver:" + VernonBachVer + "\n";
machInfo += "FPGA Ver:" + FpgaVer + "\n";
QFile kernelVer("/proc/version");
if (kernelVer.open(QFile::ReadOnly | QFile::Text)) {
QTextStream in(&kernelVer);
QString kernelVer=in.readLine();
QStringList list=kernelVer.split(" ");
QStringList list2=kernelVer.split("#");
machInfo = machInfo + "Kernel: ";
machInfo = machInfo + list.at(2);
machInfo = machInfo + "(" + list2.at(1) + ")" + "\n";
}
textEditMachInfo->setText(machInfo);
}
void LogInfo::showRemoteControll(QString SuperNode, QString edgeIP)
{
QString machInfo = textEditMachInfo->toPlainText();
machInfo += "SuperNode:" + SuperNode + "\n";
machInfo += "edgeIP:" + edgeIP + "\n";
textEditMachInfo->setText(machInfo);
}
void LogInfo::setRunStatusText(QString str){
if(!textEdit){
return;
}
const int maxTextEditHeight = 2000;
if(textEdit->document()->size().height() > maxTextEditHeight){
const QString fileNameL=QString(LOGINFOFILE_DIR)+QDate::currentDate().toString("yyyyMMdd") +"_test.txt";
QFile file(fileNameL);
if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)){
QTextStream out(&file);
out<<textEdit->toPlainText()<<endl;
file.close();
}
textEdit->clear(); //显示今天全部信息,加载太多可能会死机
}
str.prepend(QString("%1. %2:").arg(QString::number(runStatusTextIndex ++ )).arg(QTime::currentTime().toString("hh:mm:ss")));
textEdit->append(str);
saveRunStatusText();
}
void LogInfo::setDebugText(QString str){
#ifdef DEBUG1
if(textEdit3){
QSizeF size = textEdit3->document()->size();
if(size.height() > 500){
textEdit3->clear();
}
//str.prepend(QString("%1. %2: ").arg(QString::number(runStatusTextIndex ++ )).arg(QTime::currentTime().toString("hh:mm:ss")));
textEdit3->append(str);
}
#else
str;
#endif
}
QString LogInfo::getRunStatusText(void){
return "";
}
void LogInfo::saveRunStatusText()
{
QString fileName;
static QString r_fileName="";
QDir dir1;
dir1.setPath(LOGINFOFILE_DIR);
if(textEdit){
if(!dir1.exists())
{
dir1.mkdir(QString ("/home/plg/loginfo/"));
}
//currenDate=QDate::currentDate().toString("yyyyMMdd"); //
fileName=QString("/home/plg/loginfo/")+QDate::currentDate().toString("yyyyMMdd") +".txt";
#ifdef DEBUG1
// qDebug()<<fileName;
#endif
QTextDocumentWriter writer(fileName);
writer.write(textEdit->document());
if(r_fileName!="" && (r_fileName!=fileName)) textEdit->clear();
r_fileName=fileName;
}
}
void LogInfo::readRunStatusText()
{
QString fileName;
if(textEdit){
QDir dir1;
dir1.setPath(LOGINFOFILE_DIR);
if(!dir1.exists())
dir1.mkdir(QString ("/home/plg/loginfo/"));
fileName=QString("/home/plg/loginfo/")+QDate::currentDate().toString("yyyyMMdd")+".txt";
QFile file(fileName);
if(file.exists()){
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
QMessageBox::warning(this,tr("警告"),tr("无法打开文件") + file.fileName());
}
else{
QTextStream in (&file);
textEdit->setText(in.readAll());
}
file.close();
ui->tabWidget->setCurrentWidget(ui->tab);
}
QDate date1 = QDate::currentDate();
for(int i=0;i<8;i++)
{
fileName=QString("/home/plg/loginfo/")+date1.addDays(-i-5).toString("yyyyMMdd")+".txt";
file.setFileName(fileName);
if(file.exists()){
file.remove();
}
}
}
}
void LogInfo::on_pushButtonExportFile_pressed()
{
QMessageBox::StandardButton ret;
ret = QMessageBox::information(this, tr("提示"),
tr("是否确认将所有日志文件导出到U盘?"),
QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok){
//QString dirPath = ui->radioButtonLocal->isChecked()?DOC_ROOT_DIR:UDISK_LOGINFO_ROOT_DIR;
QDir dir(UDISK_LOGINFO_ROOT_DIR);
if(!dir.exists()){
system((char *)((QString("mkdir -p %1").arg(UDISK_LOGINFO_ROOT_DIR)).toAscii().data()));
}
//插入U盘后,检测目录usb-storage是否存在
if(!QDir("/proc/scsi/usb-storage/").exists()){
QMessageBox::warning(0,tr("警告"),tr("U盘未插入或无法识别,请重新插拔设备!"));
return;
}
system((char *)((QString("cp -r %1/* %2/").arg(LOGINFOFILE_DIR).arg(UDISK_LOGINFO_ROOT_DIR)).toAscii().data()));
//refreshListView(EditMode);
QMessageBox::information(this, tr("提示"),
tr("成功导出到U盘"));
}
}
void LogInfo::on_pushButtonPreState_pressed(){
if(textEdit2){
//setRunStatusText(QString("FILE COUNT:%1").arg( QDir("/home/plg/loginfo/").count()));
//if( QDir("/home/plg/loginfo/").count()<4) {
if( QDir("/home/plg/loginfo/").count()<1) {
//QMessageBox::warning(this,"警告","没有历史文件");
textEdit2->setText( "目前历史文件数量为0个");
return;
}
//qDebug()<<"3333";
if(openFileName.isEmpty()) textEdit2->clear();
if(fileDialog) {
// qDebug()<<"4444";
disconnect(fileDialog,SIGNAL(accepted()),0,0); // 如果对话框已经定义,则删除控件关联,否则也会出错。
}
else {//qDebug()<<"5";
fileDialog = new MyFileDialog(0);
//qDebug()<<"6";
}
//qDebug()<<"7";
QDir dir1;
dir1.setPath(QString ("/home/plg/loginfo/"));
if(!dir1.exists())
{dir1.mkdir(QString ("/home/plg/loginfo/"));}
if(fileDialog){
//qDebug()<<"8";
if(fileDialog->directory().path()!="/home/plg/loginfo")
fileDialog->setDirectory(QDir("/home/plg/loginfo"));
//qDebug()<<"read File 3.2"<<dir1.Name;
connect(fileDialog,SIGNAL(accepted()),this,SLOT(onOpen_FIle_select()));
//qDebug()<<"read File 4"<<dir1.Name;
fileDialog->showFileDialog(tr("选择历史记录文件"),dir1.path(),QString("Txt files (*.txt)"));
//qDebug()<<"read File 5";
}
//else qDebug()<<"read File:"<<dir1.path();
}
}
void LogInfo::onOpen_FIle_select()
{
QStringList files = fileDialog->selectedFiles();
if( files.size()==0) return ;
if(QString(files[0]).isNull()) return;
QString fileName = files[0];
if(!fileName.endsWith(".txt",Qt::CaseInsensitive)) return ;
openFileName = fileName;
QFile file(openFileName);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
QMessageBox::warning(this,tr("警告"),tr("无法打开文件") + openFileName);
}
else{
QTextStream in (&file);
textEdit2->setText(in.readAll());
textEdit2->moveCursor(QTextCursor::End);//滚动条移到底部
//ui->labelPreFileName->setText(file.fileName());
QFileInfo info(file.fileName());
ui->labelPreFileName->setText(info.fileName());
}
file.close();
ui->tabWidget->setCurrentWidget(ui->tab_2);
}
void LogInfo::on_pushButtonClear_pressed()
{
QMessageBox::StandardButton ret;
ret = QMessageBox::information(this, tr("提示"),
tr("是否确认将历史日志文件全部清除?"),
QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok){
QDir dir1(QString("/home/plg/loginfo/"));
if(dir1.exists())
{
system((char *)QString("rm /home/plg/loginfo/*.*").toAscii().data());
deleteDirectoryContents(dir1);
}
else system((char *)QString("mkdir /home/plg/loginfo/").toAscii().data());
saveRunStatusText();
}
}
void LogInfo::on_pushButtonClearCurrent_pressed()
{
QMessageBox::StandardButton ret;
ret = QMessageBox::information(this, tr("提示"),
tr("是否确认将当前日志全部清除?"),
QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok){
QString fileNameL=QString("/home/plg/loginfo/")+QDate::currentDate().toString("yyyyMMdd") +"test.txt";
QFile file(fileNameL);
if(!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)){
;
}
else{
QTextStream out(&file);
out<<textEdit->toPlainText()<<endl;
fsync(file.handle());
file.close();
}
textEdit->clear();
runStatusTextIndex=0;
saveRunStatusText();
}
//setRunStatusText(QString("FILE COUNT:%1").arg( QDir("/home/plg/loginfo/").count()));
}
void LogInfo::onReadRecorder()
{
QString fileName = ":/buge_record.txt";
if(!fileName.endsWith(".txt",Qt::CaseInsensitive)) return ;
QFile file(fileName);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
QMessageBox::warning(this,tr("警告"),tr("无法打开文件") + openFileName);
}
else{
QTextStream in (&file);
textEditMachInfo->setText(in.readAll());
}
}
void LogInfo::deleteDirectoryContents(const QDir &directory) {
QList<QFileInfo> entries = directory.entryInfoList(
QDir::NoDotAndDotDot | QDir::AllEntries);
QString today = QDate::currentDate().toString(Qt::ISODate);
// 使用传统的 for 循环遍历所有条目
for (int i = 0; i < entries.size(); ++i) {
QFileInfo entryInfo = entries.at(i);
QString dirName=entryInfo.baseName();
if(today==dirName)
continue;
QString fullPath = entryInfo.absoluteFilePath();
if (entryInfo.isFile() || entryInfo.isSymLink()) {
// 如果是文件或符号链接,尝试删除
if (!QFile::remove(fullPath)) {
qDebug() << "Failed to remove file or symlink:" << fullPath;
}
} else if (entryInfo.isDir()) {
// 如果是目录,递归调用以删除其内容
QDir subDir(fullPath);
deleteDirectoryContents(subDir);
// 目录现在应该是空的,尝试删除它
if (!QDir().rmdir(fullPath)) {
qDebug() << "Failed to remove directory:" << fullPath;
}
}
}
}