Create new rooms module
This commit is contained in:
@@ -9,19 +9,16 @@ endif()
|
||||
|
||||
add_subdirectory(libneochat)
|
||||
add_subdirectory(login)
|
||||
add_subdirectory(rooms)
|
||||
add_subdirectory(timeline)
|
||||
|
||||
add_library(neochat STATIC
|
||||
controller.cpp
|
||||
controller.h
|
||||
models/sortfilterspacelistmodel.cpp
|
||||
models/sortfilterspacelistmodel.h
|
||||
roommanager.cpp
|
||||
roommanager.h
|
||||
models/userfiltermodel.cpp
|
||||
models/userfiltermodel.h
|
||||
models/publicroomlistmodel.cpp
|
||||
models/publicroomlistmodel.h
|
||||
models/spacechildrenmodel.cpp
|
||||
models/spacechildrenmodel.h
|
||||
models/spacechildsortfiltermodel.cpp
|
||||
@@ -32,10 +29,6 @@ add_library(neochat STATIC
|
||||
models/userdirectorylistmodel.h
|
||||
notificationsmanager.cpp
|
||||
notificationsmanager.h
|
||||
models/sortfilterroomlistmodel.cpp
|
||||
models/sortfilterroomlistmodel.h
|
||||
models/roomtreemodel.cpp
|
||||
models/roomtreemodel.h
|
||||
models/webshortcutmodel.cpp
|
||||
models/webshortcutmodel.h
|
||||
blurhash.cpp
|
||||
@@ -58,21 +51,15 @@ add_library(neochat STATIC
|
||||
models/notificationsmodel.h
|
||||
proxycontroller.cpp
|
||||
proxycontroller.h
|
||||
models/sortfilterroomtreemodel.cpp
|
||||
models/sortfilterroomtreemodel.h
|
||||
mediamanager.cpp
|
||||
mediamanager.h
|
||||
models/statekeysmodel.cpp
|
||||
models/statekeysmodel.h
|
||||
sharehandler.cpp
|
||||
sharehandler.h
|
||||
models/roomtreeitem.cpp
|
||||
models/roomtreeitem.h
|
||||
foreigntypes.h
|
||||
identityserverhelper.cpp
|
||||
identityserverhelper.h
|
||||
enums/roomsortparameter.cpp
|
||||
enums/roomsortparameter.h
|
||||
models/roomsortparametermodel.cpp
|
||||
models/roomsortparametermodel.h
|
||||
models/commonroomsmodel.cpp
|
||||
@@ -98,15 +85,7 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
QML_FILES
|
||||
qml/Main.qml
|
||||
qml/AccountMenu.qml
|
||||
qml/ExploreComponent.qml
|
||||
qml/ExploreComponentMobile.qml
|
||||
qml/RoomContextMenu.qml
|
||||
qml/CollapsedRoomDelegate.qml
|
||||
qml/RoomDelegate.qml
|
||||
qml/RoomListPage.qml
|
||||
qml/SpaceListContextMenu.qml
|
||||
qml/UserInfo.qml
|
||||
qml/UserInfoDesktop.qml
|
||||
qml/RoomPage.qml
|
||||
qml/ExploreRoomsPage.qml
|
||||
qml/ManualRoomDialog.qml
|
||||
@@ -141,7 +120,6 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
qml/TimelineView.qml
|
||||
qml/InvitationView.qml
|
||||
qml/AvatarTabButton.qml
|
||||
qml/SpaceDrawer.qml
|
||||
qml/OsmLocationPlugin.qml
|
||||
qml/TextToSpeechWrapper.qml
|
||||
qml/FullScreenMap.qml
|
||||
@@ -166,7 +144,6 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
qml/UserSearchPage.qml
|
||||
qml/ManualUserDialog.qml
|
||||
qml/RecommendedSpaceDialog.qml
|
||||
qml/RoomTreeSection.qml
|
||||
qml/DelegateContextMenu.qml
|
||||
qml/ShareDialog.qml
|
||||
qml/UnlockSSSSDialog.qml
|
||||
@@ -188,6 +165,7 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
QtQuick
|
||||
IMPORTS
|
||||
org.kde.neochat.libneochat
|
||||
org.kde.neochat.rooms
|
||||
org.kde.neochat.timeline
|
||||
org.kde.neochat.settings
|
||||
org.kde.neochat.devtools
|
||||
@@ -213,15 +191,6 @@ if(WIN32)
|
||||
set_target_properties(neochat PROPERTIES OUTPUT_NAME "neochatlib")
|
||||
endif()
|
||||
|
||||
ecm_qt_declare_logging_category(neochat
|
||||
HEADER "publicroomlist_logging.h"
|
||||
IDENTIFIER "PublicRoomList"
|
||||
CATEGORY_NAME "org.kde.neochat.publicroomlistmodel"
|
||||
DESCRIPTION "Neochat: publicroomlistmodel"
|
||||
DEFAULT_SEVERITY Info
|
||||
EXPORT NEOCHAT
|
||||
)
|
||||
|
||||
add_executable(neochat-app
|
||||
main.cpp
|
||||
)
|
||||
@@ -264,8 +233,8 @@ else()
|
||||
target_compile_definitions(neochat PUBLIC -DHAVE_X11=0)
|
||||
endif()
|
||||
|
||||
target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models ${CMAKE_CURRENT_SOURCE_DIR}/enums)
|
||||
target_link_libraries(neochat PRIVATE Settingsplugin Timelineplugin devtoolsplugin Loginplugin chatbarplugin)
|
||||
target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models)
|
||||
target_link_libraries(neochat PRIVATE Settingsplugin Roomsplugin Timelineplugin devtoolsplugin Loginplugin chatbarplugin)
|
||||
target_link_libraries(neochat PUBLIC
|
||||
LibNeoChat
|
||||
Timeline
|
||||
@@ -288,6 +257,7 @@ target_link_libraries(neochat PUBLIC
|
||||
KF6::ItemModels
|
||||
QuotientQt6
|
||||
Login
|
||||
Rooms
|
||||
)
|
||||
|
||||
if (TARGET KF6::Crash)
|
||||
|
||||
@@ -20,11 +20,13 @@
|
||||
#include <Quotient/settings.h>
|
||||
|
||||
#include "accountmanager.h"
|
||||
#include "enums/roomsortparameter.h"
|
||||
#include "mediasizehelper.h"
|
||||
#include "models/actionsmodel.h"
|
||||
#include "models/messagemodel.h"
|
||||
#include "models/pushrulemodel.h"
|
||||
#include "models/roomlistmodel.h"
|
||||
#include "models/roomtreemodel.h"
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatconnection.h"
|
||||
#include "neochatroom.h"
|
||||
@@ -95,6 +97,7 @@ Controller::Controller(QObject *parent)
|
||||
|
||||
MessageModel::setHiddenFilter(hiddenEventFilter);
|
||||
RoomListModel::setHiddenFilter(hiddenEventFilter);
|
||||
RoomTreeModel::setHiddenFilter(hiddenEventFilter);
|
||||
|
||||
MediaSizeHelper::setMaxSize(NeoChatConfig::mediaMaxWidth(), NeoChatConfig::mediaMaxHeight());
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::MediaMaxWidthChanged, this, []() {
|
||||
@@ -104,6 +107,26 @@ Controller::Controller(QObject *parent)
|
||||
MediaSizeHelper::setMaxSize(NeoChatConfig::mediaMaxWidth(), NeoChatConfig::mediaMaxHeight());
|
||||
});
|
||||
|
||||
RoomSortParameter::setSortOrder(static_cast<RoomSortOrder::Order>(NeoChatConfig::sortOrder()));
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::SortOrderChanged, this, []() {
|
||||
RoomSortParameter::setSortOrder(static_cast<RoomSortOrder::Order>(NeoChatConfig::sortOrder()));
|
||||
});
|
||||
|
||||
QList<RoomSortParameter::Parameter> configParamList;
|
||||
const auto intList = NeoChatConfig::customSortOrder();
|
||||
std::transform(intList.constBegin(), intList.constEnd(), std::back_inserter(configParamList), [](int param) {
|
||||
return static_cast<RoomSortParameter::Parameter>(param);
|
||||
});
|
||||
RoomSortParameter::setCustomSortOrder(configParamList);
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::CustomSortOrderChanged, this, []() {
|
||||
QList<RoomSortParameter::Parameter> configParamList;
|
||||
const auto intList = NeoChatConfig::customSortOrder();
|
||||
std::transform(intList.constBegin(), intList.constEnd(), std::back_inserter(configParamList), [](int param) {
|
||||
return static_cast<RoomSortParameter::Parameter>(param);
|
||||
});
|
||||
RoomSortParameter::setCustomSortOrder(configParamList);
|
||||
});
|
||||
|
||||
ProxyController::instance().setApplicationProxy();
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
|
||||
@@ -26,6 +26,8 @@ target_sources(LibNeoChat PRIVATE
|
||||
enums/messagetype.h
|
||||
enums/powerlevel.cpp
|
||||
enums/pushrule.h
|
||||
enums/roomsortparameter.cpp
|
||||
enums/roomsortorder.h
|
||||
events/imagepackevent.cpp
|
||||
events/pollevent.cpp
|
||||
models/actionsmodel.cpp
|
||||
|
||||
31
src/libneochat/enums/roomsortorder.h
Normal file
31
src/libneochat/enums/roomsortorder.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// SPDX-FileCopyrightText: 2025 James Graham <james.h.graham@protonmail.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlEngine>
|
||||
|
||||
/**
|
||||
* @class RoomSortOrder
|
||||
*
|
||||
* This class is designed to define the RoomSortOrder enumeration.
|
||||
*/
|
||||
class RoomSortOrder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
QML_UNCREATABLE("")
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief The types of messages that can be shown.
|
||||
*/
|
||||
enum Order {
|
||||
Alphabetical = 0, /**< The room should be sorted alphabetically. */
|
||||
Activity, /**< The room should be sorted by important activity. */
|
||||
LastMessage, /**< The room should be sorted by last message in the room. */
|
||||
Custom, /**< Use a custom sort order. */
|
||||
};
|
||||
Q_ENUM(Order);
|
||||
};
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "neochatconfig.h"
|
||||
#include "enums/roomsortorder.h"
|
||||
#include "neochatroom.h"
|
||||
|
||||
namespace
|
||||
@@ -49,6 +49,9 @@ static const QList<RoomSortParameter::Parameter> lastMessageSortPriorities = {
|
||||
};
|
||||
}
|
||||
|
||||
RoomSortOrder::Order RoomSortParameter::m_sortOrder = RoomSortOrder::Activity;
|
||||
QList<RoomSortParameter::Parameter> RoomSortParameter::m_customSortOrder = activitySortPriorities;
|
||||
|
||||
QList<RoomSortParameter::Parameter> RoomSortParameter::allParameterList()
|
||||
{
|
||||
return allSortPriorities;
|
||||
@@ -57,21 +60,18 @@ QList<RoomSortParameter::Parameter> RoomSortParameter::allParameterList()
|
||||
QList<RoomSortParameter::Parameter> RoomSortParameter::currentParameterList()
|
||||
{
|
||||
QList<RoomSortParameter::Parameter> configParamList;
|
||||
switch (static_cast<NeoChatConfig::EnumSortOrder::type>(NeoChatConfig::sortOrder())) {
|
||||
case NeoChatConfig::EnumSortOrder::Activity:
|
||||
switch (m_sortOrder) {
|
||||
case RoomSortOrder::Activity:
|
||||
configParamList = activitySortPriorities;
|
||||
break;
|
||||
case NeoChatConfig::EnumSortOrder::Alphabetical:
|
||||
case RoomSortOrder::Alphabetical:
|
||||
configParamList = alphabeticalSortPriorities;
|
||||
break;
|
||||
case NeoChatConfig::EnumSortOrder::LastMessage:
|
||||
case RoomSortOrder::LastMessage:
|
||||
configParamList = lastMessageSortPriorities;
|
||||
break;
|
||||
case NeoChatConfig::EnumSortOrder::Custom: {
|
||||
const auto intList = NeoChatConfig::customSortOrder();
|
||||
std::transform(intList.constBegin(), intList.constEnd(), std::back_inserter(configParamList), [](int param) {
|
||||
return static_cast<Parameter>(param);
|
||||
});
|
||||
case RoomSortOrder::Custom: {
|
||||
configParamList = m_customSortOrder;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -84,17 +84,6 @@ QList<RoomSortParameter::Parameter> RoomSortParameter::currentParameterList()
|
||||
return configParamList;
|
||||
}
|
||||
|
||||
void RoomSortParameter::saveNewParameterList(const QList<Parameter> &newList)
|
||||
{
|
||||
QList<int> intList;
|
||||
std::transform(newList.constBegin(), newList.constEnd(), std::back_inserter(intList), [](Parameter param) {
|
||||
return static_cast<int>(param);
|
||||
});
|
||||
NeoChatConfig::setCustomSortOrder(intList);
|
||||
NeoChatConfig::setSortOrder(NeoChatConfig::EnumSortOrder::Custom);
|
||||
NeoChatConfig::self()->save();
|
||||
}
|
||||
|
||||
int RoomSortParameter::compareParameter(Parameter parameter, NeoChatRoom *leftRoom, NeoChatRoom *rightRoom)
|
||||
{
|
||||
switch (parameter) {
|
||||
@@ -160,3 +149,13 @@ int RoomSortParameter::compareParameter<RoomSortParameter::LastActive>(NeoChatRo
|
||||
{
|
||||
return typeCompare(leftRoom->lastActiveTime(), rightRoom->lastActiveTime());
|
||||
}
|
||||
|
||||
void RoomSortParameter::setSortOrder(RoomSortOrder::Order order)
|
||||
{
|
||||
RoomSortParameter::m_sortOrder = order;
|
||||
}
|
||||
|
||||
void RoomSortParameter::setCustomSortOrder(QList<Parameter> order)
|
||||
{
|
||||
RoomSortParameter::m_customSortOrder = order;
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "roomsortorder.h"
|
||||
#include <QObject>
|
||||
#include <QQmlEngine>
|
||||
|
||||
@@ -104,11 +105,6 @@ public:
|
||||
*/
|
||||
static QList<Parameter> currentParameterList();
|
||||
|
||||
/**
|
||||
* @brief Save the give Parameter sort order list as the custom sort order.
|
||||
*/
|
||||
static void saveNewParameterList(const QList<Parameter> &newList);
|
||||
|
||||
/**
|
||||
* @brief Compare the given parameter of the two given rooms.
|
||||
*
|
||||
@@ -118,7 +114,13 @@ public:
|
||||
*/
|
||||
static int compareParameter(Parameter parameter, NeoChatRoom *leftRoom, NeoChatRoom *rightRoom);
|
||||
|
||||
static void setSortOrder(RoomSortOrder::Order order);
|
||||
static void setCustomSortOrder(QList<Parameter> order);
|
||||
|
||||
private:
|
||||
static RoomSortOrder::Order m_sortOrder;
|
||||
static QList<Parameter> m_customSortOrder;
|
||||
|
||||
template<Parameter parameter>
|
||||
static int compareParameter(NeoChatRoom *, NeoChatRoom *)
|
||||
{
|
||||
@@ -240,6 +240,7 @@ int main(int argc, char *argv[])
|
||||
Registration::instance().setAccountManager(accountManager.get());
|
||||
|
||||
Q_IMPORT_QML_PLUGIN(org_kde_neochat_settingsPlugin)
|
||||
Q_IMPORT_QML_PLUGIN(org_kde_neochat_roomsPlugin)
|
||||
Q_IMPORT_QML_PLUGIN(org_kde_neochat_timelinePlugin)
|
||||
Q_IMPORT_QML_PLUGIN(org_kde_neochat_devtoolsPlugin)
|
||||
Q_IMPORT_QML_PLUGIN(org_kde_neochat_loginPlugin)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "roomsortparametermodel.h"
|
||||
|
||||
#include "roomsortparameter.h"
|
||||
#include "enums/roomsortparameter.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
@@ -19,6 +19,15 @@ RoomSortParameterModel::RoomSortParameterModel(QList<RoomSortParameter::Paramete
|
||||
m_currentParameters = parameters;
|
||||
}
|
||||
|
||||
QList<int> RoomSortParameterModel::currentParameterList() const
|
||||
{
|
||||
QList<int> intList;
|
||||
std::transform(m_currentParameters.constBegin(), m_currentParameters.constEnd(), std::back_inserter(intList), [](RoomSortParameter::Parameter param) {
|
||||
return static_cast<int>(param);
|
||||
});
|
||||
return intList;
|
||||
}
|
||||
|
||||
QVariant RoomSortParameterModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() < 0 || index.row() >= rowCount()) {
|
||||
@@ -93,11 +102,6 @@ void RoomSortParameterModel::moveRowDown(int row)
|
||||
endMoveRows();
|
||||
}
|
||||
|
||||
void RoomSortParameterModel::saveParameterList()
|
||||
{
|
||||
RoomSortParameter::saveNewParameterList(m_currentParameters);
|
||||
}
|
||||
|
||||
RoomSortParameterModel *RoomSortParameterModel::allParameterModel() const
|
||||
{
|
||||
return new RoomSortParameterModel(RoomSortParameter::allParameterList());
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QQmlEngine>
|
||||
|
||||
#include <KLazyLocalizedString>
|
||||
#include <qlist.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "enums/roomsortparameter.h"
|
||||
@@ -21,6 +22,11 @@ class RoomSortParameterModel : public QAbstractListModel
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
/**
|
||||
* @brief The current list of sorting paramters as an int list.
|
||||
*/
|
||||
Q_PROPERTY(QList<int> currentParameterList READ currentParameterList NOTIFY currentParameterListChanged)
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Defines the model roles.
|
||||
@@ -34,6 +40,8 @@ public:
|
||||
explicit RoomSortParameterModel(QObject *parent = nullptr);
|
||||
explicit RoomSortParameterModel(QList<RoomSortParameter::Parameter> parameters, QObject *parent = nullptr);
|
||||
|
||||
QList<int> currentParameterList() const;
|
||||
|
||||
/**
|
||||
* @brief Get the given role value at the given index.
|
||||
*
|
||||
@@ -77,16 +85,14 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void moveRowDown(int row);
|
||||
|
||||
/**
|
||||
* @brief Save the current model parameters as a custom sort order.
|
||||
*/
|
||||
Q_INVOKABLE void saveParameterList();
|
||||
|
||||
/**
|
||||
* @brief Return a RoomSortParameterModel with all available parameters.
|
||||
*/
|
||||
Q_INVOKABLE RoomSortParameterModel *allParameterModel() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentParameterListChanged();
|
||||
|
||||
private:
|
||||
QList<RoomSortParameter::Parameter> m_currentParameters;
|
||||
};
|
||||
|
||||
@@ -134,21 +134,8 @@
|
||||
</entry>
|
||||
<entry name="SortOrder" type="Enum">
|
||||
<label>The sort order for the rooms in the list.</label>
|
||||
<choices>
|
||||
<choice name="Alphabetical">
|
||||
<label>Alphabetical</label>
|
||||
</choice>
|
||||
<choice name="Activity">
|
||||
<label>Activity</label>
|
||||
</choice>
|
||||
<choice name="LastMessage">
|
||||
<label>Last Message</label>
|
||||
</choice>
|
||||
<choice name="Custom">
|
||||
<label>Custom</label>
|
||||
</choice>
|
||||
<choices name="::RoomSortOrder::Order">
|
||||
</choices>
|
||||
<default>Activity</default>
|
||||
</entry>
|
||||
<entry name="CustomSortOrder" type="IntList">
|
||||
<label>The list of parameter in order to use for custom sorting</label>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatconnection.h"
|
||||
#include "neochatroom.h"
|
||||
#include "rooms/models/sortfilterroomtreemodel.h"
|
||||
#include "spacehierarchycache.h"
|
||||
#include "urlhelper.h"
|
||||
|
||||
@@ -59,6 +60,7 @@ RoomManager::RoomManager(QObject *parent)
|
||||
|
||||
connect(this, &RoomManager::currentRoomChanged, this, [this]() {
|
||||
m_timelineModel->setRoom(m_currentRoom);
|
||||
m_sortFilterRoomTreeModel->setCurrentRoom(m_currentRoom);
|
||||
m_userListModel->setRoom(m_currentRoom);
|
||||
});
|
||||
|
||||
@@ -117,6 +119,20 @@ RoomManager::RoomManager(QObject *parent)
|
||||
Q_EMIT m_timelineModel->threadsEnabledChanged();
|
||||
}
|
||||
});
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::SortOrderChanged, this, [this]() {
|
||||
m_sortFilterRoomTreeModel->invalidate();
|
||||
});
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::CollapsedChanged, this, [this]() {
|
||||
m_sortFilterRoomTreeModel->invalidate();
|
||||
});
|
||||
SortFilterRoomTreeModel::setShowAllRoomsInHome(NeoChatConfig::allRoomsInHome());
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::AllRoomsInHomeChanged, this, [this]() {
|
||||
SortFilterRoomTreeModel::setShowAllRoomsInHome(NeoChatConfig::allRoomsInHome());
|
||||
m_sortFilterRoomTreeModel->invalidate();
|
||||
if (NeoChatConfig::allRoomsInHome()) {
|
||||
resetState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RoomManager::~RoomManager()
|
||||
|
||||
43
src/rooms/CMakeLists.txt
Normal file
43
src/rooms/CMakeLists.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
# SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
qt_add_library(Rooms STATIC)
|
||||
ecm_add_qml_module(Rooms GENERATE_PLUGIN_SOURCE
|
||||
URI org.kde.neochat.rooms
|
||||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/rooms
|
||||
QML_FILES
|
||||
RoomListPage.qml
|
||||
SpaceDrawer.qml
|
||||
RoomDelegate.qml
|
||||
RoomTreeSection.qml
|
||||
ExploreComponent.qml
|
||||
ExploreComponentMobile.qml
|
||||
UserInfo.qml
|
||||
UserInfoDesktop.qml
|
||||
RoomContextMenu.qml
|
||||
SpaceListContextMenu.qml
|
||||
SOURCES
|
||||
models/publicroomlistmodel.cpp
|
||||
models/roomtreeitem.cpp
|
||||
models/roomtreemodel.cpp
|
||||
models/sortfilterroomlistmodel.cpp
|
||||
models/sortfilterroomtreemodel.cpp
|
||||
models/sortfilterspacelistmodel.cpp
|
||||
)
|
||||
|
||||
ecm_qt_declare_logging_category(Rooms
|
||||
HEADER "publicroomlist_logging.h"
|
||||
IDENTIFIER "PublicRoomList"
|
||||
CATEGORY_NAME "org.kde.neochat.publicroomlistmodel"
|
||||
DESCRIPTION "Neochat: publicroomlistmodel"
|
||||
DEFAULT_SEVERITY Info
|
||||
EXPORT NEOCHAT
|
||||
)
|
||||
|
||||
target_include_directories(Rooms PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/models)
|
||||
target_link_libraries(Rooms PRIVATE
|
||||
Qt::Core
|
||||
Qt::Quick
|
||||
KF6::Kirigami
|
||||
LibNeoChat
|
||||
)
|
||||
@@ -8,12 +8,15 @@
|
||||
|
||||
#include "enums/neochatroomtype.h"
|
||||
#include "eventhandler.h"
|
||||
#include "neochatconfig.h"
|
||||
#include "neochatconnection.h"
|
||||
#include "spacehierarchycache.h"
|
||||
|
||||
using namespace Quotient;
|
||||
|
||||
std::function<bool(const Quotient::RoomEvent *)> RoomTreeModel::m_hiddenFilter = [](const Quotient::RoomEvent *) -> bool {
|
||||
return false;
|
||||
};
|
||||
|
||||
RoomTreeModel::RoomTreeModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_rootItem(new RoomTreeItem(nullptr))
|
||||
@@ -356,22 +359,7 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
return i18nc("@info:label", "%1 invited you", room->member(room->invitingUserId()).displayName());
|
||||
}
|
||||
const auto lastEvent = room->lastEvent([](const RoomEvent *event) -> bool {
|
||||
if (event->isStateEvent() && !NeoChatConfig::showStateEvent()) {
|
||||
return true;
|
||||
}
|
||||
if (auto roomMemberEvent = eventCast<const RoomMemberEvent>(event)) {
|
||||
if ((roomMemberEvent->isJoin() || roomMemberEvent->isLeave()) && !NeoChatConfig::showLeaveJoinEvent()) {
|
||||
return true;
|
||||
} else if (roomMemberEvent->isRename() && !roomMemberEvent->isJoin() && !roomMemberEvent->isLeave() && !NeoChatConfig::showRename()) {
|
||||
return true;
|
||||
} else if (roomMemberEvent->isAvatarUpdate() && !roomMemberEvent->isJoin() && !roomMemberEvent->isLeave()
|
||||
&& !NeoChatConfig::showAvatarUpdate()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
const auto lastEvent = room->lastEvent(m_hiddenFilter);
|
||||
if (lastEvent == nullptr || room->lastEventIsSpoiler()) {
|
||||
return QString();
|
||||
}
|
||||
@@ -432,4 +420,9 @@ QModelIndex RoomTreeModel::indexForRoom(NeoChatRoom *room) const
|
||||
return {};
|
||||
}
|
||||
|
||||
void RoomTreeModel::setHiddenFilter(std::function<bool(const Quotient::RoomEvent *)> hiddenFilter)
|
||||
{
|
||||
RoomTreeModel::m_hiddenFilter = hiddenFilter;
|
||||
}
|
||||
|
||||
#include "moc_roomtreemodel.cpp"
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <QAbstractItemModel>
|
||||
#include <QPointer>
|
||||
|
||||
#include "enums/neochatroomtype.h"
|
||||
#include "roomtreeitem.h"
|
||||
|
||||
namespace Quotient
|
||||
@@ -77,6 +76,8 @@ public:
|
||||
|
||||
Q_INVOKABLE QModelIndex indexForRoom(NeoChatRoom *room) const;
|
||||
|
||||
static void setHiddenFilter(std::function<bool(const Quotient::RoomEvent *)> hiddenFilter);
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectionChanged();
|
||||
|
||||
@@ -94,4 +95,6 @@ private:
|
||||
void moveRoom(Quotient::Room *room);
|
||||
|
||||
void refreshRoomRoles(NeoChatRoom *room, const QList<int> &roles = {});
|
||||
|
||||
static std::function<bool(const Quotient::RoomEvent *)> m_hiddenFilter;
|
||||
};
|
||||
@@ -6,25 +6,19 @@
|
||||
|
||||
#include "enums/neochatroomtype.h"
|
||||
#include "enums/roomsortparameter.h"
|
||||
#include "neochatconfig.h"
|
||||
#include "models/roomtreemodel.h"
|
||||
#include "neochatconnection.h"
|
||||
#include "neochatroom.h"
|
||||
#include "roommanager.h"
|
||||
#include "roomtreemodel.h"
|
||||
#include "spacehierarchycache.h"
|
||||
|
||||
bool SortFilterRoomTreeModel::m_showAllRoomsInHome = false;
|
||||
|
||||
SortFilterRoomTreeModel::SortFilterRoomTreeModel(RoomTreeModel *sourceModel, QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
|
||||
setRoomSortOrder(static_cast<RoomSortOrder>(NeoChatConfig::sortOrder()));
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::SortOrderChanged, this, [this]() {
|
||||
setRoomSortOrder(static_cast<RoomSortOrder>(NeoChatConfig::sortOrder()));
|
||||
invalidateFilter();
|
||||
});
|
||||
|
||||
setRecursiveFilteringEnabled(true);
|
||||
sort(0);
|
||||
connect(this, &SortFilterRoomTreeModel::filterTextChanged, this, &SortFilterRoomTreeModel::invalidateFilter);
|
||||
@@ -33,39 +27,8 @@ SortFilterRoomTreeModel::SortFilterRoomTreeModel(RoomTreeModel *sourceModel, QOb
|
||||
connect(this->sourceModel(), &QAbstractItemModel::rowsInserted, this, &SortFilterRoomTreeModel::invalidateFilter);
|
||||
connect(this->sourceModel(), &QAbstractItemModel::rowsRemoved, this, &SortFilterRoomTreeModel::invalidateFilter);
|
||||
});
|
||||
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::CollapsedChanged, this, &SortFilterRoomTreeModel::invalidateFilter);
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::AllRoomsInHomeChanged, this, [this]() {
|
||||
invalidateFilter();
|
||||
if (NeoChatConfig::self()->allRoomsInHome()) {
|
||||
RoomManager::instance().resetState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void SortFilterRoomTreeModel::setRoomSortOrder(SortFilterRoomTreeModel::RoomSortOrder sortOrder)
|
||||
{
|
||||
m_sortOrder = sortOrder;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
static const QVector<RoomSortParameter::Parameter> alphabeticalSortPriorities{
|
||||
// Does exactly what it says on the tin.
|
||||
RoomSortParameter::AlphabeticalAscending,
|
||||
};
|
||||
|
||||
static const QVector<RoomSortParameter::Parameter> activitySortPriorities{
|
||||
RoomSortParameter::HasHighlight,
|
||||
RoomSortParameter::MostHighlights,
|
||||
RoomSortParameter::HasUnread,
|
||||
RoomSortParameter::MostUnread,
|
||||
RoomSortParameter::LastActive,
|
||||
};
|
||||
|
||||
static const QVector<RoomSortParameter::Parameter> lastMessageSortPriorities{
|
||||
RoomSortParameter::LastActive,
|
||||
};
|
||||
|
||||
bool SortFilterRoomTreeModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
// Don't sort the top level categories.
|
||||
@@ -141,8 +104,7 @@ bool SortFilterRoomTreeModel::filterAcceptsRow(int source_row, const QModelIndex
|
||||
return false;
|
||||
}
|
||||
|
||||
static auto config = NeoChatConfig::self();
|
||||
if (config->allRoomsInHome() && RoomManager::instance().currentSpace().isEmpty()) {
|
||||
if (m_showAllRoomsInHome && m_activeSpaceId.isEmpty()) {
|
||||
return acceptRoom;
|
||||
}
|
||||
|
||||
@@ -169,6 +131,11 @@ void SortFilterRoomTreeModel::setActiveSpaceId(const QString &spaceId)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void SortFilterRoomTreeModel::setCurrentRoom(NeoChatRoom *room)
|
||||
{
|
||||
m_currentRoom = room;
|
||||
}
|
||||
|
||||
SortFilterRoomTreeModel::Mode SortFilterRoomTreeModel::mode() const
|
||||
{
|
||||
return m_mode;
|
||||
@@ -192,7 +159,12 @@ QModelIndex SortFilterRoomTreeModel::currentRoomIndex() const
|
||||
return {};
|
||||
}
|
||||
|
||||
return mapFromSource(roomModel->indexForRoom(RoomManager::instance().currentRoom()));
|
||||
return mapFromSource(roomModel->indexForRoom(m_currentRoom));
|
||||
}
|
||||
|
||||
void SortFilterRoomTreeModel::setShowAllRoomsInHome(bool enabled)
|
||||
{
|
||||
SortFilterRoomTreeModel::m_showAllRoomsInHome = enabled;
|
||||
}
|
||||
|
||||
#include "moc_sortfilterroomtreemodel.cpp"
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "neochatroom.h"
|
||||
#include <QQmlEngine>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
@@ -66,19 +67,24 @@ public:
|
||||
|
||||
explicit SortFilterRoomTreeModel(RoomTreeModel *sourceModel, QObject *parent = nullptr);
|
||||
|
||||
void setRoomSortOrder(RoomSortOrder sortOrder);
|
||||
|
||||
void setFilterText(const QString &text);
|
||||
[[nodiscard]] QString filterText() const;
|
||||
|
||||
QString activeSpaceId() const;
|
||||
void setActiveSpaceId(const QString &spaceId);
|
||||
|
||||
/**
|
||||
* @brief Set the current active room.
|
||||
*/
|
||||
void setCurrentRoom(NeoChatRoom *room);
|
||||
|
||||
Mode mode() const;
|
||||
void setMode(Mode mode);
|
||||
|
||||
Q_INVOKABLE QModelIndex currentRoomIndex() const;
|
||||
|
||||
static void setShowAllRoomsInHome(bool enabled);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Returns true if the value of source_left is less than source_right.
|
||||
@@ -100,8 +106,11 @@ Q_SIGNALS:
|
||||
void modeChanged();
|
||||
|
||||
private:
|
||||
RoomSortOrder m_sortOrder = Activity;
|
||||
Mode m_mode = All;
|
||||
QString m_filterText;
|
||||
QString m_activeSpaceId;
|
||||
|
||||
QPointer<NeoChatRoom> m_currentRoom;
|
||||
|
||||
static bool m_showAllRoomsInHome;
|
||||
};
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "controller.h"
|
||||
#include "models/roomlistmodel.h"
|
||||
#include "models/sortfilterroomlistmodel.h"
|
||||
#include "roommanager.h"
|
||||
#include "sortfilterroomlistmodel.h"
|
||||
#include "windowcontroller.h"
|
||||
|
||||
RemoteImage Runner::serializeImage(const QImage &image)
|
||||
|
||||
@@ -25,7 +25,11 @@ Kirigami.Dialog {
|
||||
footer.background.children[0].visible = true
|
||||
}
|
||||
|
||||
onAccepted: roomSortParameterModel.saveParameterList()
|
||||
onAccepted: {
|
||||
NeoChatConfig.customSortOrder = roomSortParameterModel.currentParameterList;
|
||||
NeoChatConfig.sortOrder = RoomSortOrder.Custom;
|
||||
NeoChatConfig.save()
|
||||
}
|
||||
|
||||
contentItem: QQC2.ScrollView {
|
||||
clip: true
|
||||
|
||||
Reference in New Issue
Block a user