feat(color): Single select option for model labels. label AND/OR filtering logic (#4532)
This commit is contained in:
@@ -210,7 +210,7 @@ ModelsVector ModelMap::getModelsByLabels(const LabelsVector &lbls)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns all models that are in multiple labels (AND function)
|
||||
* @brief Returns all models that match the selected labels
|
||||
*
|
||||
* @param lbls Labels to search
|
||||
* @return ModelsVector aka vector<ModelCell*> of all models belonging to a
|
||||
@@ -229,17 +229,37 @@ ModelsVector ModelMap::getModelsInLabels(const LabelsVector &lbls)
|
||||
|
||||
for (const auto &mdl : modelslist) {
|
||||
bool hasAllLabels = true;
|
||||
bool hasAnyLabels = false;
|
||||
bool favLabelIncluded = false;
|
||||
bool hasFavLabel = false;
|
||||
LabelsVector mdllables = getLabelsByModel(mdl);
|
||||
for (const auto &lbl : lbls) {
|
||||
if (lbl == STR_UNLABELEDMODEL) // If requesting unlabeled model ignore it
|
||||
break;
|
||||
if (std::find(mdllables.begin(), mdllables.end(), lbl) ==
|
||||
mdllables.end()) {
|
||||
hasAllLabels = false;
|
||||
break;
|
||||
bool hasLabel = std::find(mdllables.begin(), mdllables.end(), lbl) != mdllables.end();
|
||||
if (lbl == STR_FAVORITE_LABEL) {
|
||||
favLabelIncluded = true;
|
||||
hasFavLabel = hasLabel;
|
||||
} else {
|
||||
if (hasLabel) {
|
||||
hasAnyLabels = true;
|
||||
} else {
|
||||
hasAllLabels = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasAllLabels) rv.push_back(mdl);
|
||||
if (favLabelIncluded) {
|
||||
if (g_eeGeneral.favMultiMode == 0) {
|
||||
hasAnyLabels = hasAnyLabels && hasFavLabel;
|
||||
hasAllLabels = hasAllLabels && hasFavLabel;
|
||||
} else if (g_eeGeneral.favMultiMode == 1) {
|
||||
hasAnyLabels = hasAnyLabels || hasFavLabel;
|
||||
hasAllLabels = hasAllLabels && hasFavLabel;
|
||||
}
|
||||
}
|
||||
if (((g_eeGeneral.labelMultiMode == 0) && hasAllLabels) ||
|
||||
((g_eeGeneral.labelMultiMode == 1) && hasAnyLabels))
|
||||
rv.push_back(mdl);
|
||||
}
|
||||
|
||||
sortModelsBy(rv, _sortOrder);
|
||||
|
||||
@@ -157,6 +157,7 @@ class ModelMap : protected std::multimap<uint16_t, ModelCell *>
|
||||
{
|
||||
this->filtlbls = std::move(filtlbls);
|
||||
}
|
||||
void clearFilter() { filtlbls.clear(); }
|
||||
void addFilteredLabel(const std::string &lbl);
|
||||
bool isLabelFiltered(const std::string &lbl);
|
||||
std::set<uint32_t> filteredLabels() { return filtlbls; }
|
||||
|
||||
@@ -379,6 +379,9 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelSFDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "labelSingleSelect", 1 ),
|
||||
YAML_UNSIGNED( "labelMultiMode", 1 ),
|
||||
YAML_UNSIGNED( "favMultiMode", 1 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
@@ -379,6 +379,9 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelSFDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "labelSingleSelect", 1 ),
|
||||
YAML_UNSIGNED( "labelMultiMode", 1 ),
|
||||
YAML_UNSIGNED( "favMultiMode", 1 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
@@ -381,6 +381,9 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelSFDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "labelSingleSelect", 1 ),
|
||||
YAML_UNSIGNED( "labelMultiMode", 1 ),
|
||||
YAML_UNSIGNED( "favMultiMode", 1 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
@@ -381,6 +381,9 @@ static const struct YamlNode struct_RadioData[] = {
|
||||
YAML_UNSIGNED( "modelSFDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelCustomScriptsDisabled", 1 ),
|
||||
YAML_UNSIGNED( "modelTelemetryDisabled", 1 ),
|
||||
YAML_UNSIGNED( "labelSingleSelect", 1 ),
|
||||
YAML_UNSIGNED( "labelMultiMode", 1 ),
|
||||
YAML_UNSIGNED( "favMultiMode", 1 ),
|
||||
YAML_END
|
||||
};
|
||||
static const struct YamlNode struct_unsigned_8[] = {
|
||||
|
||||
Reference in New Issue
Block a user