Page MenuHomePhorge

No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 41d1d8a..e8d9b7c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,100 +1,101 @@
if(WIN32)
set(KAZV_IS_WINDOWS 1)
else()
set(KAZV_IS_WINDOWS 0)
endif()
configure_file(kazv-version.cpp.in kazv-version.cpp)
configure_file(kazv-platform.hpp.in kazv-platform.hpp)
configure_file(kazv-defs.hpp.in kazv-defs.hpp)
set(kazvprivlib_SRCS
qt-job-handler.cpp
qt-job.cpp
${CMAKE_CURRENT_BINARY_DIR}/kazv-version.cpp
matrix-sdk.cpp
matrix-room.cpp
matrix-room-list.cpp
matrix-room-timeline.cpp
matrix-room-member.cpp
matrix-room-member-list-model.cpp
matrix-event-reader.cpp
matrix-event-reader-list-model.cpp
matrix-event.cpp
+ matrix-event-list.cpp
matrix-link.cpp
meta-types.cpp
l10n-provider.cpp
qt-rand-adapter.cpp
helper.cpp
matrix-promise.cpp
kazv-util.cpp
matrix-sticker-pack.cpp
matrix-sticker.cpp
matrix-sticker-pack-list.cpp
matrix-sticker-pack-source.cpp
matrix-user-given-attrs-map.cpp
kazv-abstract-list-model.cpp
qt-promise-handler.cpp
device-mgmt/matrix-device.cpp
device-mgmt/matrix-device-list.cpp
kazv-config.cpp
kazv-path-config.cpp
kazv-io-manager.cpp
kazv-io-job.cpp
kazv-file.cpp
upload-job-model.cpp
kazv-markdown.cpp
shortcuts/shortcut-util.cpp
register-types.cpp
)
ecm_qt_declare_logging_category(kazvprivlib_SRCS
HEADER kazv-log.hpp
IDENTIFIER kazvLog
CATEGORY_NAME moe.kazv.mxc.kazv
)
add_library(kazvprivlib STATIC ${kazvprivlib_SRCS})
target_link_libraries(kazvprivlib PUBLIC
libkazv::kazvall
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::Network
Threads::Threads
Qt${QT_MAJOR_VERSION}::Gui
Qt${QT_MAJOR_VERSION}::Qml
Qt${QT_MAJOR_VERSION}::Quick
Qt${QT_MAJOR_VERSION}::QuickControls2
Qt${QT_MAJOR_VERSION}::Svg
Qt${QT_MAJOR_VERSION}::Concurrent
Qt${QT_MAJOR_VERSION}::Widgets
KF${KF_MAJOR_VERSION}::ConfigCore KF${KF_MAJOR_VERSION}::KIOCore
KF${KF_MAJOR_VERSION}::Notifications
${CMARK_TARGET_NAME}
)
target_include_directories(kazvprivlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(kazvprivlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/device-mgmt)
set(kazv_SRCS
main.cpp
resources.qrc
l10n/translations.qrc
)
add_executable(kazv ${kazv_SRCS})
target_link_libraries(kazv
PRIVATE
kazvprivlib
)
set(kazv_INSTALL_ARGS ${KF_INSTALL_TARGETS_DEFAULT_ARGS})
if(NOT kazv_INSTALL_ARGS)
set(kazv_INSTALL_ARGS ${KF${KF_MAJOR_VERSION}_INSTALL_TARGETS_DEFAULT_ARGS})
endif()
install(TARGETS kazv ${kazv_INSTALL_ARGS})
add_subdirectory(tests)
diff --git a/src/matrix-event-list.cpp b/src/matrix-event-list.cpp
new file mode 100644
index 0000000..f68b483
--- /dev/null
+++ b/src/matrix-event-list.cpp
@@ -0,0 +1,25 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#include <kazv-defs.hpp>
+#include "matrix-event.hpp"
+#include "helper.hpp"
+#include "matrix-event-list.hpp"
+
+using namespace Kazv;
+
+MatrixEventList::MatrixEventList(lager::reader<EventList> eventList, QObject *parent)
+ : KazvAbstractListModel(eventList.xform(containerSize), InitNow, parent)
+ , m_eventList(eventList)
+{
+}
+
+MatrixEventList::~MatrixEventList() = default;
+
+MatrixEvent *MatrixEventList::at(int index) const
+{
+ return new MatrixEvent(m_eventList[index][lager::lenses::or_default]);
+}
diff --git a/src/matrix-event-list.hpp b/src/matrix-event-list.hpp
new file mode 100644
index 0000000..13f6ccf
--- /dev/null
+++ b/src/matrix-event-list.hpp
@@ -0,0 +1,33 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#pragma once
+#include <kazv-defs.hpp>
+#include <QObject>
+#include <QQmlEngine>
+#include <QAbstractListModel>
+#include <lager/extra/qt.hpp>
+#include <base/types.hpp>
+#include "qt-json.hpp"
+#include "kazv-abstract-list-model.hpp"
+Q_MOC_INCLUDE("matrix-event.hpp")
+
+class MatrixEvent;
+
+class MatrixEventList : public KazvAbstractListModel
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_UNCREATABLE("")
+
+ lager::reader<Kazv::EventList> m_eventList;
+
+public:
+ explicit MatrixEventList(lager::reader<Kazv::EventList> eventList, QObject *parent = 0);
+ ~MatrixEventList() override;
+
+ Q_INVOKABLE MatrixEvent *at(int index) const;
+};
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 2ad1a65..20e6852 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,39 +1,40 @@
set(kazvtestlib_SRCS
test-model.cpp
)
add_library(kazvtestlib STATIC ${kazvtestlib_SRCS})
target_link_libraries(kazvtestlib PUBLIC kazvprivlib libkazv::kazvtestfixtures)
ecm_add_tests(
qt-job-handler-test.cpp
qt-promise-handler-test.cpp
qt-json-test.cpp
device-mgmt-test.cpp
matrix-sdk-test.cpp
matrix-promise-test.cpp
matrix-room-timeline-test.cpp
matrix-room-member-list-model-test.cpp
matrix-room-list-test.cpp
kazv-markdown-test.cpp
matrix-sticker-pack-test.cpp
matrix-link-test.cpp
matrix-user-given-attrs-map-test.cpp
kazv-abstract-list-model-test.cpp
+ matrix-event-list-test.cpp
LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test kazvtestlib
)
ecm_add_test(
quick-test.cpp
TEST_NAME quicktest
LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::QuickTest kazvtestlib
)
if(KAZV_BUILD_BENCHMARKS)
ecm_add_test(
matrix-room-timeline-benchmark-test.cpp
LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test kazvtestlib
)
endif()
set_tests_properties(quicktest PROPERTIES WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
diff --git a/src/tests/matrix-event-list-test.cpp b/src/tests/matrix-event-list-test.cpp
new file mode 100644
index 0000000..f4312dc
--- /dev/null
+++ b/src/tests/matrix-event-list-test.cpp
@@ -0,0 +1,47 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#include <kazv-defs.hpp>
+#include <QtTest>
+#include <QSignalSpy>
+#include <lager/state.hpp>
+#include <testfixtures/factory.hpp>
+#include "matrix-event-list.hpp"
+#include "matrix-event.hpp"
+#include "test-utils.hpp"
+
+using namespace Kazv;
+using namespace Kazv::Factory;
+
+class MatrixEventListTest : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void testEventList();
+};
+
+void MatrixEventListTest::testEventList()
+{
+ auto eventList = EventList{
+ makeEvent(),
+ makeEvent(),
+ };
+
+ auto state = lager::make_state(eventList, lager::automatic_tag{});
+
+ MatrixEventList list(state);
+
+ QCOMPARE(list.count(), 2);
+ auto e1 = toUniquePtr(list.at(0));
+ QCOMPARE(e1->eventId().toStdString(), eventList[0].id());
+ auto e2 = toUniquePtr(list.at(1));
+ QCOMPARE(e2->eventId().toStdString(), eventList[1].id());
+}
+
+QTEST_MAIN(MatrixEventListTest)
+
+#include "matrix-event-list-test.moc"

File Metadata

Mime Type
text/x-diff
Expires
Sat, Oct 10, 7:17 PM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1785416
Default Alt Text
(6 KB)

Event Timeline