make lint

This commit is contained in:
Max Sandholm 2017-09-29 14:46:35 +03:00 committed by vurpo
parent 736c75bdd8
commit d478057314
10 changed files with 105 additions and 88 deletions

View File

@ -17,18 +17,18 @@
#pragma once #pragma once
#include <QPushButton>
#include <QScrollArea> #include <QScrollArea>
#include <QSharedPointer> #include <QSharedPointer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
#include <QPushButton>
#include "JoinRoomDialog.h"
#include "MatrixClient.h" #include "MatrixClient.h"
#include "OverlayModal.h"
#include "RoomInfoListItem.h" #include "RoomInfoListItem.h"
#include "RoomState.h" #include "RoomState.h"
#include "Sync.h" #include "Sync.h"
#include "OverlayModal.h"
#include "JoinRoomDialog.h"
class RoomList : public QWidget class RoomList : public QWidget
{ {

View File

@ -158,10 +158,7 @@ Cache::removeRoom(const QString &roomid)
{ {
auto txn = lmdb::txn::begin(env_, nullptr, 0); auto txn = lmdb::txn::begin(env_, nullptr, 0);
lmdb::dbi_del(txn, lmdb::dbi_del(txn, roomDb_, lmdb::val(roomid.toUtf8(), roomid.toUtf8().size()), nullptr);
roomDb_,
lmdb::val(roomid.toUtf8(), roomid.toUtf8().size()),
nullptr);
txn.commit(); txn.commit();
} }

View File

@ -114,9 +114,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
connect(user_info_widget_, SIGNAL(logout()), client_.data(), SLOT(logout())); connect(user_info_widget_, SIGNAL(logout()), client_.data(), SLOT(logout()));
connect(client_.data(), SIGNAL(loggedOut()), this, SLOT(logout())); connect(client_.data(), SIGNAL(loggedOut()), this, SLOT(logout()));
connect(top_bar_, &TopRoomBar::leaveRoom, this, [=](){ connect(
client_->leaveRoom(current_room_); top_bar_, &TopRoomBar::leaveRoom, this, [=]() { client_->leaveRoom(current_room_); });
});
connect(room_list_, &RoomList::roomChanged, this, &ChatPage::changeTopRoomInfo); connect(room_list_, &RoomList::roomChanged, this, &ChatPage::changeTopRoomInfo);
connect(room_list_, &RoomList::roomChanged, text_input_, &TextInputWidget::focusLineEdit); connect(room_list_, &RoomList::roomChanged, text_input_, &TextInputWidget::focusLineEdit);
@ -198,10 +197,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
SIGNAL(joinedRoom(const QString &)), SIGNAL(joinedRoom(const QString &)),
this, this,
SLOT(joinedRoom(const QString &))); SLOT(joinedRoom(const QString &)));
connect(client_.data(), connect(
SIGNAL(leftRoom(const QString &)), client_.data(), SIGNAL(leftRoom(const QString &)), this, SLOT(leftRoom(const QString &)));
this,
SLOT(leftRoom(const QString &)));
AvatarProvider::init(client); AvatarProvider::init(client);
} }
@ -336,8 +333,8 @@ ChatPage::syncCompleted(const SyncResponse &response)
updateDisplayNames(room_state); updateDisplayNames(room_state);
state_manager_.insert(it.key(), room_state); state_manager_.insert(it.key(), room_state);
settingsManager_.insert(it.key(), settingsManager_.insert(
QSharedPointer<RoomSettings>(new RoomSettings(it.key()))); it.key(), QSharedPointer<RoomSettings>(new RoomSettings(it.key())));
for (const auto membership : room_state.memberships) { for (const auto membership : room_state.memberships) {
auto uid = membership.sender(); auto uid = membership.sender();
@ -348,7 +345,6 @@ ChatPage::syncCompleted(const SyncResponse &response)
} }
view_manager_->addRoom(it.value(), it.key()); view_manager_->addRoom(it.value(), it.key());
} }
if (it.key() == current_room_) if (it.key() == current_room_)
@ -601,7 +597,6 @@ ChatPage::joinedRoom(const QString &room_id)
this->changeTopRoomInfo(room_id); this->changeTopRoomInfo(room_id);
room_list_->highlightSelectedRoom(room_id); room_list_->highlightSelectedRoom(room_id);
} }
} }
void void

View File

@ -42,6 +42,8 @@ JoinRoomDialog::JoinRoomDialog(QWidget *parent)
layout->addWidget(roomAliasEdit_); layout->addWidget(roomAliasEdit_);
layout->addLayout(buttonLayout); layout->addLayout(buttonLayout);
connect(confirmBtn_, &QPushButton::clicked, [=]() { emit closing(true, roomAliasEdit_->text()); }); connect(confirmBtn_, &QPushButton::clicked, [=]() {
emit closing(true, roomAliasEdit_->text());
});
connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false, nullptr); }); connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false, nullptr); });
} }

View File

@ -611,11 +611,8 @@ void
MatrixClient::sync() noexcept MatrixClient::sync() noexcept
{ {
QJsonObject filter{ { "room", QJsonObject filter{ { "room",
QJsonObject{ QJsonObject{ { "include_leave", true },
{ "include_leave", true }, { "ephemeral", QJsonObject{ { "limit", 0 } } } } },
{ "ephemeral", QJsonObject{ { "limit", 0 } } }
}
},
{ "presence", QJsonObject{ { "limit", 0 } } } }; { "presence", QJsonObject{ { "limit", 0 } } } };
QUrlQuery query; QUrlQuery query;
@ -898,7 +895,7 @@ MatrixClient::joinRoom(const QString &roomIdOrAlias)
endpoint.setQuery(query); endpoint.setQuery(query);
QNetworkRequest request(endpoint); QNetworkRequest request(endpoint);
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader,"application/json"); request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
QNetworkReply *reply = post(request, "{}"); QNetworkReply *reply = post(request, "{}");
reply->setProperty("endpoint", static_cast<int>(Endpoint::JoinRoom)); reply->setProperty("endpoint", static_cast<int>(Endpoint::JoinRoom));
@ -915,7 +912,7 @@ MatrixClient::leaveRoom(const QString &roomId)
endpoint.setQuery(query); endpoint.setQuery(query);
QNetworkRequest request(endpoint); QNetworkRequest request(endpoint);
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader,"application/json"); request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
QNetworkReply *reply = post(request, "{}"); QNetworkReply *reply = post(request, "{}");
reply->setProperty("room_id", roomId); reply->setProperty("room_id", roomId);

View File

@ -58,9 +58,7 @@ RoomInfoListItem::RoomInfoListItem(QSharedPointer<RoomSettings> settings,
}); });
leaveRoom_ = new QAction(tr("Leave room"), this); leaveRoom_ = new QAction(tr("Leave room"), this);
connect(leaveRoom_, &QAction::triggered, this, [=](){ connect(leaveRoom_, &QAction::triggered, this, [=]() { emit leaveRoom(room_id); });
emit leaveRoom(room_id);
});
menu_->addAction(toggleNotifications_); menu_->addAction(toggleNotifications_);
menu_->addAction(leaveRoom_); menu_->addAction(leaveRoom_);

View File

@ -19,10 +19,10 @@
#include <QJsonArray> #include <QJsonArray>
#include <QRegularExpression> #include <QRegularExpression>
#include "MainWindow.h"
#include "RoomInfoListItem.h" #include "RoomInfoListItem.h"
#include "RoomList.h" #include "RoomList.h"
#include "Sync.h" #include "Sync.h"
#include "MainWindow.h"
RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent) RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -56,8 +56,8 @@ RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent)
scrollArea_->setWidget(scrollAreaContents_); scrollArea_->setWidget(scrollAreaContents_);
topLayout_->addWidget(scrollArea_); topLayout_->addWidget(scrollArea_);
//joinRoomButton_ = new QPushButton("Join room", this); // joinRoomButton_ = new QPushButton("Join room", this);
//topLayout_->addWidget(joinRoomButton_); // topLayout_->addWidget(joinRoomButton_);
connect(client_.data(), connect(client_.data(),
SIGNAL(roomAvatarRetrieved(const QString &, const QPixmap &)), SIGNAL(roomAvatarRetrieved(const QString &, const QPixmap &)),
@ -94,18 +94,14 @@ RoomList::addRoom(const QSharedPointer<RoomSettings> &settings,
const RoomState &state, const RoomState &state,
const QString &room_id) const QString &room_id)
{ {
RoomInfoListItem *room_item = RoomInfoListItem *room_item = new RoomInfoListItem(settings, state, room_id, scrollArea_);
new RoomInfoListItem(settings, state, room_id, scrollArea_); connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
connect( connect(room_item, &RoomInfoListItem::leaveRoom, client_.data(), &MatrixClient::leaveRoom);
room_item, &RoomInfoListItem::clicked,
this, &RoomList::highlightSelectedRoom);
connect(
room_item, &RoomInfoListItem::leaveRoom,
client_.data(), &MatrixClient::leaveRoom);
rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item)); rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item));
contentsLayout_->insertWidget(0, room_item);} contentsLayout_->insertWidget(0, room_item);
}
void void
RoomList::removeRoom(const QString &room_id, bool reset) RoomList::removeRoom(const QString &room_id, bool reset)
@ -167,11 +163,11 @@ RoomList::setInitialRooms(const QMap<QString, QSharedPointer<RoomSettings>> &set
RoomInfoListItem *room_item = RoomInfoListItem *room_item =
new RoomInfoListItem(settings[room_id], state, room_id, scrollArea_); new RoomInfoListItem(settings[room_id], state, room_id, scrollArea_);
connect( connect(
room_item, &RoomInfoListItem::clicked, room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
this, &RoomList::highlightSelectedRoom); connect(room_item,
connect( &RoomInfoListItem::leaveRoom,
room_item, &RoomInfoListItem::leaveRoom, client_.data(),
client_.data(), &MatrixClient::leaveRoom); &MatrixClient::leaveRoom);
rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item)); rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item));
@ -197,7 +193,8 @@ RoomList::sync(const QMap<QString, RoomState> &states)
// TODO: Add the new room to the list. // TODO: Add the new room to the list.
if (!rooms_.contains(room_id)) { if (!rooms_.contains(room_id)) {
addRoom(QSharedPointer<RoomSettings>(new RoomSettings(room_id)), state, room_id); addRoom(
QSharedPointer<RoomSettings>(new RoomSettings(room_id)), state, room_id);
} }
auto room = rooms_[room_id]; auto room = rooms_[room_id];

View File

@ -82,6 +82,7 @@ Rooms::deserialize(const QJsonValue &data)
QJsonObject object = data.toObject(); QJsonObject object = data.toObject();
<<<<<<< HEAD
if (object.contains("join")) { if (object.contains("join")) {
if (!object.value("join").isObject()) if (!object.value("join").isObject())
throw DeserializationException("rooms/join must be a JSON object"); throw DeserializationException("rooms/join must be a JSON object");
@ -97,6 +98,38 @@ Rooms::deserialize(const QJsonValue &data)
qWarning() << e.what(); qWarning() << e.what();
qWarning() << "Skipping malformed object for room" << it.key(); qWarning() << "Skipping malformed object for room" << it.key();
} }
=======
if (!object.contains("join"))
throw DeserializationException("rooms/join is missing");
if (!object.contains("invite"))
throw DeserializationException("rooms/invite is missing");
if (!object.contains("leave"))
throw DeserializationException("rooms/leave is missing");
if (!object.value("join").isObject())
throw DeserializationException("rooms/join must be a JSON object");
if (!object.value("invite").isObject())
throw DeserializationException("rooms/invite must be a JSON object");
if (!object.value("leave").isObject())
throw DeserializationException("rooms/leave must be a JSON object");
auto join = object.value("join").toObject();
auto leave = object.value("leave").toObject();
for (auto it = join.constBegin(); it != join.constEnd(); it++) {
JoinedRoom tmp_room;
try {
tmp_room.deserialize(it.value());
join_.insert(it.key(), tmp_room);
} catch (DeserializationException &e) {
qWarning() << e.what();
qWarning() << "Skipping malformed object for room" << it.key();
>>>>>>> `make lint`
} }
} }

View File

@ -84,9 +84,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
}); });
leaveRoom_ = new QAction(tr("Leave room"), this); leaveRoom_ = new QAction(tr("Leave room"), this);
connect(leaveRoom_, &QAction::triggered, this, [=](){ connect(leaveRoom_, &QAction::triggered, this, [=]() { emit leaveRoom(); });
emit leaveRoom();
});
menu_->addAction(toggleNotifications_); menu_->addAction(toggleNotifications_);
menu_->addAction(leaveRoom_); menu_->addAction(leaveRoom_);