From 2316c2ead6d4c71c4cbe62a41f9b0f374bfbf7bb Mon Sep 17 00:00:00 2001 From: Ali Hatami Date: Sun, 2 Jun 2024 17:12:06 +0330 Subject: [PATCH] Reconfigure project structure --- LoggerShark.pro | 3 +++ gui/gui.pro | 5 ++++- gui/main.cpp | 13 +++++++++++++ gui/view/MainWindow.cpp | 6 +++--- model/include/LogWarehouse.h | 5 ++++- model/include/parser/IParser.h | 2 +- model/include/parser/JsonParser.h | 2 +- model/include/type/Log.h | 6 +++--- model/include/type/MessagePart.h | 2 +- model/model.pro | 4 +++- model/src/LogWarehouse.cpp | 2 +- model/src/parser/JsonParser.cpp | 2 +- test/main.cpp | 4 ++++ test/test.pro | 4 ++++ 14 files changed, 46 insertions(+), 14 deletions(-) diff --git a/LoggerShark.pro b/LoggerShark.pro index 2b22b92..3c2daea 100644 --- a/LoggerShark.pro +++ b/LoggerShark.pro @@ -1,2 +1,5 @@ TEMPLATE = subdirs SUBDIRS = model gui test + +test.depends += model +gui.depends += model diff --git a/gui/gui.pro b/gui/gui.pro index 28587e9..8ec7fb8 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -2,7 +2,7 @@ QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -CONFIG += c++11 +CONFIG += c++17 # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings @@ -25,6 +25,9 @@ HEADERS += \ FORMS += \ view/MainWindow.ui +LIBS += -L$$OUT_PWD/../model/ -lmodel +PRE_TARGETDEPS += $$OUT_PWD/../model/libmodel.a + INCLUDEPATH += $$PWD/../model/include RESOURCES += \ diff --git a/gui/main.cpp b/gui/main.cpp index c396828..582f6dd 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -1,11 +1,24 @@ #include "view/MainWindow.h" #include +#include +#include +#include +#include +#include int main(int argc, char* argv[]) { QApplication a(argc, argv); MainWindow w; + QString jsonString = + R"( + [{"id":"stderr","level":1,"location":{"file":"../../../host-projects/sono/logic/src/viewModel/factory/ApplicationStarter.cpp","func":"init","lineno":69},"msg":["FUCK\n"],"scope":"global","threadId":124330260010752,"timestamp":1716911725703}] + )"; + + QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonString.toUtf8()); + QJsonArray jsonArray = jsonDoc.array(); + w.show(); return a.exec(); diff --git a/gui/view/MainWindow.cpp b/gui/view/MainWindow.cpp index 85de825..a1b8936 100644 --- a/gui/view/MainWindow.cpp +++ b/gui/view/MainWindow.cpp @@ -1,6 +1,7 @@ #include "MainWindow.h" #include "ui_MainWindow.h" +/*************************************************************************************************/ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -19,14 +20,13 @@ MainWindow::~MainWindow() void MainWindow::setTable(QAbstractTableModel* model) { ui->tableView->setModel(model); - ui->tableView->horizontalHeader()->hideSection(2); - ui->tableView->horizontalHeader()->hideSection(3); } /*************************************************************************************************/ void MainWindow::prepareTableView() { + ui->tableView->verticalHeader()->setVisible(false); ui->tableView->horizontalHeader()->setSectionResizeMode( - QHeaderView::ResizeMode::Interactive); + QHeaderView::ResizeMode::Stretch); ui->tableView->horizontalHeader()->setSectionsMovable(true); } diff --git a/model/include/LogWarehouse.h b/model/include/LogWarehouse.h index 02a9184..29885bf 100644 --- a/model/include/LogWarehouse.h +++ b/model/include/LogWarehouse.h @@ -1,8 +1,9 @@ #ifndef LOGWAREHOUSE #define LOGWAREHOUSE +#include #include -#include "include/type/Log.h" +#include "type/Log.h" class LogWarehouse : public QObject { @@ -24,4 +25,6 @@ private: QList _data; }; +using LogWarehouse_ptr = std::shared_ptr; + #endif //LOGWAREHOUSE diff --git a/model/include/parser/IParser.h b/model/include/parser/IParser.h index 7d14d9f..abc5a80 100644 --- a/model/include/parser/IParser.h +++ b/model/include/parser/IParser.h @@ -2,7 +2,7 @@ #define IPARSER #include -#include "include/type/Log.h" +#include "type/Log.h" class IParser { diff --git a/model/include/parser/JsonParser.h b/model/include/parser/JsonParser.h index a9ab0cf..4e2389b 100644 --- a/model/include/parser/JsonParser.h +++ b/model/include/parser/JsonParser.h @@ -1,7 +1,7 @@ #ifndef JSONPARSER #define JSONPARSER -#include "include/parser/IParser.h" +#include "parser/IParser.h" #include class JsonParser : public IParser diff --git a/model/include/type/Log.h b/model/include/type/Log.h index 6dd67e6..eff1b21 100644 --- a/model/include/type/Log.h +++ b/model/include/type/Log.h @@ -8,9 +8,9 @@ #include #include -#include "include/type/ELogLevel.h" -#include "include/type/MessagePart.h" -#include "include/type/SourceLocationDto.h" +#include "type/ELogLevel.h" +#include "type/MessagePart.h" +#include "type/SourceLocationDto.h" struct Log { diff --git a/model/include/type/MessagePart.h b/model/include/type/MessagePart.h index b2a4369..b4c8316 100644 --- a/model/include/type/MessagePart.h +++ b/model/include/type/MessagePart.h @@ -2,7 +2,7 @@ #define MESSAGEPART #include -#include +#include struct MessagePart { diff --git a/model/model.pro b/model/model.pro index 0b6cc80..774c13c 100644 --- a/model/model.pro +++ b/model/model.pro @@ -2,7 +2,7 @@ TEMPLATE = lib CONFIG += c++17 CONFIG += staticlib -TARGET = logic +TARGET = model HEADERS += \ include/LogWarehouse.h \ @@ -18,3 +18,5 @@ HEADERS += \ SOURCES += \ src/LogWarehouse.cpp \ src/parser/JsonParser.cpp + +INCLUDEPATH += $$PWD/include diff --git a/model/src/LogWarehouse.cpp b/model/src/LogWarehouse.cpp index d593f61..ce7f653 100644 --- a/model/src/LogWarehouse.cpp +++ b/model/src/LogWarehouse.cpp @@ -1,4 +1,4 @@ -#include "include/LogWarehouse.h" +#include "LogWarehouse.h" /*************************************************************************************************/ Log_ptr LogWarehouse::getItem(int index) diff --git a/model/src/parser/JsonParser.cpp b/model/src/parser/JsonParser.cpp index e0d7899..a97ec50 100644 --- a/model/src/parser/JsonParser.cpp +++ b/model/src/parser/JsonParser.cpp @@ -1,4 +1,4 @@ -#include "include/parser/JsonParser.h" +#include "parser/JsonParser.h" #include #include diff --git a/test/main.cpp b/test/main.cpp index 90214c6..25b3e59 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,5 +1,9 @@ #include +#include + int main(int argc, char* argv[]) { + Q_UNUSED(argc) + Q_UNUSED(argv) } diff --git a/test/test.pro b/test/test.pro index 6b8ac35..6e85cdb 100644 --- a/test/test.pro +++ b/test/test.pro @@ -9,3 +9,7 @@ TEMPLATE = app SOURCES += \ main.cpp +LIBS += -L$$OUT_PWD/../model/ -lmodel +PRE_TARGETDEPS += $$OUT_PWD/../model/libmodel.a + +INCLUDEPATH += $$PWD/../model/include