diff --git a/kybackup/backuppointlistdialog.cpp b/kybackup/backuppointlistdialog.cpp index 8f01ab3..1145fd7 100755 --- a/kybackup/backuppointlistdialog.cpp +++ b/kybackup/backuppointlistdialog.cpp @@ -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() diff --git a/kybackup/backuppointlistdialog.h b/kybackup/backuppointlistdialog.h index 6ef8132..0568dbc 100755 --- a/kybackup/backuppointlistdialog.h +++ b/kybackup/backuppointlistdialog.h @@ -5,6 +5,7 @@ #include #include #include +#include #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; diff --git a/kybackup/module/managebackuppointlist.cpp b/kybackup/module/managebackuppointlist.cpp index 73aa2a3..cc4da7d 100644 --- a/kybackup/module/managebackuppointlist.cpp +++ b/kybackup/module/managebackuppointlist.cpp @@ -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 QListsetSortingEnabled(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(); diff --git a/kybackup/module/selectrestorepoint.cpp b/kybackup/module/selectrestorepoint.cpp index b3d04a2..48b508f 100644 --- a/kybackup/module/selectrestorepoint.cpp +++ b/kybackup/module/selectrestorepoint.cpp @@ -126,6 +126,7 @@ void SelectRestorePoint::insertLines(const QList & 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 & m_tableWidget->setSortingEnabled(true); // 等录入完数据后再排序 m_tableWidget->sortItems(Column_Index::Backup_Time, Qt::DescendingOrder); } else { - // TODO: 无记录时展示图片 + m_labelEmpty->setVisible(true); + m_labelEmptyText->setVisible(true); } } diff --git a/kybackup/module/systembackup.cpp b/kybackup/module/systembackup.cpp index 3ef8144..4857c73 100755 --- a/kybackup/module/systembackup.cpp +++ b/kybackup/module/systembackup.cpp @@ -694,12 +694,24 @@ QList 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 backupPointList = getBackupPointList(); QList list = Utils::getBackupLogList(); QSet 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; diff --git a/kybackup/module/systemrestore.cpp b/kybackup/module/systemrestore.cpp index f30a22f..729996e 100755 --- a/kybackup/module/systemrestore.cpp +++ b/kybackup/module/systemrestore.cpp @@ -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(); } diff --git a/kybackup/module/systemrestore.h b/kybackup/module/systemrestore.h index 666f12a..04701d9 100755 --- a/kybackup/module/systemrestore.h +++ b/kybackup/module/systemrestore.h @@ -48,6 +48,7 @@ private: ComKylinBackupManagerInterface *m_pInterface; QString m_uuid; // 还原点的UUID + QString m_devPath; // 如果是从移动设备进行还原,此中保存移动设备挂载路径 }; #endif // SYSTEMRESTORE_H