mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Select first room on startup
This commit is contained in:
parent
2b531227a8
commit
9d90467e6a
3 changed files with 15 additions and 7 deletions
|
@ -158,6 +158,8 @@ RoomList::initialize(const QMap<QString, RoomInfo> &info)
|
||||||
if (rooms_.empty())
|
if (rooms_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sortRoomsByLastMessage();
|
||||||
|
|
||||||
auto room = firstRoom();
|
auto room = firstRoom();
|
||||||
if (room.second.isNull())
|
if (room.second.isNull())
|
||||||
return;
|
return;
|
||||||
|
@ -479,13 +481,16 @@ RoomList::addInvitedRoom(const QString &room_id, const RoomInfo &info)
|
||||||
std::pair<QString, QSharedPointer<RoomInfoListItem>>
|
std::pair<QString, QSharedPointer<RoomInfoListItem>>
|
||||||
RoomList::firstRoom() const
|
RoomList::firstRoom() const
|
||||||
{
|
{
|
||||||
auto firstRoom = rooms_.begin();
|
for (int i = 0; i < contentsLayout_->count(); i++) {
|
||||||
|
auto item = qobject_cast<RoomInfoListItem *>(contentsLayout_->itemAt(i)->widget());
|
||||||
|
|
||||||
while (firstRoom->second.isNull() && firstRoom != rooms_.end())
|
if (item) {
|
||||||
firstRoom++;
|
return std::pair<QString, QSharedPointer<RoomInfoListItem>>(
|
||||||
|
item->roomId(), rooms_.at(item->roomId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return std::pair<QString, QSharedPointer<RoomInfoListItem>>(firstRoom->first,
|
return {};
|
||||||
firstRoom->second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -59,7 +59,8 @@ private:
|
||||||
size_t posToRemove = layout_->count() - 1;
|
size_t posToRemove = layout_->count() - 1;
|
||||||
|
|
||||||
QLayoutItem *item;
|
QLayoutItem *item;
|
||||||
while (startingPos <= posToRemove && (item = layout_->takeAt(posToRemove)) != nullptr) {
|
while (startingPos <= posToRemove &&
|
||||||
|
(item = layout_->takeAt(posToRemove)) != nullptr) {
|
||||||
delete item->widget();
|
delete item->widget();
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,9 @@ class TimelineModel : public QAbstractListModel
|
||||||
typingUsersChanged)
|
typingUsersChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TimelineModel(TimelineViewManager *manager, QString room_id, QObject *parent = nullptr);
|
explicit TimelineModel(TimelineViewManager *manager,
|
||||||
|
QString room_id,
|
||||||
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
enum Roles
|
enum Roles
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue