|
|
@ -51,6 +51,7 @@ RoomlistModel::roleNames() const |
|
|
|
{IsInvite, "isInvite"}, |
|
|
|
{IsInvite, "isInvite"}, |
|
|
|
{IsSpace, "isSpace"}, |
|
|
|
{IsSpace, "isSpace"}, |
|
|
|
{Tags, "tags"}, |
|
|
|
{Tags, "tags"}, |
|
|
|
|
|
|
|
{ParentSpaces, "parentSpaces"}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,6 +94,14 @@ RoomlistModel::data(const QModelIndex &index, int role) const |
|
|
|
list.push_back(QString::fromStdString(t)); |
|
|
|
list.push_back(QString::fromStdString(t)); |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
case Roles::ParentSpaces: { |
|
|
|
|
|
|
|
auto parents = |
|
|
|
|
|
|
|
cache::client()->getParentRoomIds(roomid.toStdString()); |
|
|
|
|
|
|
|
QStringList list; |
|
|
|
|
|
|
|
for (const auto &t : parents) |
|
|
|
|
|
|
|
list.push_back(QString::fromStdString(t)); |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
@ -122,6 +131,14 @@ RoomlistModel::data(const QModelIndex &index, int role) const |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
case Roles::Tags: |
|
|
|
case Roles::Tags: |
|
|
|
return QStringList(); |
|
|
|
return QStringList(); |
|
|
|
|
|
|
|
case Roles::ParentSpaces: { |
|
|
|
|
|
|
|
auto parents = |
|
|
|
|
|
|
|
cache::client()->getParentRoomIds(roomid.toStdString()); |
|
|
|
|
|
|
|
QStringList list; |
|
|
|
|
|
|
|
for (const auto &t : parents) |
|
|
|
|
|
|
|
list.push_back(QString::fromStdString(t)); |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
@ -514,6 +531,14 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons |
|
|
|
for (const auto &t : tags) |
|
|
|
for (const auto &t : tags) |
|
|
|
if (hiddenTags.contains(t)) |
|
|
|
if (hiddenTags.contains(t)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
} else if (!hiddenSpaces.empty()) { |
|
|
|
|
|
|
|
auto parents = |
|
|
|
|
|
|
|
sourceModel() |
|
|
|
|
|
|
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces) |
|
|
|
|
|
|
|
.toStringList(); |
|
|
|
|
|
|
|
for (const auto &t : parents) |
|
|
|
|
|
|
|
if (hiddenSpaces.contains(t)) |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -528,30 +553,35 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons |
|
|
|
for (const auto &t : tags) |
|
|
|
for (const auto &t : tags) |
|
|
|
if (t != filterStr && hiddenTags.contains(t)) |
|
|
|
if (t != filterStr && hiddenTags.contains(t)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
} else if (!hiddenSpaces.empty()) { |
|
|
|
|
|
|
|
auto parents = |
|
|
|
|
|
|
|
sourceModel() |
|
|
|
|
|
|
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces) |
|
|
|
|
|
|
|
.toStringList(); |
|
|
|
|
|
|
|
for (const auto &t : parents) |
|
|
|
|
|
|
|
if (hiddenSpaces.contains(t)) |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} else if (filterType == FilterBy::Space) { |
|
|
|
} else if (filterType == FilterBy::Space) { |
|
|
|
auto roomid = sourceModel() |
|
|
|
auto parents = |
|
|
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::RoomId) |
|
|
|
sourceModel() |
|
|
|
.toString(); |
|
|
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces) |
|
|
|
|
|
|
|
.toStringList(); |
|
|
|
auto tags = sourceModel() |
|
|
|
auto tags = sourceModel() |
|
|
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags) |
|
|
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags) |
|
|
|
.toStringList(); |
|
|
|
.toStringList(); |
|
|
|
|
|
|
|
|
|
|
|
auto contains = [](const std::vector<std::string> &v, const std::string &str) { |
|
|
|
if (!parents.contains(filterStr)) |
|
|
|
for (const auto &e : v) |
|
|
|
|
|
|
|
if (e == str) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
auto parents = cache::client()->getParentRoomIds(roomid.toStdString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!contains(parents, filterStr.toStdString())) |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
else if (!hiddenTags.empty()) { |
|
|
|
else if (!hiddenTags.empty()) { |
|
|
|
for (const auto &t : tags) |
|
|
|
for (const auto &t : tags) |
|
|
|
if (hiddenTags.contains(t)) |
|
|
|
if (hiddenTags.contains(t)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
} else if (!hiddenSpaces.empty()) { |
|
|
|
|
|
|
|
for (const auto &t : parents) |
|
|
|
|
|
|
|
if (hiddenSpaces.contains(t)) |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|