From 9ab129613177f974afd10070e3a7d065d7aebbfa Mon Sep 17 00:00:00 2001 From: kamathmanu Date: Thu, 12 Aug 2021 10:45:42 -0400 Subject: Ran qmlformat and make license --- src/RoomDirectoryModel.cpp | 31 ++++++++++++++++--------------- src/RoomDirectoryModel.h | 24 +++++++++++------------- src/timeline/TimelineViewManager.cpp | 3 +-- 3 files changed, 28 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/RoomDirectoryModel.cpp b/src/RoomDirectoryModel.cpp index 7d6be13e..5873771f 100644 --- a/src/RoomDirectoryModel.cpp +++ b/src/RoomDirectoryModel.cpp @@ -82,10 +82,10 @@ RoomDirectoryModel::getViasForRoom(const std::vector &aliases) vias.reserve(aliases.size()); - std::transform( - aliases.begin(), aliases.end(), std::back_inserter(vias), [](const auto &alias) { - return alias.substr(alias.find(":") + 1); - }); + std::transform(aliases.begin(), + aliases.end(), + std::back_inserter(vias), + [](const auto &alias) { return alias.substr(alias.find(":") + 1); }); return vias; } @@ -126,7 +126,8 @@ RoomDirectoryModel::data(const QModelIndex &index, int role) const void RoomDirectoryModel::fetchMore(const QModelIndex &) { - if (!canFetchMore_) return; + if (!canFetchMore_) + return; nhlog::net()->debug("Fetching more rooms from mtxclient..."); @@ -137,18 +138,18 @@ RoomDirectoryModel::fetchMore(const QModelIndex &) // req.third_party_instance_id = third_party_instance_id; auto requested_server = server_; - reachedEndOfPagination_ = false; - emit reachedEndOfPaginationChanged(); + reachedEndOfPagination_ = false; + emit reachedEndOfPaginationChanged(); - loadingMoreRooms_ = true; - emit loadingMoreRoomsChanged(); + loadingMoreRooms_ = true; + emit loadingMoreRoomsChanged(); http::client()->post_public_rooms( req, [requested_server, this, req](const mtx::responses::PublicRooms &res, mtx::http::RequestErr err) { - loadingMoreRooms_ = false; - emit loadingMoreRoomsChanged(); + loadingMoreRooms_ = false; + emit loadingMoreRoomsChanged(); if (err) { nhlog::net()->error( @@ -184,12 +185,12 @@ RoomDirectoryModel::displayRooms(std::vector f endInsertRows(); if (next_batch.empty()) { - canFetchMore_ = false; - reachedEndOfPagination_ = true; - emit reachedEndOfPaginationChanged(); + canFetchMore_ = false; + reachedEndOfPagination_ = true; + emit reachedEndOfPaginationChanged(); } prevBatch_ = next_batch; - nhlog::ui()->debug ("Finished loading rooms"); + nhlog::ui()->debug("Finished loading rooms"); } diff --git a/src/RoomDirectoryModel.h b/src/RoomDirectoryModel.h index a7e6c0bc..b7eda00d 100644 --- a/src/RoomDirectoryModel.h +++ b/src/RoomDirectoryModel.h @@ -27,8 +27,9 @@ class RoomDirectoryModel : public QAbstractListModel { Q_OBJECT - Q_PROPERTY (bool loadingMoreRooms READ loadingMoreRooms NOTIFY loadingMoreRoomsChanged) - Q_PROPERTY (bool reachedEndOfPagination READ reachedEndOfPagination NOTIFY reachedEndOfPaginationChanged) + Q_PROPERTY(bool loadingMoreRooms READ loadingMoreRooms NOTIFY loadingMoreRoomsChanged) + Q_PROPERTY(bool reachedEndOfPagination READ reachedEndOfPagination NOTIFY + reachedEndOfPaginationChanged) public: explicit RoomDirectoryModel(QObject *parent = nullptr, const std::string &s = ""); @@ -52,14 +53,11 @@ public: return static_cast(publicRoomsData_.size()); } - bool canFetchMore(const QModelIndex &) const override - { - return canFetchMore_; - } + bool canFetchMore(const QModelIndex &) const override { return canFetchMore_; } - bool loadingMoreRooms() const { return loadingMoreRooms_; } + bool loadingMoreRooms() const { return loadingMoreRooms_; } - bool reachedEndOfPagination() const { return reachedEndOfPagination_; } + bool reachedEndOfPagination() const { return reachedEndOfPagination_; } void fetchMore(const QModelIndex &) override; @@ -69,8 +67,8 @@ public: signals: void fetchedRoomsBatch(std::vector rooms, const std::string &next_batch); - void loadingMoreRoomsChanged(); - void reachedEndOfPaginationChanged(); + void loadingMoreRoomsChanged(); + void reachedEndOfPaginationChanged(); public slots: void displayRooms(std::vector rooms, @@ -85,9 +83,9 @@ private: std::string userSearchString_; std::string prevBatch_; std::string nextBatch_; - bool canFetchMore_ {true}; - bool loadingMoreRooms_ {false}; - bool reachedEndOfPagination_ {false}; + bool canFetchMore_{true}; + bool loadingMoreRooms_{false}; + bool reachedEndOfPagination_{false}; std::vector publicRoomsData_; std::vector getViasForRoom(const std::vector &room); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index ff60856a..6f935760 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -286,8 +286,7 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par "EmojiCategory", "Error: Only enums"); - qmlRegisterType( - "im.nheko", 1, 0, "RoomDirectoryModel"); + qmlRegisterType("im.nheko", 1, 0, "RoomDirectoryModel"); #ifdef USE_QUICK_VIEW view = new QQuickView(parent); -- cgit 1.5.1