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