diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/Private/ScrollViewHelper.qml | 10 | ||||
-rw-r--r-- | src/controls/Private/TreeViewItemDelegateLoader.qml | 2 | ||||
-rw-r--r-- | src/controls/Private/qquickstyleitem.cpp | 2 | ||||
-rw-r--r-- | src/controls/Private/qquicktreemodeladaptor.cpp | 51 | ||||
-rw-r--r-- | src/controls/Private/qquicktreemodeladaptor_p.h | 5 | ||||
-rw-r--r-- | src/controls/doc/src/qtquickcontrols-examples.qdoc | 6 | ||||
-rw-r--r-- | src/controls/doc/src/qtquickcontrols-tableview.qdoc | 2 | ||||
-rw-r--r-- | src/controls/qquickmenu.cpp | 17 | ||||
-rw-r--r-- | src/controls/qquickmenu_p.h | 2 | ||||
-rw-r--r-- | src/controls/qquickpopupwindow.cpp | 3 | ||||
-rw-r--r-- | src/dialogs/qquickabstractcolordialog.cpp | 6 | ||||
-rw-r--r-- | src/dialogs/qquickabstractcolordialog_p.h | 3 | ||||
-rw-r--r-- | src/dialogs/qquickabstractfontdialog.cpp | 6 | ||||
-rw-r--r-- | src/dialogs/qquickabstractfontdialog_p.h | 3 | ||||
-rw-r--r-- | src/dialogs/qquickcolordialog.cpp | 6 | ||||
-rw-r--r-- | src/dialogs/qquickcolordialog_p.h | 3 | ||||
-rw-r--r-- | src/dialogs/qquickfontdialog.cpp | 6 | ||||
-rw-r--r-- | src/dialogs/qquickfontdialog_p.h | 3 | ||||
-rw-r--r-- | src/dialogs/qquickplatformfontdialog.cpp | 2 |
19 files changed, 106 insertions, 32 deletions
diff --git a/src/controls/Private/ScrollViewHelper.qml b/src/controls/Private/ScrollViewHelper.qml index 066bc6cd..810de91d 100644 --- a/src/controls/Private/ScrollViewHelper.qml +++ b/src/controls/Private/ScrollViewHelper.qml @@ -134,6 +134,11 @@ Item { anchors.right: cornerFill.left anchors.leftMargin: leftMargin anchors.bottomMargin: bottomMargin + onScrollAmountChanged: { + if (flickableItem && (flickableItem.atXBeginning || flickableItem.atXEnd)) { + value = flickableItem.contentX - flickableItem.originX + } + } onValueChanged: { if (!blockUpdates) { flickableItem.contentX = value + flickableItem.originX @@ -183,6 +188,11 @@ Item { anchors.top: parent.top anchors.topMargin: __scrollBarTopMargin + topMargin anchors.rightMargin: rightMargin + onScrollAmountChanged: { + if (flickableItem && (flickableItem.atYBeginning || flickableItem.atYEnd)) { + value = flickableItem.contentY - flickableItem.originY + } + } onValueChanged: { if (flickableItem && !blockUpdates && enabled) { flickableItem.contentY = value + flickableItem.originY diff --git a/src/controls/Private/TreeViewItemDelegateLoader.qml b/src/controls/Private/TreeViewItemDelegateLoader.qml index 4f8b26f6..e19215ed 100644 --- a/src/controls/Private/TreeViewItemDelegateLoader.qml +++ b/src/controls/Private/TreeViewItemDelegateLoader.qml @@ -81,7 +81,7 @@ TableViewItemDelegateLoader { readonly property color textColor: __rowItem ? __rowItem.itemTextColor : "black" readonly property string role: __column ? __column.role : "" readonly property var value: model && model.hasOwnProperty(role) ? model[role] : "" - readonly property var index: __treeModel.mapRowToModelIndex(row) + readonly property var index: model ? model["_q_TreeView_ModelIndex"] : __treeModel.index(-1,-1,null) readonly property int depth: model && column === 0 ? model["_q_TreeView_ItemDepth"] : 0 readonly property bool hasChildren: model ? model["_q_TreeView_HasChildren"] : false readonly property bool hasSibling: model ? model["_q_TreeView_HasSibling"] : false diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index 3fe68230..1d79d634 100644 --- a/src/controls/Private/qquickstyleitem.cpp +++ b/src/controls/Private/qquickstyleitem.cpp @@ -70,7 +70,7 @@ static inline HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &re returned if it can't be obtained. It is the caller's responsibility to CGContextRelease the context when finished using it. - \warning This function is only available on Mac OS X. + \warning This function is only available on \macos. \warning This function is duplicated in qmacstyle_mac.mm */ CGContextRef qt_mac_cg_context(const QPaintDevice *pdev) diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp index 9c0dd71c..26db62a3 100644 --- a/src/controls/Private/qquicktreemodeladaptor.cpp +++ b/src/controls/Private/qquicktreemodeladaptor.cpp @@ -156,6 +156,7 @@ QHash<int, QByteArray> QQuickTreeModelAdaptor1::roleNames() const modelRoleNames.insert(ExpandedRole, "_q_TreeView_ItemExpanded"); modelRoleNames.insert(HasChildrenRole, "_q_TreeView_HasChildren"); modelRoleNames.insert(HasSiblingRole, "_q_TreeView_HasSibling"); + modelRoleNames.insert(ModelIndexRole, "_q_TreeView_ModelIndex"); return modelRoleNames; } @@ -180,6 +181,8 @@ QVariant QQuickTreeModelAdaptor1::data(const QModelIndex &index, int role) const return !(modelIndex.flags() & Qt::ItemNeverHasChildren) && m_model->hasChildren(modelIndex); case HasSiblingRole: return modelIndex.row() != m_model->rowCount(modelIndex.parent()) - 1; + case ModelIndexRole: + return modelIndex; default: return m_model->data(modelIndex, role); } @@ -195,6 +198,7 @@ bool QQuickTreeModelAdaptor1::setData(const QModelIndex &index, const QVariant & case ExpandedRole: case HasChildrenRole: case HasSiblingRole: + case ModelIndexRole: return false; default: { const QModelIndex &pmi = mapToModel(index); @@ -719,8 +723,11 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source destIndex = itemIndex(m_model->index(destinationRow, 0, destinationParent)); } - beginMoveRows(QModelIndex(), startIndex, endIndex, QModelIndex(), destIndex); int totalMovedCount = endIndex - startIndex + 1; + + const bool visibleRowsMoved = startIndex != destIndex && + beginMoveRows(QModelIndex(), startIndex, endIndex, QModelIndex(), destIndex); + const QList<TreeItem> &buffer = m_items.mid(startIndex, totalMovedCount); int bufferCopyOffset; if (destIndex > endIndex) { @@ -729,6 +736,7 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source } bufferCopyOffset = destIndex - totalMovedCount; } else { + // NOTE: we will not enter this loop if startIndex == destIndex for (int i = startIndex - 1; i >= destIndex; i--) { m_items.swap(i, i + totalMovedCount); // Fast move from 1st to 2nd position } @@ -739,14 +747,49 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source item.depth += depthDifference; m_items.replace(bufferCopyOffset + i, item); } - endMoveRows(); + + if (visibleRowsMoved) + endMoveRows(); + + if (depthDifference != 0) { + const QModelIndex &topLeft = index(bufferCopyOffset, 0, QModelIndex()); + const QModelIndex &bottomRight = index(bufferCopyOffset + totalMovedCount - 1, 0, QModelIndex()); + const QVector<int> changedRole(1, DepthRole); + emit dataChanged(topLeft, bottomRight, changedRole); + } } } void QQuickTreeModelAdaptor1::modelRowsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow) { - if (!childrenVisible(sourceParent) && childrenVisible(destinationParent)) - modelRowsInserted(destinationParent, destinationRow, destinationRow + sourceEnd - sourceStart); + if (childrenVisible(destinationParent)) { + if (!childrenVisible(sourceParent)) + modelRowsInserted(destinationParent, destinationRow, destinationRow + sourceEnd - sourceStart); + else { + int destIndex = -1; + if (destinationRow == m_model->rowCount(destinationParent)) { + const QModelIndex &emi = m_model->index(destinationRow - 1, 0, destinationParent); + destIndex = lastChildIndex(emi) + 1; + } else { + destIndex = itemIndex(m_model->index(destinationRow, 0, destinationParent)); + } + + const QModelIndex &emi = m_model->index(destinationRow + sourceEnd - sourceStart, 0, destinationParent); + int endIndex = -1; + if (isExpanded(emi)) { + int rowCount = m_model->rowCount(emi); + if (rowCount > 0) + endIndex = lastChildIndex(m_model->index(rowCount - 1, 0, emi)); + } + if (endIndex == -1) + endIndex = itemIndex(emi); + + const QModelIndex &topLeft = index(destIndex, 0, QModelIndex()); + const QModelIndex &bottomRight = index(endIndex, 0, QModelIndex()); + const QVector<int> changedRole(1, ModelIndexRole); + emit dataChanged(topLeft, bottomRight, changedRole); + } + } ASSERT_CONSISTENCY(); } diff --git a/src/controls/Private/qquicktreemodeladaptor_p.h b/src/controls/Private/qquicktreemodeladaptor_p.h index ddad96cb..e7192314 100644 --- a/src/controls/Private/qquicktreemodeladaptor_p.h +++ b/src/controls/Private/qquicktreemodeladaptor_p.h @@ -77,10 +77,11 @@ public: void resetRootIndex(); enum { - DepthRole = Qt::UserRole - 4, + DepthRole = Qt::UserRole - 5, ExpandedRole, HasChildrenRole, - HasSiblingRole + HasSiblingRole, + ModelIndexRole }; QHash<int, QByteArray> roleNames() const; diff --git a/src/controls/doc/src/qtquickcontrols-examples.qdoc b/src/controls/doc/src/qtquickcontrols-examples.qdoc index 70c8eabb..08f61e10 100644 --- a/src/controls/doc/src/qtquickcontrols-examples.qdoc +++ b/src/controls/doc/src/qtquickcontrols-examples.qdoc @@ -46,7 +46,7 @@ <tr><td style="border:0px"> \endraw \image qtquickcontrols-example-gallery-osx.png - \caption OS X + \caption \macos \raw HTML </td><td style="border:0px"> \endraw @@ -157,7 +157,7 @@ import org.qtproject.example 1.0 \endcode - For more information about registering C++ classses as QML types, see + For more information about registering C++ classes as QML types, see \l {Defining QML Types from C++}. \include examples-run.qdocinc @@ -198,7 +198,7 @@ import org.qtproject.example 1.0 \endcode - For more information about registering C++ classses as QML types, see + For more information about registering C++ classes as QML types, see \l {Defining QML Types from C++}. \include examples-run.qdocinc diff --git a/src/controls/doc/src/qtquickcontrols-tableview.qdoc b/src/controls/doc/src/qtquickcontrols-tableview.qdoc index cf86174a..ba16b115 100644 --- a/src/controls/doc/src/qtquickcontrols-tableview.qdoc +++ b/src/controls/doc/src/qtquickcontrols-tableview.qdoc @@ -243,7 +243,7 @@ \endcode \b Example: To iterate over selected indexes, you can pass a callback function. - \a rowIndex is passed as as an argument to the callback function. + \a rowIndex is passed as an argument to the callback function. \code tableview.selection.forEach( function(rowIndex) {console.log(rowIndex)} ) \endcode diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp index ddb25790..67682ad3 100644 --- a/src/controls/qquickmenu.cpp +++ b/src/controls/qquickmenu.cpp @@ -442,6 +442,10 @@ void QQuickMenu1::__popup(const QRectF &targetRect, int atItemIndex, MenuType me // parentWindow may not be a QQuickWindow (happens when using QQuickWidget) if (m_platformMenu) { + if (m_windowConnection) + QObject::disconnect(m_windowConnection); + m_windowConnection = connect(parentWindow, &QWindow::visibleChanged, this, + &QQuickMenu1::platformMenuWindowVisibleChanged, Qt::UniqueConnection); QRectF globalTargetRect = targetRect.translated(m_xOffset, m_yOffset); if (visualItem()) { if (qGuiApp->isRightToLeft()) { @@ -571,6 +575,19 @@ void QQuickMenu1::windowVisibleChanged(bool v) } } +void QQuickMenu1::platformMenuWindowVisibleChanged(bool visible) +{ + if (!visible) { + if (m_windowConnection) { + QObject::disconnect(m_windowConnection); + m_windowConnection = QMetaObject::Connection(); + } + if (m_platformMenu) { + m_platformMenu->dismiss(); + } + } +} + void QQuickMenu1::clearPopupWindow() { m_popupWindow = 0; diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h index a8a14c5a..800981dd 100644 --- a/src/controls/qquickmenu_p.h +++ b/src/controls/qquickmenu_p.h @@ -168,6 +168,7 @@ protected Q_SLOTS: void updateText(); void windowVisibleChanged(bool); + void platformMenuWindowVisibleChanged(bool); private: QQuickWindow *findParentWindow(); @@ -208,6 +209,7 @@ private: QFont m_font; int m_triggerCount; bool m_proxy; + QMetaObject::Connection m_windowConnection; }; QT_END_NAMESPACE diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp index 6d87ac47..9a6519ed 100644 --- a/src/controls/qquickpopupwindow.cpp +++ b/src/controls/qquickpopupwindow.cpp @@ -227,7 +227,8 @@ void QQuickPopupWindow1::hideEvent(QHideEvent *e) { if (QWindow *tp = !m_needsActivatedEvent ? transientParent() : 0) { m_needsActivatedEvent = true; - QWindowSystemInterface::handleWindowActivated(tp); + if (tp->isVisible()) + QWindowSystemInterface::handleWindowActivated(tp); } QQuickWindow::hideEvent(e); diff --git a/src/dialogs/qquickabstractcolordialog.cpp b/src/dialogs/qquickabstractcolordialog.cpp index ee9e4023..a558b12c 100644 --- a/src/dialogs/qquickabstractcolordialog.cpp +++ b/src/dialogs/qquickabstractcolordialog.cpp @@ -124,4 +124,10 @@ void QQuickAbstractColorDialog::setShowAlphaChannel(bool arg) emit showAlphaChannelChanged(); } +void QQuickAbstractColorDialog::accept() +{ + setColor(m_currentColor); + QQuickAbstractDialog::accept(); +} + QT_END_NAMESPACE diff --git a/src/dialogs/qquickabstractcolordialog_p.h b/src/dialogs/qquickabstractcolordialog_p.h index 99be766c..16b39c26 100644 --- a/src/dialogs/qquickabstractcolordialog_p.h +++ b/src/dialogs/qquickabstractcolordialog_p.h @@ -96,6 +96,9 @@ Q_SIGNALS: void currentColorChanged(); void selectionAccepted(); +protected Q_SLOTS: + virtual void accept(); + protected: QPlatformColorDialogHelper *m_dlgHelper; QSharedPointer<QColorDialogOptions> m_options; diff --git a/src/dialogs/qquickabstractfontdialog.cpp b/src/dialogs/qquickabstractfontdialog.cpp index 9b0f0ec6..f94a36a0 100644 --- a/src/dialogs/qquickabstractfontdialog.cpp +++ b/src/dialogs/qquickabstractfontdialog.cpp @@ -154,4 +154,10 @@ void QQuickAbstractFontDialog::setProportionalFonts(bool arg) emit proportionalFontsChanged(); } +void QQuickAbstractFontDialog::accept() +{ + setFont(m_currentFont); + QQuickAbstractDialog::accept(); +} + QT_END_NAMESPACE diff --git a/src/dialogs/qquickabstractfontdialog_p.h b/src/dialogs/qquickabstractfontdialog_p.h index 3162be2a..f60c4ddb 100644 --- a/src/dialogs/qquickabstractfontdialog_p.h +++ b/src/dialogs/qquickabstractfontdialog_p.h @@ -101,6 +101,9 @@ Q_SIGNALS: void currentFontChanged(); void selectionAccepted(); +protected Q_SLOTS: + virtual void accept(); + protected: QPlatformFontDialogHelper *m_dlgHelper; QSharedPointer<QFontDialogOptions> m_options; diff --git a/src/dialogs/qquickcolordialog.cpp b/src/dialogs/qquickcolordialog.cpp index 875c6740..686bd850 100644 --- a/src/dialogs/qquickcolordialog.cpp +++ b/src/dialogs/qquickcolordialog.cpp @@ -118,10 +118,4 @@ QQuickColorDialog::~QQuickColorDialog() \l Window or an \l Item. */ -void QQuickColorDialog::accept() -{ - setColor(m_currentColor); - QQuickAbstractColorDialog::accept(); -} - QT_END_NAMESPACE diff --git a/src/dialogs/qquickcolordialog_p.h b/src/dialogs/qquickcolordialog_p.h index d3c3463b..619b7b10 100644 --- a/src/dialogs/qquickcolordialog_p.h +++ b/src/dialogs/qquickcolordialog_p.h @@ -65,9 +65,6 @@ public: explicit QQuickColorDialog(QObject *parent = 0); ~QQuickColorDialog(); -protected Q_SLOTS: - virtual void accept(); - protected: virtual QPlatformColorDialogHelper *helper() { return 0; } diff --git a/src/dialogs/qquickfontdialog.cpp b/src/dialogs/qquickfontdialog.cpp index 0e27d29a..00acf238 100644 --- a/src/dialogs/qquickfontdialog.cpp +++ b/src/dialogs/qquickfontdialog.cpp @@ -119,10 +119,4 @@ QQuickFontDialog::~QQuickFontDialog() \l Window or an \l Item. */ -void QQuickFontDialog::accept() -{ - setFont(m_currentFont); - QQuickAbstractFontDialog::accept(); -} - QT_END_NAMESPACE diff --git a/src/dialogs/qquickfontdialog_p.h b/src/dialogs/qquickfontdialog_p.h index 71301a76..bd04f536 100644 --- a/src/dialogs/qquickfontdialog_p.h +++ b/src/dialogs/qquickfontdialog_p.h @@ -65,9 +65,6 @@ public: explicit QQuickFontDialog(QObject *parent = 0); ~QQuickFontDialog(); -protected Q_SLOTS: - virtual void accept(); - protected: virtual QPlatformFontDialogHelper *helper() { return 0; } diff --git a/src/dialogs/qquickplatformfontdialog.cpp b/src/dialogs/qquickplatformfontdialog.cpp index 247e869e..2c501a1c 100644 --- a/src/dialogs/qquickplatformfontdialog.cpp +++ b/src/dialogs/qquickplatformfontdialog.cpp @@ -170,7 +170,7 @@ QPlatformFontDialogHelper *QQuickPlatformFontDialog::helper() return m_dlgHelper; connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept())); connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject())); - connect(m_dlgHelper, SIGNAL(currentFontChanged(QFont)), this, SLOT(setFont(QFont))); + connect(m_dlgHelper, SIGNAL(currentFontChanged(QFont)), this, SLOT(setCurrentFont(QFont))); connect(m_dlgHelper, SIGNAL(fontSelected(QFont)), this, SLOT(setFont(QFont))); } |