备份管理界面优化

This commit is contained in:
zhaominyong 2021-12-06 16:57:11 +08:00
parent 453e9029ea
commit 456733c02f
7 changed files with 70 additions and 7 deletions

View File

@ -34,7 +34,7 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
QStringList headerLabels;
// 注意此处的列需要和枚举Column_Index一一对应
headerLabels << tr("Backup Name") << tr("UUID") << tr("Backup Time") << tr("Backup Device") << QObject::tr("Backup State") << QObject::tr("PrefixPath");
headerLabels << tr("Backup Name") << tr("UUID") << tr("Backup Time") << tr("Backup Size") << tr("Backup Device") << QObject::tr("Backup State") << QObject::tr("PrefixPath");
m_tableWidget = new QTableWidget;
m_tableWidget->setColumnCount(headerLabels.size());
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
@ -76,6 +76,32 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
emit this->udiskChange();
});
m_udector->getStorageInfo();
// 表格中的布局
// 列表为空时展示图片
m_labelEmpty = new QLabel(m_tableWidget);
QPixmap pixmap(":/images/empty.png");
m_labelEmpty->setPixmap(pixmap);
m_labelEmptyText = new QLabel(tr("No Backup"));
m_labelEmptyText->setEnabled(false);
m_labelEmpty->setVisible(false);
m_labelEmptyText->setVisible(false);
QHBoxLayout *layoutEmptyPng = new QHBoxLayout;
layoutEmptyPng->addStretch();
layoutEmptyPng->addWidget(m_labelEmpty);
layoutEmptyPng->addStretch();
QHBoxLayout *layoutEmptyText = new QHBoxLayout;
layoutEmptyText->addStretch();
layoutEmptyText->addWidget(m_labelEmptyText);
layoutEmptyText->addStretch();
QVBoxLayout *layoutTable = new QVBoxLayout;
layoutTable->addStretch();
layoutTable->addLayout(layoutEmptyPng);
layoutTable->addLayout(layoutEmptyText);
layoutTable->addStretch();
m_tableWidget->setLayout(layoutTable);
}
BackupPointListDialog::~BackupPointListDialog()

View File

@ -5,6 +5,7 @@
#include <QTableWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include "../backup-daemon/parsebackuplist.h"
#include "./module/udiskdetector.h"
@ -20,6 +21,7 @@ public:
Backup_Name = 0,
UUID,
Backup_Time,
Backup_Size,
Backup_Device,
Backup_State,
Prefix_Path
@ -44,6 +46,8 @@ protected:
QTableWidget *m_tableWidget;
QHBoxLayout *m_bottomLayout = nullptr;
QLabel *m_labelEmpty; // 空记录图片
QLabel *m_labelEmptyText; // 空记录文本
private:
Ui::BackupPointListDialog *ui;

View File

@ -19,7 +19,8 @@ ManageBackupPointList::ManageBackupPointList(QWidget *parent, BackupPointType ba
this->setWindowTitle(tr("Data Backup Information"));
}
// 隐藏备份点状态Backup State字段
// 隐藏备份点大小Backup Size字段
m_tableWidget->hideColumn(Column_Index::Backup_Size);
initTableWidget();
// 您可以删除不需要的备份,更多细节请参考“操作日志”
@ -115,6 +116,7 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
setItem(indexOfRow, Column_Index::Backup_Name, backupPoint.m_backupName);
setItem(indexOfRow, Column_Index::UUID, backupPoint.m_uuid, Qt::AlignLeft | Qt::AlignVCenter);
setItem(indexOfRow, Column_Index::Backup_Time, backupPoint.m_time);
setItem(indexOfRow, Column_Index::Backup_Size, backupPoint.m_size);
QString prefixPath_to_device;
if (backupPoint.m_path.startsWith(preDevPath)) {
@ -138,8 +140,11 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
if (0 < indexOfRow) {
m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序
m_tableWidget->sortItems(Column_Index::Backup_Time, Qt::DescendingOrder);
m_labelEmpty->setVisible(false);
m_labelEmptyText->setVisible(false);
} else {
// TODO: 无记录时展示图片
m_labelEmpty->setVisible(true);
m_labelEmptyText->setVisible(true);
}
}
@ -154,6 +159,10 @@ void ManageBackupPointList::deleteBackupPoint(ParseBackupList::BackupPoint backu
if (result)
this->m_tableWidget->removeRow(m_deleteRow);
m_deleteRow = -1;
if (this->m_tableWidget->rowCount() ==0) {
m_labelEmpty->setVisible(true);
m_labelEmptyText->setVisible(true);
}
});
deleteDialog->exec();
deleteDialog->deleteLater();

View File

@ -126,6 +126,7 @@ void SelectRestorePoint::insertLines(const QList<ParseBackupList::BackupPoint> &
setItem(indexOfRow, Column_Index::Backup_Name, backupPoint.m_backupName);
setItem(indexOfRow, Column_Index::UUID, backupPoint.m_uuid, Qt::AlignLeft | Qt::AlignVCenter);
setItem(indexOfRow, Column_Index::Backup_Time, backupPoint.m_time);
setItem(indexOfRow, Column_Index::Backup_Size, backupPoint.m_size);
QString prefixPath_to_device;
if (backupPoint.m_path.startsWith(preDevPath)) {
@ -149,7 +150,8 @@ void SelectRestorePoint::insertLines(const QList<ParseBackupList::BackupPoint> &
m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序
m_tableWidget->sortItems(Column_Index::Backup_Time, Qt::DescendingOrder);
} else {
// TODO: 无记录时展示图片
m_labelEmpty->setVisible(true);
m_labelEmptyText->setVisible(true);
}
}

View File

@ -694,12 +694,24 @@ QList<ParseBackupList::BackupPoint> SystemBackup::getBackupPointList()
*/
bool SystemBackup::isExistsBackupName(const QString & backupName)
{
// 首先,校验唯一性文件中
QString settingPath = Utils::getSysRootPath() + UDISK_UNIQUE_SETTINGS;
settingPath.replace("//", "/");
QSettings udisk_setting(settingPath, QSettings::IniFormat);
udisk_setting.setIniCodec(QTextCodec::codecForName("utf-8"));
udisk_setting.beginGroup(backupName);
QString uuidFound = udisk_setting.value("uuid").toString();
udisk_setting.endGroup();
if (!uuidFound.isEmpty())
return false;
// 然后校验xml和log中的备份记录这一步只是为了保险而兼容老版本的备份以前的唯一性文件中只有U盘的备份
QList<ParseBackupList::BackupPoint> backupPointList = getBackupPointList();
QList<BackupWrapper> list = Utils::getBackupLogList();
QSet<QString> setName;
for (BackupWrapper& wraper : list) {
if (wraper.m_backupName == wraper.m_uuid) {
// 说明是此功能之前存在的备份点
// 如果在xml中不存在则说明是此备份点是之前存在的备份点现在已经删除
for (const ParseBackupList::BackupPoint & backupPonit : backupPointList) {
if (backupPonit.m_uuid == wraper.m_uuid) {
wraper.m_backupName = backupPonit.m_backupName;

View File

@ -190,6 +190,7 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked)
// 出厂还原,不用去选择备份点
if (m_isFactoryRestore) {
// 出厂还原后,用户数据将会丢失
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"),
QObject::tr("Restore factory settings, your system user data will not be retained"),
QObject::tr("Continue"), QObject::tr("Cancel"))) {
@ -198,10 +199,18 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked)
//出厂还原
m_uuid = FACTORY_BACKUP_UUID;
m_devPath = "";
} else {
// 系统备份点列表中选择备份点
SelectRestorePoint *backupPointListDialog = new SelectRestorePoint(this);
backupPointListDialog->exec();
SelectRestorePoint *selectRestoreDialog = new SelectRestorePoint(this);
connect(selectRestoreDialog, &SelectRestorePoint::selected, this, [=](ParseBackupList::BackupPoint backupPoint){
this->m_uuid = backupPoint.m_uuid;
this->m_devPath = backupPoint.m_path;
});
selectRestoreDialog->exec();
selectRestoreDialog->deleteLater();
}
on_next_clicked();
}

View File

@ -48,6 +48,7 @@ private:
ComKylinBackupManagerInterface *m_pInterface;
QString m_uuid; // 还原点的UUID
QString m_devPath; // 如果是从移动设备进行还原,此中保存移动设备挂载路径
};
#endif // SYSTEMRESTORE_H