Commit 3888a930 authored by Ahmad Samir's avatar Ahmad Samir Committed by Ingo Klöcker
Browse files

src/{utils,view}: port to PMF/Functor signal/slot syntax

parent 7146d36b
......@@ -66,8 +66,8 @@ public:
mousePressed(false),
sizes()
{
connect(q, SIGNAL(sectionCountChanged(int,int)), q, SLOT(_klhv_slotSectionCountChanged(int,int)));
connect(q, SIGNAL(sectionResized(int,int,int)), q, SLOT(_klhv_slotSectionResized(int,int,int)));
connect(q, &QHeaderView::sectionCountChanged, q, [this](int oldCount, int newCount) { _klhv_slotSectionCountChanged(oldCount, newCount); });
connect(q, &QHeaderView::sectionResized, q, [this](int idx, int oldSize, int newSize) { _klhv_slotSectionResized(idx, oldSize, newSize); });
}
void _klhv_slotSectionCountChanged(int oldCount, int newCount)
......
......@@ -36,8 +36,6 @@ private:
private:
class Private;
kdtools::pimpl_ptr<Private> d;
Q_PRIVATE_SLOT(d, void _klhv_slotSectionCountChanged(int, int))
Q_PRIVATE_SLOT(d, void _klhv_slotSectionResized(int, int, int))
};
}
......
......@@ -89,8 +89,8 @@ SystemTrayIcon::Private::Private(SystemTrayIcon *qq)
attentionAnimationTimer.setSingleShot(false);
attentionAnimationTimer.setInterval(1000 * ATTENTION_ANIMATION_FRAMES_PER_SEC / 2);
connect(q, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), q, SLOT(slotActivated(QSystemTrayIcon::ActivationReason)));
connect(&attentionAnimationTimer, SIGNAL(timeout()), q, SLOT(slotAttentionAnimationTimerTimout()));
connect(q, &QSystemTrayIcon::activated, q, [this](QSystemTrayIcon::ActivationReason reason) { slotActivated(reason); });
connect(&attentionAnimationTimer, &QTimer::timeout, q, [this]() { slotAttentionAnimationTimerTimout(); });
}
SystemTrayIcon::Private::~Private() {}
......
......@@ -56,8 +56,6 @@ private:
private:
class Private;
kdtools::pimpl_ptr<Private> d;
Q_PRIVATE_SLOT(d, void slotAttentionAnimationTimerTimout())
Q_PRIVATE_SLOT(d, void slotActivated(QSystemTrayIcon::ActivationReason))
};
} // namespace Kleo
......
......@@ -172,10 +172,8 @@ KeyListController::Private::Private(KeyListController *qq)
flatModel(),
hierarchicalModel()
{
connect(KeyCache::mutableInstance().get(), SIGNAL(added(GpgME::Key)),
q, SLOT(slotAddKey(GpgME::Key)));
connect(KeyCache::mutableInstance().get(), SIGNAL(aboutToRemove(GpgME::Key)),
q, SLOT(slotAboutToRemoveKey(GpgME::Key)));
connect(KeyCache::mutableInstance().get(), &KeyCache::added, q, [this](const GpgME::Key &key) { slotAddKey(key); });
connect(KeyCache::mutableInstance().get(), &KeyCache::aboutToRemove, q, [this](const GpgME::Key &key) { slotAboutToRemoveKey(key); });
}
KeyListController::Private::~Private() {}
......@@ -607,18 +605,16 @@ void KeyListController::cancelCommands()
void KeyListController::Private::connectView(QAbstractItemView *view)
{
connect(view, SIGNAL(destroyed(QObject*)),
q, SLOT(slotDestroyed(QObject*)));
connect(view, SIGNAL(doubleClicked(QModelIndex)),
q, SLOT(slotDoubleClicked(QModelIndex)));
connect(view, SIGNAL(activated(QModelIndex)),
q, SLOT(slotActivated(QModelIndex)));
connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
q, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
connect(view, &QObject::destroyed, q, [this](QObject *obj) { slotDestroyed(obj); });
connect(view, &QAbstractItemView::doubleClicked, q, [this](const QModelIndex &index) { slotDoubleClicked(index); });
connect(view, &QAbstractItemView::activated, q, [this](const QModelIndex &index) { slotActivated(index); });
connect(view->selectionModel(), &QItemSelectionModel::selectionChanged,
q, [this](const QItemSelection &oldSel, const QItemSelection &newSel) {
slotSelectionChanged(oldSel, newSel);
});
view->setContextMenuPolicy(Qt::CustomContextMenu);
connect(view, SIGNAL(customContextMenuRequested(QPoint)),
q, SLOT(slotContextMenu(QPoint)));
connect(view, &QWidget::customContextMenuRequested, q, [this](const QPoint &pos) { slotContextMenu(pos); });
}
void KeyListController::Private::connectCommand(Command *cmd)
......@@ -626,11 +622,11 @@ void KeyListController::Private::connectCommand(Command *cmd)
if (!cmd) {
return;
}
connect(cmd, SIGNAL(destroyed(QObject*)), q, SLOT(slotDestroyed(QObject*)));
connect(cmd, SIGNAL(finished()), q, SLOT(slotCommandFinished()));
connect(cmd, &QObject::destroyed, q, [this](QObject *obj) { slotDestroyed(obj); });
connect(cmd, &Command::finished, q, [this] { slotCommandFinished(); });
//connect( cmd, SIGNAL(canceled()), q, SLOT(slotCommandCanceled()) );
connect(cmd, &Command::info, q, &KeyListController::message);
connect(cmd, SIGNAL(progress(QString,int,int)), q, SLOT(slotProgress(QString,int,int)));
connect(cmd, &Command::progress, q, [this](const QString &message, int current, int total) { slotProgress(message, current, total); });
}
void KeyListController::Private::slotDoubleClicked(const QModelIndex &idx)
......
......@@ -96,15 +96,6 @@ private:
class Private;
kdtools::pimpl_ptr<Private> d;
Q_PRIVATE_SLOT(d, void slotDestroyed(QObject *))
Q_PRIVATE_SLOT(d, void slotDoubleClicked(QModelIndex))
Q_PRIVATE_SLOT(d, void slotActivated(QModelIndex))
Q_PRIVATE_SLOT(d, void slotSelectionChanged(QItemSelection, QItemSelection))
Q_PRIVATE_SLOT(d, void slotContextMenu(QPoint))
Q_PRIVATE_SLOT(d, void slotCommandFinished())
Q_PRIVATE_SLOT(d, void slotAddKey(GpgME::Key))
Q_PRIVATE_SLOT(d, void slotAboutToRemoveKey(GpgME::Key))
Q_PRIVATE_SLOT(d, void slotProgress(QString, int, int))
Q_PRIVATE_SLOT(d, void slotActionTriggered())
Q_PRIVATE_SLOT(d, void slotCurrentViewChanged(QAbstractItemView *))
};
......
......@@ -164,8 +164,8 @@ SearchBar::Private::Private(SearchBar *qq)
KDAB_SET_OBJECT_NAME(certifyButton);
connect(lineEdit, &QLineEdit::textChanged, q, &SearchBar::stringFilterChanged);
connect(combo, SIGNAL(currentIndexChanged(int)), q, SLOT(slotKeyFilterChanged(int)));
connect(certifyButton, SIGNAL(clicked()), q, SLOT(listNotCertifiedKeys()));
connect(combo, qOverload<int>(&QComboBox::currentIndexChanged), q, [this](int index) { slotKeyFilterChanged(index); });
connect(certifyButton, &QPushButton::clicked, q, [this]() { listNotCertifiedKeys(); });
connect(KeyCache::instance().get(), &KeyCache::keyListingDone,
q, [this]() { showOrHideCertifyButton(); });
......
......@@ -49,8 +49,6 @@ Q_SIGNALS:
private:
class Private;
kdtools::pimpl_ptr<Private> d;
Q_PRIVATE_SLOT(d, void slotKeyFilterChanged(int))
Q_PRIVATE_SLOT(d, void listNotCertifiedKeys())
Q_PRIVATE_SLOT(d, void showOrHideCertifyButton())
};
......
......@@ -9,6 +9,7 @@
#include <config-kleopatra.h>
#include "searchbar.h"
#include "tabwidget.h"
#include "keytreeview.h"
#include "kleopatra_debug.h"
......@@ -473,7 +474,7 @@ TabWidget::Private::Private(TabWidget *qq)
// create "Close Tab" button after tab widget to ensure correct tab order
closeTabButton = new QToolButton{q};
connect(tabWidget, SIGNAL(currentChanged(int)), q, SLOT(currentIndexChanged(int)));
connect(tabWidget, &QTabWidget::currentChanged, q, [this](int index) { currentIndexChanged(index); });
connect(tabWidget->tabBar(), &QWidget::customContextMenuRequested, q, [this](const QPoint & p) {
slotContextMenu(p);
});
......@@ -691,7 +692,6 @@ void TabWidget::Private::collapseAll(Page *page)
TabWidget::TabWidget(QWidget *p, Qt::WindowFlags f)
: QWidget(p, f), d(new Private(this))
{
}
TabWidget::~TabWidget() {
......@@ -913,10 +913,10 @@ QTreeView *TabWidget::Private::addView(Page *page, Page *columnReference)
page->setFlatModel(flatModel);
page->setHierarchicalModel(hierarchicalModel);
connect(page, SIGNAL(titleChanged(QString)), q, SLOT(slotPageTitleChanged(QString)));
connect(page, SIGNAL(keyFilterChanged(std::shared_ptr<Kleo::KeyFilter>)), q, SLOT(slotPageKeyFilterChanged(std::shared_ptr<Kleo::KeyFilter>)));
connect(page, SIGNAL(stringFilterChanged(QString)), q, SLOT(slotPageStringFilterChanged(QString)));
connect(page, SIGNAL(hierarchicalChanged(bool)), q, SLOT(slotPageHierarchyChanged(bool)));
connect(page, &Page::titleChanged, q, [this](const QString &text) { slotPageTitleChanged(text); });
connect(page, &Page::keyFilterChanged, q, [this](const std::shared_ptr<Kleo::KeyFilter> &filter) { slotPageKeyFilterChanged(filter); });
connect(page, &Page::stringFilterChanged, q, [this](const QString &text) { slotPageStringFilterChanged(text); });
connect(page, &Page::hierarchicalChanged, q, [this](bool on) { slotPageHierarchyChanged(on); });
if (columnReference) {
page->setColumnSizes(columnReference->columnSizes());
......@@ -988,22 +988,16 @@ void TabWidget::saveViews(KConfig *config) const
}
}
static void xconnect(const QObject *o1, const char *signal, const QObject *o2, const char *slot)
void TabWidget::connectSearchBar(SearchBar *sb)
{
QObject::connect(o1, signal, o2, slot);
QObject::connect(o2, signal, o1, slot);
}
connect(sb, &SearchBar::stringFilterChanged, this, &TabWidget::setStringFilter);
connect(this, &TabWidget::stringFilterChanged, sb, &SearchBar::setStringFilter);
void TabWidget::connectSearchBar(QObject *sb)
{
xconnect(sb, SIGNAL(stringFilterChanged(QString)),
this, SLOT(setStringFilter(QString)));
xconnect(sb, SIGNAL(keyFilterChanged(std::shared_ptr<Kleo::KeyFilter>)),
this, SLOT(setKeyFilter(std::shared_ptr<Kleo::KeyFilter>)));
connect(this, SIGNAL(enableChangeStringFilter(bool)),
sb, SLOT(setChangeStringFilterEnabled(bool)));
connect(this, SIGNAL(enableChangeKeyFilter(bool)),
sb, SLOT(setChangeKeyFilterEnabled(bool)));
connect(sb, &SearchBar::keyFilterChanged, this, &TabWidget::setKeyFilter);
connect(this, &TabWidget::keyFilterChanged, sb, &SearchBar::setKeyFilter);
connect(this, &TabWidget::enableChangeStringFilter, sb, &SearchBar::setChangeStringFilterEnabled);
connect(this, &TabWidget::enableChangeKeyFilter, sb, &SearchBar::setChangeKeyFilterEnabled);
}
#include "moc_tabwidget.cpp"
......
......@@ -30,6 +30,7 @@ class AbstractKeyListModel;
class AbstractKeyListSortFilterProxyModel;
class KeyFilter;
class KeyListModelInterface;
class SearchBar;
class TabWidget : public QWidget
{
......@@ -57,7 +58,7 @@ public:
unsigned int count() const;
void createActions(KActionCollection *collection);
void connectSearchBar(QObject *sb);
void connectSearchBar(SearchBar *sb);
void setMultiSelection(bool on);
......@@ -82,11 +83,6 @@ private:
class Private;
kdtools::pimpl_ptr<Private> d;
Q_PRIVATE_SLOT(d, void currentIndexChanged(int))
Q_PRIVATE_SLOT(d, void slotPageTitleChanged(const QString &))
Q_PRIVATE_SLOT(d, void slotPageKeyFilterChanged(const std::shared_ptr<Kleo::KeyFilter> &))
Q_PRIVATE_SLOT(d, void slotPageStringFilterChanged(const QString &))
Q_PRIVATE_SLOT(d, void slotPageHierarchyChanged(bool))
Q_PRIVATE_SLOT(d, void slotRenameCurrentTab())
Q_PRIVATE_SLOT(d, void slotNewTab())
Q_PRIVATE_SLOT(d, void slotDuplicateCurrentTab())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment