first commit
This commit is contained in:
39
project/fm_viewer/cfg/rm_value_selector.cpp
Normal file
39
project/fm_viewer/cfg/rm_value_selector.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user