summary refs log tree commit diff
path: root/src/InviteesModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/InviteesModel.cpp')
-rw-r--r--src/InviteesModel.cpp75
1 files changed, 37 insertions, 38 deletions
diff --git a/src/InviteesModel.cpp b/src/InviteesModel.cpp
index 27b2116f..e045581a 100644
--- a/src/InviteesModel.cpp
+++ b/src/InviteesModel.cpp
@@ -16,69 +16,68 @@ InviteesModel::InviteesModel(QObject *parent)
 void
 InviteesModel::addUser(QString mxid)
 {
-        beginInsertRows(QModelIndex(), invitees_.count(), invitees_.count());
+    beginInsertRows(QModelIndex(), invitees_.count(), invitees_.count());
 
-        auto invitee        = new Invitee{mxid, this};
-        auto indexOfInvitee = invitees_.count();
-        connect(invitee, &Invitee::userInfoLoaded, this, [this, indexOfInvitee]() {
-                emit dataChanged(index(indexOfInvitee), index(indexOfInvitee));
-        });
+    auto invitee        = new Invitee{mxid, this};
+    auto indexOfInvitee = invitees_.count();
+    connect(invitee, &Invitee::userInfoLoaded, this, [this, indexOfInvitee]() {
+        emit dataChanged(index(indexOfInvitee), index(indexOfInvitee));
+    });
 
-        invitees_.push_back(invitee);
+    invitees_.push_back(invitee);
 
-        endInsertRows();
-        emit countChanged();
+    endInsertRows();
+    emit countChanged();
 }
 
 QHash<int, QByteArray>
 InviteesModel::roleNames() const
 {
-        return {{Mxid, "mxid"}, {DisplayName, "displayName"}, {AvatarUrl, "avatarUrl"}};
+    return {{Mxid, "mxid"}, {DisplayName, "displayName"}, {AvatarUrl, "avatarUrl"}};
 }
 
 QVariant
 InviteesModel::data(const QModelIndex &index, int role) const
 {
-        if (!index.isValid() || index.row() >= (int)invitees_.size() || index.row() < 0)
-                return {};
+    if (!index.isValid() || index.row() >= (int)invitees_.size() || index.row() < 0)
+        return {};
 
-        switch (role) {
-        case Mxid:
-                return invitees_[index.row()]->mxid_;
-        case DisplayName:
-                return invitees_[index.row()]->displayName_;
-        case AvatarUrl:
-                return invitees_[index.row()]->avatarUrl_;
-        default:
-                return {};
-        }
+    switch (role) {
+    case Mxid:
+        return invitees_[index.row()]->mxid_;
+    case DisplayName:
+        return invitees_[index.row()]->displayName_;
+    case AvatarUrl:
+        return invitees_[index.row()]->avatarUrl_;
+    default:
+        return {};
+    }
 }
 
 QStringList
 InviteesModel::mxids()
 {
-        QStringList mxidList;
-        for (int i = 0; i < invitees_.length(); ++i)
-                mxidList.push_back(invitees_[i]->mxid_);
-        return mxidList;
+    QStringList mxidList;
+    for (int i = 0; i < invitees_.length(); ++i)
+        mxidList.push_back(invitees_[i]->mxid_);
+    return mxidList;
 }
 
 Invitee::Invitee(const QString &mxid, QObject *parent)
   : QObject{parent}
   , mxid_{mxid}
 {
-        http::client()->get_profile(
-          mxid_.toStdString(),
-          [this](const mtx::responses::Profile &res, mtx::http::RequestErr err) {
-                  if (err) {
-                          nhlog::net()->warn("failed to retrieve profile info");
-                          emit userInfoLoaded();
-                          return;
-                  }
+    http::client()->get_profile(
+      mxid_.toStdString(), [this](const mtx::responses::Profile &res, mtx::http::RequestErr err) {
+          if (err) {
+              nhlog::net()->warn("failed to retrieve profile info");
+              emit userInfoLoaded();
+              return;
+          }
 
-                  displayName_ = QString::fromStdString(res.display_name);
-                  avatarUrl_   = QString::fromStdString(res.avatar_url);
+          displayName_ = QString::fromStdString(res.display_name);
+          avatarUrl_   = QString::fromStdString(res.avatar_url);
 
-                  emit userInfoLoaded();
-          });
+          emit userInfoLoaded();
+      });
 }