表格显示优化
This commit is contained in:
parent
c4fef89cf8
commit
caeff6dc48
|
@ -244,6 +244,40 @@ ParseBackupList::BackupPoint ParseBackupList::findBackupPointByUuid(const QStrin
|
|||
return backupPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取xml文件中备份点uuid和backupname的映射
|
||||
* @param uuid_name,xml文件中备份点uuid和backupname的映射
|
||||
* @return
|
||||
*/
|
||||
void ParseBackupList::getXmlUuidNameMap(QMap<QString, QString> &uuid_name)
|
||||
{
|
||||
BackupPoint backupPoint;
|
||||
QDomDocument doc;
|
||||
if (!Doc_setContent(doc))
|
||||
return ;
|
||||
|
||||
QDomElement root = doc.documentElement();
|
||||
QDomNodeList list = root.childNodes();
|
||||
|
||||
for (int i = 0; i < list.count(); i++) {
|
||||
QDomNode node = list.at(i);
|
||||
if (!node.isElement())
|
||||
continue;
|
||||
|
||||
QDomElement eleUuid = node.firstChildElement(UUID);
|
||||
if (eleUuid.isNull() || eleUuid.text().isEmpty())
|
||||
continue;
|
||||
|
||||
QDomElement eleBackupName = node.firstChildElement(COMMENT);
|
||||
if (eleBackupName.isNull() || eleBackupName.text().isEmpty())
|
||||
continue;
|
||||
|
||||
uuid_name.insert(eleUuid.text(), eleBackupName.text());
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取最后一次系统备份,排除自动备份点
|
||||
* @return
|
||||
|
|
|
@ -74,6 +74,13 @@ public:
|
|||
*/
|
||||
BackupPoint findBackupPointByUuid(const QString& Uuid);
|
||||
|
||||
/**
|
||||
* @brief 获取xml文件中备份点uuid和backupname的映射
|
||||
* @param uuid_name,xml文件中备份点uuid和backupname的映射
|
||||
* @return
|
||||
*/
|
||||
void getXmlUuidNameMap(QMap<QString, QString> &uuid_name);
|
||||
|
||||
/**
|
||||
* @brief 获取最后一次系统备份
|
||||
* @return
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
#include <QStorageInfo>
|
||||
#include "../backup-daemon/parsebackuplist.h"
|
||||
|
||||
#include "mylittleparse.h"
|
||||
#include "mydefine.h"
|
||||
|
@ -894,6 +895,9 @@ QString Utils::executeCmd(const QString &cmd, const QStringList &args)
|
|||
*/
|
||||
QList<BackupWrapper> Utils::getBackupLogList()
|
||||
{
|
||||
// 为兼容以前的老备份数据,在此处先获取uuid-name键值对
|
||||
QMap<QString, QString> uuid_name = Utils::getBackupUuidNameMap();
|
||||
|
||||
QString logFile = Utils::getSysRootPath() + BACKUP_LOG_TEXT_PATH;
|
||||
logFile.replace("//", "/");
|
||||
QFile file(logFile);
|
||||
|
@ -944,8 +948,11 @@ QList<BackupWrapper> Utils::getBackupLogList()
|
|||
if (FACTORY_BACKUP_UUID == record.m_uuid) {
|
||||
record.m_backupName = QObject::tr("Factory Backup");
|
||||
}
|
||||
else if (AUTO_BACKUP_UUID == record.m_uuid) {
|
||||
record.m_backupName = QObject::tr("Auto Backup");
|
||||
// else if (AUTO_BACKUP_UUID == record.m_uuid) {
|
||||
// record.m_backupName = QObject::tr("Auto Backup");
|
||||
// }
|
||||
else if (uuid_name.contains(record.m_uuid)) {
|
||||
record.m_backupName = uuid_name.value(record.m_uuid);
|
||||
}
|
||||
else {
|
||||
record.m_backupName = record.m_time;
|
||||
|
@ -1131,14 +1138,31 @@ void Utils::deleteBackupUniqueRecord(const QString& backupName)
|
|||
udisk_unique_settings.remove(backupName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取备份点Uuid-BackupName键值对
|
||||
* @return Uuid-BackupName键值对
|
||||
*/
|
||||
QMap<QString, QString> Utils::getBackupUuidNameMap()
|
||||
{
|
||||
// 1、udisk_unique_file文件中的信息
|
||||
QString backupUniqueSetting = Utils::getSysRootPath() + UDISK_UNIQUE_SETTINGS;
|
||||
backupUniqueSetting.replace("//", "/");
|
||||
QSettings udisk_unique_settings(backupUniqueSetting, QSettings::IniFormat);
|
||||
QStringList groups = udisk_unique_settings.childGroups();
|
||||
|
||||
QMap<QString, QString> result;
|
||||
for (const QString& group : groups) {
|
||||
udisk_unique_settings.beginGroup(group);
|
||||
QString uuid = udisk_unique_settings.value("uuid").toString();
|
||||
udisk_unique_settings.endGroup();
|
||||
result.insert(uuid, group);
|
||||
}
|
||||
|
||||
// 2、本地xml文件中的信息
|
||||
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||
xmlPath.replace("//", "/");
|
||||
ParseBackupList parse(xmlPath);
|
||||
parse.getXmlUuidNameMap(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ BackupPointListDialog::BackupPointListDialog(QWidget *parent, bool isOnlyShowLoc
|
|||
m_tableWidget = new QTableWidget;
|
||||
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()->resizeSection(Column_Index::Backup_Name, 200);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::UUID, 310);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Time, 150);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Size, 120);
|
||||
m_tableWidget->horizontalHeader()->setSectionResizeMode(Column_Index::Backup_Device, QHeaderView::Stretch);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_State, 150);
|
||||
m_tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
|
||||
m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Name, 200);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::UUID, 310);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Time, 150);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Size, 120);
|
||||
// m_tableWidget->horizontalHeader()->setSectionResizeMode(Column_Index::Backup_Device, QHeaderView::Stretch);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_State, 150);
|
||||
m_tableWidget->horizontalHeader()->setTextElideMode( Qt::ElideRight);
|
||||
m_tableWidget->horizontalHeader()->setFixedHeight(30);
|
||||
m_tableWidget->verticalHeader()->setHidden(true); // 好像隐藏不掉
|
||||
|
|
|
@ -44,7 +44,7 @@ signals:
|
|||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
void setItem(int row, int column, const QString& text, int alignFlag = Qt::AlignLeft | Qt::AlignVCenter);
|
||||
void setItem(int row, int column, const QString& text, int alignFlag = Qt::AlignCenter);
|
||||
QString text(int row, int column);
|
||||
|
||||
QTableWidget *m_tableWidget;
|
||||
|
|
|
@ -105,8 +105,8 @@ bool BackupListWidget::appendItem(const QString &text)
|
|||
m_List << text;
|
||||
|
||||
QPushButton *buttonDelete = new QPushButton;
|
||||
buttonDelete->setProperty("isWindowButton", 0x2);
|
||||
buttonDelete->setProperty("useIconHighlightEffect", 0x8);
|
||||
// buttonDelete->setProperty("isWindowButton", 0x2);
|
||||
// buttonDelete->setProperty("useIconHighlightEffect", 0x8);
|
||||
buttonDelete->setFlat(true);
|
||||
buttonDelete->setFixedSize(20, 20);
|
||||
buttonDelete->setIcon(QIcon::fromTheme("window-close-symbolic"));
|
||||
|
|
|
@ -105,7 +105,6 @@ void MainDialog::initUI()
|
|||
m_totalHLayout->addStretch();
|
||||
|
||||
initTileBar();
|
||||
initStyleSheet();
|
||||
}
|
||||
|
||||
void MainDialog::initTileBar()
|
||||
|
@ -177,27 +176,6 @@ void MainDialog::initTileBar()
|
|||
m_titleWidget->setLayout(m_titleLayout);
|
||||
}
|
||||
|
||||
void MainDialog::initStyleSheet()
|
||||
{
|
||||
// // 左侧菜单背景色设置
|
||||
// m_leftSiderBarWidget->setAutoFillBackground(true);
|
||||
// QPalette paletteLeft = m_leftSiderBarWidget->palette();
|
||||
// QColor colorLeftSider(COLOR_WINDOW_LIGHT_LEFT);
|
||||
// colorLeftSider.setAlphaF(g_GSettingWrapper.m_transparency);
|
||||
// paletteLeft.setColor(QPalette::Window, colorLeftSider);
|
||||
// m_leftSiderBarWidget->setPalette(paletteLeft);
|
||||
// g_GSettingWrapper.connectUkuiBackground(m_leftSiderBarWidget, colorLeftSider, QColor(COLOR_WINDOW_DARK_LEFT));
|
||||
|
||||
// // 右侧窗口背景色设置
|
||||
// m_rightWidget->setAutoFillBackground(true);
|
||||
// QPalette palette = m_rightWidget->palette();
|
||||
// QColor colorRight(palette.color(QPalette::Base));
|
||||
// colorRight.setAlphaF(g_GSettingWrapper.m_transparency);
|
||||
// palette.setColor(QPalette::Window, colorRight);
|
||||
// m_rightWidget->setPalette(palette);
|
||||
// g_GSettingWrapper.connectUkuiBackground(m_rightWidget, colorRight, QColor(COLOR_WINDOW_DARK_RIGHT));
|
||||
}
|
||||
|
||||
void MainDialog::initConnect()
|
||||
{
|
||||
// 左侧功能选择栏
|
||||
|
|
|
@ -31,7 +31,6 @@ public slots:
|
|||
private:
|
||||
void initUI();
|
||||
void initTileBar();
|
||||
void initStyleSheet();
|
||||
void initConnect();
|
||||
|
||||
void mountBackupPartition();
|
||||
|
|
|
@ -55,12 +55,13 @@ void OperationLog::initFirstWidget()
|
|||
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::Fixed);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Name, 200);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::UUID, 310);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Operation, 150);
|
||||
m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Operation_Time, 150);
|
||||
m_tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
|
||||
m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Backup_Name, 200);
|
||||
// m_tableWidget->horizontalHeader()->setSectionResizeMode(Column_Index::Backup_Name, QHeaderView::ResizeToContents);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::UUID, 310);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Operation, 150);
|
||||
// m_tableWidget->horizontalHeader()->resizeSection(Column_Index::Operation_Time, 150);
|
||||
m_tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
m_tableWidget->horizontalHeader()->setTextElideMode(Qt::ElideRight);
|
||||
m_tableWidget->horizontalHeader()->setFixedHeight(30);
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
private:
|
||||
void initFirstWidget();
|
||||
void initOperationLogs(const QList<BackupWrapper>& list);
|
||||
void setItem(int row, int column, const QString& text, int alignFlag = Qt::AlignLeft | Qt::AlignVCenter);
|
||||
void setItem(int row, int column, const QString& text, int alignFlag = Qt::AlignCenter/*Qt::AlignLeft | Qt::AlignVCenter*/);
|
||||
QString castTypeToString(int type);
|
||||
|
||||
QTableWidget *m_tableWidget;
|
||||
|
|
Loading…
Reference in New Issue