2024-05-24 15:17:20 +08:00
|
|
|
#include "GetProtocalHelper.h"
|
|
|
|
|
|
|
|
|
|
#include "json/jsonobject.h"
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
QStringList GetProtocalHelper::getProtocalList()
|
|
|
|
|
{
|
|
|
|
|
QStringList protocalList = JsonObject::Instance()->protocals();
|
|
|
|
|
QStringList result;
|
|
|
|
|
foreach(QString protocal, protocalList)
|
|
|
|
|
{
|
|
|
|
|
result << switchProtocalIntToProtocalString(protocal.toInt());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetProtocalHelper::getProtocal()
|
|
|
|
|
{
|
|
|
|
|
return JsonObject::Instance()->defaultProtocal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GetProtocalHelper::getProtocalStr()
|
|
|
|
|
{
|
|
|
|
|
return switchProtocalIntToProtocalString(getProtocal());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GetProtocalHelper::setProtocal(const QString& aProtocal)
|
|
|
|
|
{
|
|
|
|
|
JsonObject::Instance()->setDefaultProtocal(switchProtocalStringToProtocalInt(aProtocal));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GetProtocalHelper::switchProtocalIntToProtocalString(int aProtocal)
|
|
|
|
|
{
|
|
|
|
|
switch(aProtocal)
|
|
|
|
|
{
|
|
|
|
|
case 0 :
|
|
|
|
|
return QObject::tr("LeftToRight");
|
|
|
|
|
case 1 :
|
|
|
|
|
return QObject::tr("RightToLeft");
|
|
|
|
|
case 2 :
|
|
|
|
|
return QObject::tr("Left");
|
|
|
|
|
case 3 :
|
|
|
|
|
return QObject::tr("Right");
|
|
|
|
|
default:
|
|
|
|
|
return QObject::tr("LeftToRight");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GetProtocalHelper::switchProtocalStringToProtocalInt(const QString& aPortocal)
|
|
|
|
|
{
|
|
|
|
|
if(aPortocal == QObject::tr("LeftToRight"))
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if(aPortocal == QObject::tr("RightToLeft"))
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else if(aPortocal == QObject::tr("Left"))
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
2024-07-19 15:35:20 +08:00
|
|
|
else if(aPortocal == QObject::tr("Right"))
|
2024-05-24 15:17:20 +08:00
|
|
|
{
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|