From e97d6fd52cacc1aa0903512d6571c1aa7b30ae92 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 16 Feb 2017 15:17:15 +0100 Subject: [PATCH] Build fix for -no-feature-action Change-Id: I62291af347dca7c1bb4a53d2cb698e4f1a38743d Reviewed-by: Lars Knoll --- src/widgets/widgets/qlineedit.cpp | 11 ++++++++++- src/widgets/widgets/qlineedit.h | 2 ++ src/widgets/widgets/qlineedit_p.cpp | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index fb0ffd60837..0a35bae200a 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -437,6 +437,7 @@ bool QLineEdit::hasFrame() const \since 5.2 */ +#if QT_CONFIG(action) /*! \overload @@ -466,7 +467,7 @@ QAction *QLineEdit::addAction(const QIcon &icon, ActionPosition position) addAction(result, position); return result; } - +#endif // QT_CONFIG(action) /*! \property QLineEdit::clearButtonEnabled \brief Whether the line edit displays a clear button when it is not empty. @@ -483,6 +484,7 @@ static const char clearButtonActionNameC[] = "_q_qlineeditclearaction"; void QLineEdit::setClearButtonEnabled(bool enable) { +#if QT_CONFIG(action) Q_D(QLineEdit); if (enable == isClearButtonEnabled()) return; @@ -497,11 +499,16 @@ void QLineEdit::setClearButtonEnabled(bool enable) d->removeAction(clearAction); delete clearAction; } +#endif // QT_CONFIG(action) } bool QLineEdit::isClearButtonEnabled() const { +#if QT_CONFIG(action) return findChild(QLatin1String(clearButtonActionNameC)); +#else + return false; +#endif } void QLineEdit::setFrame(bool enable) @@ -1432,8 +1439,10 @@ bool QLineEdit::event(QEvent * e) || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) d->setCursorVisible(true); } +#if QT_CONFIG(action) } else if (e->type() == QEvent::ActionRemoved) { d->removeAction(static_cast(e)->action()); +#endif } else if (e->type() == QEvent::Resize) { d->positionSideWidgets(); } diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 96dd64164fb..4d32b11f065 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -174,9 +174,11 @@ class Q_WIDGETS_EXPORT QLineEdit : public QWidget void getTextMargins(int *left, int *top, int *right, int *bottom) const; QMargins textMargins() const; +#if QT_CONFIG(action) using QWidget::addAction; void addAction(QAction *action, ActionPosition position); QAction *addAction(const QIcon &icon, ActionPosition position); +#endif public Q_SLOTS: void setText(const QString &); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 13f18f66d2d..791fba49aab 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -448,12 +448,14 @@ QIcon QLineEditPrivate::clearButtonIcon() const void QLineEditPrivate::setClearButtonEnabled(bool enabled) { +#if QT_CONFIG(action) for (const SideWidgetEntry &e : trailingSideWidgets) { if (e.flags & SideWidgetClearButton) { e.action->setEnabled(enabled); break; } } +#endif } void QLineEditPrivate::positionSideWidgets() @@ -467,14 +469,18 @@ void QLineEditPrivate::positionSideWidgets() QSize(p.widgetWidth, p.widgetHeight)); for (const SideWidgetEntry &e : leftSideWidgetList()) { e.widget->setGeometry(widgetGeometry); +#if QT_CONFIG(action) if (e.action->isVisible()) widgetGeometry.moveLeft(widgetGeometry.left() + delta); +#endif } widgetGeometry.moveLeft(contentRect.width() - p.widgetWidth - p.margin); for (const SideWidgetEntry &e : rightSideWidgetList()) { e.widget->setGeometry(widgetGeometry); +#if QT_CONFIG(action) if (e.action->isVisible()) widgetGeometry.moveLeft(widgetGeometry.left() - delta); +#endif } } } @@ -508,10 +514,12 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE QWidget *w = 0; // Store flags about QWidgetAction here since removeAction() may be called from ~QAction, // in which a qobject_cast<> no longer works. +#if QT_CONFIG(action) if (QWidgetAction *widgetAction = qobject_cast(newAction)) { if ((w = widgetAction->requestWidget(q))) flags |= SideWidgetCreatedByWidgetAction; } +#endif if (!w) { #if QT_CONFIG(toolbutton) QLineEditIconButton *toolButton = new QLineEditIconButton(q); @@ -538,6 +546,7 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE void QLineEditPrivate::removeAction(QAction *action) { +#if QT_CONFIG(action) Q_Q(QLineEdit); const PositionIndexPair positionIndex = findSideWidget(action); if (positionIndex.second == -1) @@ -553,6 +562,7 @@ void QLineEditPrivate::removeAction(QAction *action) if (!hasSideWidgets()) // Last widget, remove connection QObject::disconnect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); q->update(); +#endif // QT_CONFIG(action) } static bool isSideWidgetVisible(const QLineEditPrivate::SideWidgetEntry &e)