diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-06-09 17:05:22 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-06-10 14:11:43 +0000 |
commit | 467cb4a1862fb48949fb0da84076648234869a9b (patch) | |
tree | 2384f877f00161ca1f22b0666ff8dd3f7e8f592b /src/plugins/git | |
parent | 046fb9a0001fbe6a969ea6d8a5091f86bf3d5925 (diff) |
Gerrit: Use Qt5 style connects
Change-Id: I54f2f02f93fc99b896dc479f390f63611ab22e98
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/gerrit/gerritdialog.cpp | 44 | ||||
-rw-r--r-- | src/plugins/git/gerrit/gerritdialog.h | 2 | ||||
-rw-r--r-- | src/plugins/git/gerrit/gerritmodel.cpp | 30 | ||||
-rw-r--r-- | src/plugins/git/gerrit/gerritplugin.cpp | 39 | ||||
-rw-r--r-- | src/plugins/git/gerrit/gerritplugin.h | 5 |
5 files changed, 55 insertions, 65 deletions
diff --git a/src/plugins/git/gerrit/gerritdialog.cpp b/src/plugins/git/gerrit/gerritdialog.cpp index 40b8fd79310..f1a2e31f33c 100644 --- a/src/plugins/git/gerrit/gerritdialog.cpp +++ b/src/plugins/git/gerrit/gerritdialog.cpp @@ -84,7 +84,7 @@ QueryValidatingLineEdit::QueryValidatingLineEdit(QWidget *parent) , m_errorTextColor(Qt::red) { setFiltering(true); - connect(this, SIGNAL(textChanged(QString)), this, SLOT(setValid())); + connect(this, &QLineEdit::textChanged, this, &QueryValidatingLineEdit::setValid); } void QueryValidatingLineEdit::setTextColor(const QColor &c) @@ -147,11 +147,10 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, m_filterLineEdit->setFixedWidth(300); m_filterLineEdit->setFiltering(true); filterLayout->addWidget(m_filterLineEdit); - connect(m_filterLineEdit, SIGNAL(filterChanged(QString)), - m_filterModel, SLOT(setFilterFixedString(QString))); - connect(m_queryLineEdit, SIGNAL(returnPressed()), - this, SLOT(slotRefresh())); - connect(m_model, SIGNAL(queryError()), m_queryLineEdit, SLOT(setInvalid())); + connect(m_filterLineEdit, &Utils::FancyLineEdit::filterChanged, + m_filterModel, &QSortFilterProxyModel::setFilterFixedString); + connect(m_queryLineEdit, &QLineEdit::returnPressed, this, &GerritDialog::slotRefresh); + connect(m_model, &GerritModel::queryError, m_queryLineEdit, &QueryValidatingLineEdit::setInvalid); m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); changesLayout->addLayout(filterLayout); changesLayout->addWidget(m_treeView); @@ -169,10 +168,10 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, m_treeView->setActivationMode(Utils::DoubleClickActivation); QItemSelectionModel *selectionModel = m_treeView->selectionModel(); - connect(selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(slotCurrentChanged())); - connect(m_treeView, SIGNAL(activated(QModelIndex)), - this, SLOT(slotActivated(QModelIndex))); + connect(selectionModel, &QItemSelectionModel::currentChanged, + this, &GerritDialog::slotCurrentChanged); + connect(m_treeView, &QAbstractItemView::activated, + this, &GerritDialog::slotActivated); QGroupBox *detailsGroup = new QGroupBox(tr("Details")); QVBoxLayout *detailsLayout = new QVBoxLayout(detailsGroup); @@ -188,17 +187,17 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, repoPathLayout->addWidget(m_repositoryChooser); detailsLayout->addLayout(repoPathLayout); - m_displayButton = addActionButton(tr("&Show"), SLOT(slotFetchDisplay())); - m_cherryPickButton = addActionButton(tr("Cherry &Pick"), SLOT(slotFetchCherryPick())); - m_checkoutButton = addActionButton(tr("&Checkout"), SLOT(slotFetchCheckout())); - m_refreshButton = addActionButton(tr("&Refresh"), SLOT(slotRefresh())); + m_displayButton = addActionButton(tr("&Show"), [this]() { slotFetchDisplay(); }); + m_cherryPickButton = addActionButton(tr("Cherry &Pick"), [this]() { slotFetchCherryPick(); }); + m_checkoutButton = addActionButton(tr("&Checkout"), [this]() { slotFetchCheckout(); }); + m_refreshButton = addActionButton(tr("&Refresh"), [this]() { slotRefresh(); }); - connect(m_model, SIGNAL(refreshStateChanged(bool)), - m_refreshButton, SLOT(setDisabled(bool))); - connect(m_model, SIGNAL(refreshStateChanged(bool)), - this, SLOT(slotRefreshStateChanged(bool))); - connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_model, &GerritModel::refreshStateChanged, + m_refreshButton, &QWidget::setDisabled); + connect(m_model, &GerritModel::refreshStateChanged, + this, &GerritDialog::slotRefreshStateChanged); + connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); QSplitter *splitter = new QSplitter(Qt::Vertical, this); splitter->addWidget(changesGroup); @@ -227,10 +226,11 @@ void GerritDialog::setCurrentPath(const QString &path) m_repositoryChooser->setPath(path); } -QPushButton *GerritDialog::addActionButton(const QString &text, const char *buttonSlot) +QPushButton *GerritDialog::addActionButton(const QString &text, + const std::function<void()> &buttonSlot) { QPushButton *button = m_buttonBox->addButton(text, QDialogButtonBox::ActionRole); - connect(button, SIGNAL(clicked()), this, buttonSlot); + connect(button, &QPushButton::clicked, this, buttonSlot); return button; } diff --git a/src/plugins/git/gerrit/gerritdialog.h b/src/plugins/git/gerrit/gerritdialog.h index bbcb2524166..a53c8e4a7d3 100644 --- a/src/plugins/git/gerrit/gerritdialog.h +++ b/src/plugins/git/gerrit/gerritdialog.h @@ -90,7 +90,7 @@ private slots: private: QModelIndex currentIndex() const; - QPushButton *addActionButton(const QString &text, const char *buttonSlot); + QPushButton *addActionButton(const QString &text, const std::function<void()> &buttonSlot); void updateCompletions(const QString &query); void updateButtons(); diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp index 10b7b8e737f..a1bfa56fbd8 100644 --- a/src/plugins/git/gerrit/gerritmodel.cpp +++ b/src/plugins/git/gerrit/gerritmodel.cpp @@ -268,16 +268,15 @@ QueryContext::QueryContext(const QStringList &queries, , m_currentQuery(0) , m_baseArguments(p->baseCommandArguments()) { - connect(&m_process, SIGNAL(readyReadStandardError()), - this, SLOT(readyReadStandardError())); - connect(&m_process, SIGNAL(readyReadStandardOutput()), - this, SLOT(readyReadStandardOutput())); - connect(&m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(processFinished(int,QProcess::ExitStatus))); - connect(&m_process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); - connect(&m_watcher, &QFutureWatcherBase::canceled, - this, &QueryContext::terminate); + connect(&m_process, &QProcess::readyReadStandardError, + this, &QueryContext::readyReadStandardError); + connect(&m_process, &QProcess::readyReadStandardOutput, + this, &QueryContext::readyReadStandardOutput); + connect(&m_process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + this, &QueryContext::processFinished); + connect(&m_process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), + this, &QueryContext::processError); + connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate); m_watcher.setFuture(m_progress.future()); m_process.setProcessEnvironment(Git::Internal::GitPlugin::instance()-> client()->processEnvironment()); @@ -292,7 +291,7 @@ QueryContext::QueryContext(const QStringList &queries, m_timer.setInterval(timeOutMS); m_timer.setSingleShot(true); - connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout())); + connect(&m_timer, &QTimer::timeout, this, &QueryContext::timeout); } QueryContext::~QueryContext() @@ -396,7 +395,8 @@ void QueryContext::timeout() arg(timeOutMS / 1000), QMessageBox::NoButton, parent); QPushButton *terminateButton = box.addButton(tr("Terminate"), QMessageBox::YesRole); box.addButton(tr("Keep Running"), QMessageBox::NoRole); - connect(&m_process, SIGNAL(finished(int)), &box, SLOT(reject())); + connect(&m_process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + &box, &QDialog::reject); box.exec(); if (m_process.state() != QProcess::Running) return; @@ -542,10 +542,8 @@ void GerritModel::refresh(const QString &query) } m_query = new QueryContext(queries, m_parameters, this); - connect(m_query, SIGNAL(queryFinished(QByteArray)), - this, SLOT(queryFinished(QByteArray))); - connect(m_query, SIGNAL(finished()), - this, SLOT(queriesFinished())); + connect(m_query, &QueryContext::queryFinished, this, &GerritModel::queryFinished); + connect(m_query, &QueryContext::finished, this, &GerritModel::queriesFinished); emit refreshStateChanged(true); m_query->start(); } diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index be359a69580..ab5e141fe6d 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -153,16 +153,15 @@ FetchContext::FetchContext(const QSharedPointer<GerritChange> &change, , m_parameters(p) , m_state(FetchState) { - connect(&m_process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); - connect(&m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(processFinished(int,QProcess::ExitStatus))); - connect(&m_process, SIGNAL(readyReadStandardError()), - this, SLOT(processReadyReadStandardError())); - connect(&m_process, SIGNAL(readyReadStandardOutput()), - this, SLOT(processReadyReadStandardOutput())); - connect(&m_watcher, &QFutureWatcher<void>::canceled, - this, &FetchContext::terminate); + connect(&m_process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), + this, &FetchContext::processError); + connect(&m_process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + this, &FetchContext::processFinished); + connect(&m_process, &QProcess::readyReadStandardError, + this, &FetchContext::processReadyReadStandardError); + connect(&m_process, &QProcess::readyReadStandardOutput, + this, &FetchContext::processReadyReadStandardOutput); + connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate); m_watcher.setFuture(m_progress.future()); m_process.setWorkingDirectory(repository); m_process.setProcessEnvironment(gitClient()->processEnvironment()); @@ -298,14 +297,14 @@ bool GerritPlugin::initialize(ActionContainer *ac) m_gerritCommand = ActionManager::registerAction(openViewAction, Constants::GERRIT_OPEN_VIEW); - connect(openViewAction, SIGNAL(triggered()), this, SLOT(openView())); + connect(openViewAction, &QAction::triggered, this, &GerritPlugin::openView); ac->addAction(m_gerritCommand); QAction *pushAction = new QAction(tr("Push to Gerrit..."), this); m_pushToGerritCommand = ActionManager::registerAction(pushAction, Constants::GERRIT_PUSH); - connect(pushAction, SIGNAL(triggered()), this, SLOT(push())); + connect(pushAction, &QAction::triggered, this, [this]() { push(); }); ac->addAction(m_pushToGerritCommand); GitPlugin::instance()->addAutoReleasedObject(new GerritOptionsPage(m_parameters)); @@ -377,15 +376,11 @@ void GerritPlugin::openView() } GerritDialog *gd = new GerritDialog(m_parameters, ICore::mainWindow()); gd->setModal(false); - connect(gd, SIGNAL(fetchDisplay(QSharedPointer<Gerrit::Internal::GerritChange>)), - this, SLOT(fetchDisplay(QSharedPointer<Gerrit::Internal::GerritChange>))); - connect(gd, SIGNAL(fetchCherryPick(QSharedPointer<Gerrit::Internal::GerritChange>)), - this, SLOT(fetchCherryPick(QSharedPointer<Gerrit::Internal::GerritChange>))); - connect(gd, SIGNAL(fetchCheckout(QSharedPointer<Gerrit::Internal::GerritChange>)), - this, SLOT(fetchCheckout(QSharedPointer<Gerrit::Internal::GerritChange>))); - connect(this, SIGNAL(fetchStarted(QSharedPointer<Gerrit::Internal::GerritChange>)), - gd, SLOT(fetchStarted(QSharedPointer<Gerrit::Internal::GerritChange>))); - connect(this, SIGNAL(fetchFinished()), gd, SLOT(fetchFinished())); + connect(gd, &GerritDialog::fetchDisplay, this, &GerritPlugin::fetchDisplay); + connect(gd, &GerritDialog::fetchCherryPick, this, &GerritPlugin::fetchCherryPick); + connect(gd, &GerritDialog::fetchCheckout, this, &GerritPlugin::fetchCheckout); + connect(this, &GerritPlugin::fetchStarted, gd, &GerritDialog::fetchStarted); + connect(this, &GerritPlugin::fetchFinished, gd, &GerritDialog::fetchFinished); m_dialog = gd; } if (!m_dialog->isVisible()) @@ -518,7 +513,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) FetchContext *fc = new FetchContext(change, repository, git, m_parameters, FetchMode(mode), this); - connect(fc, SIGNAL(destroyed(QObject*)), this, SIGNAL(fetchFinished())); + connect(fc, &QObject::destroyed, this, &GerritPlugin::fetchFinished); emit fetchStarted(change); fc->start(); } diff --git a/src/plugins/git/gerrit/gerritplugin.h b/src/plugins/git/gerrit/gerritplugin.h index a60ee5e7e51..18e72835500 100644 --- a/src/plugins/git/gerrit/gerritplugin.h +++ b/src/plugins/git/gerrit/gerritplugin.h @@ -70,21 +70,18 @@ public: void addToLocator(Core::CommandLocator *locator); void push(const QString &topLevel); -public slots: void fetchDisplay(const QSharedPointer<Gerrit::Internal::GerritChange> &change); void fetchCherryPick(const QSharedPointer<Gerrit::Internal::GerritChange> &change); void fetchCheckout(const QSharedPointer<Gerrit::Internal::GerritChange> &change); void updateActions(bool hasTopLevel); -signals: +private: void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change); void fetchFinished(); -private slots: void openView(); void push(); -private: QString findLocalRepository(QString project, const QString &branch) const; void fetch(const QSharedPointer<GerritChange> &change, int mode); |