操作日志
This commit is contained in:
parent
cb92357cbd
commit
aae6b39ca7
|
@ -350,7 +350,8 @@ bool DataBackupProxy::backupData()
|
||||||
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
||||||
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size
|
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size
|
||||||
+ "," + QString::number(m_backupWrapper.m_frontUid));
|
+ "," + QString::number(m_backupWrapper.m_frontUid)
|
||||||
|
+ "," + m_backupWrapper.m_backupName);
|
||||||
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ void DataRestoreProxy::restoreData()
|
||||||
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
|
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName);
|
||||||
}
|
}
|
||||||
emit this->workResult(result);
|
emit this->workResult(result);
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,8 +45,6 @@ private:
|
||||||
|
|
||||||
// 是否还原成功
|
// 是否还原成功
|
||||||
bool m_bSuccess;
|
bool m_bSuccess;
|
||||||
// 当前备份uuid
|
|
||||||
QString m_curUuid;
|
|
||||||
// 当前还原源目录
|
// 当前还原源目录
|
||||||
QString m_srcPath;
|
QString m_srcPath;
|
||||||
// 还原进程
|
// 还原进程
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "deletebackupproxy.h"
|
#include "deletebackupproxy.h"
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "../common/utils.h"
|
#include "../common/utils.h"
|
||||||
|
|
||||||
|
@ -66,5 +67,8 @@ void DeleteBackupProxy::deleteBackupPointDir()
|
||||||
args << "-rf";
|
args << "-rf";
|
||||||
args << uuidPath;
|
args << uuidPath;
|
||||||
QProcess::execute("rm", args);
|
QProcess::execute("rm", args);
|
||||||
|
|
||||||
|
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
|
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ private:
|
||||||
bool deleteXmlBackupPoint();
|
bool deleteXmlBackupPoint();
|
||||||
|
|
||||||
void deleteBackupPointDir();
|
void deleteBackupPointDir();
|
||||||
|
|
||||||
|
ParseBackupList::BackupPoint m_backupPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DELETEBACKUPPROXY_H
|
#endif // DELETEBACKUPPROXY_H
|
||||||
|
|
|
@ -434,7 +434,8 @@ bool SystemBackupProxy::backupSystem()
|
||||||
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","+ m_backupWrapper.m_note + "," + m_backupPoint.m_size+ "," + QString::number(m_backupWrapper.m_frontUid));
|
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","+ m_backupWrapper.m_note + "," + m_backupPoint.m_size+ "," + QString::number(m_backupWrapper.m_frontUid));
|
||||||
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
||||||
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size);
|
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size
|
||||||
|
+ ",," + m_backupWrapper.m_backupName);
|
||||||
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,9 @@ void SystemRestoreProxy::restoreSystem()
|
||||||
}
|
}
|
||||||
|
|
||||||
args << m_srcPath + "/";
|
args << m_srcPath + "/";
|
||||||
args << destPath + "/";
|
destPath += "/";
|
||||||
|
destPath.replace("//", "/");
|
||||||
|
args << destPath;
|
||||||
|
|
||||||
m_p = new RsyncPathToDirProcess(this);
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
connect(m_p, &RsyncPathToDirProcess::progress, this, &SystemRestoreProxy::progress);
|
connect(m_p, &RsyncPathToDirProcess::progress, this, &SystemRestoreProxy::progress);
|
||||||
|
@ -328,7 +330,7 @@ void SystemRestoreProxy::restoreSystem()
|
||||||
if (result) {
|
if (result) {
|
||||||
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
|
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
|
||||||
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,");
|
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName);
|
||||||
|
|
||||||
Utils::updateSyncFile();
|
Utils::updateSyncFile();
|
||||||
QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC;
|
QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC;
|
||||||
|
|
|
@ -311,7 +311,8 @@ bool UDiskDataBackupProxy::backupDataToUdisk()
|
||||||
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
||||||
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size
|
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size
|
||||||
+ "," + QString::number(m_backupWrapper.m_frontUid));
|
+ "," + QString::number(m_backupWrapper.m_frontUid)
|
||||||
|
+ "," + m_backupWrapper.m_backupName);
|
||||||
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ void UDiskDataRestoreProxy::restoreData()
|
||||||
m_isFinished = true;
|
m_isFinished = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
|
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName);
|
||||||
}
|
}
|
||||||
emit this->workResult(result);
|
emit this->workResult(result);
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,8 +50,6 @@ private:
|
||||||
bool m_bSuccess;
|
bool m_bSuccess;
|
||||||
// 是否完成
|
// 是否完成
|
||||||
bool m_isFinished;
|
bool m_isFinished;
|
||||||
// 当前备份uuid
|
|
||||||
QString m_curUuid;
|
|
||||||
// 当前还原源目录
|
// 当前还原源目录
|
||||||
QString m_srcPath;
|
QString m_srcPath;
|
||||||
// 还原进程
|
// 还原进程
|
||||||
|
|
|
@ -470,7 +470,8 @@ bool UDiskSystemBackupProxy::backup(const QStringList &args)
|
||||||
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","+ m_backupWrapper.m_note + "," + m_backupPoint.m_size+ "," + QString::number(m_backupWrapper.m_frontUid));
|
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","+ m_backupWrapper.m_note + "," + m_backupPoint.m_size+ "," + QString::number(m_backupWrapper.m_frontUid));
|
||||||
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
Utils::writeBackupLog(m_backupPoint.m_time + ","
|
||||||
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
+ m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size);
|
+ m_backupWrapper.m_note + "," + m_backupPoint.m_size
|
||||||
|
+ ",," + m_backupWrapper.m_backupName);
|
||||||
|
|
||||||
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
Utils::update_backup_unique_settings(m_curUuid, m_backupPoint.m_backupName);
|
||||||
m_bSuccess = true;
|
m_bSuccess = true;
|
||||||
|
|
|
@ -325,7 +325,9 @@ void UDiskSystemRestoreProxy::restoreSystem()
|
||||||
QStringList args = getRsyncArgs(SystemRestoreScene::SYSTEM_RESTORE);
|
QStringList args = getRsyncArgs(SystemRestoreScene::SYSTEM_RESTORE);
|
||||||
|
|
||||||
args << m_srcPath + "/";
|
args << m_srcPath + "/";
|
||||||
args << destPath + "/";
|
destPath += "/";
|
||||||
|
destPath.replace("//", "/");
|
||||||
|
args << destPath;
|
||||||
|
|
||||||
m_p = new RsyncPathToDirProcess(this);
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskSystemRestoreProxy::progress);
|
connect(m_p, &RsyncPathToDirProcess::progress, this, &UDiskSystemRestoreProxy::progress);
|
||||||
|
@ -333,7 +335,7 @@ void UDiskSystemRestoreProxy::restoreSystem()
|
||||||
if (result) {
|
if (result) {
|
||||||
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
|
// Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid));
|
||||||
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,");
|
Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName);
|
||||||
|
|
||||||
Utils::updateSyncFile();
|
Utils::updateSyncFile();
|
||||||
QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC;
|
QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC;
|
||||||
|
|
|
@ -65,9 +65,6 @@ Worker * WorkerFactory::createWorker(int type, int position)
|
||||||
className = "SystemBackupProxy";
|
className = "SystemBackupProxy";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BackupType::AUTO_BACKUP_SYSTEM:
|
|
||||||
className = "AutoSystemBackupProxy";
|
|
||||||
break;
|
|
||||||
case BackupType::RESTORE_SYSTEM:
|
case BackupType::RESTORE_SYSTEM:
|
||||||
case BackupType::RESTORE_SYSTEM_WITH_DATA:
|
case BackupType::RESTORE_SYSTEM_WITH_DATA:
|
||||||
if (BackupPosition::UDISK == position) {
|
if (BackupPosition::UDISK == position) {
|
||||||
|
|
|
@ -76,8 +76,6 @@ enum BackupType {
|
||||||
DELETE_BACKUP = 8,
|
DELETE_BACKUP = 8,
|
||||||
// ghost镜像
|
// ghost镜像
|
||||||
GHOST_IMAGE = 9,
|
GHOST_IMAGE = 9,
|
||||||
// 自动升级模块的自动备份
|
|
||||||
AUTO_BACKUP_SYSTEM = 10,
|
|
||||||
|
|
||||||
// 仅仅初始化BackupType枚举类变量用,没有用于持久化,不用固定其值
|
// 仅仅初始化BackupType枚举类变量用,没有用于持久化,不用固定其值
|
||||||
BACKUP_TYPE_INIT,
|
BACKUP_TYPE_INIT,
|
||||||
|
|
|
@ -619,7 +619,7 @@ bool Utils::writeBackupLog(QString line)
|
||||||
std::fputs("#5:retaining user data\n", fp.get());
|
std::fputs("#5:retaining user data\n", fp.get());
|
||||||
std::fputs("#6:restore data\n", fp.get());
|
std::fputs("#6:restore data\n", fp.get());
|
||||||
std::fputs("#8:delete backup\n", fp.get());
|
std::fputs("#8:delete backup\n", fp.get());
|
||||||
std::fputs("#for example: 17-04-25 10:43:56,{uuidxxxxx},0,this is a note\n", fp.get());
|
std::fputs("#for example: 17-04-25 10:43:56,{uuidxxxxx},0,this is a note,21.19KB,userid-1000,备份名称\n", fp.get());
|
||||||
}
|
}
|
||||||
std::fputs(line.toStdString().data(), fp.get());
|
std::fputs(line.toStdString().data(), fp.get());
|
||||||
std::fflush(fp.get());
|
std::fflush(fp.get());
|
||||||
|
@ -938,13 +938,15 @@ QList<BackupWrapper> Utils::getBackupLogList()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.m_backupName.isEmpty()) {
|
if (record.m_backupName.isEmpty()) {
|
||||||
// if (FACTORY_BACKUP_UUID == record.m_uuid) {
|
if (FACTORY_BACKUP_UUID == record.m_uuid) {
|
||||||
// record.m_backupName = QObject::tr("Factory Backup");
|
record.m_backupName = QObject::tr("Factory Backup");
|
||||||
// } else if (AUTO_BACKUP_UUID == record.m_uuid) {
|
}
|
||||||
|
// else if (AUTO_BACKUP_UUID == record.m_uuid) {
|
||||||
// record.m_backupName = QObject::tr("Auto Backup");
|
// record.m_backupName = QObject::tr("Auto Backup");
|
||||||
// } else {
|
|
||||||
record.m_backupName = record.m_uuid;
|
|
||||||
// }
|
// }
|
||||||
|
else {
|
||||||
|
record.m_backupName = record.m_uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list << record;
|
list << record;
|
||||||
|
|
|
@ -62,6 +62,7 @@ HEADERS += \
|
||||||
module/databackup.h \
|
module/databackup.h \
|
||||||
module/datarestore.h \
|
module/datarestore.h \
|
||||||
module/managebackuppointlist.h \
|
module/managebackuppointlist.h \
|
||||||
|
module/operationlog.h \
|
||||||
module/selectrestorepoint.h \
|
module/selectrestorepoint.h \
|
||||||
module/systembackup.h \
|
module/systembackup.h \
|
||||||
module/systemrestore.h \
|
module/systemrestore.h \
|
||||||
|
@ -102,6 +103,7 @@ SOURCES += \
|
||||||
module/databackup.cpp \
|
module/databackup.cpp \
|
||||||
module/datarestore.cpp \
|
module/datarestore.cpp \
|
||||||
module/managebackuppointlist.cpp \
|
module/managebackuppointlist.cpp \
|
||||||
|
module/operationlog.cpp \
|
||||||
module/selectrestorepoint.cpp \
|
module/selectrestorepoint.cpp \
|
||||||
module/systembackup.cpp \
|
module/systembackup.cpp \
|
||||||
module/systemrestore.cpp \
|
module/systemrestore.cpp \
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "module/systemrestore.h"
|
#include "module/systemrestore.h"
|
||||||
#include "module/databackup.h"
|
#include "module/databackup.h"
|
||||||
#include "module/datarestore.h"
|
#include "module/datarestore.h"
|
||||||
|
#include "module/operationlog.h"
|
||||||
#include "backup_manager_interface.h"
|
#include "backup_manager_interface.h"
|
||||||
#include "globalbackupinfo.h"
|
#include "globalbackupinfo.h"
|
||||||
#include "messageboxutils.h"
|
#include "messageboxutils.h"
|
||||||
|
@ -222,6 +223,10 @@ void MainDialog::selected(int func_type)
|
||||||
m_stackedWidget = new DataRestore(ui->centralwidget);
|
m_stackedWidget = new DataRestore(ui->centralwidget);
|
||||||
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::RESTORE_DATA);
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::RESTORE_DATA);
|
||||||
break;
|
break;
|
||||||
|
case FuncTypeConverter::FunType::OPERATION_LOG:
|
||||||
|
m_stackedWidget = new OperationLog(ui->centralwidget);
|
||||||
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::OPERATION_LOG);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
m_stackedWidget = new SystemBackup(ui->centralwidget);
|
m_stackedWidget = new SystemBackup(ui->centralwidget);
|
||||||
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::BACKUP_SYSTEM);
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::BACKUP_SYSTEM);
|
||||||
|
|
|
@ -0,0 +1,180 @@
|
||||||
|
#include "operationlog.h"
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
OperationLog::OperationLog(QWidget *parent) :
|
||||||
|
QStackedWidget(parent)
|
||||||
|
{
|
||||||
|
// 界面手写代码创建,作为练手
|
||||||
|
initFirstWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
OperationLog::~OperationLog()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 第一页
|
||||||
|
*/
|
||||||
|
void OperationLog::initFirstWidget()
|
||||||
|
{
|
||||||
|
QWidget *first = new QWidget;
|
||||||
|
|
||||||
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||||
|
vlayout->addSpacing(10);
|
||||||
|
|
||||||
|
QHBoxLayout *hlayoutLine1 = new QHBoxLayout;
|
||||||
|
// 列表为空时展示图片
|
||||||
|
QLabel *labelEmptyLogo = new QLabel(this);
|
||||||
|
QPixmap pixmap(":/images/empty.png");
|
||||||
|
labelEmptyLogo->setPixmap(pixmap);
|
||||||
|
hlayoutLine1->addStretch();
|
||||||
|
hlayoutLine1->addWidget(labelEmptyLogo);
|
||||||
|
hlayoutLine1->addStretch();
|
||||||
|
vlayout->addLayout(hlayoutLine1);
|
||||||
|
|
||||||
|
QHBoxLayout *hlayoutLine2 = new QHBoxLayout;
|
||||||
|
QLabel *labelEmptyText = new QLabel(tr("No operation log"));
|
||||||
|
labelEmptyText->setAlignment(Qt::AlignCenter);
|
||||||
|
labelEmptyText->setEnabled(false);
|
||||||
|
hlayoutLine2->addStretch();
|
||||||
|
hlayoutLine2->addWidget(labelEmptyText);
|
||||||
|
hlayoutLine2->addStretch();
|
||||||
|
vlayout->addLayout(hlayoutLine2);
|
||||||
|
|
||||||
|
QHBoxLayout *hlayoutLine3 = new QHBoxLayout;
|
||||||
|
QStringList headerLabels;
|
||||||
|
headerLabels << tr("Backup Name") << tr("UUID") << tr("Operation") << tr("Operation Time");
|
||||||
|
m_tableWidget = new QTableWidget;
|
||||||
|
m_tableWidget->setFixedSize(680, 560);
|
||||||
|
m_tableWidget->setColumnCount(headerLabels.size());
|
||||||
|
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
|
||||||
|
m_tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
|
m_tableWidget->horizontalHeader()->setTextElideMode(Qt::ElideRight);
|
||||||
|
m_tableWidget->horizontalHeader()->setFixedHeight(30);
|
||||||
|
m_tableWidget->verticalHeader()->setHidden(true); // 好像隐藏不掉
|
||||||
|
m_tableWidget->verticalHeader()->setVisible(false); //左侧标题不可见
|
||||||
|
m_tableWidget->verticalHeader()->setDefaultSectionSize(30); // 设置行高
|
||||||
|
m_tableWidget->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
|
m_tableWidget->setSortingEnabled(false); // 等录入完数据后再排序
|
||||||
|
m_tableWidget->setAlternatingRowColors(true);
|
||||||
|
m_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
m_tableWidget->hideColumn(1); // 隐藏uuid
|
||||||
|
hlayoutLine3->addStretch();
|
||||||
|
hlayoutLine3->addWidget(m_tableWidget);
|
||||||
|
hlayoutLine3->addStretch();
|
||||||
|
vlayout->addLayout(hlayoutLine3);
|
||||||
|
|
||||||
|
vlayout->addStretch();
|
||||||
|
first->setLayout(vlayout);
|
||||||
|
|
||||||
|
QList<BackupWrapper> list = Utils::getBackupLogList();
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
labelEmptyLogo->setVisible(true);
|
||||||
|
labelEmptyText->setVisible(true);
|
||||||
|
m_tableWidget->setVisible(false);
|
||||||
|
} else {
|
||||||
|
labelEmptyLogo->setVisible(false);
|
||||||
|
labelEmptyText->setVisible(false);
|
||||||
|
m_tableWidget->setVisible(true);
|
||||||
|
initOperationLogs(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
addWidget(first);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化操作日志表格
|
||||||
|
*/
|
||||||
|
void OperationLog::initOperationLogs(const QList<BackupWrapper>& list)
|
||||||
|
{
|
||||||
|
m_tableWidget->clearContents();
|
||||||
|
m_tableWidget->setRowCount(0);
|
||||||
|
m_tableWidget->setSortingEnabled(false); // 等录入完数据后再排序
|
||||||
|
|
||||||
|
int indexOfRow = 0;
|
||||||
|
for (const BackupWrapper& backupPoint : list) {
|
||||||
|
m_tableWidget->insertRow(indexOfRow);
|
||||||
|
setItem(indexOfRow, 0, backupPoint.m_backupName);
|
||||||
|
setItem(indexOfRow, 1, backupPoint.m_uuid);
|
||||||
|
setItem(indexOfRow, 2, castTypeToString(backupPoint.m_type));
|
||||||
|
setItem(indexOfRow, 3, backupPoint.m_time);
|
||||||
|
++indexOfRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序
|
||||||
|
m_tableWidget->sortItems(3, Qt::DescendingOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置QTableWidget的单元格内容
|
||||||
|
* @param row
|
||||||
|
* @param column
|
||||||
|
* @param text
|
||||||
|
*/
|
||||||
|
void OperationLog::setItem(int row, int column, const QString& text, int alignFlag)
|
||||||
|
{
|
||||||
|
QTableWidgetItem *item = new QTableWidgetItem;
|
||||||
|
item->setText(text);
|
||||||
|
item->setToolTip(text);
|
||||||
|
item->setTextAlignment(alignFlag);
|
||||||
|
m_tableWidget->setItem(row, column, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 翻译操作类型
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QString OperationLog::castTypeToString(int type)
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
switch (type) {
|
||||||
|
case BackupType::BACKUP_SYSTEM :
|
||||||
|
name = tr("new system backup");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::INC_BACKUP_SYSTEM :
|
||||||
|
name = tr("udpate system backup");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::BACKUP_DATA :
|
||||||
|
name = tr("new data backup");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::INC_BACKUP_DATA :
|
||||||
|
name = tr("update data backup");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::RESTORE_SYSTEM :
|
||||||
|
name = tr("restore system");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::RESTORE_SYSTEM_WITH_DATA :
|
||||||
|
name = tr("restore retaining user data");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::RESTORE_DATA :
|
||||||
|
name = tr("restore data");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::DELETE_BACKUP :
|
||||||
|
name = tr("delete backup");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BackupType::GHOST_IMAGE :
|
||||||
|
name = tr("make ghost image");
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef OPERATIONLOG_H
|
||||||
|
#define OPERATIONLOG_H
|
||||||
|
|
||||||
|
#include <QStackedWidget>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include "../common/utils.h"
|
||||||
|
|
||||||
|
class OperationLog : public QStackedWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit OperationLog(QWidget* parent = nullptr);
|
||||||
|
virtual ~OperationLog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initFirstWidget();
|
||||||
|
void initOperationLogs(const QList<BackupWrapper>& list);
|
||||||
|
void setItem(int row, int column, const QString& text, int alignFlag = Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
QString castTypeToString(int type);
|
||||||
|
|
||||||
|
QTableWidget *m_tableWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OPERATIONLOG_H
|
|
@ -190,6 +190,7 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked)
|
||||||
|
|
||||||
this->m_uuid = "";
|
this->m_uuid = "";
|
||||||
this->m_devPath = "";
|
this->m_devPath = "";
|
||||||
|
this->m_backupName = "";
|
||||||
this->m_isOtherMachine = "";
|
this->m_isOtherMachine = "";
|
||||||
|
|
||||||
// 出厂还原,不用去选择备份点
|
// 出厂还原,不用去选择备份点
|
||||||
|
@ -204,6 +205,7 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked)
|
||||||
//出厂还原
|
//出厂还原
|
||||||
m_uuid = FACTORY_BACKUP_UUID;
|
m_uuid = FACTORY_BACKUP_UUID;
|
||||||
m_devPath = "";
|
m_devPath = "";
|
||||||
|
this->m_backupName = "";
|
||||||
this->m_isOtherMachine = false;
|
this->m_isOtherMachine = false;
|
||||||
} else {
|
} else {
|
||||||
// 系统备份点列表中选择备份点
|
// 系统备份点列表中选择备份点
|
||||||
|
@ -211,6 +213,7 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked)
|
||||||
connect(selectRestoreDialog, &SelectRestorePoint::selected, this, [=](ParseBackupList::BackupPoint backupPoint){
|
connect(selectRestoreDialog, &SelectRestorePoint::selected, this, [=](ParseBackupList::BackupPoint backupPoint){
|
||||||
this->m_uuid = backupPoint.m_uuid;
|
this->m_uuid = backupPoint.m_uuid;
|
||||||
this->m_devPath = backupPoint.m_path;
|
this->m_devPath = backupPoint.m_path;
|
||||||
|
this->m_backupName = backupPoint.m_backupName;
|
||||||
this->m_isOtherMachine = backupPoint.m_iPosition == BackupPosition::OTHER ? true : false;
|
this->m_isOtherMachine = backupPoint.m_iPosition == BackupPosition::OTHER ? true : false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -483,6 +486,7 @@ void SystemRestore::on_checkEnv_start()
|
||||||
backupWrapper.m_type = m_isRetainUserData ? BackupType::RESTORE_SYSTEM_WITH_DATA : BackupType::RESTORE_SYSTEM;
|
backupWrapper.m_type = m_isRetainUserData ? BackupType::RESTORE_SYSTEM_WITH_DATA : BackupType::RESTORE_SYSTEM;
|
||||||
backupWrapper.m_iPosition = m_devPath.isEmpty() ? BackupPosition::LOCAL : BackupPosition::UDISK;
|
backupWrapper.m_iPosition = m_devPath.isEmpty() ? BackupPosition::LOCAL : BackupPosition::UDISK;
|
||||||
backupWrapper.m_uuid = m_uuid;
|
backupWrapper.m_uuid = m_uuid;
|
||||||
|
backupWrapper.m_backupName = m_backupName;
|
||||||
backupWrapper.m_prefixDestPath = m_devPath;
|
backupWrapper.m_prefixDestPath = m_devPath;
|
||||||
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
@ -683,6 +687,7 @@ void SystemRestore::on_restore_start()
|
||||||
backupWrapper.m_type = m_isRetainUserData ? BackupType::RESTORE_SYSTEM_WITH_DATA : BackupType::RESTORE_SYSTEM;
|
backupWrapper.m_type = m_isRetainUserData ? BackupType::RESTORE_SYSTEM_WITH_DATA : BackupType::RESTORE_SYSTEM;
|
||||||
backupWrapper.m_iPosition = m_devPath.isEmpty() ? BackupPosition::LOCAL : BackupPosition::UDISK;
|
backupWrapper.m_iPosition = m_devPath.isEmpty() ? BackupPosition::LOCAL : BackupPosition::UDISK;
|
||||||
backupWrapper.m_uuid = m_uuid;
|
backupWrapper.m_uuid = m_uuid;
|
||||||
|
backupWrapper.m_backupName = m_backupName;
|
||||||
backupWrapper.m_prefixDestPath = m_devPath;
|
backupWrapper.m_prefixDestPath = m_devPath;
|
||||||
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
|
|
@ -62,6 +62,7 @@ private:
|
||||||
|
|
||||||
QString m_uuid; // 还原点的UUID
|
QString m_uuid; // 还原点的UUID
|
||||||
QString m_devPath; // 如果是从移动设备进行还原,此中保存移动设备挂载路径
|
QString m_devPath; // 如果是从移动设备进行还原,此中保存移动设备挂载路径
|
||||||
|
QString m_backupName; // 还原点的备份点名称
|
||||||
bool m_isOtherMachine; // 是否异机备份点还原
|
bool m_isOtherMachine; // 是否异机备份点还原
|
||||||
// 系统备份状态
|
// 系统备份状态
|
||||||
int m_systemRestoreState;
|
int m_systemRestoreState;
|
||||||
|
|
Loading…
Reference in New Issue