Use C++11 braced list style (#121)

This commit is contained in:
Benjamin Saunders 2017-11-05 13:04:55 -08:00 committed by mujx
parent 4ccb5ed81f
commit 5bd5555a51
25 changed files with 1517 additions and 1515 deletions

View file

@ -1,5 +1,6 @@
--- ---
Language: Cpp Language: Cpp
Standard: Cpp11
AccessModifierOffset: -8 AccessModifierOffset: -8
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true AlignConsecutiveAssignments: true
@ -10,3 +11,4 @@ IndentCaseLabels: false
IndentWidth: 8 IndentWidth: 8
KeepEmptyLinesAtTheStartOfBlocks: false KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Right PointerAlignment: Right
Cpp11BracedListStyle: true

View file

@ -31,11 +31,11 @@ static const lmdb::val NEXT_BATCH_KEY("next_batch");
static const lmdb::val transactionID("transaction_id"); static const lmdb::val transactionID("transaction_id");
Cache::Cache(const QString &userId) Cache::Cache(const QString &userId)
: env_{ nullptr } : env_{nullptr}
, stateDb_{ 0 } , stateDb_{0}
, roomDb_{ 0 } , roomDb_{0}
, isMounted_{ false } , isMounted_{false}
, userId_{ userId } , userId_{userId}
{} {}
void void

View file

@ -26,11 +26,11 @@
EmojiPanel::EmojiPanel(QWidget *parent) EmojiPanel::EmojiPanel(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, shadowMargin_{ 2 } , shadowMargin_{2}
, width_{ 370 } , width_{370}
, height_{ 350 } , height_{350}
, animationDuration_{ 100 } , animationDuration_{100}
, categoryIconSize_{ 20 } , categoryIconSize_{20}
{ {
setStyleSheet("QWidget {background: #fff; color: #e8e8e8; border: none;}" setStyleSheet("QWidget {background: #fff; color: #e8e8e8; border: none;}"
"QScrollBar:vertical { background-color: #fff; width: 8px; margin: 0px " "QScrollBar:vertical { background-color: #fff; width: 8px; margin: 0px "

View file

@ -20,7 +20,7 @@
EmojiPickButton::EmojiPickButton(QWidget *parent) EmojiPickButton::EmojiPickButton(QWidget *parent)
: FlatButton(parent) : FlatButton(parent)
, panel_{ nullptr } , panel_{nullptr}
{} {}
void void

File diff suppressed because it is too large Load diff

View file

@ -32,8 +32,8 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
const events::MessageEvent<msgs::Image> &event, const events::MessageEvent<msgs::Image> &event,
QWidget *parent) QWidget *parent)
: QWidget(parent) : QWidget(parent)
, event_{ event } , event_{event}
, client_{ client } , client_{client}
{ {
setMouseTracking(true); setMouseTracking(true);
setCursor(Qt::PointingHandCursor); setCursor(Qt::PointingHandCursor);
@ -66,9 +66,9 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
const QString &filename, const QString &filename,
QWidget *parent) QWidget *parent)
: QWidget(parent) : QWidget(parent)
, url_{ url } , url_{url}
, text_{ QFileInfo(filename).fileName() } , text_{QFileInfo(filename).fileName()}
, client_{ client } , client_{client}
{ {
setMouseTracking(true); setMouseTracking(true);
setCursor(Qt::PointingHandCursor); setCursor(Qt::PointingHandCursor);

View file

@ -22,8 +22,8 @@
#include "ImageOverlayDialog.h" #include "ImageOverlayDialog.h"
ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent) ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent)
: QWidget{ parent } : QWidget{parent}
, originalImage_{ image } , originalImage_{image}
{ {
setMouseTracking(true); setMouseTracking(true);
setParent(0); setParent(0);

View file

@ -39,10 +39,10 @@ LoginRequest::serialize() noexcept
#endif #endif
QJsonObject body{ QJsonObject body{
{ "type", "m.login.password" }, {"type", "m.login.password"},
{ "user", user_ }, {"user", user_},
{ "password", password_ }, {"password", password_},
{ "initial_device_display_name", initialDeviceName }, {"initial_device_display_name", initialDeviceName},
}; };
return QJsonDocument(body).toJson(QJsonDocument::Compact); return QJsonDocument(body).toJson(QJsonDocument::Compact);

View file

@ -28,7 +28,7 @@
LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent) LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, inferredServerAddress_() , inferredServerAddress_()
, client_{ client } , client_{client}
{ {
setStyleSheet("background-color: #fff"); setStyleSheet("background-color: #fff");

View file

@ -38,8 +38,8 @@ MainWindow *MainWindow::instance_ = nullptr;
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, progressModal_{ nullptr } , progressModal_{nullptr}
, spinner_{ nullptr } , spinner_{nullptr}
{ {
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setSizePolicy(sizePolicy); setSizePolicy(sizePolicy);

View file

@ -38,9 +38,9 @@
MatrixClient::MatrixClient(QString server, QObject *parent) MatrixClient::MatrixClient(QString server, QObject *parent)
: QNetworkAccessManager(parent) : QNetworkAccessManager(parent)
, clientApiUrl_{ "/_matrix/client/r0" } , clientApiUrl_{"/_matrix/client/r0"}
, mediaApiUrl_{ "/_matrix/media/r0" } , mediaApiUrl_{"/_matrix/media/r0"}
, server_{ "https://" + server } , server_{"https://" + server}
{ {
QSettings settings; QSettings settings;
txn_id_ = settings.value("client/transaction_id", 1).toInt(); txn_id_ = settings.value("client/transaction_id", 1).toInt();
@ -203,10 +203,10 @@ void
MatrixClient::sync() noexcept MatrixClient::sync() noexcept
{ {
QJsonObject filter{ QJsonObject filter{
{ "room", {"room",
QJsonObject{ QJsonObject{
{ "include_leave", true }, {"include_leave", true},
} }, }},
}; };
QUrlQuery query; QUrlQuery query;
@ -278,13 +278,13 @@ MatrixClient::sendRoomMessage(matrix::events::MessageEventType ty,
switch (ty) { switch (ty) {
case matrix::events::MessageEventType::Text: case matrix::events::MessageEventType::Text:
body = { { "msgtype", "m.text" }, { "body", msg } }; body = {{"msgtype", "m.text"}, {"body", msg}};
break; break;
case matrix::events::MessageEventType::Emote: case matrix::events::MessageEventType::Emote:
body = { { "msgtype", "m.emote" }, { "body", msg } }; body = {{"msgtype", "m.emote"}, {"body", msg}};
break; break;
case matrix::events::MessageEventType::Image: case matrix::events::MessageEventType::Image:
body = { { "msgtype", "m.image" }, { "body", msg }, { "url", url } }; body = {{"msgtype", "m.image"}, {"body", msg}, {"url", url}};
break; break;
default: default:
qDebug() << "SendRoomMessage: Unknown message type for" << msg; qDebug() << "SendRoomMessage: Unknown message type for" << msg;
@ -812,7 +812,7 @@ MatrixClient::sendTypingNotification(const QString &roomid, int timeoutInMillis)
QString msgType(""); QString msgType("");
QJsonObject body; QJsonObject body;
body = { { "typing", true }, { "timeout", timeoutInMillis } }; body = {{"typing", true}, {"timeout", timeoutInMillis}};
QNetworkRequest request(QString(endpoint.toEncoded())); QNetworkRequest request(QString(endpoint.toEncoded()));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
@ -837,7 +837,7 @@ MatrixClient::removeTypingNotification(const QString &roomid)
QString msgType(""); QString msgType("");
QJsonObject body; QJsonObject body;
body = { { "typing", false } }; body = {{"typing", false}};
QNetworkRequest request(QString(endpoint.toEncoded())); QNetworkRequest request(QString(endpoint.toEncoded()));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

View file

@ -27,7 +27,7 @@ RegisterRequest::RegisterRequest(const QString &username, const QString &passwor
QByteArray QByteArray
RegisterRequest::serialize() noexcept RegisterRequest::serialize() noexcept
{ {
QJsonObject body{ { "username", user_ }, { "password", password_ } }; QJsonObject body{{"username", user_}, {"password", password_}};
return QJsonDocument(body).toJson(QJsonDocument::Compact); return QJsonDocument(body).toJson(QJsonDocument::Compact);
} }

View file

@ -33,7 +33,7 @@ RoomInfoListItem::RoomInfoListItem(QSharedPointer<RoomSettings> settings,
: QWidget(parent) : QWidget(parent)
, state_(state) , state_(state)
, roomId_(room_id) , roomId_(room_id)
, roomSettings_{ settings } , roomSettings_{settings}
, isPressed_(false) , isPressed_(false)
, maxHeight_(IconSize + 2 * Padding) , maxHeight_(IconSize + 2 * Padding)
, unreadMsgCount_(0) , unreadMsgCount_(0)

View file

@ -5,7 +5,7 @@
#include "Theme.h" #include "Theme.h"
SideBarActions::SideBarActions(QWidget *parent) SideBarActions::SideBarActions(QWidget *parent)
: QWidget{ parent } : QWidget{parent}
{ {
setFixedHeight(conf::sidebarActions::height); setFixedHeight(conf::sidebarActions::height);

View file

@ -85,11 +85,10 @@ TimelineItem::TimelineItem(events::MessageEventType ty,
if (ty == events::MessageEventType::Emote) { if (ty == events::MessageEventType::Emote) {
body = QString("* %1 %2").arg(displayName).arg(body); body = QString("* %1 %2").arg(displayName).arg(body);
descriptionMsg_ = { "", userid, body, descriptiveTime(timestamp) }; descriptionMsg_ = {"", userid, body, descriptiveTime(timestamp)};
} else { } else {
descriptionMsg_ = { descriptionMsg_ = {
"You: ", userid, body, descriptiveTime(QDateTime::currentDateTime()) "You: ", userid, body, descriptiveTime(QDateTime::currentDateTime())};
};
} }
body = body.toHtmlEscaped(); body = body.toHtmlEscaped();
@ -114,14 +113,14 @@ TimelineItem::TimelineItem(ImageItem *image,
const QString &userid, const QString &userid,
bool withSender, bool withSender,
QWidget *parent) QWidget *parent)
: QWidget{ parent } : QWidget{parent}
{ {
init(); init();
auto displayName = TimelineViewManager::displayName(userid); auto displayName = TimelineViewManager::displayName(userid);
auto timestamp = QDateTime::currentDateTime(); auto timestamp = QDateTime::currentDateTime();
descriptionMsg_ = { "You", userid, " sent an image", descriptiveTime(timestamp) }; descriptionMsg_ = {"You", userid, " sent an image", descriptiveTime(timestamp)};
generateTimestamp(timestamp); generateTimestamp(timestamp);
@ -158,10 +157,10 @@ TimelineItem::TimelineItem(ImageItem *image,
auto displayName = TimelineViewManager::displayName(event.sender()); auto displayName = TimelineViewManager::displayName(event.sender());
QSettings settings; QSettings settings;
descriptionMsg_ = { event.sender() == settings.value("auth/user_id") ? "You" : displayName, descriptionMsg_ = {event.sender() == settings.value("auth/user_id") ? "You" : displayName,
event.sender(), event.sender(),
" sent an image", " sent an image",
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) }; descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
generateTimestamp(timestamp); generateTimestamp(timestamp);
@ -193,10 +192,10 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Notice> &event,
: QWidget(parent) : QWidget(parent)
{ {
init(); init();
descriptionMsg_ = { TimelineViewManager::displayName(event.sender()), descriptionMsg_ = {TimelineViewManager::displayName(event.sender()),
event.sender(), event.sender(),
" sent a notification", " sent a notification",
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) }; descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
auto body = event.content().body().trimmed().toHtmlEscaped(); auto body = event.content().body().trimmed().toHtmlEscaped();
auto timestamp = QDateTime::fromMSecsSinceEpoch(event.timestamp()); auto timestamp = QDateTime::fromMSecsSinceEpoch(event.timestamp());
@ -238,10 +237,10 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Emote> &event,
auto displayName = TimelineViewManager::displayName(event.sender()); auto displayName = TimelineViewManager::displayName(event.sender());
auto emoteMsg = QString("* %1 %2").arg(displayName).arg(body); auto emoteMsg = QString("* %1 %2").arg(displayName).arg(body);
descriptionMsg_ = { "", descriptionMsg_ = {"",
event.sender(), event.sender(),
emoteMsg, emoteMsg,
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) }; descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
generateTimestamp(timestamp); generateTimestamp(timestamp);
emoteMsg = emoteMsg.toHtmlEscaped(); emoteMsg = emoteMsg.toHtmlEscaped();
@ -276,10 +275,10 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Text> &event,
auto displayName = TimelineViewManager::displayName(event.sender()); auto displayName = TimelineViewManager::displayName(event.sender());
QSettings settings; QSettings settings;
descriptionMsg_ = { event.sender() == settings.value("auth/user_id") ? "You" : displayName, descriptionMsg_ = {event.sender() == settings.value("auth/user_id") ? "You" : displayName,
event.sender(), event.sender(),
QString(": %1").arg(body), QString(": %1").arg(body),
descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp())) }; descriptiveTime(QDateTime::fromMSecsSinceEpoch(event.timestamp()))};
generateTimestamp(timestamp); generateTimestamp(timestamp);

View file

@ -49,8 +49,8 @@ TimelineView::TimelineView(const Timeline &timeline,
const QString &room_id, const QString &room_id,
QWidget *parent) QWidget *parent)
: QWidget(parent) : QWidget(parent)
, room_id_{ room_id } , room_id_{room_id}
, client_{ client } , client_{client}
{ {
init(); init();
addEvents(timeline); addEvents(timeline);
@ -60,8 +60,8 @@ TimelineView::TimelineView(QSharedPointer<MatrixClient> client,
const QString &room_id, const QString &room_id,
QWidget *parent) QWidget *parent)
: QWidget(parent) : QWidget(parent)
, room_id_{ room_id } , room_id_{room_id}
, client_{ client } , client_{client}
{ {
init(); init();
client_->messages(room_id_, ""); client_->messages(room_id_, "");

View file

@ -194,7 +194,7 @@ QString
TimelineViewManager::chooseRandomColor() TimelineViewManager::chooseRandomColor()
{ {
std::random_device random_device; std::random_device random_device;
std::mt19937 engine{ random_device() }; std::mt19937 engine{random_device()};
std::uniform_real_distribution<float> dist(0, 1); std::uniform_real_distribution<float> dist(0, 1);
float hue = dist(engine); float hue = dist(engine);

View file

@ -30,7 +30,7 @@
TopRoomBar::TopRoomBar(QWidget *parent) TopRoomBar::TopRoomBar(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, buttonSize_{ 32 } , buttonSize_{32}
{ {
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setMinimumSize(QSize(0, 65)); setMinimumSize(QSize(0, 65));

View file

@ -6,7 +6,7 @@
TypingDisplay::TypingDisplay(QWidget *parent) TypingDisplay::TypingDisplay(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, leftPadding_{ 24 } , leftPadding_{24}
{ {
QFont font; QFont font;
font.setPixelSize(conf::typingNotificationFontSize); font.setPixelSize(conf::typingNotificationFontSize);

View file

@ -29,9 +29,9 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, display_name_("User") , display_name_("User")
, user_id_("@user:homeserver.org") , user_id_("@user:homeserver.org")
, logoutModal_{ nullptr } , logoutModal_{nullptr}
, logoutDialog_{ nullptr } , logoutDialog_{nullptr}
, logoutButtonSize_{ 20 } , logoutButtonSize_{20}
{ {
QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
setSizePolicy(sizePolicy); setSizePolicy(sizePolicy);

View file

@ -51,15 +51,15 @@ UserSettings::save()
} }
HorizontalLine::HorizontalLine(QWidget *parent) HorizontalLine::HorizontalLine(QWidget *parent)
: QFrame{ parent } : QFrame{parent}
{ {
setFrameShape(QFrame::HLine); setFrameShape(QFrame::HLine);
setFrameShadow(QFrame::Sunken); setFrameShadow(QFrame::Sunken);
} }
UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidget *parent) UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidget *parent)
: QWidget{ parent } : QWidget{parent}
, settings_{ settings } , settings_{settings}
{ {
topLayout_ = new QVBoxLayout(this); topLayout_ = new QVBoxLayout(this);

View file

@ -22,8 +22,8 @@
OverlayModal::OverlayModal(QWidget *parent, QWidget *content) OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
: OverlayWidget(parent) : OverlayWidget(parent)
, duration_{ 500 } , duration_{500}
, color_{ QColor(55, 55, 55) } , color_{QColor(55, 55, 55)}
{ {
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);

View file

@ -23,7 +23,7 @@
ScrollBar::ScrollBar(QScrollArea *area, QWidget *parent) ScrollBar::ScrollBar(QScrollArea *area, QWidget *parent)
: QScrollBar(parent) : QScrollBar(parent)
, area_{ area } , area_{area}
{ {
hideTimer_.setSingleShot(true); hideTimer_.setSingleShot(true);

View file

@ -54,15 +54,21 @@ void
Theme::setColor(const QString &key, ui::Color color) Theme::setColor(const QString &key, ui::Color color)
{ {
static const QColor palette[] = { static const QColor palette[] = {
QColor("#171919"), QColor("#171919"),
QColor("#EBEBEB"), QColor("#C9C9C9"), QColor("#929292"), QColor("#EBEBEB"),
QColor("#C9C9C9"),
QColor("#929292"),
QColor("#1C3133"), QColor("#577275"), QColor("#46A451"), QColor("#1C3133"),
QColor("#577275"),
QColor("#46A451"),
QColor("#5D6565"), QColor("#E22826"), QColor("#81B3A9"), QColor("#5D6565"),
QColor("#E22826"),
QColor("#81B3A9"),
rgba(0, 0, 0, 0), rgba(0, 0, 0, 0),
}; };
colors_.insert(key, palette[static_cast<int>(color)]); colors_.insert(key, palette[static_cast<int>(color)]);

View file

@ -12,7 +12,7 @@ Toggle::paintEvent(QPaintEvent *event)
} }
Toggle::Toggle(QWidget *parent) Toggle::Toggle(QWidget *parent)
: QAbstractButton{ parent } : QAbstractButton{parent}
{ {
init(); init();
@ -89,10 +89,10 @@ Toggle::setTrackColor(const QColor &color)
} }
ToggleThumb::ToggleThumb(Toggle *parent) ToggleThumb::ToggleThumb(Toggle *parent)
: QWidget{ parent } : QWidget{parent}
, toggle_{ parent } , toggle_{parent}
, position_{ Position::Right } , position_{Position::Right}
, offset_{ 0 } , offset_{0}
{ {
parent->installEventFilter(this); parent->installEventFilter(this);
} }
@ -158,8 +158,8 @@ ToggleThumb::updateOffset()
} }
ToggleTrack::ToggleTrack(Toggle *parent) ToggleTrack::ToggleTrack(Toggle *parent)
: QWidget{ parent } : QWidget{parent}
, toggle_{ parent } , toggle_{parent}
{ {
Q_ASSERT(parent); Q_ASSERT(parent);