Files
fmviewer3/project/fm_viewer/cfg/rm_value_selector.cpp
2026-02-21 17:11:31 +09:00

40 lines
1011 B
C++

#include "rm_value_selector.h"
#if (USE_JSON_SETTINGS)
#include <QJsonArray>
#include <QJsonObject>
#include "rm_settings_cfg.h"
RMValueSelector::RMValueSelector(int object)
{
_object = object;
}
unsigned char RMValueSelector::realValue(int index)
{
QJsonObject obj = CFG::items.at(_object).toObject();
if(obj.contains("index_map")) {
QJsonArray a = obj.value("index_map").toArray();
return a.at(index).toInt();
}
return index;
}
int RMValueSelector::realIndex(unsigned char value)
{
QJsonObject obj = CFG::items.at(_object).toObject();
if(obj.contains("index_map")) {
QJsonArray a = obj.value("index_map").toArray();
for(int i=0;i<a.size();i++) {
if(a.at(i).toInt() == value) {
return i;
}
}
}
return value;
}
#else // USE_JSON_SETTINGS
RMValueSelector::RMValueSelector(unsigned char* value,QList<int> indexMap)
{
_value = value;
_indexMap = indexMap;
}
#endif // USE_JSON_SETTINGS