summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-07-22 18:21:04 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-07-22 18:29:57 +0000
commit34acf65f27578e819356eda48e7c597850d06fd6 (patch)
tree6929d2b1233c1ffd5070b2862d2c58f8cce32c15
parenta4307189203f95a5094f55c239cb1f19f89766a1 (diff)
parent940c7a154ebf42735d51038e71601c0263ac06df (diff)
downloadqtquickcontrols-34acf65f27578e819356eda48e7c597850d06fd6.tar.gz
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
-rw-r--r--examples/quick/controls/filesystembrowser/main.cpp87
-rw-r--r--examples/quick/controls/filesystembrowser/main.qml16
-rw-r--r--src/controls/MenuBar.qml6
-rw-r--r--src/controls/Private/MenuContentItem.qml16
-rw-r--r--src/controls/Private/qquicktreemodeladaptor.cpp14
-rw-r--r--src/controls/Private/qquicktreemodeladaptor_p.h6
-rw-r--r--src/controls/Styles/Android/CursorHandleStyle.qml1
-rw-r--r--src/controls/Styles/Base/TumblerStyle.qml2
-rw-r--r--src/controls/Styles/Desktop/MenuBarStyle.qml5
-rw-r--r--src/controls/Styles/Desktop/MenuStyle.qml5
-rw-r--r--src/controls/TreeView.qml58
-rw-r--r--src/controls/qquickmenupopupwindow.cpp11
-rw-r--r--src/controls/qquickpopupwindow_p.h6
-rw-r--r--src/dialogs/qquickfiledialog_p.h4
-rw-r--r--src/dialogs/qquickplatformfiledialog_p.h2
-rw-r--r--src/extras/TumblerColumn.qml2
-rw-r--r--src/extras/doc/src/qtquickextras-index.qdoc2
-rw-r--r--src/widgets/qquickqfiledialog_p.h2
-rw-r--r--tests/auto/controls/data/tst_treeview.qml29
-rw-r--r--tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp35
-rw-r--r--tests/auto/shared/testmodel.h4
21 files changed, 243 insertions, 70 deletions
diff --git a/examples/quick/controls/filesystembrowser/main.cpp b/examples/quick/controls/filesystembrowser/main.cpp
index e64a9a22..176d334c 100644
--- a/examples/quick/controls/filesystembrowser/main.cpp
+++ b/examples/quick/controls/filesystembrowser/main.cpp
@@ -42,13 +42,98 @@
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QFileSystemModel>
+#include <QDateTime>
+#include <QDesktopServices>
+#include <QUrl>
+
+static inline QString permissionString(const QFileInfo &fi)
+{
+ const QFile::Permissions permissions = fi.permissions();
+ QString result = QLatin1String("----------");
+ if (fi.isSymLink())
+ result[0] = QLatin1Char('l');
+ else if (fi.isDir())
+ result[0] = QLatin1Char('d');
+ if (permissions & QFileDevice::ReadUser)
+ result[1] = QLatin1Char('r');
+ if (permissions & QFileDevice::WriteUser)
+ result[2] = QLatin1Char('w');
+ if (permissions & QFileDevice::ExeUser)
+ result[3] = QLatin1Char('x');
+ if (permissions & QFileDevice::ReadGroup)
+ result[4] = QLatin1Char('r');
+ if (permissions & QFileDevice::WriteGroup)
+ result[5] = QLatin1Char('w');
+ if (permissions & QFileDevice::ExeGroup)
+ result[6] = QLatin1Char('x');
+ if (permissions & QFileDevice::ReadOther)
+ result[7] = QLatin1Char('r');
+ if (permissions & QFileDevice::WriteOther)
+ result[8] = QLatin1Char('w');
+ if (permissions & QFileDevice::ExeOther)
+ result[9] = QLatin1Char('x');
+ return result;
+}
+
+static inline QString sizeString(const QFileInfo &fi)
+{
+ if (!fi.isFile())
+ return QString();
+ const qint64 size = fi.size();
+ if (size > 1024 * 1024 * 10)
+ return QString::number(size / (1024 * 1024)) + QLatin1Char('M');
+ if (size > 1024 * 10)
+ return QString::number(size / 1024) + QLatin1Char('K');
+ return QString::number(size);
+}
+
+class DisplayFileSystemModel : public QFileSystemModel {
+public:
+ explicit DisplayFileSystemModel(QObject *parent = Q_NULLPTR)
+ : QFileSystemModel(parent) {}
+
+ enum {
+ SizeRole = Qt::UserRole + 4,
+ DisplayableFilePermissionsRole = Qt::UserRole + 5,
+ LastModifiedRole = Qt::UserRole + 6,
+ UrlStringRole = Qt::UserRole + 7 // 263
+ };
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE
+ {
+ if (index.isValid() && role >= SizeRole) {
+ switch (role) {
+ case SizeRole:
+ return QVariant(sizeString(fileInfo(index)));
+ case DisplayableFilePermissionsRole:
+ return QVariant(permissionString(fileInfo(index)));
+ case LastModifiedRole:
+ return QVariant(fileInfo(index).lastModified().toString(Qt::SystemLocaleShortDate));
+ case UrlStringRole:
+ return QVariant(QUrl::fromLocalFile(filePath(index)).toString());
+ default:
+ break;
+ }
+ }
+ return QFileSystemModel::data(index, role);
+ }
+
+ QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE
+ {
+ QHash<int, QByteArray> result = QFileSystemModel::roleNames();
+ result.insert(SizeRole, QByteArrayLiteral("size"));
+ result.insert(DisplayableFilePermissionsRole, QByteArrayLiteral("displayableFilePermissions"));
+ result.insert(LastModifiedRole, QByteArrayLiteral("lastModified"));
+ return result;
+ }
+};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
- QFileSystemModel *fsm = new QFileSystemModel(&engine);
+ QFileSystemModel *fsm = new DisplayFileSystemModel(&engine);
fsm->setRootPath(QDir::homePath());
fsm->setResolveSymlinks(true);
engine.rootContext()->setContextProperty("fileSystemModel", fsm);
diff --git a/examples/quick/controls/filesystembrowser/main.qml b/examples/quick/controls/filesystembrowser/main.qml
index 454a9f31..abc3c20c 100644
--- a/examples/quick/controls/filesystembrowser/main.qml
+++ b/examples/quick/controls/filesystembrowser/main.qml
@@ -99,11 +99,25 @@ ApplicationWindow {
}
TableViewColumn {
+ title: "Size"
+ role: "size"
+ resizable: true
+ horizontalAlignment : Text.AlignRight
+ }
+
+ TableViewColumn {
title: "Permissions"
- role: "filePermissions"
+ role: "displayableFilePermissions"
+ resizable: true
+ }
+
+ TableViewColumn {
+ title: "Date Modified"
+ role: "lastModified"
resizable: true
}
onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index)
+ onActivated : Qt.openUrlExternally(fileSystemModel.data(index, 263))
}
}
diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml
index 3410528c..0d9f8ee8 100644
--- a/src/controls/MenuBar.qml
+++ b/src/controls/MenuBar.qml
@@ -116,6 +116,7 @@ MenuBarPrivate {
property Component __menuBarComponent: Loader {
id: menuBarLoader
+ Accessible.role: Accessible.MenuBar
onStatusChanged: if (status === Loader.Error) console.error("Failed to load panel for", root)
@@ -230,7 +231,12 @@ MenuBarPrivate {
Loader {
id: menuItemLoader
+ Accessible.role: Accessible.MenuItem
+ Accessible.name: StyleHelpers.removeMnemonics(opts.text)
+ Accessible.onPressAction: d.openedMenuIndex = opts.index
+
property var styleData: QtObject {
+ id: opts
readonly property int index: __menuItemIndex
readonly property string text: !!__menuItem && __menuItem.title
readonly property bool enabled: !!__menuItem && __menuItem.enabled
diff --git a/src/controls/Private/MenuContentItem.qml b/src/controls/Private/MenuContentItem.qml
index 6006f8d8..07edea2f 100644
--- a/src/controls/Private/MenuContentItem.qml
+++ b/src/controls/Private/MenuContentItem.qml
@@ -37,12 +37,15 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.1
+import QtQuick.Controls.Private 1.0
Loader {
id: menuFrameLoader
property var __menu
+ Accessible.role: Accessible.PopupMenu
+
visible: status === Loader.Ready
width: content.width + (d.style ? d.style.padding.left + d.style.padding.right : 0)
height: content.height + (d.style ? d.style.padding.top + d.style.padding.bottom : 0)
@@ -172,6 +175,19 @@ Loader {
Loader {
id: menuItemLoader
+ Accessible.role: opts.type === MenuItemType.Item || opts.type === MenuItemType.Menu ?
+ Accessible.MenuItem : Acccessible.NoRole
+ Accessible.name: StyleHelpers.removeMnemonics(opts.text)
+ Accessible.checkable: opts.checkable
+ Accessible.checked: opts.checked
+ Accessible.onPressAction: {
+ if (opts.type === MenuItemType.Item) {
+ d.triggerAndDismiss(menuItemLoader)
+ } else if (opts.type === MenuItemType.Menu) {
+ __showSubMenu(true /*immediately*/)
+ }
+ }
+
property QtObject styleData: QtObject {
id: opts
readonly property int index: __menuItemIndex
diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp
index c9e31712..dddcdd01 100644
--- a/src/controls/Private/qquicktreemodeladaptor.cpp
+++ b/src/controls/Private/qquicktreemodeladaptor.cpp
@@ -177,7 +177,7 @@ bool QQuickTreeModelAdaptor::setData(const QModelIndex &index, const QVariant &v
}
}
-int QQuickTreeModelAdaptor::itemIndex(const QModelIndex &index)
+int QQuickTreeModelAdaptor::itemIndex(const QModelIndex &index) const
{
// This is basically a plagiarism of QTreeViewPrivate::viewIndex()
if (!index.isValid() || m_items.isEmpty())
@@ -244,11 +244,15 @@ QModelIndex QQuickTreeModelAdaptor::mapRowToModelIndex(int row) const
return m_items.at(row).index;
}
-QItemSelection QQuickTreeModelAdaptor::selectionForRowRange(int from, int to) const
+QItemSelection QQuickTreeModelAdaptor::selectionForRowRange(const QModelIndex &fromIndex, const QModelIndex &toIndex) const
{
- Q_ASSERT(0 <= from && from < m_items.count());
- Q_ASSERT(0 <= to && to < m_items.count());
-
+ int from = itemIndex(fromIndex);
+ int to = itemIndex(toIndex);
+ if (from == -1) {
+ if (to == -1)
+ return QItemSelection();
+ return QItemSelection(toIndex, toIndex);
+ }
if (from > to)
qSwap(from, to);
diff --git a/src/controls/Private/qquicktreemodeladaptor_p.h b/src/controls/Private/qquicktreemodeladaptor_p.h
index 8059f681..2297c365 100644
--- a/src/controls/Private/qquicktreemodeladaptor_p.h
+++ b/src/controls/Private/qquicktreemodeladaptor_p.h
@@ -89,12 +89,12 @@ public:
const QModelIndex &mapToModel(const QModelIndex &index) const;
Q_INVOKABLE QModelIndex mapRowToModelIndex(int row) const;
- Q_INVOKABLE QItemSelection selectionForRowRange(int from, int to) const;
+ Q_INVOKABLE QItemSelection selectionForRowRange(const QModelIndex &fromIndex, const QModelIndex &toIndex) const;
void showModelTopLevelItems(bool doInsertRows = true);
void showModelChildItems(const TreeItem &parent, int start, int end, bool doInsertRows = true, bool doExpandPendingRows = true);
- int itemIndex(const QModelIndex &index);
+ int itemIndex(const QModelIndex &index) const;
void expandPendingRows(bool doInsertRows = true);
int lastChildIndex(const QModelIndex &index);
void removeVisibleRows(int startIndex, int endIndex, bool doRemoveRows = true);
@@ -152,7 +152,7 @@ private:
QList<TreeItem> m_items;
QSet<QPersistentModelIndex> m_expandedItems;
QList<TreeItem *> m_itemsToExpand;
- int m_lastItemIndex;
+ mutable int m_lastItemIndex;
};
QT_END_NAMESPACE
diff --git a/src/controls/Styles/Android/CursorHandleStyle.qml b/src/controls/Styles/Android/CursorHandleStyle.qml
index c3e32186..1534f4a9 100644
--- a/src/controls/Styles/Android/CursorHandleStyle.qml
+++ b/src/controls/Styles/Android/CursorHandleStyle.qml
@@ -55,6 +55,7 @@ DrawableLoader {
window_focused: focused && control.Window.active
opacity: hasText && (styleData.hasSelection || styleData.pressed || idle.running) ? 1.0 : 0.0
+ visible: opacity > 0.0 && focused
Timer {
id: idle
diff --git a/src/controls/Styles/Base/TumblerStyle.qml b/src/controls/Styles/Base/TumblerStyle.qml
index 2661837e..46605538 100644
--- a/src/controls/Styles/Base/TumblerStyle.qml
+++ b/src/controls/Styles/Base/TumblerStyle.qml
@@ -49,8 +49,6 @@ import QtQuick.Extras.Private 1.0
\ingroup controlsstyling
\brief Provides custom styling for Tumbler.
- \note TumblerStyle requires Qt 5.3.2 or later.
-
You can create a custom tumbler by replacing the following delegates:
\list
\li \l background
diff --git a/src/controls/Styles/Desktop/MenuBarStyle.qml b/src/controls/Styles/Desktop/MenuBarStyle.qml
index 470ccdb6..a31b2bb7 100644
--- a/src/controls/Styles/Desktop/MenuBarStyle.qml
+++ b/src/controls/Styles/Desktop/MenuBarStyle.qml
@@ -45,8 +45,6 @@ Style {
property Component background: StyleItem {
elementType: "menubar"
- Accessible.role: Accessible.MenuBar
-
Component.onCompleted: {
styleRoot.padding.left = pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth")
styleRoot.padding.right = pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth")
@@ -69,9 +67,6 @@ Style {
selected: (parent && styleData.selected) || sunken
hints: { "showUnderlined": styleData.underlineMnemonic }
-
- Accessible.role: Accessible.MenuItem
- Accessible.name: plainText
}
property Component menuStyle: Desktop.MenuStyle { }
diff --git a/src/controls/Styles/Desktop/MenuStyle.qml b/src/controls/Styles/Desktop/MenuStyle.qml
index 244bbca4..60e73d2f 100644
--- a/src/controls/Styles/Desktop/MenuStyle.qml
+++ b/src/controls/Styles/Desktop/MenuStyle.qml
@@ -60,8 +60,6 @@ Style {
color: SystemPaletteSingleton.window(control.enabled)
}
- Accessible.role: Accessible.PopupMenu
-
Component.onCompleted: {
var menuHMargin = pixelMetric("menuhmargin")
var menuVMargin = pixelMetric("menuvmargin")
@@ -106,9 +104,6 @@ Style {
"scrollerDirection": styleData.scrollerDirection,
"icon": !!__menuItem && __menuItem.__icon
}
-
- Accessible.role: Accessible.MenuItem
- Accessible.name: StyleHelpers.removeMnemonics(text)
}
property Component scrollIndicator: menuItemPanel
diff --git a/src/controls/TreeView.qml b/src/controls/TreeView.qml
index 84c30edd..c97930f3 100644
--- a/src/controls/TreeView.qml
+++ b/src/controls/TreeView.qml
@@ -118,10 +118,11 @@ BasicTableView {
// the flickable from eating our mouse press events
preventStealing: !Settings.hasTouchScreen
- property int clickedRow: -1
- property int pressedRow: -1
+ property var clickedIndex: undefined
+ property var pressedIndex: undefined
property int pressedColumn: -1
readonly property alias currentRow: root.__currentRow
+ readonly property alias currentIndex: root.currentIndex
// Handle vertical scrolling whem dragging mouse outside boundaries
property int autoScroll: 0 // 0 -> do nothing; 1 -> increment; 2 -> decrement
@@ -132,7 +133,7 @@ BasicTableView {
interval: 20
repeat: true
onTriggered: {
- var oldPressedRow = mouseArea.pressedRow
+ var oldPressedIndex = mouseArea.pressedIndex
var row
if (mouseArea.autoScroll === 1) {
__listView.incrementCurrentIndexBlocking();
@@ -144,28 +145,33 @@ BasicTableView {
row = __listView.indexAt(0, __listView.contentY)
}
- if (row !== oldPressedRow) {
- mouseArea.pressedRow = row
+ var index = modelAdaptor.mapRowToModelIndex(row)
+ if (index !== oldPressedIndex) {
+ mouseArea.pressedIndex = index
var modifiers = mouseArea.shiftPressed ? Qt.ShiftModifier : Qt.NoModifier
- mouseArea.mouseSelect(row, modifiers, true /* drag */)
+ mouseArea.mouseSelect(index, modifiers, true /* drag */)
}
}
}
- function mouseSelect(row, modifiers, drag) {
+ function mouseSelect(modelIndex, modifiers, drag) {
if (!selection) {
maybeWarnAboutSelectionMode()
return
}
if (selectionMode) {
- var modelIndex = modelAdaptor.mapRowToModelIndex(row)
selection.setCurrentIndex(modelIndex, ItemSelectionModel.NoUpdate)
if (selectionMode === SelectionMode.SingleSelection) {
selection.select(modelIndex, ItemSelectionModel.ClearAndSelect)
} else {
- var itemSelection = clickedRow === row ? modelIndex
- : modelAdaptor.selectionForRowRange(clickedRow, row)
+ var selectRowRange = (drag && (selectionMode === SelectionMode.MultiSelection
+ || (selectionMode === SelectionMode.ExtendedSelection
+ && modifiers & Qt.ControlModifier)))
+ || modifiers & Qt.ShiftModifier
+ var itemSelection = !selectRowRange || clickedIndex === modelIndex ? modelIndex
+ : modelAdaptor.selectionForRowRange(clickedIndex, modelIndex)
+
if (selectionMode === SelectionMode.MultiSelection
|| selectionMode === SelectionMode.ExtendedSelection && modifiers & Qt.ControlModifier) {
if (drag)
@@ -175,7 +181,7 @@ BasicTableView {
} else if (modifiers & Qt.ShiftModifier) {
selection.select(itemSelection, ItemSelectionModel.SelectCurrent)
} else {
- clickedRow = row // Needed only when drag is true
+ clickedIndex = modelIndex // Needed only when drag is true
selection.select(modelIndex, ItemSelectionModel.ClearAndSelect)
}
}
@@ -185,9 +191,9 @@ BasicTableView {
function keySelect(keyModifiers) {
if (selectionMode) {
if (!keyModifiers)
- clickedRow = currentRow
+ clickedIndex = currentIndex
if (!(keyModifiers & Qt.ControlModifier))
- mouseSelect(currentRow, keyModifiers, keyModifiers & Qt.ShiftModifier)
+ mouseSelect(currentIndex, keyModifiers, keyModifiers & Qt.ShiftModifier)
}
}
@@ -227,22 +233,23 @@ BasicTableView {
}
onPressed: {
- pressedRow = __listView.indexAt(0, mouseY + __listView.contentY)
+ var pressedRow = __listView.indexAt(0, mouseY + __listView.contentY)
+ pressedIndex = modelAdaptor.mapRowToModelIndex(pressedRow)
pressedColumn = __listView.columnAt(mouseX)
__listView.forceActiveFocus()
if (pressedRow > -1 && !Settings.hasTouchScreen
&& !branchDecorationContains(mouse.x, mouse.y)) {
__listView.currentIndex = pressedRow
- if (clickedRow === -1)
- clickedRow = pressedRow
- mouseSelect(pressedRow, mouse.modifiers, false)
+ if (!clickedIndex)
+ clickedIndex = pressedIndex
+ mouseSelect(pressedIndex, mouse.modifiers, false)
if (!mouse.modifiers)
- clickedRow = pressedRow
+ clickedIndex = pressedIndex
}
}
onReleased: {
- pressedRow = -1
+ pressedIndex = undefined
pressedColumn = -1
autoScroll = 0
}
@@ -261,23 +268,24 @@ BasicTableView {
}
if (pressed && containsMouse) {
- var oldPressedRow = pressedRow
- pressedRow = __listView.indexAt(0, mouseY + __listView.contentY)
+ var oldPressedIndex = pressedIndex
+ var pressedRow = __listView.indexAt(0, mouseY + __listView.contentY)
+ pressedIndex = modelAdaptor.mapRowToModelIndex(pressedRow)
pressedColumn = __listView.columnAt(mouseX)
- if (pressedRow > -1 && oldPressedRow !== pressedRow) {
+ if (pressedRow > -1 && oldPressedIndex !== pressedIndex) {
__listView.currentIndex = pressedRow
- mouseSelect(pressedRow, mouse.modifiers, true /* drag */)
+ mouseSelect(pressedIndex, mouse.modifiers, true /* drag */)
}
}
}
onExited: {
- pressedRow = -1
+ pressedIndex = undefined
pressedColumn = -1
}
onCanceled: {
- pressedRow = -1
+ pressedIndex = undefined
pressedColumn = -1
autoScroll = 0
}
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index e28e63b1..2a91940e 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -130,11 +130,15 @@ void QQuickMenuPopupWindow::setGeometry(int posx, int posy, int w, int h)
void QQuickMenuPopupWindow::updateSize()
{
+ const QQuickItem *contentItem = popupContentItem();
+ if (!contentItem)
+ return;
+
qreal x = m_initialPos.x();
qreal y = m_initialPos.y();
if (qGuiApp->layoutDirection() == Qt::RightToLeft)
- x -= popupContentItem()->width();
- setGeometry(x, y, popupContentItem()->width(), popupContentItem()->height());
+ x -= contentItem->width();
+ setGeometry(x, y, contentItem->width(), contentItem->height());
}
void QQuickMenuPopupWindow::updatePosition()
@@ -154,6 +158,9 @@ void QQuickMenuPopupWindow::exposeEvent(QExposeEvent *e)
m_initialPos += m_logicalParentWindow->geometry().topLeft();
}
QQuickPopupWindow::exposeEvent(e);
+
+ if (isExposed())
+ updateSize();
}
QQuickMenu *QQuickMenuPopupWindow::menu() const
diff --git a/src/controls/qquickpopupwindow_p.h b/src/controls/qquickpopupwindow_p.h
index b95275c0..617df53d 100644
--- a/src/controls/qquickpopupwindow_p.h
+++ b/src/controls/qquickpopupwindow_p.h
@@ -37,12 +37,12 @@
#ifndef QQUICKPOPUPWINDOW_H
#define QQUICKPOPUPWINDOW_H
+#include <QtCore/QPointer>
+#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
QT_BEGIN_NAMESPACE
-class QQuickItem;
-
class QQuickPopupWindow : public QQuickWindow
{
Q_OBJECT
@@ -84,7 +84,7 @@ private:
void forwardEventToTransientParent(QMouseEvent *);
QQuickItem *m_parentItem;
- QQuickItem *m_contentItem;
+ QPointer<QQuickItem> m_contentItem;
bool m_mouseMoved;
bool m_needsActivatedEvent;
bool m_dismissed;
diff --git a/src/dialogs/qquickfiledialog_p.h b/src/dialogs/qquickfiledialog_p.h
index d7b0804b..1dd65531 100644
--- a/src/dialogs/qquickfiledialog_p.h
+++ b/src/dialogs/qquickfiledialog_p.h
@@ -65,7 +65,7 @@ class QQuickFileDialog : public QQuickAbstractFileDialog
public:
explicit QQuickFileDialog(QObject *parent = 0);
~QQuickFileDialog();
- virtual QList<QUrl> fileUrls() const;
+ virtual QList<QUrl> fileUrls() const Q_DECL_OVERRIDE;
QJSValue shortcuts();
QJSValue __shortcuts();
@@ -78,7 +78,7 @@ public Q_SLOTS:
bool addSelection(const QUrl &path);
protected:
- virtual QPlatformFileDialogHelper *helper() { return 0; }
+ virtual QPlatformFileDialogHelper *helper() Q_DECL_OVERRIDE { return 0; }
Q_INVOKABLE QString urlToPath(const QUrl &url) { return url.toLocalFile(); }
Q_INVOKABLE QUrl pathToUrl(const QString &path) { return QUrl::fromLocalFile(path); }
Q_INVOKABLE QUrl pathFolder(const QString &path);
diff --git a/src/dialogs/qquickplatformfiledialog_p.h b/src/dialogs/qquickplatformfiledialog_p.h
index 5a5cc75f..4053db56 100644
--- a/src/dialogs/qquickplatformfiledialog_p.h
+++ b/src/dialogs/qquickplatformfiledialog_p.h
@@ -63,7 +63,7 @@ public:
virtual QList<QUrl> fileUrls() const Q_DECL_OVERRIDE;
protected:
- QPlatformFileDialogHelper *helper();
+ QPlatformFileDialogHelper *helper() Q_DECL_OVERRIDE;
Q_DISABLE_COPY(QQuickPlatformFileDialog)
};
diff --git a/src/extras/TumblerColumn.qml b/src/extras/TumblerColumn.qml
index 6dfecb04..cef4a592 100644
--- a/src/extras/TumblerColumn.qml
+++ b/src/extras/TumblerColumn.qml
@@ -45,8 +45,6 @@ import QtQuick.Controls.Private 1.0
\ingroup extras
\brief A column within a tumbler.
- \note TumblerColumn requires Qt 5.5.0 or later.
-
TumblerColumn represents a column within a tumbler, providing the interface
to define the items and width of each column.
diff --git a/src/extras/doc/src/qtquickextras-index.qdoc b/src/extras/doc/src/qtquickextras-index.qdoc
index 63966614..9237eff5 100644
--- a/src/extras/doc/src/qtquickextras-index.qdoc
+++ b/src/extras/doc/src/qtquickextras-index.qdoc
@@ -35,7 +35,7 @@
The Qt Quick Extras module provides a specialized set of
controls that can be used to build interfaces in Qt Quick.
- The module requires \l{Qt Quick} 2.2, and \l{Qt Quick Controls} 1.1.
+ The module was introduced in Qt 5.5.
Visit the \l{Qt Quick Extras Overview} page to get started.
diff --git a/src/widgets/qquickqfiledialog_p.h b/src/widgets/qquickqfiledialog_p.h
index 2747749e..7b9e5cbe 100644
--- a/src/widgets/qquickqfiledialog_p.h
+++ b/src/widgets/qquickqfiledialog_p.h
@@ -64,7 +64,7 @@ public:
virtual QList<QUrl> fileUrls() const Q_DECL_OVERRIDE;
protected:
- QPlatformFileDialogHelper *helper();
+ QPlatformFileDialogHelper *helper() Q_DECL_OVERRIDE;
Q_DISABLE_COPY(QQuickQFileDialog)
};
diff --git a/tests/auto/controls/data/tst_treeview.qml b/tests/auto/controls/data/tst_treeview.qml
index 9db58f14..6e17e318 100644
--- a/tests/auto/controls/data/tst_treeview.qml
+++ b/tests/auto/controls/data/tst_treeview.qml
@@ -785,5 +785,34 @@ Item {
compare(treeIndex.column, modelIndex.column)
compare(treeIndex.internalId, modelIndex.internalId)
}
+
+ function test_QTBUG_46891_selection_collapse_parent()
+ {
+ var component = Qt.createComponent("treeview/treeview_1.qml")
+ compare(component.status, Component.Ready)
+ var tree = component.createObject(container);
+ verify(tree !== null, "tree created is null")
+ var model = tree.model
+ model.removeRows(1, 9)
+ model.removeRows(1, 9, model.index(0, 0))
+ waitForRendering(tree)
+
+ var selectionModel = Qt.createQmlObject(testCase.instance_selectionModel, container, '')
+ selectionModel.model = tree.model
+ tree.selection = selectionModel
+ tree.selectionMode = SelectionMode.ExtendedSelection
+
+ var parentItem = tree.model.index(0, 0)
+ tree.expand(parentItem)
+ verify(tree.isExpanded(parentItem))
+
+ wait(100)
+ mouseClick(tree, semiIndent + 50, 20 + 100, Qt.LeftButton)
+ verify(selectionModel.isSelected(tree.currentIndex))
+
+ tree.collapse(parentItem)
+ mouseClick(tree, semiIndent + 50, 20 + 50, Qt.LeftButton)
+ verify(selectionModel.isSelected(parentItem))
+ }
}
}
diff --git a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
index 503b9e6f..b484665d 100644
--- a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
+++ b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
@@ -1138,7 +1138,8 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
for (int i = 0; i < ModelRowCount; i += ModelRowCountLoopStep) {
// Single row selection
- const QItemSelection &sel = tma.selectionForRowRange(i, i);
+ const QModelIndex &idx = model.index(i, 0);
+ const QItemSelection &sel = tma.selectionForRowRange(idx, idx);
QCOMPARE(sel.count(), 1);
const QItemSelectionRange &range = sel.first();
QCOMPARE(QModelIndex(range.topLeft()), model.index(i, 0));
@@ -1147,7 +1148,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
for (int i = 0; i < ModelRowCount - ModelRowCountLoopStep; i += ModelRowCountLoopStep) {
// Single range selection
- const QItemSelection &sel = tma.selectionForRowRange(i, i + ModelRowCountLoopStep);
+ const QModelIndex &from = model.index(i, 0);
+ const QModelIndex &to = model.index(i + ModelRowCountLoopStep, 0);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 1);
const QItemSelectionRange &range = sel.first();
QCOMPARE(QModelIndex(range.topLeft()), model.index(i, 0));
@@ -1155,7 +1158,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
}
{ // Select all, no branch expanded
- const QItemSelection &sel = tma.selectionForRowRange(0, ModelRowCount - 1);
+ const QModelIndex &from = model.index(0, 0);
+ const QModelIndex &to = model.index(ModelRowCount - 1, 0);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 1);
const QItemSelectionRange &range = sel.first();
QCOMPARE(QModelIndex(range.topLeft()), model.index(0, 0));
@@ -1167,7 +1172,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
tma.expand(parent);
{ // 1st item expanded, select first 5 rows
- const QItemSelection &sel = tma.selectionForRowRange(0, 4);
+ const QModelIndex &from = tma.mapRowToModelIndex(0);
+ const QModelIndex &to = tma.mapRowToModelIndex(4);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 2);
// We don't know in which order the selection ranges are
// being added, so we iterate and try to find what we expect.
@@ -1182,7 +1189,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
}
{ // 1st item expanded, select first 5 top-level items
- const QItemSelection &sel = tma.selectionForRowRange(0, 4 + ModelRowCount);
+ const QModelIndex &from = tma.mapRowToModelIndex(0);
+ const QModelIndex &to = tma.mapRowToModelIndex(4 + ModelRowCount);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 2);
// We don't know in which order the selection ranges are
// being added, so we iterate and try to find what we expect.
@@ -1201,7 +1210,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
tma.expand(parent2);
{ // 1st two items expanded, select first 5 top-level items
- const QItemSelection &sel = tma.selectionForRowRange(0, 4 + 2 * ModelRowCount);
+ const QModelIndex &from = tma.mapRowToModelIndex(0);
+ const QModelIndex &to = tma.mapRowToModelIndex(4 + 2 * ModelRowCount);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 3);
// We don't know in which order the selection ranges are
// being added, so we iterate and try to find what we expect.
@@ -1222,7 +1233,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
tma.expand(parent3);
{ // 1st two items, and 1st child of 1st item expanded, select first 5 rows
- const QItemSelection &sel = tma.selectionForRowRange(0, 4);
+ const QModelIndex &from = tma.mapRowToModelIndex(0);
+ const QModelIndex &to = tma.mapRowToModelIndex(4);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 3);
// We don't know in which order the selection ranges are
// being added, so we iterate and try to find what we expect.
@@ -1239,7 +1252,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
}
{ // 1st two items, and 1st child of 1st item expanded, select all
- const QItemSelection &sel = tma.selectionForRowRange(0, 4 * ModelRowCount - 1);
+ const QModelIndex &from = tma.mapRowToModelIndex(0);
+ const QModelIndex &to = tma.mapRowToModelIndex(4 * ModelRowCount - 1);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 4);
// We don't know in which order the selection ranges are
// being added, so we iterate and try to find what we expect.
@@ -1258,7 +1273,9 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
}
{ // 1st two items, and 1st child of 1st item expanded, select rows across branches
- const QItemSelection &sel = tma.selectionForRowRange(8, 23);
+ const QModelIndex &from = tma.mapRowToModelIndex(8);
+ const QModelIndex &to = tma.mapRowToModelIndex(23);
+ const QItemSelection &sel = tma.selectionForRowRange(from, to);
QCOMPARE(sel.count(), 4);
// We don't know in which order the selection ranges are
// being added, so we iterate and try to find what we expect.
diff --git a/tests/auto/shared/testmodel.h b/tests/auto/shared/testmodel.h
index 0bc06757..00e74129 100644
--- a/tests/auto/shared/testmodel.h
+++ b/tests/auto/shared/testmodel.h
@@ -124,7 +124,7 @@ public:
return false;
}
- Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
{
if (row < 0 || column < 0 || (level(parent) > levels) || column >= cols)
return QModelIndex();
@@ -199,7 +199,7 @@ public:
emit layoutChanged(parents);
}
- bool removeRows(int row, int count, const QModelIndex &parent)
+ Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
{
beginRemoveRows(parent, row, row + count - 1);
Node *n = (Node *)parent.internalPointer();