yhkylin-backup-tools/kybackup/functypeconverter.cpp

89 lines
2.1 KiB
C++
Executable File

#include "functypeconverter.h"
FuncTypeConverter::FuncTypeConverter()
{
m_metaModule = QMetaEnum::fromType<FuncTypeConverter::FunType>();
}
FuncTypeConverter::~FuncTypeConverter()
{
}
QString FuncTypeConverter::keycodeTokeystring(int code){
//未匹配到则返回空
return m_metaModule.valueToKey(code);
}
int FuncTypeConverter::keystringTokeycode(QString string){
//QString to const char *
QByteArray ba = string.toUpper().toLocal8Bit(); const char * str = ba.data();
return m_metaModule.keyToValue(str);
}
/**
* @brief 功能编码对应的功能名称
* @param code 功能编码
* @return 功能名称
*/
QString FuncTypeConverter::keycodeTokeyi18nstring(int code)
{
QString nameString;
switch (code) {
case BACKUP_SYSTEM:
nameString = tr("System Backup");
break;
case RESTORE_SYSTEM:
nameString = tr("System Recovery");
break;
case BACKUP_DATA:
nameString = tr("Data Backup");
break;
case RESTORE_DATA:
nameString = tr("Data Recovery");
break;
case OPERATION_LOG:
nameString = tr("Log Records");
break;
case GHOST_IMAGE:
nameString = tr("Ghost Image");
break;
default:
break;
}
return nameString;
}
/**
* @brief 功能编码对应的主题图标名称
* @param code 功能编码
* @return 主题图标名称
*/
QString FuncTypeConverter::keycodeToThemeIconString(int code)
{
QString nameString;
switch (code) {
case BACKUP_SYSTEM:
nameString = "ukui-bf-system-backup-symbolic";
break;
case RESTORE_SYSTEM:
nameString = "ukui-bf-system-restore-symbolic";
break;
case BACKUP_DATA:
nameString = "ukui-bf-data-backup-symbolic";
break;
case RESTORE_DATA:
nameString = "ukui-bf-data-restore-symbolic";
break;
case OPERATION_LOG:
nameString = "ukui-bf-operation-log-symbolic";
break;
case GHOST_IMAGE:
nameString = "ukui-bf-ghost-mirror-symbolic";
break;
default:
break;
}
return nameString;
}