diff --git a/dbc/dbcmaineditor.cpp b/dbc/dbcmaineditor.cpp index 74a238c..b30ac6b 100644 --- a/dbc/dbcmaineditor.cpp +++ b/dbc/dbcmaineditor.cpp @@ -462,7 +462,7 @@ QString DBCMainEditor::createSignalText(DBC_SIGNAL *sig) //Signals can have a hierarchial relationship with other signals so this function is separate and calls itself recursively to build the tree void DBCMainEditor::processSignalToTree(QTreeWidgetItem *parent, DBC_SIGNAL *sig) { - QTreeWidgetItem *sigItem = new QTreeWidgetItem(parent); + QTreeWidgetSignalItem *sigItem = new QTreeWidgetSignalItem(parent); QString sigInfo = createSignalText(sig); sigItem->setText(0, sigInfo); if (sig->isMultiplexor) sigItem->setIcon(0, multiplexorSignalIcon); diff --git a/dbc/dbcmaineditor.h b/dbc/dbcmaineditor.h index 75780ea..b30ea23 100644 --- a/dbc/dbcmaineditor.h +++ b/dbc/dbcmaineditor.h @@ -18,6 +18,20 @@ namespace Ui { class DBCMainEditor; } +class QTreeWidgetSignalItem : public QTreeWidgetItem +{ +public: + using QTreeWidgetItem::QTreeWidgetItem; + + // DBCSignalHandler::getSignalsAsList returns a list sorted by start bit + // becuase C++ uses a stable sorting algorithm (also for sorting QTreeWidgetItems) the order is not changed if the comparison function always returns false + bool operator<(const QTreeWidgetItem &other) const override + { + Q_UNUSED(other); + return false; + } +}; + enum DBCItemTypes { NODE = 1,