From a83f8d1dfdc5b937300d225438fcaa7f36d33428 Mon Sep 17 00:00:00 2001 From: noavarice Date: Wed, 19 Apr 2017 21:42:45 +0300 Subject: [PATCH] refactor: returned correct code style --- src/widget/contentdialog.cpp | 31 ++++++++++------------ src/widget/contentdialog.h | 3 +-- src/widget/form/genericchatform.cpp | 4 +-- src/widget/form/genericchatform.h | 3 +-- src/widget/friendlistwidget.cpp | 40 +++++++++++++---------------- src/widget/widget.cpp | 2 +- 6 files changed, 36 insertions(+), 47 deletions(-) diff --git a/src/widget/contentdialog.cpp b/src/widget/contentdialog.cpp index 65423d6dd..34e0ba214 100644 --- a/src/widget/contentdialog.cpp +++ b/src/widget/contentdialog.cpp @@ -69,11 +69,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent) friendLayout->setMargin(0); friendLayout->setSpacing(0); - layouts = { - friendLayout->getLayoutOnline(), - groupLayout.getLayout(), - friendLayout->getLayoutOffline() - }; + layouts = {friendLayout->getLayoutOnline(), groupLayout.getLayout(), + friendLayout->getLayoutOffline()}; if (s.getGroupchatPosition()) { layouts.swap(0, 1); @@ -141,8 +138,9 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent) Translator::registerHandler(std::bind(&ContentDialog::retranslateUi, this), this); } -void ContentDialog::removeCurrent(QHash& infos) { - for (auto it = infos.begin(); it != infos.end(); ) { +void ContentDialog::removeCurrent(QHash& infos) +{ + for (auto it = infos.begin(); it != infos.end();) { if (std::get<0>(*it) == this) { it = infos.erase(it); } else { @@ -352,9 +350,9 @@ void ContentDialog::cycleContacts(bool forward, bool inverse) bool isCurOffline = currentLayout == friendLayout->getLayoutOffline(); bool isCurOnline = currentLayout == friendLayout->getLayoutOnline(); bool isCurGroup = currentLayout == groupLayout.getLayout(); - bool nextIsEmpty = (isCurOnline && offlineEmpty && (groupsEmpty || groupsOnTop)) || - (isCurGroup && offlineEmpty && (onlineEmpty || !groupsOnTop)) || - isCurOffline; + bool nextIsEmpty = (isCurOnline && offlineEmpty && (groupsEmpty || groupsOnTop)) + || (isCurGroup && offlineEmpty && (onlineEmpty || !groupsOnTop)) + || isCurOffline; if (nextIsEmpty) { forward = !forward; @@ -507,12 +505,10 @@ void ContentDialog::updateTitleAndStatusIcon() Status currentStatus = activeChatroomWidget->getFriend()->getStatus(); - QMap icons { - {Status::Online, QIcon(":/img/status/dot_online.svg")}, - {Status::Away, QIcon(":/img/status/dot_away.svg")}, - {Status::Busy, QIcon(":/img/status/dot_busy.svg")}, - {Status::Offline, QIcon(":/img/status/dot_offline.svg")} - }; + QMap icons{{Status::Online, QIcon(":/img/status/dot_online.svg")}, + {Status::Away, QIcon(":/img/status/dot_away.svg")}, + {Status::Busy, QIcon(":/img/status/dot_busy.svg")}, + {Status::Offline, QIcon(":/img/status/dot_offline.svg")}}; setWindowIcon(icons[currentStatus]); } @@ -819,8 +815,7 @@ bool ContentDialog::hasWidget(int id, GenericChatroomWidget* chatroomWidget, return false; } - return std::get<0>(*iter) == this && - std::get<1>(*iter) == chatroomWidget; + return std::get<0>(*iter) == this && std::get<1>(*iter) == chatroomWidget; } /** diff --git a/src/widget/contentdialog.h b/src/widget/contentdialog.h index 95c4bcd2c..7aee1df32 100644 --- a/src/widget/contentdialog.h +++ b/src/widget/contentdialog.h @@ -112,8 +112,7 @@ private: QLayout* nextLayout(QLayout* layout, bool forward) const; int getCurrentLayout(QLayout*& layout); - bool hasWidget(int id, GenericChatroomWidget* chatroomWidget, - const QHash& list); + bool hasWidget(int id, GenericChatroomWidget* chatroomWidget, const QHash& list); void removeCurrent(QHash& infos); static bool existsWidget(int id, const QHash& list); static void focusDialog(int id, const QHash& list); diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 368f59a80..ca957c526 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -443,8 +443,8 @@ void GenericChatForm::addMessage(const ToxPk& author, const QString& message, co /** * @brief Inserts int ChatLog message that you have sent */ -void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime, - bool isAction, bool isSent) +void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime, + bool isAction, bool isSent) { insertChatMessage(createSelfMessage(message, datetime, isAction, isSent)); } diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index 9b5614ea6..b0cdd5905 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -68,8 +68,7 @@ public: void addMessage(const ToxPk& author, const QString& message, const QDateTime& datetime, bool isAction, bool isSent); - void addSelfMessage(const QString& message, const QDateTime& datetime, - bool isAction, bool isSent); + void addSelfMessage(const QString& message, const QDateTime& datetime, bool isAction, bool isSent); void addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type, const QDateTime& datetime); void addAlertMessage(const ToxPk& author, const QString& message, const QDateTime& datetime); diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp index dec5e7e16..394f1772e 100644 --- a/src/widget/friendlistwidget.cpp +++ b/src/widget/friendlistwidget.cpp @@ -57,16 +57,12 @@ Time getTime(const QDate& date) } QDate today = QDate::currentDate(); - const QMap dates { - { Time::Today, today.addDays(0) }, - { Time::Yesterday, today.addDays(-1) }, - { Time::ThisWeek, today.addDays(-6) }, - { Time::ThisMonth, today.addMonths(-1) }, - { Time::Month1Ago, today.addMonths(-2) }, - { Time::Month2Ago, today.addMonths(-3) }, - { Time::Month3Ago, today.addMonths(-4) }, - { Time::Month4Ago, today.addMonths(-5) }, - { Time::Month5Ago, today.addMonths(-6) }, + const QMap dates{ + {Time::Today, today.addDays(0)}, {Time::Yesterday, today.addDays(-1)}, + {Time::ThisWeek, today.addDays(-6)}, {Time::ThisMonth, today.addMonths(-1)}, + {Time::Month1Ago, today.addMonths(-2)}, {Time::Month2Ago, today.addMonths(-3)}, + {Time::Month3Ago, today.addMonths(-4)}, {Time::Month4Ago, today.addMonths(-5)}, + {Time::Month5Ago, today.addMonths(-6)}, }; for (Time time : dates.keys()) { @@ -193,18 +189,18 @@ void FriendListWidget::setMode(Mode mode) QLocale ql(Settings::getInstance().getTranslation()); QDate today = QDate::currentDate(); #define COMMENT "Category for sorting friends by activity" - const QMap names { - { Time::Today, tr("Today", COMMENT) }, - { Time::Yesterday, tr("Yesterday", COMMENT) }, - { Time::ThisWeek, tr("Last 7 days", COMMENT) }, - { Time::ThisMonth, tr("This month", COMMENT) }, - { Time::LongAgo, tr("Older than 6 Months", COMMENT) }, - { Time::Never, tr("Never", COMMENT) }, - { Time::Month1Ago, ql.monthName(today.addMonths(-1).month()) }, - { Time::Month2Ago, ql.monthName(today.addMonths(-2).month()) }, - { Time::Month3Ago, ql.monthName(today.addMonths(-3).month()) }, - { Time::Month4Ago, ql.monthName(today.addMonths(-4).month()) }, - { Time::Month5Ago, ql.monthName(today.addMonths(-5).month()) }, + const QMap names{ + {Time::Today, tr("Today", COMMENT)}, + {Time::Yesterday, tr("Yesterday", COMMENT)}, + {Time::ThisWeek, tr("Last 7 days", COMMENT)}, + {Time::ThisMonth, tr("This month", COMMENT)}, + {Time::LongAgo, tr("Older than 6 Months", COMMENT)}, + {Time::Never, tr("Never", COMMENT)}, + {Time::Month1Ago, ql.monthName(today.addMonths(-1).month())}, + {Time::Month2Ago, ql.monthName(today.addMonths(-2).month())}, + {Time::Month3Ago, ql.monthName(today.addMonths(-3).month())}, + {Time::Month4Ago, ql.monthName(today.addMonths(-4).month())}, + {Time::Month5Ago, ql.monthName(today.addMonths(-5).month())}, }; #undef COMMENT diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index b34f3e7bc..d2e3e89a9 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1463,7 +1463,7 @@ ContentDialog* Widget::createContentDialog() const connect(&s, &Settings::groupchatPositionChanged, contentDialog, &ContentDialog::reorderLayouts); #ifdef Q_OS_MAC - Nexus &n = Nexus::getInstance(); + Nexus& n = Nexus::getInstance(); connect(contentDialog, &ContentDialog::destroyed, &n, &Nexus::updateWindowsClosed); connect(contentDialog, &ContentDialog::windowStateChanged, &n, &Nexus::onWindowStateChanged); connect(contentDialog->windowHandle(), &QWindow::windowTitleChanged, &n, &Nexus::updateWindows);