@@ -84,6 +84,7 @@ extern "C" {
84
84
#include " sortfilterproxymodel.h"
85
85
#include " qdltoptmanager.h"
86
86
#include " qdltctrlmsg.h"
87
+ #include " ecutree.h"
87
88
88
89
89
90
MainWindow::MainWindow (QWidget *parent) :
@@ -1889,45 +1890,52 @@ void MainWindow::on_action_menuFile_Clear_triggered()
1889
1890
return ;
1890
1891
}
1891
1892
1892
- void MainWindow::contextLoadingFile ( const QDltMsg &msg )
1893
+ void MainWindow::populateEcusTree (EcuTree&& ecuTree )
1893
1894
{
1894
- /* find ecu item */
1895
- EcuItem *ecuitemFound = 0 ;
1896
- for (int num = 0 ; num < project.ecu ->topLevelItemCount (); num++)
1897
- {
1898
- EcuItem *ecuitem = (EcuItem*)project.ecu ->topLevelItem (num);
1899
- if (ecuitem->id == msg.getEcuid ())
1900
- {
1901
- ecuitemFound = ecuitem;
1902
- break ;
1903
- }
1904
- }
1895
+ QList<QTreeWidgetItem*> ecus;
1896
+ // populate ECUs tree view
1897
+ for (auto & [ecuid, apps] : ecuTree.ecus ) {
1898
+ EcuItem* ecuItem = new EcuItem (nullptr );
1905
1899
1906
- if (!ecuitemFound)
1907
- {
1908
- /* no Ecuitem found, create a new one */
1909
- ecuitemFound = new EcuItem (0 );
1900
+ ecuItem->id = ecuid;
1910
1901
1911
- /* update ECU item */
1912
- ecuitemFound->id = msg.getEcuid ();
1913
- ecuitemFound->update ();
1902
+ QList<QTreeWidgetItem*> appsItems;
1903
+ for (const auto & [appid, appdata] : apps) {
1904
+ ApplicationItem* appItem = new ApplicationItem (ecuItem);
1905
+ appItem->id = appid;
1906
+ appItem->description = appdata.description ;
1907
+ appItem->update ();
1914
1908
1915
- /* add ECU to configuration */
1916
- project.ecu ->addTopLevelItem (ecuitemFound);
1909
+ QList<QTreeWidgetItem*> contextsItems;
1910
+ for (const auto & [ctxid, ctxdata] : appdata.contexts ) {
1911
+ ContextItem* conItem = new ContextItem (appItem);
1912
+ conItem->id = ctxid;
1913
+ conItem->loglevel = ctxdata.logLevel ;
1914
+ conItem->tracestatus = ctxdata.traceStatus ;
1915
+ conItem->description = ctxdata.description ;
1916
+ conItem->status = ContextItem::valid;
1917
+ conItem->update ();
1917
1918
1918
- /* Update the ECU list in control plugins */
1919
- updatePluginsECUList ();
1919
+ contextsItems. append (conItem);
1920
+ }
1920
1921
1921
- pluginManager.stateChanged (project.ecu ->indexOfTopLevelItem (ecuitemFound), QDltConnection::QDltConnectionOffline,ecuitemFound->getHostname ());
1922
+ appItem->addChildren (contextsItems);
1923
+ appsItems.append (appItem);
1924
+ }
1922
1925
1923
- }
1926
+ ecuItem->addChildren (appsItems);
1927
+ ecuItem->update ();
1924
1928
1925
- controlMessage_ReceiveControlMessage (ecuitemFound, msg);
1926
- }
1929
+ pluginManager. stateChanged (ecus. size (), QDltConnection::QDltConnectionOffline,
1930
+ ecuItem-> getHostname ());
1927
1931
1928
- void MainWindow::reloadLogFileStop ()
1929
- {
1932
+ ecus.append (ecuItem);
1933
+ }
1934
+
1935
+ project.ecu ->addTopLevelItems (ecus);
1930
1936
1937
+ /* Update the ECU list in control plugins */
1938
+ updatePluginsECUList ();
1931
1939
}
1932
1940
1933
1941
void MainWindow::reloadLogFileProgressMax (int num)
@@ -2058,13 +2066,21 @@ void MainWindow::reloadLogFileFinishFilter()
2058
2066
settings->updateContextLoadingFile ) {
2059
2067
const QList<int > &msgIndexList = dltIndexer->getGetLogInfoList ();
2060
2068
2061
- // FIXME: this is slow operation running in the main loop
2062
2069
QDltMsg msg;
2070
+ EcuTree ecuTree;
2063
2071
for (const auto msgIndex : msgIndexList) {
2064
2072
if (qfile.getMsg (msgIndex, msg)) {
2065
- contextLoadingFile (msg);
2073
+ auto ctrlMsg = qdlt::msg::payload::parse (msg.getPayload (), msg.getEndianness () == QDlt::DltEndiannessBigEndian);
2074
+ std::visit ([&ecuTree, ecuId = msg.getEcuid ()](auto && payload) {
2075
+ using T = std::decay_t <decltype (payload)>;
2076
+ if constexpr (std::is_same_v<T, qdlt::msg::payload::GetLogInfo>) {
2077
+ ecuTree.add (ecuId, payload);
2078
+ }
2079
+ }, ctrlMsg);
2066
2080
}
2067
2081
}
2082
+ project.ecu ->clear ();
2083
+ populateEcusTree (std::move (ecuTree));
2068
2084
}
2069
2085
2070
2086
// reconnect ecus again
0 commit comments