diff options
author | hjk <hjk@qt.io> | 2019-04-24 12:01:53 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-04-24 12:48:54 +0000 |
commit | 8a3bf12fe61a07cff838ad8036f9f9cef9d4c4ff (patch) | |
tree | 117b4f0263bdc6183f560b58bd8b2b33c69fa05e /src/plugins/remotelinux | |
parent | ceff49ec40fdbbdb6e466a740f025ca49a04c93e (diff) | |
download | qt-creator-8a3bf12fe61a07cff838ad8036f9f9cef9d4c4ff.tar.gz |
RemoteLinux: Aspectify RemoteLinuxCheckForFreeDiskSpaceStep
Change-Id: I40c2639b0cbc0d36920394a2ff34fbfcfdadb27f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/remotelinux')
5 files changed, 27 insertions, 152 deletions
diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 4ec8891937..5314e25d64 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -90,8 +90,7 @@ SOURCES += \ FORMS += \ genericlinuxdeviceconfigurationwizardsetuppage.ui \ - genericlinuxdeviceconfigurationwidget.ui \ - remotelinuxcheckforfreediskspacestepwidget.ui + genericlinuxdeviceconfigurationwidget.ui RESOURCES += remotelinux.qrc diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 92e94b6549..e2a9551393 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -60,7 +60,6 @@ Project { "remotelinuxcheckforfreediskspaceservice.h", "remotelinuxcheckforfreediskspacestep.cpp", "remotelinuxcheckforfreediskspacestep.h", - "remotelinuxcheckforfreediskspacestepwidget.ui", "remotelinuxcustomcommanddeploymentstep.cpp", "remotelinuxcustomcommanddeploymentstep.h", "remotelinuxcustomcommanddeployservice.cpp", diff --git a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp b/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp index 29676b1140..d99e386c5e 100644 --- a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp +++ b/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp @@ -24,11 +24,10 @@ ****************************************************************************/ #include "remotelinuxcheckforfreediskspacestep.h" -#include "ui_remotelinuxcheckforfreediskspacestepwidget.h" #include "remotelinuxcheckforfreediskspaceservice.h" -#include <QString> +#include <projectexplorer/projectconfigurationaspects.h> #include <limits> @@ -36,63 +35,44 @@ using namespace ProjectExplorer; namespace RemoteLinux { namespace Internal { -namespace { -class RemoteLinuxCheckForFreeDiskSpaceStepWidget : public BuildStepConfigWidget -{ - Q_OBJECT - -public: - explicit RemoteLinuxCheckForFreeDiskSpaceStepWidget(RemoteLinuxCheckForFreeDiskSpaceStep &step) - : BuildStepConfigWidget(&step), m_step(step) - { - m_ui.setupUi(this); - m_ui.requiredSpaceSpinBox->setSuffix(tr("MB")); - m_ui.requiredSpaceSpinBox->setMinimum(1); - m_ui.requiredSpaceSpinBox->setMaximum(std::numeric_limits<int>::max()); - - m_ui.pathLineEdit->setText(m_step.pathToCheck()); - m_ui.requiredSpaceSpinBox->setValue(m_step.requiredSpaceInBytes()/multiplier); - - connect(m_ui.pathLineEdit, &QLineEdit::textChanged, - this, &RemoteLinuxCheckForFreeDiskSpaceStepWidget::handlePathChanged); - connect(m_ui.requiredSpaceSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), - this, &RemoteLinuxCheckForFreeDiskSpaceStepWidget::handleRequiredSpaceChanged); - } - -private: - void handlePathChanged() { m_step.setPathToCheck(m_ui.pathLineEdit->text().trimmed()); } - void handleRequiredSpaceChanged() { - m_step.setRequiredSpaceInBytes(quint64(m_ui.requiredSpaceSpinBox->value())*multiplier); - } - - static const int multiplier = 1024*1024; - - Ui::RemoteLinuxCheckForFreeDiskSpaceStepWidget m_ui; - RemoteLinuxCheckForFreeDiskSpaceStep &m_step; -}; - -} // anonymous namespace +const char PathToCheckAspectId[] = "PathToCheckAspectId"; const char PathToCheckKey[] = "RemoteLinux.CheckForFreeDiskSpaceStep.PathToCheck"; + +const char RequiredSpaceAspectId[] = "RequiredSpaceAspectId"; const char RequiredSpaceKey[] = "RemoteLinux.CheckForFreeDiskSpaceStep.RequiredSpace"; class RemoteLinuxCheckForFreeDiskSpaceStepPrivate { public: RemoteLinuxCheckForFreeDiskSpaceService deployService; - QString pathToCheck; - quint64 requiredSpaceInBytes; }; + } // namespace Internal +using namespace Internal; RemoteLinuxCheckForFreeDiskSpaceStep::RemoteLinuxCheckForFreeDiskSpaceStep(BuildStepList *bsl) : AbstractRemoteLinuxDeployStep(bsl, stepId()) { d = new Internal::RemoteLinuxCheckForFreeDiskSpaceStepPrivate; setDefaultDisplayName(displayName()); - setPathToCheck("/"); - setRequiredSpaceInBytes(5*1024*1024); + + auto pathToCheckAspect = addAspect<BaseStringAspect>(); + pathToCheckAspect->setId(PathToCheckAspectId); + pathToCheckAspect->setSettingsKey(PathToCheckKey); + pathToCheckAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); + pathToCheckAspect->setValue("/"); + pathToCheckAspect->setLabelText(tr("Remote path to check for free space:")); + + auto requiredSpaceAspect = addAspect<BaseIntegerAspect>(); + requiredSpaceAspect->setId(RequiredSpaceAspectId); + requiredSpaceAspect->setSettingsKey(RequiredSpaceKey); + requiredSpaceAspect->setLabel(tr("Required disk space:")); + requiredSpaceAspect->setDisplayScaleFactor(1024*1024); + requiredSpaceAspect->setValue(5*1024*1024); + requiredSpaceAspect->setSuffix(tr("MB")); + requiredSpaceAspect->setRange(1, std::numeric_limits<int>::max()); } RemoteLinuxCheckForFreeDiskSpaceStep::~RemoteLinuxCheckForFreeDiskSpaceStep() @@ -100,53 +80,13 @@ RemoteLinuxCheckForFreeDiskSpaceStep::~RemoteLinuxCheckForFreeDiskSpaceStep() delete d; } -void RemoteLinuxCheckForFreeDiskSpaceStep::setPathToCheck(const QString &path) -{ - d->pathToCheck = path; -} - -QString RemoteLinuxCheckForFreeDiskSpaceStep::pathToCheck() const -{ - return d->pathToCheck; -} - -void RemoteLinuxCheckForFreeDiskSpaceStep::setRequiredSpaceInBytes(quint64 space) -{ - d->requiredSpaceInBytes = space; -} - -quint64 RemoteLinuxCheckForFreeDiskSpaceStep::requiredSpaceInBytes() const -{ - return d->requiredSpaceInBytes; -} - -bool RemoteLinuxCheckForFreeDiskSpaceStep::fromMap(const QVariantMap &map) -{ - if (!AbstractRemoteLinuxDeployStep::fromMap(map)) - return false; - d->pathToCheck = map.value(QLatin1String(Internal::PathToCheckKey)).toString(); - d->requiredSpaceInBytes = map.value(QLatin1String(Internal::RequiredSpaceKey)).toULongLong(); - return true; -} - -QVariantMap RemoteLinuxCheckForFreeDiskSpaceStep::toMap() const -{ - QVariantMap map = AbstractRemoteLinuxDeployStep::toMap(); - map.insert(QLatin1String(Internal::PathToCheckKey), d->pathToCheck); - map.insert(QLatin1String(Internal::RequiredSpaceKey), d->requiredSpaceInBytes); - return map; -} - -BuildStepConfigWidget *RemoteLinuxCheckForFreeDiskSpaceStep::createConfigWidget() -{ - return new Internal::RemoteLinuxCheckForFreeDiskSpaceStepWidget(*this); -} - bool RemoteLinuxCheckForFreeDiskSpaceStep::initInternal(QString *error) { Q_UNUSED(error); - d->deployService.setPathToCheck(d->pathToCheck); - d->deployService.setRequiredSpaceInBytes(d->requiredSpaceInBytes); + d->deployService.setPathToCheck( + static_cast<BaseStringAspect *>(aspect(PathToCheckAspectId))->value()); + d->deployService.setRequiredSpaceInBytes( + static_cast<BaseIntegerAspect *>(aspect(RequiredSpaceAspectId))->value()); return true; } @@ -166,5 +106,3 @@ QString RemoteLinuxCheckForFreeDiskSpaceStep::displayName() } } // namespace RemoteLinux - -#include "remotelinuxcheckforfreediskspacestep.moc" diff --git a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.h b/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.h index f102c93c62..f02748d511 100644 --- a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.h +++ b/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.h @@ -37,20 +37,10 @@ public: explicit RemoteLinuxCheckForFreeDiskSpaceStep(ProjectExplorer::BuildStepList *bsl); ~RemoteLinuxCheckForFreeDiskSpaceStep() override; - void setPathToCheck(const QString &path); - QString pathToCheck() const; - - void setRequiredSpaceInBytes(quint64 space); - quint64 requiredSpaceInBytes() const; - static Core::Id stepId(); static QString displayName(); protected: - bool fromMap(const QVariantMap &map) override; - QVariantMap toMap() const override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - bool initInternal(QString *error) override; AbstractRemoteLinuxDeployService *deployService() const override; diff --git a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestepwidget.ui b/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestepwidget.ui deleted file mode 100644 index b310833f6c..0000000000 --- a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestepwidget.ui +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>RemoteLinuxCheckForFreeDiskSpaceStepWidget</class> - <widget class="QWidget" name="RemoteLinuxCheckForFreeDiskSpaceStepWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>420</width> - <height>74</height> - </rect> - </property> - <property name="windowTitle"> - <string/> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="pathLabel"> - <property name="text"> - <string>Remote path to check for free space:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="pathLineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="requiredSpaceLabel"> - <property name="text"> - <string>Required disk space:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="requiredSpaceSpinBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="suffix"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> |