Suggested rooms spaces
Add the ability to set and show suggested rooms for spaces. This is just adding the basic functionality, we can do more things with it later like sort/filter the space home for example.
This commit is contained in:
@@ -15,7 +15,8 @@ SpaceTreeItem::SpaceTreeItem(NeoChatConnection *connection,
|
||||
const QUrl &avatarUrl,
|
||||
bool allowGuests,
|
||||
bool worldReadable,
|
||||
bool isSpace)
|
||||
bool isSpace,
|
||||
Quotient::StateEvents childStates)
|
||||
: m_connection(connection)
|
||||
, m_parentItem(parent)
|
||||
, m_id(id)
|
||||
@@ -27,6 +28,7 @@ SpaceTreeItem::SpaceTreeItem(NeoChatConnection *connection,
|
||||
, m_allowGuests(allowGuests)
|
||||
, m_worldReadable(worldReadable)
|
||||
, m_isSpace(isSpace)
|
||||
, m_childStates(std::move(childStates))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -74,7 +76,7 @@ int SpaceTreeItem::row() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
SpaceTreeItem *SpaceTreeItem::parentItem()
|
||||
SpaceTreeItem *SpaceTreeItem::parentItem() const
|
||||
{
|
||||
return m_parentItem;
|
||||
}
|
||||
@@ -138,3 +140,34 @@ bool SpaceTreeItem::isSpace() const
|
||||
{
|
||||
return m_isSpace;
|
||||
}
|
||||
|
||||
QJsonObject SpaceTreeItem::childStateContent(const SpaceTreeItem *child) const
|
||||
{
|
||||
if (child == nullptr) {
|
||||
return {};
|
||||
}
|
||||
if (child->parentItem() != this) {
|
||||
return {};
|
||||
}
|
||||
for (const auto &childState : m_childStates) {
|
||||
if (childState->stateKey() == child->id()) {
|
||||
return childState->contentJson();
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void SpaceTreeItem::setChildStates(Quotient::StateEvents childStates)
|
||||
{
|
||||
m_childStates.clear();
|
||||
m_childStates = std::move(childStates);
|
||||
}
|
||||
|
||||
bool SpaceTreeItem::isSuggested() const
|
||||
{
|
||||
if (m_parentItem == nullptr) {
|
||||
return false;
|
||||
}
|
||||
const auto childStateContent = m_parentItem->childStateContent(this);
|
||||
return childStateContent.value(QLatin1String("suggested")).toBool();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user