From b1c50ab1ecebe247d629962a4a4eb354a835c0f2 Mon Sep 17 00:00:00 2001 From: sepehrmoghiseh Date: Sat, 3 Sep 2022 17:44:30 +0430 Subject: [PATCH] reUploading --- .gitignore | 76 +++++++++++++++++++++++++ appLogReader.pro | 7 +++ appLogReaderCore/AppLogReaderApp.cpp | 35 ++++++++++++ appLogReaderCore/AppLogReaderApp.h | 21 +++++++ appLogReaderCore/LinkedList.cpp | 0 appLogReaderCore/LinkedList.h | 4 ++ appLogReaderCore/MainViewModel.cpp | 27 +++++++++ appLogReaderCore/MainViewModel.h | 29 ++++++++++ appLogReaderCore/Node.h | 4 ++ appLogReaderCore/SortedLinkedList.cpp | 6 ++ appLogReaderCore/SortedLinkedList.h | 11 ++++ appLogReaderCore/appLogReaderCore.pro | 29 ++++++++++ appLogReaderCore/applogreadercore.qrc | 5 ++ appLogReaderCore/settings.xml | 8 +++ appLogReaderQuick/App.qml | 6 ++ appLogReaderQuick/MainView.qml | 70 +++++++++++++++++++++++ appLogReaderQuick/appLogReaderQuick.pro | 36 ++++++++++++ appLogReaderQuick/applogreaderquick.qrc | 8 +++ appLogReaderQuick/main.cpp | 23 ++++++++ appLogReaderTest/LinkedListTest.cpp | 6 ++ appLogReaderTest/LinkedListTest.h | 11 ++++ appLogReaderTest/appLogReaderTest.pro | 9 +++ appLogReaderTest/main.cpp | 35 ++++++++++++ 23 files changed, 466 insertions(+) create mode 100644 .gitignore create mode 100644 appLogReader.pro create mode 100644 appLogReaderCore/AppLogReaderApp.cpp create mode 100644 appLogReaderCore/AppLogReaderApp.h create mode 100644 appLogReaderCore/LinkedList.cpp create mode 100644 appLogReaderCore/LinkedList.h create mode 100644 appLogReaderCore/MainViewModel.cpp create mode 100644 appLogReaderCore/MainViewModel.h create mode 100644 appLogReaderCore/Node.h create mode 100644 appLogReaderCore/SortedLinkedList.cpp create mode 100644 appLogReaderCore/SortedLinkedList.h create mode 100644 appLogReaderCore/appLogReaderCore.pro create mode 100644 appLogReaderCore/applogreadercore.qrc create mode 100644 appLogReaderCore/settings.xml create mode 100644 appLogReaderQuick/App.qml create mode 100644 appLogReaderQuick/MainView.qml create mode 100644 appLogReaderQuick/appLogReaderQuick.pro create mode 100644 appLogReaderQuick/applogreaderquick.qrc create mode 100644 appLogReaderQuick/main.cpp create mode 100644 appLogReaderTest/LinkedListTest.cpp create mode 100644 appLogReaderTest/LinkedListTest.h create mode 100644 appLogReaderTest/appLogReaderTest.pro create mode 100644 appLogReaderTest/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f0e60b --- /dev/null +++ b/.gitignore @@ -0,0 +1,76 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + +# qpmx +.qpmx-dev-cache +*.cppdummy diff --git a/appLogReader.pro b/appLogReader.pro new file mode 100644 index 0000000..7b31963 --- /dev/null +++ b/appLogReader.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + appLogReaderQuick \ + appLogReaderCore + +appLogReaderQuick.depends += appLogReaderCore diff --git a/appLogReaderCore/AppLogReaderApp.cpp b/appLogReaderCore/AppLogReaderApp.cpp new file mode 100644 index 0000000..79f3655 --- /dev/null +++ b/appLogReaderCore/AppLogReaderApp.cpp @@ -0,0 +1,35 @@ +#include "appLogReaderApp.h" +#include "MainViewModel.h" + +#include + +appLogReaderApp::appLogReaderApp(QObject *parent) : + CoreApp(parent) +{ + QCoreApplication::setApplicationName(QStringLiteral("appLogReader")); + QCoreApplication::setApplicationVersion(QStringLiteral("1.0.0")); + QCoreApplication::setOrganizationName(QStringLiteral("Example Organization")); +} + +void appLogReaderApp::performRegistrations() +{ + //if you are using a qt resource (e.g. "applogreadercore.qrc"), initialize it here + Q_INIT_RESOURCE(applogreadercore); +} + +int appLogReaderApp::startApp(const QStringList &arguments) +{ + QCommandLineParser parser; + parser.addVersionOption(); + parser.addHelpOption(); + + //add more options + + //shows help or version automatically + if(!autoParse(parser, arguments)) + return EXIT_SUCCESS; + + //show a viewmodel to complete the startup + show(); + return EXIT_SUCCESS; +} diff --git a/appLogReaderCore/AppLogReaderApp.h b/appLogReaderCore/AppLogReaderApp.h new file mode 100644 index 0000000..166e0c0 --- /dev/null +++ b/appLogReaderCore/AppLogReaderApp.h @@ -0,0 +1,21 @@ +#ifndef APPLOGREADERAPP_H +#define APPLOGREADERAPP_H + +#include + +class appLogReaderApp : public QtMvvm::CoreApp +{ + Q_OBJECT + +public: + explicit appLogReaderApp(QObject *parent = nullptr); + +protected: + void performRegistrations() override; + int startApp(const QStringList &arguments) override; +}; + +#undef coreApp +#define coreApp static_cast(CoreApp::instance()) + +#endif // APPLOGREADERAPP_H diff --git a/appLogReaderCore/LinkedList.cpp b/appLogReaderCore/LinkedList.cpp new file mode 100644 index 0000000..e69de29 diff --git a/appLogReaderCore/LinkedList.h b/appLogReaderCore/LinkedList.h new file mode 100644 index 0000000..b33261f --- /dev/null +++ b/appLogReaderCore/LinkedList.h @@ -0,0 +1,4 @@ +#ifndef LINKEDLIST_H +#define LINKEDLIST_H + +#endif // LINKEDLIST_H diff --git a/appLogReaderCore/MainViewModel.cpp b/appLogReaderCore/MainViewModel.cpp new file mode 100644 index 0000000..c02e2d8 --- /dev/null +++ b/appLogReaderCore/MainViewModel.cpp @@ -0,0 +1,27 @@ +#include "MainViewModel.h" + +#include + +MainViewModel::MainViewModel(QObject *parent) : + ViewModel(parent), + _text(QStringLiteral("hello world")) +{} + +QString MainViewModel::text() const +{ + return _text; +} + +void MainViewModel::showSettings() +{ + show(); +} + +void MainViewModel::setText(const QString &text) +{ + if (_text == text) + return; + + _text = text; + emit textChanged(_text); +} diff --git a/appLogReaderCore/MainViewModel.h b/appLogReaderCore/MainViewModel.h new file mode 100644 index 0000000..aa8c00d --- /dev/null +++ b/appLogReaderCore/MainViewModel.h @@ -0,0 +1,29 @@ +#ifndef MAINVIEWMODEL_H +#define MAINVIEWMODEL_H + +#include + +class MainViewModel : public QtMvvm::ViewModel +{ + Q_OBJECT + + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) + +public: + Q_INVOKABLE explicit MainViewModel(QObject *parent = nullptr); + + QString text() const; + +public Q_SLOTS: + void showSettings(); + + void setText(const QString &text); + +Q_SIGNALS: + void textChanged(const QString &text); + +private: + QString _text; +}; + +#endif // MAINVIEWMODEL_H diff --git a/appLogReaderCore/Node.h b/appLogReaderCore/Node.h new file mode 100644 index 0000000..3685b95 --- /dev/null +++ b/appLogReaderCore/Node.h @@ -0,0 +1,4 @@ +#ifndef NODE_H +#define NODE_H + +#endif // NODE_H diff --git a/appLogReaderCore/SortedLinkedList.cpp b/appLogReaderCore/SortedLinkedList.cpp new file mode 100644 index 0000000..ba92521 --- /dev/null +++ b/appLogReaderCore/SortedLinkedList.cpp @@ -0,0 +1,6 @@ +#include "SortedLinkedList.h" + +SortedLinkedList::SortedLinkedList() +{ + +} diff --git a/appLogReaderCore/SortedLinkedList.h b/appLogReaderCore/SortedLinkedList.h new file mode 100644 index 0000000..07c43bc --- /dev/null +++ b/appLogReaderCore/SortedLinkedList.h @@ -0,0 +1,11 @@ +#ifndef SORTEDLINKEDLIST_H +#define SORTEDLINKEDLIST_H + + +class SortedLinkedList +{ +public: + SortedLinkedList(); +}; + +#endif // SORTEDLINKEDLIST_H diff --git a/appLogReaderCore/appLogReaderCore.pro b/appLogReaderCore/appLogReaderCore.pro new file mode 100644 index 0000000..a2f70d1 --- /dev/null +++ b/appLogReaderCore/appLogReaderCore.pro @@ -0,0 +1,29 @@ +TEMPLATE = lib + +QT += mvvmcore +# Creating a static library is typically more efficient. You can still create a shared library if you want to +CONFIG += c++14 static + +TARGET = appLogReaderCore + +DEFINES += QT_DEPRECATED_WARNINGS + +HEADERS += \ + appLogReaderApp.h \ + MainViewModel.h + +SOURCES += \ + appLogReaderApp.cpp \ + MainViewModel.cpp + +RESOURCES += \ + applogreadercore.qrc + +TRANSLATIONS += applogreader_core_de.ts \ + applogreader_core_template.ts + +DISTFILES += $$TRANSLATIONS +QTMVVM_TS_SETTINGS = settings.xml +_never_true_condition: SOURCES += $$files($$PWD/.ts-dummy/*) +# Uncomment the following line to automatically generated and update settings translations when building +#PRE_TARGETDEPS += qtmvvm-tsgen diff --git a/appLogReaderCore/applogreadercore.qrc b/appLogReaderCore/applogreadercore.qrc new file mode 100644 index 0000000..9d84d5c --- /dev/null +++ b/appLogReaderCore/applogreadercore.qrc @@ -0,0 +1,5 @@ + + + settings.xml + + diff --git a/appLogReaderCore/settings.xml b/appLogReaderCore/settings.xml new file mode 100644 index 0000000..d34233a --- /dev/null +++ b/appLogReaderCore/settings.xml @@ -0,0 +1,8 @@ + + + + diff --git a/appLogReaderQuick/App.qml b/appLogReaderQuick/App.qml new file mode 100644 index 0000000..c34f7dc --- /dev/null +++ b/appLogReaderQuick/App.qml @@ -0,0 +1,6 @@ +import QtQuick 2.10 +import de.skycoder42.QtMvvm.Quick 1.0 + +QtMvvmApp { + title: qsTr("appLogReader") +} diff --git a/appLogReaderQuick/MainView.qml b/appLogReaderQuick/MainView.qml new file mode 100644 index 0000000..f363752 --- /dev/null +++ b/appLogReaderQuick/MainView.qml @@ -0,0 +1,70 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import de.skycoder42.QtMvvm.Core 1.0 +import de.skycoder42.QtMvvm.Quick 1.0 +import com.example.applogreader 1.0 + +Page { + id: mainView + property MainViewModel viewModel: null + + header: ContrastToolBar { + RowLayout { + anchors.fill: parent + spacing: 0 + + ToolBarLabel { + text: qsTr("MainViewModel") + Layout.fillWidth: true + } + + MenuButton { + MenuItem { + id: settings + text: qsTr("Settings") + onClicked: viewModel.showSettings() + } + } + } + } + + PresenterProgress {} + + Pane { + anchors.fill: parent + + ColumnLayout { + anchors.fill: parent + + TextField { + id: textEdit + Layout.fillWidth: true + + MvvmBinding { + viewModel: mainView.viewModel + viewModelProperty: "text" + view: textEdit + viewProperty: "text" + } + } + + Label { + id: textLabel + Layout.fillWidth: true + + MvvmBinding { + viewModel: mainView.viewModel + viewModelProperty: "text" + view: textLabel + viewProperty: "text" + type: MvvmBinding.OneWayToView + } + } + + Item { + Layout.fillHeight: true + } + } + } +} diff --git a/appLogReaderQuick/appLogReaderQuick.pro b/appLogReaderQuick/appLogReaderQuick.pro new file mode 100644 index 0000000..400c051 --- /dev/null +++ b/appLogReaderQuick/appLogReaderQuick.pro @@ -0,0 +1,36 @@ +TEMPLATE = app + +QT += quick mvvmquick +CONFIG += c++14 + +TARGET = appLogReaderQuick + +DEFINES += QT_DEPRECATED_WARNINGS + +SOURCES += main.cpp + +RESOURCES += \ + applogreaderquick.qrc + +TRANSLATIONS += applogreader_quick_de.ts \ + applogreader_quick_template.ts + +# Link with core project +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../appLogReaderCore/release/ -lappLogReaderCore +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../appLogReaderCore/debug/ -lappLogReaderCore +else:unix: LIBS += -L$$OUT_PWD/../appLogReaderCore/ -lappLogReaderCore + +INCLUDEPATH += $$PWD/../appLogReaderCore +DEPENDPATH += $$PWD/../appLogReaderCore + +win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../appLogReaderCore/release/libappLogReaderCore.a +else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../appLogReaderCore/debug/libappLogReaderCore.a +else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../appLogReaderCore/release/appLogReaderCore.lib +else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../appLogReaderCore/debug/appLogReaderCore.lib +else:unix: PRE_TARGETDEPS += $$OUT_PWD/../appLogReaderCore/libappLogReaderCore.a + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Additional import path used to resolve QML modules just for Qt Quick Designer +QML_DESIGNER_IMPORT_PATH = diff --git a/appLogReaderQuick/applogreaderquick.qrc b/appLogReaderQuick/applogreaderquick.qrc new file mode 100644 index 0000000..224b44c --- /dev/null +++ b/appLogReaderQuick/applogreaderquick.qrc @@ -0,0 +1,8 @@ + + + App.qml + + + MainView.qml + + diff --git a/appLogReaderQuick/main.cpp b/appLogReaderQuick/main.cpp new file mode 100644 index 0000000..550f661 --- /dev/null +++ b/appLogReaderQuick/main.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +QTMVVM_REGISTER_CORE_APP(appLogReaderApp) + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + // If you want to support file dialogs on platforms other then android, use a QApplication instead (and add QT += widgets to the pro file) + QGuiApplication app(argc, argv); + + QtMvvm::QuickPresenter::getInputViewFactory(); //Workaround for QTBUG-69963 + qmlRegisterUncreatableType("com.example.applogreader", 1, 0, "MainViewModel", "ViewModels cannot be created!"); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/App.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +} diff --git a/appLogReaderTest/LinkedListTest.cpp b/appLogReaderTest/LinkedListTest.cpp new file mode 100644 index 0000000..0a89435 --- /dev/null +++ b/appLogReaderTest/LinkedListTest.cpp @@ -0,0 +1,6 @@ +#include "LinkedListTest.h" + +LinkedListTest::LinkedListTest() +{ + +} diff --git a/appLogReaderTest/LinkedListTest.h b/appLogReaderTest/LinkedListTest.h new file mode 100644 index 0000000..fc9d43c --- /dev/null +++ b/appLogReaderTest/LinkedListTest.h @@ -0,0 +1,11 @@ +#ifndef LINKEDLISTTEST_H +#define LINKEDLISTTEST_H + + +class LinkedListTest +{ +public: + LinkedListTest(); +}; + +#endif // LINKEDLISTTEST_H diff --git a/appLogReaderTest/appLogReaderTest.pro b/appLogReaderTest/appLogReaderTest.pro new file mode 100644 index 0000000..d2d7b7f --- /dev/null +++ b/appLogReaderTest/appLogReaderTest.pro @@ -0,0 +1,9 @@ +QT += testlib +QT -= gui + +CONFIG += qt console warn_on depend_includepath testcase +CONFIG -= app_bundle + +TEMPLATE = app + +SOURCES += tst_test.cpp diff --git a/appLogReaderTest/main.cpp b/appLogReaderTest/main.cpp new file mode 100644 index 0000000..195722f --- /dev/null +++ b/appLogReaderTest/main.cpp @@ -0,0 +1,35 @@ +#include + +// add necessary includes here + +class test : public QObject +{ + Q_OBJECT + +public: + test(); + ~test(); + +private slots: + void test_case1(); + +}; + +test::test() +{ + +} + +test::~test() +{ + +} + +void test::test_case1() +{ + +} + +QTEST_APPLESS_MAIN(test) + +#include "tst_test.moc"