From ea23628c1c6ca98350c32a213d8be4838998bf5e Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 28 Jan 2020 14:15:59 +0100 Subject: Bazaar: Move plugin pimpl into .cpp Change-Id: If355d4dc34febcda7da24d85370f3ab607f5cd82 Reviewed-by: Orgad Shaneh --- src/plugins/bazaar/CMakeLists.txt | 2 +- src/plugins/bazaar/bazaar.pro | 8 +- src/plugins/bazaar/bazaar.qbs | 2 - src/plugins/bazaar/bazaarplugin.cpp | 217 ++++++++++++++++++++++++---------- src/plugins/bazaar/bazaarplugin.h | 95 +-------------- src/plugins/bazaar/optionspage.cpp | 15 ++- src/plugins/bazaar/optionspage.h | 4 +- src/plugins/bazaar/uncommitdialog.cpp | 76 ------------ src/plugins/bazaar/uncommitdialog.h | 53 --------- 9 files changed, 169 insertions(+), 303 deletions(-) delete mode 100644 src/plugins/bazaar/uncommitdialog.cpp delete mode 100644 src/plugins/bazaar/uncommitdialog.h (limited to 'src/plugins/bazaar') diff --git a/src/plugins/bazaar/CMakeLists.txt b/src/plugins/bazaar/CMakeLists.txt index 145323c42a7..8d165410485 100644 --- a/src/plugins/bazaar/CMakeLists.txt +++ b/src/plugins/bazaar/CMakeLists.txt @@ -15,5 +15,5 @@ add_qtc_plugin(Bazaar optionspage.cpp optionspage.h optionspage.ui pullorpushdialog.cpp pullorpushdialog.h pullorpushdialog.ui revertdialog.ui - uncommitdialog.cpp uncommitdialog.h uncommitdialog.ui + uncommitdialog.ui ) diff --git a/src/plugins/bazaar/bazaar.pro b/src/plugins/bazaar/bazaar.pro index cbb7f4429b2..71cf023dc1d 100644 --- a/src/plugins/bazaar/bazaar.pro +++ b/src/plugins/bazaar/bazaar.pro @@ -10,8 +10,8 @@ SOURCES += \ bazaareditor.cpp \ annotationhighlighter.cpp \ pullorpushdialog.cpp \ - branchinfo.cpp \ - uncommitdialog.cpp + branchinfo.cpp + HEADERS += \ bazaarclient.h \ constants.h \ @@ -24,8 +24,8 @@ HEADERS += \ bazaareditor.h \ annotationhighlighter.h \ pullorpushdialog.h \ - branchinfo.h \ - uncommitdialog.h + branchinfo.h + FORMS += \ optionspage.ui \ revertdialog.ui \ diff --git a/src/plugins/bazaar/bazaar.qbs b/src/plugins/bazaar/bazaar.qbs index 06e0c27a534..c14cce6b4e2 100644 --- a/src/plugins/bazaar/bazaar.qbs +++ b/src/plugins/bazaar/bazaar.qbs @@ -38,8 +38,6 @@ QtcPlugin { "pullorpushdialog.h", "pullorpushdialog.ui", "revertdialog.ui", - "uncommitdialog.cpp", - "uncommitdialog.h", "uncommitdialog.ui", ] } diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 87e58a97b37..0b99c23bd21 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -24,17 +24,22 @@ ****************************************************************************/ #include "bazaarplugin.h" -#include "constants.h" + #include "bazaarclient.h" -#include "bazaarcontrol.h" -#include "optionspage.h" #include "bazaarcommitwidget.h" +#include "bazaarcontrol.h" #include "bazaareditor.h" -#include "pullorpushdialog.h" -#include "uncommitdialog.h" +#include "bazaarsettings.h" #include "commiteditor.h" +#include "constants.h" +#include "optionspage.h" +#include "pullorpushdialog.h" #include "ui_revertdialog.h" +#include "ui_uncommitdialog.h" + +#include +#include #include #include @@ -57,12 +62,12 @@ #include #include -#include #include -#include #include -#include #include +#include +#include +#include #ifdef WITH_TESTS #include @@ -128,72 +133,155 @@ const VcsBaseSubmitEditorParameters submitEditorParameters = { VcsBaseSubmitEditorParameters::DiffFiles }; +class BazaarPluginPrivate final : public VcsBasePluginPrivate +{ + Q_DECLARE_TR_FUNCTIONS(Bazaar::Internal::BazaarPlugin) + +public: + BazaarPluginPrivate(); + + void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final; + bool submitEditorAboutToClose() final; + + // File menu action slots + void addCurrentFile(); + void annotateCurrentFile(); + void diffCurrentFile(); + void logCurrentFile(); + void revertCurrentFile(); + void statusCurrentFile(); + + // Directory menu action slots + void diffRepository(); + void logRepository(); + void revertAll(); + void statusMulti(); + + // Repository menu action slots + void pull(); + void push(); + void update(); + void commit(); + void showCommitWidget(const QList &status); + void commitFromEditor() override; + void uncommit(); + void diffFromEditorSelected(const QStringList &files); + + // Functions + void createFileActions(const Core::Context &context); + void createDirectoryActions(const Core::Context &context); + void createRepositoryActions(const Core::Context &context); + + // Variables + BazaarSettings m_bazaarSettings; + BazaarClient m_client{&m_bazaarSettings}; + BazaarControl m_control{&m_client}; + + OptionsPage m_optionsPage{[this] { m_control.configurationChanged(); }, &m_bazaarSettings}; + + VcsSubmitEditorFactory m_submitEditorFactory { + &submitEditorParameters, + [] { return new CommitEditor(&submitEditorParameters); }, + this + }; + Core::CommandLocator *m_commandLocator = nullptr; + Core::ActionContainer *m_bazaarContainer = nullptr; + + QList m_repositoryActionList; -static BazaarPluginPrivate *dd = nullptr; + // Menu Items (file actions) + ParameterAction *m_addAction = nullptr; + ParameterAction *m_deleteAction = nullptr; + ParameterAction *m_annotateFile = nullptr; + ParameterAction *m_diffFile = nullptr; + ParameterAction *m_logFile = nullptr; + ParameterAction *m_revertFile = nullptr; + ParameterAction *m_statusFile = nullptr; -BazaarPluginPrivate::~BazaarPluginPrivate() -{ - delete m_client; - m_client = nullptr; -} + QAction *m_menuAction = nullptr; + + QString m_submitRepository; + bool m_submitActionTriggered = false; +}; + +class UnCommitDialog : public QDialog +{ + Q_DECLARE_TR_FUNCTIONS(Bazaar::Internal::UnCommitDialog) + +public: + explicit UnCommitDialog(BazaarPluginPrivate *plugin) + : QDialog(ICore::dialogParent()) + { + m_ui.setupUi(this); + + auto dryRunBtn = new QPushButton(tr("Dry Run")); + dryRunBtn->setToolTip(tr("Test the outcome of removing the last committed revision, without actually removing anything.")); + m_ui.buttonBox->addButton(dryRunBtn, QDialogButtonBox::ApplyRole); + connect(dryRunBtn, &QPushButton::clicked, this, [this, plugin] { + QTC_ASSERT(plugin->currentState().hasTopLevel(), return); + plugin->m_client.synchronousUncommit(plugin->currentState().topLevel(), + revision(), + extraOptions() << "--dry-run"); + }); + } + + QStringList extraOptions() const + { + QStringList opts; + if (m_ui.keepTagsCheckBox->isChecked()) + opts += "--keep-tags"; + if (m_ui.localCheckBox->isChecked()) + opts += "--local"; + return opts; + } + + QString revision() const + { + return m_ui.revisionLineEdit->text().trimmed(); + } + +private: + Ui::UnCommitDialog m_ui; +}; BazaarPlugin::~BazaarPlugin() { - delete dd; - dd = nullptr; + delete d; + d = nullptr; } bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments) Q_UNUSED(errorMessage) - dd = new BazaarPluginPrivate; + d = new BazaarPluginPrivate; return true; } void BazaarPlugin::extensionsInitialized() { - dd->extensionsInitialized(); + d->extensionsInitialized(); } BazaarPluginPrivate::BazaarPluginPrivate() { - dd = this; - Context context(Constants::BAZAAR_CONTEXT); + initializeVcs(&m_control, context); - m_client = new BazaarClient(&m_bazaarSettings); - auto vcsCtrl = new BazaarControl(m_client); - initializeVcs(vcsCtrl, context); - - connect(m_client, &VcsBaseClient::changed, vcsCtrl, &BazaarControl::changed); - - new OptionsPage(vcsCtrl, &m_bazaarSettings, this); + connect(&m_client, &VcsBaseClient::changed, &m_control, &BazaarControl::changed); const auto describeFunc = [this](const QString &source, const QString &id) { - m_client->view(source, id); + m_client.view(source, id); }; + const int editorCount = sizeof(editorParameters) / sizeof(VcsBaseEditorParameters); const auto widgetCreator = []() { return new BazaarEditorWidget; }; for (int i = 0; i < editorCount; i++) new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc, this); - (void) new VcsSubmitEditorFactory(&submitEditorParameters, - []() { return new CommitEditor(&submitEditorParameters); }, this); - const QString prefix = QLatin1String("bzr"); m_commandLocator = new CommandLocator("Bazaar", prefix, prefix, this); - createMenu(context); -} - -BazaarClient *BazaarPluginPrivate::client() const -{ - return m_client; -} - -void BazaarPluginPrivate::createMenu(const Context &context) -{ // Create menu item for Bazaar m_bazaarContainer = ActionManager::createMenu("Bazaar.BazaarMenu"); QMenu *menu = m_bazaarContainer->menu(); @@ -273,28 +361,28 @@ void BazaarPluginPrivate::addCurrentFile() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasFile(), return); - m_client->synchronousAdd(state.currentFileTopLevel(), state.relativeCurrentFile()); + m_client.synchronousAdd(state.currentFileTopLevel(), state.relativeCurrentFile()); } void BazaarPluginPrivate::annotateCurrentFile() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasFile(), return); - m_client->annotate(state.currentFileTopLevel(), state.relativeCurrentFile()); + m_client.annotate(state.currentFileTopLevel(), state.relativeCurrentFile()); } void BazaarPluginPrivate::diffCurrentFile() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasFile(), return); - m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile())); + m_client.diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile())); } void BazaarPluginPrivate::logCurrentFile() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasFile(), return); - m_client->log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), + m_client.log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()), QStringList(), true); } @@ -308,7 +396,7 @@ void BazaarPluginPrivate::revertCurrentFile() revertUi.setupUi(&dialog); if (dialog.exec() != QDialog::Accepted) return; - m_client->revertFile(state.currentFileTopLevel(), + m_client.revertFile(state.currentFileTopLevel(), state.relativeCurrentFile(), revertUi.revisionLineEdit->text()); } @@ -317,7 +405,7 @@ void BazaarPluginPrivate::statusCurrentFile() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasFile(), return); - m_client->status(state.currentFileTopLevel(), state.relativeCurrentFile()); + m_client.status(state.currentFileTopLevel(), state.relativeCurrentFile()); } void BazaarPluginPrivate::createDirectoryActions(const Context &context) @@ -351,12 +439,11 @@ void BazaarPluginPrivate::createDirectoryActions(const Context &context) m_commandLocator->appendCommand(command); } - void BazaarPluginPrivate::diffRepository() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); - m_client->diff(state.topLevel()); + m_client.diff(state.topLevel()); } void BazaarPluginPrivate::logRepository() @@ -364,8 +451,8 @@ void BazaarPluginPrivate::logRepository() const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); QStringList extraOptions; - extraOptions += QLatin1String("--limit=") + QString::number(m_client->settings().intValue(BazaarSettings::logCountKey)); - m_client->log(state.topLevel(), QStringList(), extraOptions); + extraOptions += QLatin1String("--limit=") + QString::number(m_client.settings().intValue(BazaarSettings::logCountKey)); + m_client.log(state.topLevel(), QStringList(), extraOptions); } void BazaarPluginPrivate::revertAll() @@ -378,14 +465,14 @@ void BazaarPluginPrivate::revertAll() revertUi.setupUi(&dialog); if (dialog.exec() != QDialog::Accepted) return; - m_client->revertAll(state.topLevel(), revertUi.revisionLineEdit->text()); + m_client.revertAll(state.topLevel(), revertUi.revisionLineEdit->text()); } void BazaarPluginPrivate::statusMulti() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); - m_client->status(state.topLevel()); + m_client.status(state.topLevel()); } void BazaarPluginPrivate::createRepositoryActions(const Context &context) @@ -449,7 +536,7 @@ void BazaarPluginPrivate::pull() extraOptions += QLatin1String("--local"); if (!dialog.revision().isEmpty()) extraOptions << QLatin1String("-r") << dialog.revision(); - m_client->synchronousPull(state.topLevel(), dialog.branchLocation(), extraOptions); + m_client.synchronousPull(state.topLevel(), dialog.branchLocation(), extraOptions); } void BazaarPluginPrivate::push() @@ -471,7 +558,7 @@ void BazaarPluginPrivate::push() extraOptions += QLatin1String("--create-prefix"); if (!dialog.revision().isEmpty()) extraOptions << QLatin1String("-r") << dialog.revision(); - m_client->synchronousPush(state.topLevel(), dialog.branchLocation(), extraOptions); + m_client.synchronousPush(state.topLevel(), dialog.branchLocation(), extraOptions); } void BazaarPluginPrivate::update() @@ -485,7 +572,7 @@ void BazaarPluginPrivate::update() dialog.setWindowTitle(tr("Update")); if (dialog.exec() != QDialog::Accepted) return; - m_client->update(state.topLevel(), revertUi.revisionLineEdit->text()); + m_client.update(state.topLevel(), revertUi.revisionLineEdit->text()); } void BazaarPluginPrivate::commit() @@ -501,16 +588,16 @@ void BazaarPluginPrivate::commit() m_submitRepository = state.topLevel(); - QObject::connect(m_client, &VcsBaseClient::parsedStatus, + QObject::connect(&m_client, &VcsBaseClient::parsedStatus, this, &BazaarPluginPrivate::showCommitWidget); // The "--short" option allows to easily parse status output - m_client->emitParsedStatus(m_submitRepository, QStringList(QLatin1String("--short"))); + m_client.emitParsedStatus(m_submitRepository, QStringList(QLatin1String("--short"))); } void BazaarPluginPrivate::showCommitWidget(const QList &status) { //Once we receive our data release the connection so it can be reused elsewhere - QObject::disconnect(m_client, &VcsBaseClient::parsedStatus, + QObject::disconnect(&m_client, &VcsBaseClient::parsedStatus, this, &BazaarPluginPrivate::showCommitWidget); if (status.isEmpty()) { @@ -549,8 +636,8 @@ void BazaarPluginPrivate::showCommitWidget(const QListdocument()->setPreferredDisplayName(msg); - const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository); - const VcsBaseClientSettings &s = m_client->settings(); + const BranchInfo branch = m_client.synchronousBranchQuery(m_submitRepository); + const VcsBaseClientSettings &s = m_client.settings(); commitEditor->setFields(m_submitRepository, branch, s.stringValue(BazaarSettings::userNameKey), s.stringValue(BazaarSettings::userEmailKey), status); @@ -558,7 +645,7 @@ void BazaarPluginPrivate::showCommitWidget(const QListdiff(m_submitRepository, files); + m_client.diff(m_submitRepository, files); } #ifdef WITH_TESTS @@ -630,9 +717,9 @@ void BazaarPluginPrivate::uncommit() const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); - UnCommitDialog dialog(this, ICore::dialogParent()); + UnCommitDialog dialog(this); if (dialog.exec() == QDialog::Accepted) - m_client->synchronousUncommit(state.topLevel(), dialog.revision(), dialog.extraOptions()); + m_client.synchronousUncommit(state.topLevel(), dialog.revision(), dialog.extraOptions()); } bool BazaarPluginPrivate::submitEditorAboutToClose() @@ -682,7 +769,7 @@ bool BazaarPluginPrivate::submitEditorAboutToClose() // Whether local commit or not if (commitWidget->isLocalOptionEnabled()) extraOptions += QLatin1String("--local"); - m_client->commit(m_submitRepository, files, editorDocument->filePath().toString(), extraOptions); + m_client.commit(m_submitRepository, files, editorDocument->filePath().toString(), extraOptions); } return true; } diff --git a/src/plugins/bazaar/bazaarplugin.h b/src/plugins/bazaar/bazaarplugin.h index 7aea2a53172..7be7479785c 100644 --- a/src/plugins/bazaar/bazaarplugin.h +++ b/src/plugins/bazaar/bazaarplugin.h @@ -25,101 +25,11 @@ #pragma once -#include "bazaarsettings.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QAction; -QT_END_NAMESPACE - -namespace Core { -class ActionContainer; -class CommandLocator; -class Id; -} // namespace Core - -namespace Utils { class ParameterAction; } +#include namespace Bazaar { namespace Internal { -class OptionsPage; -class BazaarClient; -class BazaarControl; -class BazaarEditorWidget; - -class BazaarPluginPrivate final : public VcsBase::VcsBasePluginPrivate -{ - Q_OBJECT - -public: - BazaarPluginPrivate(); - ~BazaarPluginPrivate() final; - - BazaarClient *client() const; - -protected: - void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final; - bool submitEditorAboutToClose() final; - -private: - // File menu action slots - void addCurrentFile(); - void annotateCurrentFile(); - void diffCurrentFile(); - void logCurrentFile(); - void revertCurrentFile(); - void statusCurrentFile(); - - // Directory menu action slots - void diffRepository(); - void logRepository(); - void revertAll(); - void statusMulti(); - - // Repository menu action slots - void pull(); - void push(); - void update(); - void commit(); - void showCommitWidget(const QList &status); - void commitFromEditor() override; - void uncommit(); - void diffFromEditorSelected(const QStringList &files); - - // Functions - void createMenu(const Core::Context &context); - void createFileActions(const Core::Context &context); - void createDirectoryActions(const Core::Context &context); - void createRepositoryActions(const Core::Context &context); - - // Variables - BazaarSettings m_bazaarSettings; - BazaarClient *m_client = nullptr; - - Core::CommandLocator *m_commandLocator = nullptr; - Core::ActionContainer *m_bazaarContainer = nullptr; - - QList m_repositoryActionList; - - // Menu Items (file actions) - Utils::ParameterAction *m_addAction = nullptr; - Utils::ParameterAction *m_deleteAction = nullptr; - Utils::ParameterAction *m_annotateFile = nullptr; - Utils::ParameterAction *m_diffFile = nullptr; - Utils::ParameterAction *m_logFile = nullptr; - Utils::ParameterAction *m_revertFile = nullptr; - Utils::ParameterAction *m_statusFile = nullptr; - - QAction *m_menuAction = nullptr; - - QString m_submitRepository; - bool m_submitActionTriggered = false; -}; - class BazaarPlugin final : public ExtensionSystem::IPlugin { Q_OBJECT @@ -136,6 +46,9 @@ private slots: void testDiffFileResolving(); void testLogResolving(); #endif + +private: + class BazaarPluginPrivate *d = nullptr; }; } // namespace Internal diff --git a/src/plugins/bazaar/optionspage.cpp b/src/plugins/bazaar/optionspage.cpp index 38e787aadc2..b6b41296fc5 100644 --- a/src/plugins/bazaar/optionspage.cpp +++ b/src/plugins/bazaar/optionspage.cpp @@ -42,13 +42,13 @@ class OptionsPageWidget final : public Core::IOptionsPageWidget Q_DECLARE_TR_FUNCTIONS(Bazaar::Internal::OptionsPageWidget) public: - OptionsPageWidget(Core::IVersionControl *control, BazaarSettings *settings); + OptionsPageWidget(const std::function &onApply, BazaarSettings *settings); void apply() final; private: Ui::OptionsPage m_ui; - Core::IVersionControl *m_control; + const std::function m_onApply; BazaarSettings *m_settings; }; @@ -65,11 +65,11 @@ void OptionsPageWidget::apply() return; *m_settings = s; - emit m_control->configurationChanged(); + m_onApply(); } -OptionsPageWidget::OptionsPageWidget(Core::IVersionControl *control, BazaarSettings *settings) - : m_control(control), m_settings(settings) +OptionsPageWidget::OptionsPageWidget(const std::function &onApply, BazaarSettings *settings) + : m_onApply(onApply), m_settings(settings) { m_ui.setupUi(this); m_ui.commandChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); @@ -83,12 +83,11 @@ OptionsPageWidget::OptionsPageWidget(Core::IVersionControl *control, BazaarSetti m_ui.timeout->setValue(m_settings->intValue(BazaarSettings::timeoutKey)); } -OptionsPage::OptionsPage(Core::IVersionControl *control, BazaarSettings *settings, QObject *parent) : - Core::IOptionsPage(parent) +OptionsPage::OptionsPage(const std::function &onApply, BazaarSettings *settings) { setId(VcsBase::Constants::VCS_ID_BAZAAR); setDisplayName(OptionsPageWidget::tr("Bazaar")); - setWidgetCreator([control, settings] { return new OptionsPageWidget(control, settings); }); + setWidgetCreator([onApply, settings] { return new OptionsPageWidget(onApply, settings); }); setCategory(Constants::VCS_SETTINGS_CATEGORY); } diff --git a/src/plugins/bazaar/optionspage.h b/src/plugins/bazaar/optionspage.h index ccfaa8f0cf0..4e6c69e9fbf 100644 --- a/src/plugins/bazaar/optionspage.h +++ b/src/plugins/bazaar/optionspage.h @@ -27,8 +27,6 @@ #include -namespace Core { class IVersionControl; } - namespace Bazaar { namespace Internal { @@ -37,7 +35,7 @@ class BazaarSettings; class OptionsPage final : public Core::IOptionsPage { public: - OptionsPage(Core::IVersionControl *control, BazaarSettings *settings, QObject *parent); + OptionsPage(const std::function &onApply, BazaarSettings *settings); }; } // namespace Internal diff --git a/src/plugins/bazaar/uncommitdialog.cpp b/src/plugins/bazaar/uncommitdialog.cpp deleted file mode 100644 index 97832dfe86c..00000000000 --- a/src/plugins/bazaar/uncommitdialog.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Hugues Delorme -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "uncommitdialog.h" - -#include "ui_uncommitdialog.h" -#include "bazaarclient.h" -#include "bazaarplugin.h" -#include - -#include - -namespace Bazaar { -namespace Internal { - -UnCommitDialog::UnCommitDialog(BazaarPluginPrivate *bzrPlugin, QWidget *parent) : - QDialog(parent), - m_ui(new Ui::UnCommitDialog) -{ - m_ui->setupUi(this); - - auto dryRunBtn = new QPushButton(tr("Dry Run")); - dryRunBtn->setToolTip(tr("Test the outcome of removing the last committed revision, without actually removing anything.")); - m_ui->buttonBox->addButton(dryRunBtn, QDialogButtonBox::ApplyRole); - connect(dryRunBtn, &QPushButton::clicked, this, [this, bzrPlugin] { - QTC_ASSERT(bzrPlugin->currentState().hasTopLevel(), return); - bzrPlugin->client()->synchronousUncommit(bzrPlugin->currentState().topLevel(), - revision(), - extraOptions() << QLatin1String("--dry-run")); - }); -} - -UnCommitDialog::~UnCommitDialog() -{ - delete m_ui; -} - -QStringList UnCommitDialog::extraOptions() const -{ - QStringList opts; - if (m_ui->keepTagsCheckBox->isChecked()) - opts += QLatin1String("--keep-tags"); - if (m_ui->localCheckBox->isChecked()) - opts += QLatin1String("--local"); - return opts; -} - -QString UnCommitDialog::revision() const -{ - return m_ui->revisionLineEdit->text().trimmed(); -} - -} // namespace Internal -} // namespace Bazaar diff --git a/src/plugins/bazaar/uncommitdialog.h b/src/plugins/bazaar/uncommitdialog.h deleted file mode 100644 index 335250150e9..00000000000 --- a/src/plugins/bazaar/uncommitdialog.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Hugues Delorme -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -namespace Bazaar { -namespace Internal { - -namespace Ui { class UnCommitDialog; } - -class BazaarPluginPrivate; - -class UnCommitDialog : public QDialog -{ - Q_OBJECT - -public: - explicit UnCommitDialog(BazaarPluginPrivate *plugin, QWidget *parent = nullptr); - ~UnCommitDialog() override; - - QStringList extraOptions() const; - QString revision() const; - -private: - Ui::UnCommitDialog *m_ui; -}; - -} // namespace Internal -} // namespace Bazaar -- cgit v1.2.3