clazy: Convert many old-style connects into function pointer based
[quassel.git] / src / uisupport / bufferview.cpp
index 969107c..6a7badd 100644 (file)
 BufferView::BufferView(QWidget *parent)
     : TreeViewTouch(parent)
 {
-    connect(this, SIGNAL(collapsed(const QModelIndex &)), SLOT(storeExpandedState(const QModelIndex &)));
-    connect(this, SIGNAL(expanded(const QModelIndex &)), SLOT(storeExpandedState(const QModelIndex &)));
+    connect(this, &QTreeView::collapsed, this, &BufferView::storeExpandedState);
+    connect(this, &QTreeView::expanded, this, &BufferView::storeExpandedState);
 
     setSelectionMode(QAbstractItemView::ExtendedSelection);
 
     QAbstractItemDelegate *oldDelegate = itemDelegate();
-    BufferViewDelegate *tristateDelegate = new BufferViewDelegate(this);
+    auto *tristateDelegate = new BufferViewDelegate(this);
     setItemDelegate(tristateDelegate);
     delete oldDelegate;
 }
@@ -94,8 +94,8 @@ void BufferView::init()
     disconnect(this, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex)));
     connect(this, SIGNAL(activated(QModelIndex)), SLOT(joinChannel(QModelIndex)));
 #else
-    disconnect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(joinChannel(QModelIndex)));
-    connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(joinChannel(QModelIndex)));
+    disconnect(this, &QAbstractItemView::doubleClicked, this, &BufferView::joinChannel);
+    connect(this, &QAbstractItemView::doubleClicked, this, &BufferView::joinChannel);
 #endif
 }
 
@@ -124,11 +124,11 @@ void BufferView::setModel(QAbstractItemModel *model)
         showSection->setCheckable(true);
         showSection->setChecked(!isColumnHidden(i));
         showSection->setProperty("column", i);
-        connect(showSection, SIGNAL(toggled(bool)), this, SLOT(toggleHeader(bool)));
+        connect(showSection, &QAction::toggled, this, &BufferView::toggleHeader);
         header()->addAction(showSection);
     }
 
-    connect(model, SIGNAL(layoutChanged()), this, SLOT(on_layoutChanged()));
+    connect(model, &QAbstractItemModel::layoutChanged, this, &BufferView::on_layoutChanged);
 
     // Make sure collapsation is correct after setting a model
     // This might not be needed here, only in BufferView::setFilteredModel().  If issues arise, just
@@ -139,7 +139,7 @@ void BufferView::setModel(QAbstractItemModel *model)
 
 void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config)
 {
-    BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+    auto *filter = qobject_cast<BufferViewFilter *>(model());
     if (filter) {
         filter->setConfig(config);
         setConfig(config);
@@ -147,17 +147,17 @@ void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *
     }
 
     if (model()) {
-        disconnect(this, 0, model(), 0);
-        disconnect(model(), 0, this, 0);
+        disconnect(this, nullptr, model(), nullptr);
+        disconnect(model(), nullptr, this, nullptr);
     }
 
     if (!model_) {
         setModel(model_);
     }
     else {
-        BufferViewFilter *filter = new BufferViewFilter(model_, config);
+        auto *filter = new BufferViewFilter(model_, config);
         setModel(filter);
-        connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged()));
+        connect(filter, &BufferViewFilter::configChanged, this, &BufferView::on_configChanged);
     }
     setConfig(config);
 }
@@ -169,12 +169,12 @@ void BufferView::setConfig(BufferViewConfig *config)
         return;
 
     if (_config) {
-        disconnect(_config, 0, this, 0);
+        disconnect(_config, nullptr, this, nullptr);
     }
 
     _config = config;
     if (config) {
-        connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(setRootIndexForNetworkId(const NetworkId &)));
+        connect(config, &BufferViewConfig::networkIdSet, this, &BufferView::setRootIndexForNetworkId);
         setRootIndexForNetworkId(config->networkId());
     }
     else {
@@ -262,7 +262,7 @@ void BufferView::dropEvent(QDropEvent *event)
         return TreeViewTouch::dropEvent(event);
 
     // Confirm that the user really wants to merge the buffers before doing so
-    int res = QMessageBox::question(0, tr("Merge buffers permanently?"),
+    int res = QMessageBox::question(nullptr, tr("Merge buffers permanently?"),
         tr("Do you want to merge the buffer \"%1\" permanently into buffer \"%2\"?\n This cannot be reversed!").arg(Client::networkModel()->bufferName(bufferId2)).arg(Client::networkModel()->bufferName(bufferId1)),
         QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
     if (res == QMessageBox::Yes) {
@@ -410,7 +410,7 @@ void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bott
 
 void BufferView::toggleHeader(bool checked)
 {
-    QAction *action = qobject_cast<QAction *>(sender());
+    auto *action = qobject_cast<QAction *>(sender());
     header()->setSectionHidden((action->property("column")).toInt(), !checked);
 }
 
@@ -447,7 +447,7 @@ void BufferView::addActionsToMenu(QMenu *contextMenu, const QModelIndex &index)
 
 void BufferView::addFilterActions(QMenu *contextMenu, const QModelIndex &index)
 {
-    BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+    auto *filter = qobject_cast<BufferViewFilter *>(model());
     if (filter) {
         QList<QAction *> filterActions = filter->actions(index);
         if (!filterActions.isEmpty()) {
@@ -588,7 +588,7 @@ void BufferView::hideCurrentBuffer()
 
 void BufferView::filterTextChanged(const QString& filterString)
 {
-    BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+    auto *filter = qobject_cast<BufferViewFilter *>(model());
     if (!filter) {
         return;
     }
@@ -605,21 +605,21 @@ QSize BufferView::sizeHint() const
         return TreeViewTouch::sizeHint();
 
     if (model()->rowCount() == 0)
-        return QSize(120, 50);
+        return {120, 50};
 
     int columnSize = 0;
     for (int i = 0; i < model()->columnCount(); i++) {
         if (!isColumnHidden(i))
             columnSize += sizeHintForColumn(i);
     }
-    return QSize(columnSize, 50);
+    return {columnSize, 50};
 }
 
 
 void BufferView::changeHighlight(BufferView::Direction direction)
 {
     // If for some weird reason we get a new delegate
-    BufferViewDelegate *delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
+    auto delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
     if (delegate) {
         delegate->currentHighlight = QModelIndex();
     }
@@ -663,7 +663,7 @@ void BufferView::selectHighlighted()
 void BufferView::clearHighlight()
 {
     // If for some weird reason we get a new delegate
-    BufferViewDelegate *delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
+    auto delegate = qobject_cast<BufferViewDelegate*>(itemDelegate(_currentHighlight));
     if (delegate) {
         delegate->currentHighlight = QModelIndex();
     }
@@ -712,12 +712,12 @@ bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, c
     initStyleOption(&viewOpt, index);
 
     QRect checkRect = viewOpt.widget->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, viewOpt.widget);
-    QMouseEvent *me = static_cast<QMouseEvent *>(event);
+    auto *me = static_cast<QMouseEvent *>(event);
 
     if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos()))
         return QStyledItemDelegate::editorEvent(event, model, option, index);
 
-    Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
+    auto state = static_cast<Qt::CheckState>(value.toInt());
     if (state == Qt::Unchecked)
         state = Qt::PartiallyChecked;
     else if (state == Qt::PartiallyChecked)
@@ -734,7 +734,7 @@ bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, c
 // ==============================
 BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent)
     : QDockWidget(parent),
-    _childWidget(0),
+    _childWidget(nullptr),
     _widget(new QWidget(parent)),
     _filterEdit(new QLineEdit(parent)),
     _active(false),
@@ -743,8 +743,8 @@ BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent)
     setObjectName("BufferViewDock-" + QString::number(config->bufferViewId()));
     toggleViewAction()->setData(config->bufferViewId());
     setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
-    connect(config, SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(bufferViewRenamed(const QString &)));
-    connect(config, SIGNAL(configChanged()), SLOT(configChanged()));
+    connect(config, &BufferViewConfig::bufferViewNameSet, this, &BufferViewDock::bufferViewRenamed);
+    connect(config, &BufferViewConfig::configChanged, this, &BufferViewDock::configChanged);
     updateTitle();
 
     _widget->setLayout(new QVBoxLayout);
@@ -756,7 +756,7 @@ BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent)
     _filterEdit->setFocusPolicy(Qt::ClickFocus);
     _filterEdit->installEventFilter(this);
     _filterEdit->setPlaceholderText(tr("Search..."));
-    connect(_filterEdit, SIGNAL(returnPressed()), SLOT(onFilterReturnPressed()));
+    connect(_filterEdit, &QLineEdit::returnPressed, this, &BufferViewDock::onFilterReturnPressed);
 
     _widget->layout()->addWidget(_filterEdit);
     QDockWidget::setWidget(_widget);
@@ -764,7 +764,7 @@ BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent)
 
 void BufferViewDock::setLocked(bool locked) {
     if (locked) {
-        setFeatures(0);
+        setFeatures(nullptr);
     }
     else {
         setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
@@ -791,7 +791,7 @@ void BufferViewDock::onFilterReturnPressed()
 {
     if (_oldFocusItem) {
         _oldFocusItem->setFocus();
-        _oldFocusItem = 0;
+        _oldFocusItem = nullptr;
     }
 
     if (!config()->showSearch()) {
@@ -834,7 +834,7 @@ bool BufferViewDock::eventFilter(QObject *object, QEvent *event)
            return true;
        }
    } else if (event->type() == QEvent::KeyRelease) {
-       QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+       auto keyEvent = static_cast<QKeyEvent*>(event);
 
        BufferView *view = bufferView();
        if (!view) {
@@ -894,7 +894,7 @@ BufferViewConfig *BufferViewDock::config() const
 {
     BufferView *view = bufferView();
     if (!view)
-        return 0;
+        return nullptr;
     else
         return view->config();
 }
@@ -904,7 +904,7 @@ void BufferViewDock::setWidget(QWidget *newWidget)
     _widget->layout()->addWidget(newWidget);
     _childWidget = newWidget;
 
-    connect(_filterEdit, SIGNAL(textChanged(QString)), bufferView(), SLOT(filterTextChanged(QString)));
+    connect(_filterEdit, &QLineEdit::textChanged, bufferView(), &BufferView::filterTextChanged);
 }
 
 void BufferViewDock::activateFilter()