cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / qtui / channellistdlg.cpp
index 204590e..e8826d0 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2022 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 
 #include "channellistdlg.h"
 
-#include <QHeaderView>
 #include <QHBoxLayout>
+#include <QHeaderView>
 #include <QSpacerItem>
 
 #include "client.h"
 #include "clientirclisthelper.h"
 #include "icon.h"
 
-ChannelListDlg::ChannelListDlg(QWidget *parent)
-    : QDialog(parent),
-    _listFinished(true),
-    _ircListModel(this),
-    _sortFilter(this),
-    _simpleModeSpacer(nullptr),
-    _advancedMode(false)
+ChannelListDlg::ChannelListDlg(QWidget* parent)
+    : QDialog(parent)
+    , _ircListModel(this)
+    , _sortFilter(this)
 {
     _sortFilter.setSourceModel(&_ircListModel);
     _sortFilter.setFilterCaseSensitivity(Qt::CaseInsensitive);
@@ -58,15 +55,14 @@ ChannelListDlg::ChannelListDlg(QWidget *parent)
 
     setWindowIcon(icon::get("format-list-unordered"));
 
-    connect(ui.advancedModeLabel, SIGNAL(clicked()), this, SLOT(toggleMode()));
-    connect(ui.searchChannelsButton, SIGNAL(clicked()), this, SLOT(requestSearch()));
-    connect(ui.channelNameLineEdit, SIGNAL(returnPressed()), this, SLOT(requestSearch()));
-    connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), &_sortFilter, SLOT(setFilterFixedString(QString)));
-    connect(Client::ircListHelper(), SIGNAL(channelListReceived(const NetworkId &, const QStringList &, QList<IrcListHelper::ChannelDescription> )),
-        this, SLOT(receiveChannelList(NetworkId, QStringList, QList<IrcListHelper::ChannelDescription> )));
-    connect(Client::ircListHelper(), SIGNAL(finishedListReported(const NetworkId &)), this, SLOT(reportFinishedList()));
-    connect(Client::ircListHelper(), SIGNAL(errorReported(const QString &)), this, SLOT(showError(const QString &)));
-    connect(ui.channelListView, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex)));
+    connect(ui.advancedModeLabel, &ClickableLabel::clicked, this, &ChannelListDlg::toggleMode);
+    connect(ui.searchChannelsButton, &QAbstractButton::clicked, this, &ChannelListDlg::requestSearch);
+    connect(ui.channelNameLineEdit, &QLineEdit::returnPressed, this, &ChannelListDlg::requestSearch);
+    connect(ui.filterLineEdit, &QLineEdit::textChanged, &_sortFilter, &QSortFilterProxyModel::setFilterFixedString);
+    connect(Client::ircListHelper(), &ClientIrcListHelper::channelListReceived, this, &ChannelListDlg::receiveChannelList);
+    connect(Client::ircListHelper(), &ClientIrcListHelper::finishedListReported, this, &ChannelListDlg::reportFinishedList);
+    connect(Client::ircListHelper(), &ClientIrcListHelper::errorReported, this, &ChannelListDlg::showError);
+    connect(ui.channelListView, &QAbstractItemView::activated, this, &ChannelListDlg::joinChannel);
 
     setAdvancedMode(false);
     enableQuery(true);
@@ -77,7 +73,6 @@ ChannelListDlg::ChannelListDlg(QWidget *parent)
     updateInputFocus();
 }
 
-
 void ChannelListDlg::setNetwork(NetworkId netId)
 {
     if (_netId == netId)
@@ -88,8 +83,7 @@ void ChannelListDlg::setNetwork(NetworkId netId)
     showFilterLine(false);
 }
 
-
-void ChannelListDlg::setChannelFilters(const QString &channelFilters)
+void ChannelListDlg::setChannelFilters(const QString& channelFilters)
 {
     // Enable advanced mode if searching
     setAdvancedMode(!channelFilters.isEmpty());
@@ -97,7 +91,6 @@ void ChannelListDlg::setChannelFilters(const QString &channelFilters)
     ui.channelNameLineEdit->setText(channelFilters.trimmed());
 }
 
-
 void ChannelListDlg::requestSearch()
 {
     if (!_netId.isValid()) {
@@ -113,8 +106,9 @@ void ChannelListDlg::requestSearch()
     Client::ircListHelper()->requestChannelList(_netId, channelFilters);
 }
 
-
-void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList<IrcListHelper::ChannelDescription> &channelList)
+void ChannelListDlg::receiveChannelList(const NetworkId& netId,
+                                        const QStringList& channelFilters,
+                                        const QList<IrcListHelper::ChannelDescription>& channelList)
 {
     Q_UNUSED(channelFilters)
     if (netId != _netId)
@@ -127,7 +121,6 @@ void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringLis
     updateInputFocus();
 }
 
-
 void ChannelListDlg::showFilterLine(bool show)
 {
     ui.line->setVisible(show);
@@ -135,14 +128,12 @@ void ChannelListDlg::showFilterLine(bool show)
     ui.filterLineEdit->setVisible(show);
 }
 
-
 void ChannelListDlg::enableQuery(bool enable)
 {
     ui.channelNameLineEdit->setEnabled(enable);
     ui.searchChannelsButton->setEnabled(enable);
 }
 
-
 void ChannelListDlg::setAdvancedMode(bool advanced)
 {
     _advancedMode = advanced;
@@ -168,19 +159,18 @@ void ChannelListDlg::setAdvancedMode(bool advanced)
     ui.searchPatternLabel->setVisible(advanced);
 }
 
-
 void ChannelListDlg::updateInputFocus()
 {
     // Update keyboard focus to match what options are available.  Prioritize the channel name
     // editor as one likely won't need to filter when already limiting the list.
     if (ui.channelNameLineEdit->isVisible()) {
         ui.channelNameLineEdit->setFocus();
-    } else if (ui.filterLineEdit->isVisible()) {
+    }
+    else if (ui.filterLineEdit->isVisible()) {
         ui.filterLineEdit->setFocus();
     }
 }
 
-
 void ChannelListDlg::showErrors(bool show)
 {
     if (!show) {
@@ -190,22 +180,20 @@ void ChannelListDlg::showErrors(bool show)
     ui.errorTextEdit->setVisible(show);
 }
 
-
 void ChannelListDlg::reportFinishedList()
 {
     _listFinished = true;
 }
 
-
-void ChannelListDlg::showError(const QString &error)
+void ChannelListDlg::showError(const QString& error)
 {
     showErrors(true);
     ui.errorTextEdit->moveCursor(QTextCursor::End);
     ui.errorTextEdit->insertPlainText(error + "\n");
 }
 
-
-void ChannelListDlg::joinChannel(const QModelIndex &index)
+void ChannelListDlg::joinChannel(const QModelIndex& index)
 {
-    Client::instance()->userInput(BufferInfo::fakeStatusBuffer(_netId), QString("/JOIN %1").arg(index.sibling(index.row(), 0).data().toString()));
+    Client::instance()->userInput(BufferInfo::fakeStatusBuffer(_netId),
+                                  QString("/JOIN %1").arg(index.sibling(index.row(), 0).data().toString()));
 }