From ac8322f3477b19244b6963cd3154193ce0692342 Mon Sep 17 00:00:00 2001 From: mmtalaie Date: Sun, 10 Mar 2024 09:28:35 +0330 Subject: [PATCH] Fix database address from relevant addressing to absolute by use environment variables --- logic/include/viewModel/MainViewModel.h | 1 + logic/src/viewModel/MainViewModel.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/logic/include/viewModel/MainViewModel.h b/logic/include/viewModel/MainViewModel.h index 039769a..1c54b8c 100644 --- a/logic/include/viewModel/MainViewModel.h +++ b/logic/include/viewModel/MainViewModel.h @@ -157,6 +157,7 @@ public: Q_INVOKABLE explicit MainViewModel(QObject* parent = nullptr); private: + const QString _dbPath = "database/ProbeProperties.db"; signals: void ledChanged(char value); diff --git a/logic/src/viewModel/MainViewModel.cpp b/logic/src/viewModel/MainViewModel.cpp index b3b1fa4..02faedd 100644 --- a/logic/src/viewModel/MainViewModel.cpp +++ b/logic/src/viewModel/MainViewModel.cpp @@ -7,6 +7,7 @@ #include "network/UdpDataSender.h" #include "model/DatabaseManager.h" +#define US_HOME_PATH "US_HOME" #define CONNECT_LED(NAME) \ connect(panel, SIGNAL(NAME ## LedChanged(char)), this, SLOT(NAME ## LedHandle(char))); @@ -21,8 +22,7 @@ MainViewModel::MainViewModel(QObject* parent) : ViewModel(parent) connect(network, &UdpDataSender::dataReady, panel, &Console::newData); connect(network, &UdpDataSender::probeSlotsDataReady, panel, &Console::newData); - //Read probe ids from the database - QString databasePath = "../../../US_Home/database/ProbeProperties.db"; + QString databasePath = QString("%1/%2").arg(qgetenv(US_HOME_PATH), _dbPath); DatabaseManager manager(databasePath); QList globalNames = manager.getProbeNames();