{
setColumnCount(2);
setSelectionMode(QAbstractItemView::SingleSelection);
- setSortingEnabled(false); // Items
+ setSortingEnabled(false);
header()->setSectionResizeMode(QHeaderView::Interactive);
{
QMap<int, QString> labelMap;
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
+ mySortKey = SUIT_FoundActionTree::SortKey::MatchMetrics;
+ mySortOrder = SUIT_FoundActionTree::SortOrder::Ascending;
+
connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(onItemExecuted(QTreeWidgetItem*, int)));
}
return std::pair<SUIT_FoundActionTreeModule*, int>(nullptr, -1);
}
+template <typename Float>
+bool approximatelyEqual(Float a, Float b, Float relativeTol = std::numeric_limits<Float>::epsilon())
+{
+ return std::abs(a - b) <= ( (std::abs(a) < std::abs(b) ? std::abs(b) : std::abs(a)) * relativeTol);
+}
+
std::set<SUIT_FoundActionTreeAction*, std::function<bool(SUIT_FoundActionTreeAction*, SUIT_FoundActionTreeAction*)>> SUIT_FoundActionTree::createActionSetWithComparator() const
{
QList<std::pair<SUIT_FoundActionTree::SortKey, SUIT_FoundActionTree::SortOrder>> sortSchema = SUIT_FoundActionTree::DEFAULT_SORT_SCHEMA;
bool* const fieldOfBIsDouble = new bool(false);
const double matchMetricsA = fieldOfA.toDouble(fieldOfAIsDouble);
const double matchMetricsB = fieldOfB.toDouble(fieldOfBIsDouble);
- if (fieldOfAIsDouble && fieldOfBIsDouble) {
- const double res = matchMetricsA - matchMetricsB;
- if (std::abs(res) > std::numeric_limits<double>::epsilon())
+ if (*fieldOfAIsDouble && *fieldOfBIsDouble) {
+ if (!approximatelyEqual(matchMetricsA, matchMetricsB)) {
+ const double res = matchMetricsA - matchMetricsB;
return keyAndOrder.second == SUIT_FoundActionTree::SortOrder::Ascending ? res < 0 : res > 0;
+ }
}
else {
const int res = collator.compare(fieldOfA.toString(), fieldOfB.toString());