备份管理界面优化
This commit is contained in:
parent
453e9029ea
commit
456733c02f
|
@ -34,7 +34,7 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
|
||||||
|
|
||||||
QStringList headerLabels;
|
QStringList headerLabels;
|
||||||
// 注意:此处的列需要和枚举Column_Index一一对应
|
// 注意:此处的列需要和枚举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 = new QTableWidget;
|
||||||
m_tableWidget->setColumnCount(headerLabels.size());
|
m_tableWidget->setColumnCount(headerLabels.size());
|
||||||
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
|
m_tableWidget->setHorizontalHeaderLabels(headerLabels);
|
||||||
|
@ -76,6 +76,32 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
|
||||||
emit this->udiskChange();
|
emit this->udiskChange();
|
||||||
});
|
});
|
||||||
m_udector->getStorageInfo();
|
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()
|
BackupPointListDialog::~BackupPointListDialog()
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
#include "../backup-daemon/parsebackuplist.h"
|
#include "../backup-daemon/parsebackuplist.h"
|
||||||
#include "./module/udiskdetector.h"
|
#include "./module/udiskdetector.h"
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ public:
|
||||||
Backup_Name = 0,
|
Backup_Name = 0,
|
||||||
UUID,
|
UUID,
|
||||||
Backup_Time,
|
Backup_Time,
|
||||||
|
Backup_Size,
|
||||||
Backup_Device,
|
Backup_Device,
|
||||||
Backup_State,
|
Backup_State,
|
||||||
Prefix_Path
|
Prefix_Path
|
||||||
|
@ -44,6 +46,8 @@ protected:
|
||||||
|
|
||||||
QTableWidget *m_tableWidget;
|
QTableWidget *m_tableWidget;
|
||||||
QHBoxLayout *m_bottomLayout = nullptr;
|
QHBoxLayout *m_bottomLayout = nullptr;
|
||||||
|
QLabel *m_labelEmpty; // 空记录图片
|
||||||
|
QLabel *m_labelEmptyText; // 空记录文本
|
||||||
private:
|
private:
|
||||||
Ui::BackupPointListDialog *ui;
|
Ui::BackupPointListDialog *ui;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ ManageBackupPointList::ManageBackupPointList(QWidget *parent, BackupPointType ba
|
||||||
this->setWindowTitle(tr("Data Backup Information"));
|
this->setWindowTitle(tr("Data Backup Information"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 隐藏备份点状态Backup State字段
|
// 隐藏备份点大小Backup Size字段
|
||||||
|
m_tableWidget->hideColumn(Column_Index::Backup_Size);
|
||||||
initTableWidget();
|
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::Backup_Name, backupPoint.m_backupName);
|
||||||
setItem(indexOfRow, Column_Index::UUID, backupPoint.m_uuid, Qt::AlignLeft | Qt::AlignVCenter);
|
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_Time, backupPoint.m_time);
|
||||||
|
setItem(indexOfRow, Column_Index::Backup_Size, backupPoint.m_size);
|
||||||
|
|
||||||
QString prefixPath_to_device;
|
QString prefixPath_to_device;
|
||||||
if (backupPoint.m_path.startsWith(preDevPath)) {
|
if (backupPoint.m_path.startsWith(preDevPath)) {
|
||||||
|
@ -138,8 +140,11 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
|
||||||
if (0 < indexOfRow) {
|
if (0 < indexOfRow) {
|
||||||
m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序
|
m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序
|
||||||
m_tableWidget->sortItems(Column_Index::Backup_Time, Qt::DescendingOrder);
|
m_tableWidget->sortItems(Column_Index::Backup_Time, Qt::DescendingOrder);
|
||||||
|
m_labelEmpty->setVisible(false);
|
||||||
|
m_labelEmptyText->setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
// TODO: 无记录时展示图片
|
m_labelEmpty->setVisible(true);
|
||||||
|
m_labelEmptyText->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +159,10 @@ void ManageBackupPointList::deleteBackupPoint(ParseBackupList::BackupPoint backu
|
||||||
if (result)
|
if (result)
|
||||||
this->m_tableWidget->removeRow(m_deleteRow);
|
this->m_tableWidget->removeRow(m_deleteRow);
|
||||||
m_deleteRow = -1;
|
m_deleteRow = -1;
|
||||||
|
if (this->m_tableWidget->rowCount() ==0) {
|
||||||
|
m_labelEmpty->setVisible(true);
|
||||||
|
m_labelEmptyText->setVisible(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
deleteDialog->exec();
|
deleteDialog->exec();
|
||||||
deleteDialog->deleteLater();
|
deleteDialog->deleteLater();
|
||||||
|
|
|
@ -126,6 +126,7 @@ void SelectRestorePoint::insertLines(const QList<ParseBackupList::BackupPoint> &
|
||||||
setItem(indexOfRow, Column_Index::Backup_Name, backupPoint.m_backupName);
|
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::UUID, backupPoint.m_uuid, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
setItem(indexOfRow, Column_Index::Backup_Time, backupPoint.m_time);
|
setItem(indexOfRow, Column_Index::Backup_Time, backupPoint.m_time);
|
||||||
|
setItem(indexOfRow, Column_Index::Backup_Size, backupPoint.m_size);
|
||||||
|
|
||||||
QString prefixPath_to_device;
|
QString prefixPath_to_device;
|
||||||
if (backupPoint.m_path.startsWith(preDevPath)) {
|
if (backupPoint.m_path.startsWith(preDevPath)) {
|
||||||
|
@ -149,7 +150,8 @@ void SelectRestorePoint::insertLines(const QList<ParseBackupList::BackupPoint> &
|
||||||
m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序
|
m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序
|
||||||
m_tableWidget->sortItems(Column_Index::Backup_Time, Qt::DescendingOrder);
|
m_tableWidget->sortItems(Column_Index::Backup_Time, Qt::DescendingOrder);
|
||||||
} else {
|
} else {
|
||||||
// TODO: 无记录时展示图片
|
m_labelEmpty->setVisible(true);
|
||||||
|
m_labelEmptyText->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -694,12 +694,24 @@ QList<ParseBackupList::BackupPoint> SystemBackup::getBackupPointList()
|
||||||
*/
|
*/
|
||||||
bool SystemBackup::isExistsBackupName(const QString & backupName)
|
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<ParseBackupList::BackupPoint> backupPointList = getBackupPointList();
|
||||||
QList<BackupWrapper> list = Utils::getBackupLogList();
|
QList<BackupWrapper> list = Utils::getBackupLogList();
|
||||||
QSet<QString> setName;
|
QSet<QString> setName;
|
||||||
for (BackupWrapper& wraper : list) {
|
for (BackupWrapper& wraper : list) {
|
||||||
if (wraper.m_backupName == wraper.m_uuid) {
|
if (wraper.m_backupName == wraper.m_uuid) {
|
||||||
// 说明是此功能之前存在的备份点
|
// 如果在xml中不存在,则说明是此备份点是之前存在的备份点,现在已经删除
|
||||||
for (const ParseBackupList::BackupPoint & backupPonit : backupPointList) {
|
for (const ParseBackupList::BackupPoint & backupPonit : backupPointList) {
|
||||||
if (backupPonit.m_uuid == wraper.m_uuid) {
|
if (backupPonit.m_uuid == wraper.m_uuid) {
|
||||||
wraper.m_backupName = backupPonit.m_backupName;
|
wraper.m_backupName = backupPonit.m_backupName;
|
||||||
|
|
|
@ -190,6 +190,7 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked)
|
||||||
|
|
||||||
// 出厂还原,不用去选择备份点
|
// 出厂还原,不用去选择备份点
|
||||||
if (m_isFactoryRestore) {
|
if (m_isFactoryRestore) {
|
||||||
|
// 出厂还原后,用户数据将会丢失
|
||||||
if (!MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(this, QObject::tr("Warning"),
|
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("Restore factory settings, your system user data will not be retained"),
|
||||||
QObject::tr("Continue"), QObject::tr("Cancel"))) {
|
QObject::tr("Continue"), QObject::tr("Cancel"))) {
|
||||||
|
@ -198,10 +199,18 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked)
|
||||||
|
|
||||||
//出厂还原
|
//出厂还原
|
||||||
m_uuid = FACTORY_BACKUP_UUID;
|
m_uuid = FACTORY_BACKUP_UUID;
|
||||||
|
m_devPath = "";
|
||||||
} else {
|
} else {
|
||||||
// 系统备份点列表中选择备份点
|
// 系统备份点列表中选择备份点
|
||||||
SelectRestorePoint *backupPointListDialog = new SelectRestorePoint(this);
|
SelectRestorePoint *selectRestoreDialog = new SelectRestorePoint(this);
|
||||||
backupPointListDialog->exec();
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ private:
|
||||||
ComKylinBackupManagerInterface *m_pInterface;
|
ComKylinBackupManagerInterface *m_pInterface;
|
||||||
|
|
||||||
QString m_uuid; // 还原点的UUID
|
QString m_uuid; // 还原点的UUID
|
||||||
|
QString m_devPath; // 如果是从移动设备进行还原,此中保存移动设备挂载路径
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYSTEMRESTORE_H
|
#endif // SYSTEMRESTORE_H
|
||||||
|
|
Loading…
Reference in New Issue