diff options
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickapplicationwindow.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 17 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcontainer.cpp | 25 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcontainer_p_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdeferredexecute.cpp | 5 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdialogbuttonbox.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 18 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenu.cpp | 59 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenu_p_p.h | 3 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenubar.cpp | 41 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenubar_p.h | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenubar_p_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenuseparator.cpp | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpage.cpp | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopuppositioner.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickslider.cpp | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktextfield.cpp | 16 |
18 files changed, 79 insertions, 132 deletions
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index f5d80fb9..acd98470 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE \image qtquickcontrols2-applicationwindow-wireframe.png \qml - import QtQuick.Controls 2.3 + import QtQuick.Controls 2.12 ApplicationWindow { visible: true diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 77abee07..ffdb7cc2 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -41,7 +41,7 @@ #include "qquickpopup_p_p.h" #include "qquickdeferredexecute_p_p.h" -#include <QtCore/qregexp.h> +#include <QtCore/qregularexpression.h> #include <QtCore/qabstractitemmodel.h> #include <QtGui/qinputmethod.h> #include <QtGui/qguiapplication.h> @@ -573,6 +573,8 @@ int QQuickComboBoxPrivate::match(int start, const QString &text, Qt::MatchFlags uint matchType = flags & 0x0F; bool wrap = flags & Qt::MatchWrap; Qt::CaseSensitivity cs = flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive; + QRegularExpression::PatternOptions options = flags & Qt::MatchCaseSensitive ? QRegularExpression::NoPatternOption + : QRegularExpression::CaseInsensitiveOption; int from = start; int to = q->count(); @@ -585,14 +587,19 @@ int QQuickComboBoxPrivate::match(int start, const QString &text, Qt::MatchFlags if (t == text) return idx; break; - case Qt::MatchRegExp: - if (QRegExp(text, cs).exactMatch(t)) + case Qt::MatchRegExp: { + QRegularExpression rx(QRegularExpression::anchoredPattern(text), options); + if (rx.match(t).hasMatch()) return idx; break; - case Qt::MatchWildcard: - if (QRegExp(text, cs, QRegExp::Wildcard).exactMatch(t)) + } + case Qt::MatchWildcard: { + QRegularExpression rx(QRegularExpression::wildcardToRegularExpression(text), + options); + if (rx.match(t).hasMatch()) return idx; break; + } case Qt::MatchStartsWith: if (t.startsWith(text, cs)) return idx; diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp index 8217a3ff..c4af6151 100644 --- a/src/quicktemplates2/qquickcontainer.cpp +++ b/src/quicktemplates2/qquickcontainer.cpp @@ -336,21 +336,6 @@ void QQuickContainerPrivate::reorderItems() } } -// Helper function needed for derived classes such as QQuickMenuBarPrivate. -void QQuickContainerPrivate::addObject(QObject *obj) -{ - Q_Q(QQuickContainer); - QQuickItem *item = qobject_cast<QQuickItem *>(obj); - if (item) { - if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) - item->setParentItem(effectiveContentItem(contentItem)); - else if (contentModel->indexOf(item, nullptr) == -1) - q->addItem(item); - } else { - contentData.append(obj); - } -} - void QQuickContainerPrivate::_q_currentIndexChanged() { Q_Q(QQuickContainer); @@ -394,7 +379,15 @@ void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop, { QQuickContainer *q = static_cast<QQuickContainer *>(prop->object); QQuickContainerPrivate *p = QQuickContainerPrivate::get(q); - p->addObject(obj); + QQuickItem *item = qobject_cast<QQuickItem *>(obj); + if (item) { + if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) + item->setParentItem(effectiveContentItem(p->contentItem)); + else if (p->contentModel->indexOf(item, nullptr) == -1) + q->addItem(item); + } else { + p->contentData.append(obj); + } } int QQuickContainerPrivate::contentData_count(QQmlListProperty<QObject> *prop) diff --git a/src/quicktemplates2/qquickcontainer_p_p.h b/src/quicktemplates2/qquickcontainer_p_p.h index 5ddf298a..16e9c9f6 100644 --- a/src/quicktemplates2/qquickcontainer_p_p.h +++ b/src/quicktemplates2/qquickcontainer_p_p.h @@ -73,8 +73,6 @@ public: void removeItem(int index, QQuickItem *item); void reorderItems(); - void addObject(QObject *obj); - void _q_currentIndexChanged(); void itemChildAdded(QQuickItem *item, QQuickItem *child) override; diff --git a/src/quicktemplates2/qquickdeferredexecute.cpp b/src/quicktemplates2/qquickdeferredexecute.cpp index b298a81d..800dcedb 100644 --- a/src/quicktemplates2/qquickdeferredexecute.cpp +++ b/src/quicktemplates2/qquickdeferredexecute.cpp @@ -76,8 +76,9 @@ static bool beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &pro for (auto dit = ddata->deferredData.rbegin(); dit != ddata->deferredData.rend(); ++dit) { QQmlData::DeferredData *deferData = *dit; - auto range = deferData->bindings.equal_range(propertyIndex); - if (range.first == deferData->bindings.end()) + auto bindings = deferData->bindings; + auto range = bindings.equal_range(propertyIndex); + if (range.first == bindings.end()) continue; QQmlComponentPrivate::ConstructionState *state = new QQmlComponentPrivate::ConstructionState; diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index 03f5f8e8..8559ad15 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -241,8 +241,11 @@ void QQuickDialogButtonBoxPrivate::resizeContent() return; QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding()); - if (alignment != 0) - geometry = alignedRect(q->isMirrored() ? Qt::RightToLeft : Qt::LeftToRight, alignment, QSizeF(contentWidth, contentHeight), geometry); + if (alignment != 0) { + qreal cw = (alignment & Qt::AlignHorizontal_Mask) == 0 ? q->availableWidth() : contentItem->property("contentWidth").toReal(); + qreal ch = (alignment & Qt::AlignVertical_Mask) == 0 ? q->availableHeight() : contentItem->property("contentHeight").toReal(); + geometry = alignedRect(q->isMirrored() ? Qt::RightToLeft : Qt::LeftToRight, alignment, QSizeF(cw, ch), geometry); + } contentItem->setPosition(geometry.topLeft()); contentItem->setSize(geometry.size()); diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index f2d74b31..95b27512 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -68,9 +68,9 @@ QT_BEGIN_NAMESPACE drawer is then opened by \e "dragging" it out from the left edge of the window. - \code - import QtQuick 2.7 - import QtQuick.Controls 2.0 + \code \QtMinorVersion + import QtQuick 2.\1 + import QtQuick.Controls 2.\1 ApplicationWindow { id: window @@ -98,9 +98,9 @@ QT_BEGIN_NAMESPACE Drawer can be configured to cover only part of its window edge. The following example illustrates how Drawer can be positioned to appear below a window header: - \code - import QtQuick 2.7 - import QtQuick.Controls 2.0 + \code \QtMinorVersion + import QtQuick 2.\1 + import QtQuick.Controls 2.\1 ApplicationWindow { id: window @@ -124,9 +124,9 @@ QT_BEGIN_NAMESPACE In the image above, the application's contents are \e "pushed" across the screen. This is achieved by applying a translation to the contents: - \code - import QtQuick 2.7 - import QtQuick.Controls 2.1 + \code \QtMinorVersion + import QtQuick 2.\1 + import QtQuick.Controls 2.\1 ApplicationWindow { id: window diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 7086db91..f52405c9 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -251,41 +251,6 @@ void QQuickMenuPrivate::removeItem(int index, QQuickItem *item) } } -void QQuickMenuPrivate::createAndAppendItem(QObject *object) -{ - Q_Q(QQuickMenu); - QQuickItem *item = qobject_cast<QQuickItem *>(object); - if (!item) { - if (QQuickAction *action = qobject_cast<QQuickAction *>(object)) - item = createItem(action); - else if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(object)) - item = createItem(menu); - } - - if (item) { - if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) { - QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder); - item->setParentItem(contentItem); - } else if (contentModel->indexOf(item, nullptr) == -1) { - q->addItem(item); - } - } else { - contentData.append(object); - } -} - -void QQuickMenuPrivate::recreateItems() -{ - // removeItem() will remove stuff from contentData, so we have to make a copy of it. - const auto originalContentData = contentData; - - while (contentModel->count() > 0) - removeItem(0, itemAt(0)); - - for (QObject *object : originalContentData) - createAndAppendItem(object); -} - QQuickItem *QQuickMenuPrivate::beginCreateItem() { Q_Q(QQuickMenu); @@ -661,14 +626,24 @@ void QQuickMenuPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObj QQuickMenu *q = qobject_cast<QQuickMenu *>(prop->object); QQuickMenuPrivate *p = QQuickMenuPrivate::get(q); - if (!p->complete) { - // Don't add items until we're complete, as the delegate could change in the meantime. - // We'll add it to contentData and create it when we're complete. - p->contentData.append(obj); - return; + QQuickItem *item = qobject_cast<QQuickItem *>(obj); + if (!item) { + if (QQuickAction *action = qobject_cast<QQuickAction *>(obj)) + item = p->createItem(action); + else if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj)) + item = p->createItem(menu); } - p->createAndAppendItem(obj); + if (item) { + if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) { + QQuickItemPrivate::get(item)->addItemChangeListener(p, QQuickItemPrivate::SiblingOrder); + item->setParentItem(p->contentItem); + } else if (p->contentModel->indexOf(item, nullptr) == -1) { + q->addItem(item); + } + } else { + p->contentData.append(obj); + } } int QQuickMenuPrivate::contentData_count(QQmlListProperty<QObject> *prop) @@ -1381,7 +1356,7 @@ void QQuickMenu::componentComplete() { Q_D(QQuickMenu); QQuickPopup::componentComplete(); - d->recreateItems(); + d->resizeItems(); } void QQuickMenu::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h index c0bb2702..6146b960 100644 --- a/src/quicktemplates2/qquickmenu_p_p.h +++ b/src/quicktemplates2/qquickmenu_p_p.h @@ -78,9 +78,6 @@ public: void moveItem(int from, int to); void removeItem(int index, QQuickItem *item); - void createAndAppendItem(QObject *object); - void recreateItems(); - QQuickItem *beginCreateItem(); void completeCreateItem(); diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp index 62205b6e..6016e70d 100644 --- a/src/quicktemplates2/qquickmenubar.cpp +++ b/src/quicktemplates2/qquickmenubar.cpp @@ -76,25 +76,6 @@ QT_BEGIN_NAMESPACE {Focus Management in Qt Quick Controls 2} */ -void QQuickMenuBarPrivate::createItems() -{ - // removeItem() will remove stuff from contentData, so we have to make a copy of it. - const auto originalContentData = QQuickContainerPrivate::contentData; - // Sanity check that there aren't any items we don't know about. - Q_ASSERT(contentModel->count() == 0); - - for (QObject *object : originalContentData) { - if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(object)) { - // It's a QQuickMenu; create a QQuickMenuBarItem for it. - QQuickItem *menuItem = createItem(menu); - addObject(menuItem); - } else if (qobject_cast<QQuickMenuBarItem *>(object)) { - addObject(object); - } - // If it's neither, skip it because we don't care about it. - } -} - QQuickItem *QQuickMenuBarPrivate::beginCreateItem() { Q_Q(QQuickMenuBar); @@ -273,18 +254,9 @@ void QQuickMenuBarPrivate::itemImplicitHeightChanged(QQuickItem *item) void QQuickMenuBarPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObject *obj) { QQuickMenuBar *menuBar = static_cast<QQuickMenuBar *>(prop->object); - QQuickMenuBarPrivate *menuBarPrivate = QQuickMenuBarPrivate::get(menuBar); - if (!menuBarPrivate->componentComplete) { - // Don't add items until we're complete, as the delegate could change in the meantime. - // We'll add it to contentData and create it when we're complete. - menuBarPrivate->QQuickContainerPrivate::contentData.append(obj); - return; - } - - if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj)) { - QQuickItem *menuItem = menuBarPrivate->createItem(menu); - menuBarPrivate->addObject(menuItem); - } + if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj)) + obj = QQuickMenuBarPrivate::get(menuBar)->createItem(menu); + QQuickContainerPrivate::contentData_append(prop, obj); } void QQuickMenuBarPrivate::menus_append(QQmlListProperty<QQuickMenu> *prop, QQuickMenu *obj) @@ -482,13 +454,6 @@ QQmlListProperty<QObject> QQuickMenuBarPrivate::contentData() QQuickContainerPrivate::contentData_clear); } -void QQuickMenuBar::componentComplete() -{ - Q_D(QQuickMenuBar); - QQuickContainer::componentComplete(); - d->createItems(); -} - bool QQuickMenuBar::eventFilter(QObject *object, QEvent *event) { return QObject::eventFilter(object, event); diff --git a/src/quicktemplates2/qquickmenubar_p.h b/src/quicktemplates2/qquickmenubar_p.h index 983bb578..af37d0f2 100644 --- a/src/quicktemplates2/qquickmenubar_p.h +++ b/src/quicktemplates2/qquickmenubar_p.h @@ -81,7 +81,6 @@ Q_SIGNALS: void menusChanged(); protected: - void componentComplete() override; bool eventFilter(QObject *object, QEvent *event) override; void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; diff --git a/src/quicktemplates2/qquickmenubar_p_p.h b/src/quicktemplates2/qquickmenubar_p_p.h index 4d5e61e6..75fbed73 100644 --- a/src/quicktemplates2/qquickmenubar_p_p.h +++ b/src/quicktemplates2/qquickmenubar_p_p.h @@ -69,8 +69,6 @@ public: QQmlListProperty<QQuickMenu> menus(); QQmlListProperty<QObject> contentData(); - void createItems(); - QQuickItem *beginCreateItem(); void completeCreateItem(); diff --git a/src/quicktemplates2/qquickmenuseparator.cpp b/src/quicktemplates2/qquickmenuseparator.cpp index 0e2ed9e3..f6b8c4b2 100644 --- a/src/quicktemplates2/qquickmenuseparator.cpp +++ b/src/quicktemplates2/qquickmenuseparator.cpp @@ -54,8 +54,8 @@ QT_BEGIN_NAMESPACE \image qtquickcontrols2-menuseparator.png \quotefromfile qtquickcontrols2-menuseparator-custom.qml - \skipto import QtQuick 2.6 - \printuntil import QtQuick.Controls 2.1 + \skipto import QtQuick + \printuntil import QtQuick.Controls \skipto Menu \printto contentItem.parent: window \skipline contentItem.parent: window diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index 93196c4c..56034297 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE toolbar header and an application-wide tabbar footer. \qml - import QtQuick.Controls 2.1 + import QtQuick.Controls 2.12 ApplicationWindow { visible: true @@ -344,7 +344,7 @@ void QQuickPage::setFooter(QQuickItem *footer) if (d->footer) { QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, LayoutChanges); - footer->setParentItem(nullptr); + d->footer->setParentItem(nullptr); } d->footer = footer; if (footer) { diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index d5e2c940..dcced8dc 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE \qml import QtQuick.Window 2.2 - import QtQuick.Controls 2.1 + import QtQuick.Controls 2.12 ApplicationWindow { id: window diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp index ebd8ff29..69a57674 100644 --- a/src/quicktemplates2/qquickpopuppositioner.cpp +++ b/src/quicktemplates2/qquickpopuppositioner.cpp @@ -300,7 +300,7 @@ void QQuickPopupPositioner::addAncestorListeners(QQuickItem *item) QQuickItem *p = item; while (p) { - QQuickItemPrivate::get(p)->updateOrAddItemChangeListener(this, AncestorChangeTypes); + QQuickItemPrivate::get(p)->addItemChangeListener(this, AncestorChangeTypes); p = p->parentItem(); } } diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 179dcb64..054ea502 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -848,7 +848,6 @@ void QQuickSlider::wheelEvent(QWheelEvent *event) const bool wasMoved = !qFuzzyCompare(d->value, oldValue); if (wasMoved) emit moved(); - event->setAccepted(wasMoved); } } #endif diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index 15acfeb6..56ffc52f 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -184,13 +184,20 @@ void QQuickTextFieldPrivate::resizeBackground() QQuickItemPrivate *p = QQuickItemPrivate::get(background); if (((!p->widthValid || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x())) || (extra.isAllocated() && (extra->hasLeftInset || extra->hasRightInset))) { + const bool wasWidthValid = p->widthValid; background->setX(getLeftInset()); background->setWidth(width - getLeftInset() - getRightInset()); + // If the user hadn't previously set the width, that shouldn't change when we set it for them. + if (!wasWidthValid) + p->widthValid = false; } if (((!p->heightValid || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y())) || (extra.isAllocated() && (extra->hasTopInset || extra->hasBottomInset))) { + const bool wasHeightValid = p->heightValid; background->setY(getTopInset()); background->setHeight(height - getTopInset() - getBottomInset()); + if (!wasHeightValid) + p->heightValid = false; } resizingBackground = false; @@ -386,8 +393,13 @@ void QQuickTextFieldPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometr return; QQuickItemPrivate *p = QQuickItemPrivate::get(item); - extra.value().hasBackgroundWidth = p->widthValid; - extra.value().hasBackgroundHeight = p->heightValid; + // QTBUG-71875: only allocate the extra data if we have to. + // resizeBackground() relies on the value of extra.isAllocated() + // as part of its checks to see whether it should resize the background or not. + if (p->widthValid || extra.isAllocated()) + extra.value().hasBackgroundWidth = p->widthValid; + if (p->heightValid || extra.isAllocated()) + extra.value().hasBackgroundHeight = p->heightValid; resizeBackground(); } |