From e390c9d851a53294ed706c544d3bf4adc376743e Mon Sep 17 00:00:00 2001
From: Viktor Kopp <vifactor@gmail.com>
Date: Sun, 24 Nov 2024 17:00:04 +0100
Subject: [PATCH] No use of QtGlobal in c-code

Signed-off-by: Viktor Kopp <vifactor@gmail.com>
---
 plugin/dlttestrobotplugin/dlttestrobotplugin.cpp | 11 +----------
 qdlt/dlt_types.h                                 |  2 +-
 qdlt/dlt_user.h                                  |  1 -
 qdlt/export_rules.h                              |  8 ++------
 qdlt/qdltsegmentedmsg.h                          |  1 -
 src/dltmsgqueue.cpp                              |  2 ++
 src/mainwindow.cpp                               | 10 ++--------
 7 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/plugin/dlttestrobotplugin/dlttestrobotplugin.cpp b/plugin/dlttestrobotplugin/dlttestrobotplugin.cpp
index 14291b90..99fcdb23 100644
--- a/plugin/dlttestrobotplugin/dlttestrobotplugin.cpp
+++ b/plugin/dlttestrobotplugin/dlttestrobotplugin.cpp
@@ -108,16 +108,7 @@ bool DltTestRobotPlugin::controlMsg(int , QDltMsg &)
     return false;
 }
 
-bool DltTestRobotPlugin::stateChanged(int index, QDltConnection::QDltConnectionState connectionState,QString hostname){
-    Q_UNUSED(index)
-    Q_UNUSED(connectionState)
-    Q_UNUSED(hostname)
-
-#if QT_5_SUPPORTED_VERSION
-    //qDebug() << ecuList->at(index) << "ConnectionState:" << connectionState << "Hostname:" << hostname << Qt::endl;
-#else
-    //qDebug() << ecuList->at(index) << "ConnectionState:" << connectionState << "Hostname:" << hostname << endl;
-#endif
+bool DltTestRobotPlugin::stateChanged(int, QDltConnection::QDltConnectionState, QString) {
     return true;
 }
 
diff --git a/qdlt/dlt_types.h b/qdlt/dlt_types.h
index d806c639..d4494abe 100644
--- a/qdlt/dlt_types.h
+++ b/qdlt/dlt_types.h
@@ -59,7 +59,7 @@
 typedef int pid_t;
 #endif
 
-#ifdef TARGET_OS_MAC
+#ifdef __APPLE__
 typedef unsigned long speed_t;
 #else
 typedef unsigned int speed_t;
diff --git a/qdlt/dlt_user.h b/qdlt/dlt_user.h
index f9baef79..194602d2 100644
--- a/qdlt/dlt_user.h
+++ b/qdlt/dlt_user.h
@@ -71,7 +71,6 @@
   \{
 */
 
-#include "dlt_types.h"
 #include "dlt_common.h"
 
 #ifdef __cplusplus
diff --git a/qdlt/export_rules.h b/qdlt/export_rules.h
index 61e79ed5..588b173c 100644
--- a/qdlt/export_rules.h
+++ b/qdlt/export_rules.h
@@ -1,24 +1,20 @@
-#include <QtGlobal>
-
 #ifndef EXPORT_RULES_H
 #define EXPORT_RULES_H
 
 #if defined(QDLT_LIBRARY)
 # define QDLT_EXPORT Q_DECL_EXPORT
-# ifdef Q_OS_WIN
+# if defined(_WIN32) || defined(_WIN64)
 #  define QDLT_C_EXPORT __declspec(dllexport)
 # else
 #  define QDLT_C_EXPORT __attribute__((visibility("default")))
 # endif
 #else
 # define QDLT_EXPORT Q_DECL_IMPORT
-# ifdef Q_OS_WIN
+# if defined(_WIN32) || defined(_WIN64)
 #  define QDLT_C_EXPORT __declspec(dllimport)
 # else
 #  define QDLT_C_EXPORT
 # endif
 #endif
 
-#define QT_5_SUPPORTED_VERSION (QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR >= 14) || (QT_VERSION_MAJOR >= 6)
-
 #endif // EXPORT_RULES_H
diff --git a/qdlt/qdltsegmentedmsg.h b/qdlt/qdltsegmentedmsg.h
index 9ac08d67..8c03daf5 100644
--- a/qdlt/qdltsegmentedmsg.h
+++ b/qdlt/qdltsegmentedmsg.h
@@ -25,7 +25,6 @@
 #include "export_rules.h"
 
 #include <qdltmsg.h>
-#include <dlt_types.h>
 
 //! Combine segmented network messages
 /*!
diff --git a/src/dltmsgqueue.cpp b/src/dltmsgqueue.cpp
index 3c0c0590..61297674 100644
--- a/src/dltmsgqueue.cpp
+++ b/src/dltmsgqueue.cpp
@@ -1,6 +1,8 @@
 #include "dltmsgqueue.h"
 #include <QThread>
 
+#define QT_5_SUPPORTED_VERSION (QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR >= 14) || (QT_VERSION_MAJOR >= 6)
+
 DltMsgQueue::DltMsgQueue(int size)
     : bufferSize(size),
       buffer(new QPair<QSharedPointer<QDltMsg>, int> [size]),
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 100ee7da..f28bb4e2 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -7139,14 +7139,10 @@ void MainWindow::filterUpdate()
 
         if(filter->enableRegexp_Appid || filter->enableRegexp_Context || filter->enableRegexp_Header || filter->enableRegexp_Payload)
         {
-            if(false == filter->compileRegexps())
+            if(!filter->compileRegexps())
             {
                 // This is also validated in the UI part
-#if QT_5_SUPPORTED_VERSION
-                qDebug() << "Error compiling a regexp" << Qt::endl << "in" << __FILE__ << __LINE__;
-#else
-                qDebug() << "Error compiling a regexp" << endl << "in" << __FILE__ << __LINE__;
-#endif
+                qDebug() << "Error compiling a regexp\nin" << __FILE__ << __LINE__;
             }
         }
 
@@ -7155,8 +7151,6 @@ void MainWindow::filterUpdate()
     qfile.updateSortedFilter();
 }
 
-
-
 void MainWindow::on_tableView_customContextMenuRequested(QPoint pos)
 {
     /* show custom pop menu  for configuration */
