make lint
This commit is contained in:
parent
736c75bdd8
commit
d478057314
@ -17,18 +17,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QScrollArea>
|
||||
#include <QSharedPointer>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "JoinRoomDialog.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "OverlayModal.h"
|
||||
#include "RoomInfoListItem.h"
|
||||
#include "RoomState.h"
|
||||
#include "Sync.h"
|
||||
#include "OverlayModal.h"
|
||||
#include "JoinRoomDialog.h"
|
||||
|
||||
class RoomList : public QWidget
|
||||
{
|
||||
|
@ -156,14 +156,11 @@ Cache::insertRoomState(lmdb::txn &txn, const QString &roomid, const RoomState &s
|
||||
void
|
||||
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,
|
||||
roomDb_,
|
||||
lmdb::val(roomid.toUtf8(), roomid.toUtf8().size()),
|
||||
nullptr);
|
||||
lmdb::dbi_del(txn, roomDb_, lmdb::val(roomid.toUtf8(), roomid.toUtf8().size()), nullptr);
|
||||
|
||||
txn.commit();
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
QMap<QString, RoomState>
|
||||
|
@ -114,14 +114,13 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||
connect(user_info_widget_, SIGNAL(logout()), client_.data(), SLOT(logout()));
|
||||
connect(client_.data(), SIGNAL(loggedOut()), this, SLOT(logout()));
|
||||
|
||||
connect(top_bar_, &TopRoomBar::leaveRoom, this, [=](){
|
||||
client_->leaveRoom(current_room_);
|
||||
});
|
||||
connect(
|
||||
top_bar_, &TopRoomBar::leaveRoom, this, [=]() { client_->leaveRoom(current_room_); });
|
||||
|
||||
connect(room_list_, &RoomList::roomChanged, this, &ChatPage::changeTopRoomInfo);
|
||||
connect(room_list_, &RoomList::roomChanged, text_input_, &TextInputWidget::focusLineEdit);
|
||||
connect(
|
||||
room_list_, &RoomList::roomChanged, view_manager_, &TimelineViewManager::setHistoryView);
|
||||
room_list_, &RoomList::roomChanged, view_manager_, &TimelineViewManager::setHistoryView);
|
||||
|
||||
connect(view_manager_,
|
||||
&TimelineViewManager::unreadMessages,
|
||||
@ -198,10 +197,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||
SIGNAL(joinedRoom(const QString &)),
|
||||
this,
|
||||
SLOT(joinedRoom(const QString &)));
|
||||
connect(client_.data(),
|
||||
SIGNAL(leftRoom(const QString &)),
|
||||
this,
|
||||
SLOT(leftRoom(const QString &)));
|
||||
connect(
|
||||
client_.data(), SIGNAL(leftRoom(const QString &)), this, SLOT(leftRoom(const QString &)));
|
||||
|
||||
AvatarProvider::init(client);
|
||||
}
|
||||
@ -336,19 +333,18 @@ ChatPage::syncCompleted(const SyncResponse &response)
|
||||
updateDisplayNames(room_state);
|
||||
|
||||
state_manager_.insert(it.key(), room_state);
|
||||
settingsManager_.insert(it.key(),
|
||||
QSharedPointer<RoomSettings>(new RoomSettings(it.key())));
|
||||
settingsManager_.insert(
|
||||
it.key(), QSharedPointer<RoomSettings>(new RoomSettings(it.key())));
|
||||
|
||||
for (const auto membership : room_state.memberships) {
|
||||
auto uid = membership.sender();
|
||||
auto url = membership.content().avatarUrl();
|
||||
auto uid = membership.sender();
|
||||
auto url = membership.content().avatarUrl();
|
||||
|
||||
if (!url.toString().isEmpty())
|
||||
AvatarProvider::setAvatarUrl(uid, url);
|
||||
if (!url.toString().isEmpty())
|
||||
AvatarProvider::setAvatarUrl(uid, url);
|
||||
}
|
||||
|
||||
view_manager_->addRoom(it.value(), it.key());
|
||||
|
||||
}
|
||||
|
||||
if (it.key() == current_room_)
|
||||
@ -358,9 +354,9 @@ ChatPage::syncCompleted(const SyncResponse &response)
|
||||
auto leave = response.rooms().leave();
|
||||
|
||||
for (auto it = leave.constBegin(); it != leave.constEnd(); it++) {
|
||||
if (state_manager_.contains(it.key())) {
|
||||
leftRoom(it.key());
|
||||
}
|
||||
if (state_manager_.contains(it.key())) {
|
||||
leftRoom(it.key());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@ -589,34 +585,33 @@ ChatPage::showQuickSwitcher()
|
||||
void
|
||||
ChatPage::joinedRoom(const QString &room_id)
|
||||
{
|
||||
if (!state_manager_.contains(room_id)) {
|
||||
RoomState room_state;
|
||||
if (!state_manager_.contains(room_id)) {
|
||||
RoomState room_state;
|
||||
|
||||
state_manager_.insert(room_id, room_state);
|
||||
settingsManager_.insert(room_id,
|
||||
QSharedPointer<RoomSettings>(new RoomSettings(room_id)));
|
||||
state_manager_.insert(room_id, room_state);
|
||||
settingsManager_.insert(room_id,
|
||||
QSharedPointer<RoomSettings>(new RoomSettings(room_id)));
|
||||
|
||||
room_list_->addRoom(settingsManager_[room_id], state_manager_[room_id], room_id);
|
||||
|
||||
this->changeTopRoomInfo(room_id);
|
||||
room_list_->highlightSelectedRoom(room_id);
|
||||
}
|
||||
room_list_->addRoom(settingsManager_[room_id], state_manager_[room_id], room_id);
|
||||
|
||||
this->changeTopRoomInfo(room_id);
|
||||
room_list_->highlightSelectedRoom(room_id);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ChatPage::leftRoom(const QString &room_id)
|
||||
{
|
||||
state_manager_.remove(room_id);
|
||||
settingsManager_.remove(room_id);
|
||||
try {
|
||||
cache_->removeRoom(room_id);
|
||||
} catch (const lmdb::error &e) {
|
||||
qCritical() << "The cache couldn't be updated: " << e.what();
|
||||
// TODO: Notify the user.
|
||||
cache_->unmount();
|
||||
}
|
||||
room_list_->removeRoom(room_id, room_id == current_room_);
|
||||
state_manager_.remove(room_id);
|
||||
settingsManager_.remove(room_id);
|
||||
try {
|
||||
cache_->removeRoom(room_id);
|
||||
} catch (const lmdb::error &e) {
|
||||
qCritical() << "The cache couldn't be updated: " << e.what();
|
||||
// TODO: Notify the user.
|
||||
cache_->unmount();
|
||||
}
|
||||
room_list_->removeRoom(room_id, room_id == current_room_);
|
||||
}
|
||||
|
||||
ChatPage::~ChatPage()
|
||||
|
@ -42,6 +42,8 @@ JoinRoomDialog::JoinRoomDialog(QWidget *parent)
|
||||
layout->addWidget(roomAliasEdit_);
|
||||
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); });
|
||||
}
|
||||
|
@ -474,9 +474,9 @@ MatrixClient::onJoinRoomResponse(QNetworkReply *reply)
|
||||
return;
|
||||
}
|
||||
|
||||
auto data = reply->readAll();
|
||||
auto data = reply->readAll();
|
||||
QJsonDocument response = QJsonDocument::fromJson(data);
|
||||
QString room_id = response.object()["room_id"].toString();
|
||||
QString room_id = response.object()["room_id"].toString();
|
||||
emit joinedRoom(room_id);
|
||||
}
|
||||
|
||||
@ -611,11 +611,8 @@ void
|
||||
MatrixClient::sync() noexcept
|
||||
{
|
||||
QJsonObject filter{ { "room",
|
||||
QJsonObject{
|
||||
{ "include_leave", true },
|
||||
{ "ephemeral", QJsonObject{ { "limit", 0 } } }
|
||||
}
|
||||
},
|
||||
QJsonObject{ { "include_leave", true },
|
||||
{ "ephemeral", QJsonObject{ { "limit", 0 } } } } },
|
||||
{ "presence", QJsonObject{ { "limit", 0 } } } };
|
||||
|
||||
QUrlQuery query;
|
||||
@ -898,7 +895,7 @@ MatrixClient::joinRoom(const QString &roomIdOrAlias)
|
||||
endpoint.setQuery(query);
|
||||
|
||||
QNetworkRequest request(endpoint);
|
||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader,"application/json");
|
||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||
|
||||
QNetworkReply *reply = post(request, "{}");
|
||||
reply->setProperty("endpoint", static_cast<int>(Endpoint::JoinRoom));
|
||||
@ -915,7 +912,7 @@ MatrixClient::leaveRoom(const QString &roomId)
|
||||
endpoint.setQuery(query);
|
||||
|
||||
QNetworkRequest request(endpoint);
|
||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader,"application/json");
|
||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||
|
||||
QNetworkReply *reply = post(request, "{}");
|
||||
reply->setProperty("room_id", roomId);
|
||||
|
@ -58,9 +58,7 @@ RoomInfoListItem::RoomInfoListItem(QSharedPointer<RoomSettings> settings,
|
||||
});
|
||||
|
||||
leaveRoom_ = new QAction(tr("Leave room"), this);
|
||||
connect(leaveRoom_, &QAction::triggered, this, [=](){
|
||||
emit leaveRoom(room_id);
|
||||
});
|
||||
connect(leaveRoom_, &QAction::triggered, this, [=]() { emit leaveRoom(room_id); });
|
||||
|
||||
menu_->addAction(toggleNotifications_);
|
||||
menu_->addAction(leaveRoom_);
|
||||
|
@ -19,10 +19,10 @@
|
||||
#include <QJsonArray>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "RoomInfoListItem.h"
|
||||
#include "RoomList.h"
|
||||
#include "Sync.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@ -56,8 +56,8 @@ RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent)
|
||||
scrollArea_->setWidget(scrollAreaContents_);
|
||||
topLayout_->addWidget(scrollArea_);
|
||||
|
||||
//joinRoomButton_ = new QPushButton("Join room", this);
|
||||
//topLayout_->addWidget(joinRoomButton_);
|
||||
// joinRoomButton_ = new QPushButton("Join room", this);
|
||||
// topLayout_->addWidget(joinRoomButton_);
|
||||
|
||||
connect(client_.data(),
|
||||
SIGNAL(roomAvatarRetrieved(const QString &, const QPixmap &)),
|
||||
@ -94,18 +94,14 @@ RoomList::addRoom(const QSharedPointer<RoomSettings> &settings,
|
||||
const RoomState &state,
|
||||
const QString &room_id)
|
||||
{
|
||||
RoomInfoListItem *room_item =
|
||||
new RoomInfoListItem(settings, state, room_id, scrollArea_);
|
||||
connect(
|
||||
room_item, &RoomInfoListItem::clicked,
|
||||
this, &RoomList::highlightSelectedRoom);
|
||||
connect(
|
||||
room_item, &RoomInfoListItem::leaveRoom,
|
||||
client_.data(), &MatrixClient::leaveRoom);
|
||||
RoomInfoListItem *room_item = new RoomInfoListItem(settings, state, room_id, scrollArea_);
|
||||
connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
|
||||
connect(room_item, &RoomInfoListItem::leaveRoom, client_.data(), &MatrixClient::leaveRoom);
|
||||
|
||||
rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item));
|
||||
|
||||
contentsLayout_->insertWidget(0, room_item);}
|
||||
contentsLayout_->insertWidget(0, room_item);
|
||||
}
|
||||
|
||||
void
|
||||
RoomList::removeRoom(const QString &room_id, bool reset)
|
||||
@ -167,11 +163,11 @@ RoomList::setInitialRooms(const QMap<QString, QSharedPointer<RoomSettings>> &set
|
||||
RoomInfoListItem *room_item =
|
||||
new RoomInfoListItem(settings[room_id], state, room_id, scrollArea_);
|
||||
connect(
|
||||
room_item, &RoomInfoListItem::clicked,
|
||||
this, &RoomList::highlightSelectedRoom);
|
||||
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));
|
||||
|
||||
@ -197,7 +193,8 @@ RoomList::sync(const QMap<QString, RoomState> &states)
|
||||
|
||||
// TODO: Add the new room to the list.
|
||||
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];
|
||||
@ -267,6 +264,6 @@ RoomList::closeJoinRoomDialog(bool isJoining, QString roomAlias)
|
||||
joinRoomModal_->fadeOut();
|
||||
|
||||
if (isJoining) {
|
||||
client_->joinRoom(roomAlias);
|
||||
client_->joinRoom(roomAlias);
|
||||
}
|
||||
}
|
||||
|
33
src/Sync.cc
33
src/Sync.cc
@ -82,6 +82,7 @@ Rooms::deserialize(const QJsonValue &data)
|
||||
|
||||
QJsonObject object = data.toObject();
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (object.contains("join")) {
|
||||
if (!object.value("join").isObject())
|
||||
throw DeserializationException("rooms/join must be a JSON object");
|
||||
@ -97,6 +98,38 @@ Rooms::deserialize(const QJsonValue &data)
|
||||
qWarning() << e.what();
|
||||
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`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,9 +121,9 @@ TimelineViewManager::addRoom(const JoinedRoom &room, const QString &room_id)
|
||||
views_.insert(room_id, QSharedPointer<TimelineView>(view));
|
||||
|
||||
connect(view,
|
||||
&TimelineView::updateLastTimelineMessage,
|
||||
this,
|
||||
&TimelineViewManager::updateRoomsLastMessage);
|
||||
&TimelineView::updateLastTimelineMessage,
|
||||
this,
|
||||
&TimelineViewManager::updateRoomsLastMessage);
|
||||
|
||||
// Add the view in the widget stack.
|
||||
addWidget(view);
|
||||
@ -137,9 +137,9 @@ TimelineViewManager::addRoom(const QString &room_id)
|
||||
views_.insert(room_id, QSharedPointer<TimelineView>(view));
|
||||
|
||||
connect(view,
|
||||
&TimelineView::updateLastTimelineMessage,
|
||||
this,
|
||||
&TimelineViewManager::updateRoomsLastMessage);
|
||||
&TimelineView::updateLastTimelineMessage,
|
||||
this,
|
||||
&TimelineViewManager::updateRoomsLastMessage);
|
||||
|
||||
// Add the view in the widget stack.
|
||||
addWidget(view);
|
||||
|
@ -84,9 +84,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
|
||||
});
|
||||
|
||||
leaveRoom_ = new QAction(tr("Leave room"), this);
|
||||
connect(leaveRoom_, &QAction::triggered, this, [=](){
|
||||
emit leaveRoom();
|
||||
});
|
||||
connect(leaveRoom_, &QAction::triggered, this, [=]() { emit leaveRoom(); });
|
||||
|
||||
menu_->addAction(toggleNotifications_);
|
||||
menu_->addAction(leaveRoom_);
|
||||
|
Loading…
Reference in New Issue
Block a user