99 lines
3.0 KiB
C++
99 lines
3.0 KiB
C++
#ifndef METADATUPDATEPAGE_H
|
|
#define METADATUPDATEPAGE_H
|
|
|
|
#include "ElaScrollPage.h"
|
|
#include "ElaPushButton.h"
|
|
#include "ElaText.h"
|
|
#include "ElaProgressBar.h"
|
|
#include "ElaCheckBox.h"
|
|
#include "metadataupdate/metadataprocessor.h"
|
|
#include "utils/uf2configreader.h"
|
|
#include "utils/uft3configreader.h"
|
|
#include <QGridLayout>
|
|
#include <QMessageBox>
|
|
#include <QThread>
|
|
#include <QFutureWatcher>
|
|
#include <QElapsedTimer>
|
|
|
|
// 后台线程执行结果:success 表示整体是否成功,needReload 表示是否需要重新加载数据缓存
|
|
struct UpdateResult {
|
|
bool success;
|
|
bool needReload;
|
|
};
|
|
|
|
class MetadataUpdatePage : public ElaScrollPage
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MetadataUpdatePage(QWidget *parent = nullptr);
|
|
~MetadataUpdatePage();
|
|
|
|
protected:
|
|
void showEvent(QShowEvent* event) override;
|
|
|
|
private slots:
|
|
void onUF20SelectAll();
|
|
void onUF20SelectNone();
|
|
void onUpdateUF20();
|
|
void onUFT3SelectAll();
|
|
void onUFT3SelectNone();
|
|
void onUpdateUFT3();
|
|
|
|
private slots:
|
|
void onUpdateProgress(int progress, const QString& message);
|
|
void onUpdateFinished(bool success, const QString& message);
|
|
void onWorkerFinished(); // QFutureWatcher::finished 的回调(运行在主线程)
|
|
|
|
signals:
|
|
void sigProgress(int progress, const QString& message); // 后台线程 -> 主线程回传进度
|
|
|
|
private:
|
|
void initUI();
|
|
void showUpdateItems();
|
|
void updateCardStyle(); // 根据 Ela 主题(浅色/深色)刷新卡片背景样式
|
|
|
|
// 后台线程执行体(由 QtConcurrent 调用,禁止直接操作 UI)
|
|
UpdateResult runUpdateUf2(const QStringList& items);
|
|
UpdateResult runUpdateUft3(const QStringList& items);
|
|
// 在主线程启动后台任务
|
|
void startUpdate(const QStringList& items, const QString& taskName);
|
|
|
|
bool processUf2StdFields();
|
|
bool processUf2DataType();
|
|
bool processUf2ErrNumber();
|
|
bool processUf2Constants();
|
|
bool processUf2MenuFunc();
|
|
bool processUf2Module();
|
|
bool processUf2Table();
|
|
bool processUf2Interface(const QString& basePath);
|
|
|
|
bool processUft3StdFields();
|
|
bool processUft3DataType();
|
|
bool processUft3Table();
|
|
bool processUft3Interface(const QString& basePath);
|
|
|
|
QGridLayout* _updateGridLayout{nullptr};
|
|
QGridLayout* _updateUf2GridLayout{nullptr};
|
|
ElaPushButton* _uf2UpdateBtn{nullptr};
|
|
ElaPushButton* _uf2CancelBtn{nullptr};
|
|
ElaPushButton* _uft3AllBtn{nullptr};
|
|
ElaPushButton* _uft3CancelBtn{nullptr};
|
|
ElaPushButton* _uf2AllBtn{nullptr};
|
|
ElaPushButton* _uft3UpdateBtn{nullptr};
|
|
ElaCheckBox* _forceFullCheckBox{nullptr};
|
|
ElaText* _processLabel{nullptr};
|
|
ElaProgressBar* _progressBar{nullptr};
|
|
|
|
QList<ElaCheckBox*> uft3CheckBoxes;
|
|
QList<ElaCheckBox*> uf20CheckBoxes;
|
|
QList<QWidget*> m_cardWidgets; // 需要跟随主题切换背景的卡片
|
|
|
|
MetadataProcessor* _processor{nullptr};
|
|
QFutureWatcher<UpdateResult>* _watcher{nullptr};
|
|
QElapsedTimer _updateTimer;
|
|
QString m_currentTaskName; // "UF20" / "UFT30",用于区分当前任务
|
|
};
|
|
|
|
#endif
|