Page MenuHomePhorge

No OneTemporary

Size
26 KB
Referenced Files
None
Subscribers
None
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 637dfae..18f4d6e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,17 +1,19 @@
set(kazv_SRCS
main.cpp
matrix-sdk.cpp
matrix-room.cpp
matrix-room-list.cpp
+ matrix-room-timeline.cpp
+ matrix-event.cpp
meta-types.cpp
resources.qrc
)
add_executable(kazv ${kazv_SRCS})
target_link_libraries(kazv
libkazv::kazvall
libkazv::kazvbase
libkazv::kazvjob
Threads::Threads
Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::Svg KF5::I18n)
install(TARGETS kazv ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/src/contents/ui/RoomListView.qml b/src/contents/ui/RoomListView.qml
index ae57c4b..8a9c432 100644
--- a/src/contents/ui/RoomListView.qml
+++ b/src/contents/ui/RoomListView.qml
@@ -1,51 +1,59 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.2
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
ListView {
id: roomListView
property var roomList
width: parent.width
Layout.fillHeight: true
model: roomList.count
Layout.minimumHeight: childrenRect.height
+
+ //currentIndex: -1
+
+ onCurrentIndexChanged: {
+ root.roomPage.roomId = roomList.roomIdAt(currentIndex)
+ }
+
delegate: Kirigami.SwipeListItem {
property var item: roomList.at(index)
- onClicked: print("clicked room %1".arg(index))
+ onClicked: roomListView.currentIndex = index
+ //onClicked: print("clicked room %1".arg(index))
checkable: true
checked: roomListView.currentIndex == index
- autoExclusive: true
+ //autoExclusive: true
Label {
text: i18n("%1 (%2)", item.name, item.roomId)
}
actions: [
Kirigami.Action {
text: i18n("Set as favourite")
iconName: "non-starred-symbolic"
onTriggered: showPassiveNotification(i18n("Set %1 as favourite", item.name))
}
]
}
}
diff --git a/src/matrix-room.cpp b/src/contents/ui/RoomPage.qml
similarity index 66%
copy from src/matrix-room.cpp
copy to src/contents/ui/RoomPage.qml
index 1090be8..3f1fce6 100644
--- a/src/matrix-room.cpp
+++ b/src/contents/ui/RoomPage.qml
@@ -1,34 +1,37 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
-#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
+import QtQuick 2.2
+import QtQuick.Layouts 1.15
+import QtQuick.Controls 2.15
-#include "matrix-room.hpp"
+import org.kde.kirigami 2.13 as Kirigami
-#include "helper.hpp"
+import '.' as Kazv
-MatrixRoom::MatrixRoom(Kazv::Room room, QObject *parent)
- : QObject(parent)
- , m_room(room)
- , LAGER_QT(roomId)(m_room.roomId().xform(strToQt))
- , LAGER_QT(name)(m_room.name().xform(strToQt))
-{
-}
+Kirigami.ScrollablePage {
+ property string roomId: ''
+ property var room: root.roomList.room(roomId)
+
+ title: room.name || roomId
-MatrixRoom::~MatrixRoom() = default;
+ RoomTimelineView {
+ timeline: room.timeline()
+ }
+}
diff --git a/src/contents/ui/RoomListView.qml b/src/contents/ui/RoomTimelineView.qml
similarity index 76%
copy from src/contents/ui/RoomListView.qml
copy to src/contents/ui/RoomTimelineView.qml
index ae57c4b..287373b 100644
--- a/src/contents/ui/RoomListView.qml
+++ b/src/contents/ui/RoomTimelineView.qml
@@ -1,51 +1,55 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.2
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
ListView {
id: roomListView
- property var roomList
+ property var timeline
width: parent.width
Layout.fillHeight: true
- model: roomList.count
+ model: timeline.count
Layout.minimumHeight: childrenRect.height
- delegate: Kirigami.SwipeListItem {
- property var item: roomList.at(index)
- onClicked: print("clicked room %1".arg(index))
+
+ //currentIndex: -1
+
+ delegate: Kirigami.BasicListItem {
+ property var item: timeline.at(index)
+ onClicked: roomListView.currentIndex = index
+ //onClicked: print("clicked room %1".arg(index))
checkable: true
checked: roomListView.currentIndex == index
- autoExclusive: true
+ //autoExclusive: true
Label {
- text: i18n("%1 (%2)", item.name, item.roomId)
+ text: i18n("Message from %1 of type %2: %3", item.sender, item.type, item.content)
}
- actions: [
+/* actions: [
Kirigami.Action {
text: i18n("Set as favourite")
iconName: "non-starred-symbolic"
onTriggered: showPassiveNotification(i18n("Set %1 as favourite", item.name))
}
- ]
+ ]*/
}
}
diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml
index a514337..9fb6781 100644
--- a/src/contents/ui/main.qml
+++ b/src/contents/ui/main.qml
@@ -1,64 +1,79 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.1
import org.kde.kirigami 2.4 as Kirigami
import QtQuick.Controls 2.0 as Controls
import moe.kazv.mxc.kazv 0.0 as MK
Kirigami.ApplicationWindow {
id: root
property var matrixSdk: MK.MatrixSdk {
onLoginSuccessful: switchToMainPage()
}
+ property var roomList: matrixSdk.roomList()
+
title: i18n("kazv")
globalDrawer: Kirigami.GlobalDrawer {
title: i18n("kazv")
titleIcon: "applications-graphics"
actions: [
Kirigami.Action {
text: i18n("Switch to main page")
iconName: "view-list-icons"
onTriggered: switchToMainPage()
},
Kirigami.Action {
text: i18n("Action 1")
onTriggered: showPassiveNotification(i18n("Action 1 clicked"))
},
Kirigami.Action {
text: i18n("Action 2")
onTriggered: showPassiveNotification(i18n("Action 2 clicked"))
}
]
}
contextDrawer: Kirigami.ContextDrawer {
id: contextDrawer
}
pageStack.initialPage: Qt.resolvedUrl("LoginPage.qml")
+ property var mainPageLoader: Loader {
+ id: mainPageLoader
+ source: Qt.resolvedUrl("MainPage.qml")
+ }
+
+ property var roomPageLoader: Loader {
+ id: roomPageLoader
+ source: Qt.resolvedUrl("RoomPage.qml")
+ }
+
+ property alias mainPage: mainPageLoader.item
+ property alias roomPage: roomPageLoader.item
+
function switchToMainPage() {
- pageStack.replace(Qt.resolvedUrl("MainPage.qml"))
+ pageStack.replace([mainPage, roomPage])
}
}
diff --git a/src/main.cpp b/src/main.cpp
index 04b9679..2aed4f8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,54 +1,58 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QUrl>
#include <KLocalizedContext>
#include "matrix-sdk.hpp"
#include "matrix-room-list.hpp"
#include "matrix-room.hpp"
+#include "matrix-room-timeline.hpp"
+#include "matrix-event.hpp"
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("The Kazv Project");
QCoreApplication::setOrganizationDomain("kazv.moe");
QCoreApplication::setApplicationName("kazv");
QQmlApplicationEngine engine;
qmlRegisterType<MatrixSdk>("moe.kazv.mxc.kazv", 0, 0, "MatrixSdk");
qmlRegisterUncreatableType<MatrixRoomList>("moe.kazv.mxc.kazv", 0, 0, "MatrixRoomList", "");
qmlRegisterUncreatableType<MatrixRoom>("moe.kazv.mxc.kazv", 0, 0, "MatrixRoom", "");
+ qmlRegisterUncreatableType<MatrixRoomTimeline>("moe.kazv.mxc.kazv", 0, 0, "MatrixRoomTimeline", "");
+ qmlRegisterUncreatableType<MatrixEvent>("moe.kazv.mxc.kazv", 0, 0, "MatrixEvent", "");
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
if (engine.rootObjects().isEmpty()) {
return -1;
}
return app.exec();
}
diff --git a/src/matrix-room.cpp b/src/matrix-event.cpp
similarity index 53%
copy from src/matrix-room.cpp
copy to src/matrix-event.cpp
index 1090be8..673334a 100644
--- a/src/matrix-room.cpp
+++ b/src/matrix-event.cpp
@@ -1,34 +1,40 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
-#include "matrix-room.hpp"
+#include "matrix-event.hpp"
#include "helper.hpp"
-MatrixRoom::MatrixRoom(Kazv::Room room, QObject *parent)
+using namespace Kazv;
+
+MatrixEvent::MatrixEvent(lager::reader<Event> event, QObject *parent)
: QObject(parent)
- , m_room(room)
- , LAGER_QT(roomId)(m_room.roomId().xform(strToQt))
- , LAGER_QT(name)(m_room.name().xform(strToQt))
+ , m_event(event)
+ , LAGER_QT(eventId)(m_event.xform(zug::map([](Event e) { return e.id(); }) | strToQt))
+ , LAGER_QT(sender)(m_event.xform(zug::map([](Event e) { return e.sender(); }) | strToQt))
+ , LAGER_QT(type)(m_event.xform(zug::map([](Event e) { return e.type(); }) | strToQt))
+ , LAGER_QT(stateKey)(m_event.xform(zug::map([](Event e) { return e.stateKey(); }) | strToQt))
+ , LAGER_QT(content)(m_event.xform(zug::map([](Event e) { return e.content().get().dump(); }) | strToQt))
+ , LAGER_QT(encrypted)(m_event.xform(zug::map([](Event e) { return e.encrypted(); })))
{
}
-MatrixRoom::~MatrixRoom() = default;
+MatrixEvent::~MatrixEvent() = default;
diff --git a/src/matrix-room.hpp b/src/matrix-event.hpp
similarity index 70%
copy from src/matrix-room.hpp
copy to src/matrix-event.hpp
index 01d1a92..f443e34 100644
--- a/src/matrix-room.hpp
+++ b/src/matrix-event.hpp
@@ -1,45 +1,49 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <QObject>
#include <QQmlEngine>
#include <lager/extra/qt.hpp>
#include <client/room/room.hpp>
-class MatrixRoom : public QObject
+class MatrixEvent : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
- Kazv::Room m_room;
+ lager::reader<Kazv::Event> m_event;
public:
- explicit MatrixRoom(Kazv::Room room, QObject *parent = 0);
- ~MatrixRoom() override;
-
- LAGER_QT_READER(QString, roomId);
- LAGER_QT_READER(QString, name);
+ explicit MatrixEvent(lager::reader<Kazv::Event> event, QObject *parent = 0);
+ ~MatrixEvent() override;
+
+ LAGER_QT_READER(QString, eventId);
+ LAGER_QT_READER(QString, sender);
+ LAGER_QT_READER(QString, type);
+ LAGER_QT_READER(QString, stateKey);
+ LAGER_QT_READER(QString, content);
+ LAGER_QT_READER(bool, encrypted);
};
diff --git a/src/matrix-room-list.cpp b/src/matrix-room-list.cpp
index 01a3117..3f7902e 100644
--- a/src/matrix-room-list.cpp
+++ b/src/matrix-room-list.cpp
@@ -1,52 +1,64 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <lager/constant.hpp>
+#include <lager/lenses/optional.hpp>
#include "matrix-room-list.hpp"
#include "matrix-room.hpp"
#include "helper.hpp"
MatrixRoomList::MatrixRoomList(Kazv::Client client, QObject *parent)
: QObject(parent)
, m_client(client)
, m_roomIds(m_client.roomIds())
, LAGER_QT(count)(m_roomIds.xform(containerSize))
{
}
MatrixRoomList::~MatrixRoomList() = default;
MatrixRoom *MatrixRoomList::at(int index) const
{
qDebug() << "Room at index " << index << " requested";
return new MatrixRoom(
m_client.roomByCursor(
lager::with(m_roomIds, lager::make_constant(index))
.xform(zug::map([](auto ids, auto i) {
try {
return ids.at(i);
} catch (const std::out_of_range &) {
return std::string{};
}
}))));
}
+
+QString MatrixRoomList::roomIdAt(int index) const
+{
+ using namespace Kazv::CursorOp;
+ return +m_roomIds[index][lager::lenses::or_default].xform(strToQt);
+}
+
+MatrixRoom *MatrixRoomList::room(QString roomId) const
+{
+ return new MatrixRoom(m_client.room(roomId.toStdString()));
+}
diff --git a/src/matrix-room-list.hpp b/src/matrix-room-list.hpp
index dd0d127..69d5b1a 100644
--- a/src/matrix-room-list.hpp
+++ b/src/matrix-room-list.hpp
@@ -1,50 +1,51 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <QObject>
#include <QQmlEngine>
#include <lager/extra/qt.hpp>
#include <client/client.hpp>
class MatrixRoom;
class MatrixRoomList : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
Kazv::Client m_client;
lager::reader<immer::flex_vector<std::string>> m_roomIds;
public:
explicit MatrixRoomList(Kazv::Client client, QObject *parent = 0);
~MatrixRoomList() override;
LAGER_QT_READER(int, count);
Q_INVOKABLE MatrixRoom *at(int index) const;
-
+ Q_INVOKABLE QString roomIdAt(int index) const;
+ Q_INVOKABLE MatrixRoom *room(QString roomId) const;
};
diff --git a/src/matrix-room.cpp b/src/matrix-room-timeline.cpp
similarity index 66%
copy from src/matrix-room.cpp
copy to src/matrix-room-timeline.cpp
index 1090be8..f3955fd 100644
--- a/src/matrix-room.cpp
+++ b/src/matrix-room-timeline.cpp
@@ -1,34 +1,42 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
-#include "matrix-room.hpp"
+#include <lager/lenses/optional.hpp>
+
+#include "matrix-room-timeline.hpp"
+#include "matrix-event.hpp"
#include "helper.hpp"
-MatrixRoom::MatrixRoom(Kazv::Room room, QObject *parent)
+MatrixRoomTimeline::MatrixRoomTimeline(Kazv::Room room, QObject *parent)
: QObject(parent)
, m_room(room)
- , LAGER_QT(roomId)(m_room.roomId().xform(strToQt))
- , LAGER_QT(name)(m_room.name().xform(strToQt))
+ , m_timeline(m_room.timelineEvents())
+ , LAGER_QT(count)(m_timeline.xform(containerSize))
{
}
-MatrixRoom::~MatrixRoom() = default;
+MatrixRoomTimeline::~MatrixRoomTimeline() = default;
+
+MatrixEvent *MatrixRoomTimeline::at(int index) const
+{
+ return new MatrixEvent(m_timeline[index][lager::lenses::or_default]);
+}
diff --git a/src/matrix-room.hpp b/src/matrix-room-timeline.hpp
similarity index 77%
copy from src/matrix-room.hpp
copy to src/matrix-room-timeline.hpp
index 01d1a92..6555402 100644
--- a/src/matrix-room.hpp
+++ b/src/matrix-room-timeline.hpp
@@ -1,45 +1,50 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <QObject>
#include <QQmlEngine>
#include <lager/extra/qt.hpp>
#include <client/room/room.hpp>
-class MatrixRoom : public QObject
+class MatrixEvent;
+
+class MatrixRoomTimeline : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
Kazv::Room m_room;
+ lager::reader<Kazv::EventList> m_timeline;
+
public:
- explicit MatrixRoom(Kazv::Room room, QObject *parent = 0);
- ~MatrixRoom() override;
+ explicit MatrixRoomTimeline(Kazv::Room room, QObject *parent = 0);
+ ~MatrixRoomTimeline() override;
+
+ LAGER_QT_READER(int, count);
- LAGER_QT_READER(QString, roomId);
- LAGER_QT_READER(QString, name);
+ Q_INVOKABLE MatrixEvent *at(int index) const;
};
diff --git a/src/matrix-room.cpp b/src/matrix-room.cpp
index 1090be8..30a0968 100644
--- a/src/matrix-room.cpp
+++ b/src/matrix-room.cpp
@@ -1,34 +1,40 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include "matrix-room.hpp"
+#include "matrix-room-timeline.hpp"
#include "helper.hpp"
MatrixRoom::MatrixRoom(Kazv::Room room, QObject *parent)
: QObject(parent)
, m_room(room)
, LAGER_QT(roomId)(m_room.roomId().xform(strToQt))
, LAGER_QT(name)(m_room.name().xform(strToQt))
{
}
MatrixRoom::~MatrixRoom() = default;
+
+MatrixRoomTimeline *MatrixRoom::timeline() const
+{
+ return new MatrixRoomTimeline(m_room);
+}
diff --git a/src/matrix-room.hpp b/src/matrix-room.hpp
index 01d1a92..95ebbe9 100644
--- a/src/matrix-room.hpp
+++ b/src/matrix-room.hpp
@@ -1,45 +1,49 @@
/*
* Copyright (C) 2020 Tusooa Zhu <tusooa@vista.aero>
*
* This file is part of kazv.
*
* kazv is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* kazv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with kazv. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <immer/config.hpp> // https://github.com/arximboldi/immer/issues/168
#include <QObject>
#include <QQmlEngine>
#include <lager/extra/qt.hpp>
#include <client/room/room.hpp>
+class MatrixRoomTimeline;
+
class MatrixRoom : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
Kazv::Room m_room;
public:
explicit MatrixRoom(Kazv::Room room, QObject *parent = 0);
~MatrixRoom() override;
LAGER_QT_READER(QString, roomId);
LAGER_QT_READER(QString, name);
+
+ Q_INVOKABLE MatrixRoomTimeline *timeline() const;
};
diff --git a/src/resources.qrc b/src/resources.qrc
index 36c757a..15ff16f 100644
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -1,10 +1,12 @@
<RCC>
<qresource prefix="/">
<file alias="main.qml">contents/ui/main.qml</file>
<file alias="LoginPage.qml">contents/ui/LoginPage.qml</file>
<file alias="MainPage.qml">contents/ui/MainPage.qml</file>
<file alias="TabView.qml">contents/ui/TabView.qml</file>
<file alias="Tab.qml">contents/ui/Tab.qml</file>
<file alias="RoomListView.qml">contents/ui/RoomListView.qml</file>
+ <file alias="RoomPage.qml">contents/ui/RoomPage.qml</file>
+ <file alias="RoomTimelineView.qml">contents/ui/RoomTimelineView.qml</file>
</qresource>
</RCC>

File Metadata

Mime Type
text/x-diff
Expires
Fri, Oct 9, 2:36 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1784760
Default Alt Text
(26 KB)

Event Timeline