Add option to show all rooms in "uncategorized" tab
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
#include "neochatconnection.h"
|
#include "neochatconnection.h"
|
||||||
#include "neochatroomtype.h"
|
#include "neochatroomtype.h"
|
||||||
|
#include "roommanager.h"
|
||||||
#include "roomtreemodel.h"
|
#include "roomtreemodel.h"
|
||||||
#include "spacehierarchycache.h"
|
#include "spacehierarchycache.h"
|
||||||
|
|
||||||
@@ -32,6 +33,12 @@ SortFilterRoomTreeModel::SortFilterRoomTreeModel(RoomTreeModel *sourceModel, QOb
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(NeoChatConfig::self(), &NeoChatConfig::CollapsedChanged, 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)
|
void SortFilterRoomTreeModel::setRoomSortOrder(SortFilterRoomTreeModel::RoomSortOrder sortOrder)
|
||||||
@@ -154,6 +161,11 @@ bool SortFilterRoomTreeModel::filterAcceptsRow(int source_row, const QModelIndex
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static auto config = NeoChatConfig::self();
|
||||||
|
if (config->allRoomsInHome() && RoomManager::instance().currentSpace().isEmpty()) {
|
||||||
|
return acceptRoom;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_activeSpaceId.isEmpty()) {
|
if (m_activeSpaceId.isEmpty()) {
|
||||||
if (!SpaceHierarchyCache::instance().isChild(sourceModel()->data(index, RoomTreeModel::RoomIdRole).toString())) {
|
if (!SpaceHierarchyCache::instance().isChild(sourceModel()->data(index, RoomTreeModel::RoomIdRole).toString())) {
|
||||||
return acceptRoom;
|
return acceptRoom;
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||||
<kcfgfile name="neochatrc" />
|
<kcfgfile name="neochatrc" />
|
||||||
<group name="General">
|
<group name="General">
|
||||||
|
<entry name="AllRoomsInHome" type="bool">
|
||||||
|
<label>Show all rooms in the home tab</label>
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
<entry name="CollapsedSections" type="IntList">
|
<entry name="CollapsedSections" type="IntList">
|
||||||
<label>Collapsed sections in the room list</label>
|
<label>Collapsed sections in the room list</label>
|
||||||
</entry>
|
</entry>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "eventhandler.h"
|
#include "eventhandler.h"
|
||||||
#include "models/timelinemodel.h"
|
#include "models/timelinemodel.h"
|
||||||
|
#include "neochatconfig.h"
|
||||||
#include "neochatconnection.h"
|
#include "neochatconnection.h"
|
||||||
#include "neochatroom.h"
|
#include "neochatroom.h"
|
||||||
#include "spacehierarchycache.h"
|
#include "spacehierarchycache.h"
|
||||||
@@ -421,6 +422,11 @@ void RoomManager::setCurrentRoom(const QString &roomId)
|
|||||||
if (parentSpaces.contains(m_currentSpaceId)) {
|
if (parentSpaces.contains(m_currentSpaceId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
static auto config = NeoChatConfig::self();
|
||||||
|
if (config->allRoomsInHome()) {
|
||||||
|
setCurrentSpace({}, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (const auto &parent = m_connection->room(m_currentRoom->canonicalParent())) {
|
if (const auto &parent = m_connection->room(m_currentRoom->canonicalParent())) {
|
||||||
for (const auto &parentParent : SpaceHierarchyCache::instance().parentSpaces(parent->id())) {
|
for (const auto &parentParent : SpaceHierarchyCache::instance().parentSpaces(parent->id())) {
|
||||||
if (SpaceHierarchyCache::instance().parentSpaces(parentParent).isEmpty()) {
|
if (SpaceHierarchyCache::instance().parentSpaces(parentParent).isEmpty()) {
|
||||||
@@ -445,4 +451,10 @@ QString RoomManager::currentSpace() const
|
|||||||
return m_currentSpaceId;
|
return m_currentSpaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RoomManager::resetState()
|
||||||
|
{
|
||||||
|
setCurrentRoom({});
|
||||||
|
setCurrentSpace({});
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_roommanager.cpp"
|
#include "moc_roommanager.cpp"
|
||||||
|
|||||||
@@ -238,6 +238,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setConnection(NeoChatConnection *connection);
|
void setConnection(NeoChatConnection *connection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the current room and space; for situations, where it is unclear which room should be opened.
|
||||||
|
*/
|
||||||
|
void resetState();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/** Ask the user whether the room should be joined. */
|
/** Ask the user whether the room should be joined. */
|
||||||
void askJoinRoom(const QString &nameOrId);
|
void askJoinRoom(const QString &nameOrId);
|
||||||
|
|||||||
@@ -64,6 +64,22 @@ FormCard.FormCardPage {
|
|||||||
Config.save();
|
Config.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormCard.FormDelegateSeparator {
|
||||||
|
above: automaticallyDelegate
|
||||||
|
below: categorizeDelegate
|
||||||
|
}
|
||||||
|
FormCard.FormCheckDelegate {
|
||||||
|
id: categorizeDelegate
|
||||||
|
text: i18n("Show all rooms in \"Home\" tab")
|
||||||
|
checked: Config.allRoomsInHome
|
||||||
|
enabled: !Config.isAllRoomsInHomeImmutable
|
||||||
|
onToggled: {
|
||||||
|
Config.allRoomsInHome = checked;
|
||||||
|
Config.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
FormCard.FormHeader {
|
FormCard.FormHeader {
|
||||||
title: i18n("Room list sort order")
|
title: i18n("Room list sort order")
|
||||||
|
|||||||
Reference in New Issue
Block a user