Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
viewtestutils_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICKVIEWTESTUTILS_P_H
5#define QQUICKVIEWTESTUTILS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QAbstractListModel>
19#include <QtQml/QQmlExpression>
20#include <QtQuick/QQuickItem>
21#include <QtCore/private/qglobal_p.h>
22#include <QtQuick/private/qtquickglobal_p.h>
23
27
29
31{
33
34 void flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration);
40
41 QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
42 QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);
43 QList<int> adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count);
44
45 struct ListChange {
47 int index;
48 int count;
49 int to; // Move
50 qreal pos; // setContentY
51
52 static ListChange insert(int index, int count = 1) { ListChange c = { Inserted, index, count, -1, 0.0 }; return c; }
53 static ListChange remove(int index, int count = 1) { ListChange c = { Removed, index, count, -1, 0.0 }; return c; }
54 static ListChange move(int index, int to, int count) { ListChange c = { Moved, index, count, to, 0.0 }; return c; }
55 static ListChange setCurrent(int index) { ListChange c = { SetCurrent, index, -1, -1, 0.0 }; return c; }
56 static ListChange setContentY(qreal pos) { ListChange c = { SetContentY, -1, -1, -1, pos }; return c; }
57 static ListChange polish() { ListChange c = { Polish, -1, -1, -1, 0.0 }; return c; }
58 };
59
61 {
63 public:
65
67
68 int rowCount(const QModelIndex &parent=QModelIndex()) const override;
69 int columnCount(const QModelIndex &parent=QModelIndex()) const override;
70 QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override;
71 QHash<int,QByteArray> roleNames() const override;
72
73 int count() const;
74 QString name(int index) const;
75 QString number(int index) const;
76
77 Q_INVOKABLE void addItem(const QString &name, const QString &number);
78 void addItems(const QList<QPair<QString, QString> > &items);
79 void insertItem(int index, const QString &name, const QString &number);
80 void insertItems(int index, const QList<QPair<QString, QString> > &items);
81
83 void removeItems(int index, int count);
84
85 void moveItem(int from, int to);
86 void moveItems(int from, int to, int count);
87
88 void modifyItem(int idx, const QString &name, const QString &number);
89
90 void clear();
91 void reset();
92 void resetItems(const QList<QPair<QString, QString> > &items);
93
94 void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
95
97
98 int columns = 1;
99
100 private:
101 QList<QPair<QString,QString> > list;
102 };
103
105 {
106 public:
107 ListRange();
108 ListRange(const ListRange &other);
109 ListRange(int start, int end);
110
111 ~ListRange();
112
113 ListRange operator+(const ListRange &other) const;
114 bool operator==(const ListRange &other) const;
115 bool operator!=(const ListRange &other) const;
116
117 bool isValid() const;
118 int count() const;
119
120 QList<QPair<QString,QString> > getModelDataValues(const QaimModel &model);
121
122 QList<int> indexes;
123 bool valid;
124 };
125
126 template<typename T>
127 static void qquickmodelviewstestutil_move(int from, int to, int n, T *items)
128 {
129 if (from > to) {
130 // Only move forwards - flip if backwards moving
131 int tfrom = from;
132 int tto = to;
133 from = tto;
134 to = tto+n;
135 n = tfrom-tto;
136 }
137
138 T replaced;
139 int i=0;
140 typename T::ConstIterator it=items->begin(); it += from+n;
141 for (; i<to-from; ++i,++it)
142 replaced.append(*it);
143 i=0;
144 it=items->begin(); it += from;
145 for (; i<n; ++i,++it)
146 replaced.append(*it);
147 typename T::ConstIterator f=replaced.begin();
148 typename T::Iterator t=items->begin(); t += from;
149 for (; f != replaced.end(); ++f, ++t)
150 *t = *f;
151 }
152
154 {
156
157 public:
158
160
161 int rowCount(const QModelIndex &) const override;
162 QVariant data(const QModelIndex &, int) const override;
163
164 public Q_SLOTS:
165 void updateModel();
166
167 private:
168 int m_rowCount;
169 };
170
171#if QT_CONFIG(quick_itemview) && defined(QT_BUILD_INTERNAL)
172 [[nodiscard]] bool testVisibleItems(const QQuickItemViewPrivate *priv,
173 bool *nonUnique, FxViewItem **failItem, int *expectedIdx);
174#endif
175}
176
177namespace QQuickTouchUtils {
179}
180
181namespace QQuickTest {
182 [[nodiscard]] bool initView(QQuickView &v, const QUrl &url,
183 bool moveMouseOut = true, QByteArray *errorMessage = nullptr);
184 [[nodiscard]] bool showView(QQuickView &v, const QUrl &url);
185
187 int pointId, const QPoint &p, Qt::MouseButton button = Qt::LeftButton,
188 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
189
190 void pointerMove(const QPointingDevice *dev, QQuickWindow *window, int pointId,
191 const QPoint &p);
192
193 void pointerRelease(const QPointingDevice *dev, QQuickWindow *window, int pointId,
195 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
196}
197
199
202Q_DECLARE_METATYPE(QList<QQuickViewTestUtils::ListChange>)
204
205
206#endif // QQUICKVIEWTESTUTILS_P_H
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
Definition qbytearray.h:57
Definition qlist.h:75
iterator begin()
Definition qlist.h:625
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
bool operator==(const ListRange &other) const
QList< QPair< QString, QString > > getModelDataValues(const QaimModel &model)
bool operator!=(const ListRange &other) const
ListRange operator+(const ListRange &other) const
void insertItem(int index, const QString &name, const QString &number)
Q_INVOKABLE void addItem(const QString &name, const QString &number)
QHash< int, QByteArray > roleNames() const override
Q_INVOKABLE void removeItem(int index)
void removeItems(int index, int count)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows under the given parent.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void matchAgainst(const QList< QPair< QString, QString > > &other, const QString &error1, const QString &error2)
void insertItems(int index, const QList< QPair< QString, QString > > &items)
void resetItems(const QList< QPair< QString, QString > > &items)
void modifyItem(int idx, const QString &name, const QString &number)
void addItems(const QList< QPair< QString, QString > > &items)
void moveItems(int from, int to, int count)
void moveItem(int from, int to)
int rowCount(const QModelIndex &) const override
Returns the number of rows under the given parent.
The QQuickView class provides a window for displaying a Qt Quick user interface.
Definition qquickview.h:20
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
iterator begin()
Definition qset.h:136
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
EGLImageKHR int int EGLuint64KHR * modifiers
QPushButton * button
[2]
QSet< QString >::iterator it
std::list< QString >::iterator Name
Definition lalr.h:28
void pointerRelease(const QPointingDevice *dev, QQuickWindow *window, int pointId, const QPoint &p, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
bool initView(QQuickView &view, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage)
bool showView(QQuickView &view, const QUrl &url)
void pointerMove(const QPointingDevice *dev, QQuickWindow *window, int pointId, const QPoint &p)
void pointerPress(const QPointingDevice *dev, QQuickWindow *window, int pointId, const QPoint &p, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
void flush(QQuickWindow *window)
QQuickView * createView()
QList< int > adjustIndexesForAddDisplaced(const QList< int > &indexes, int index, int count)
QList< int > adjustIndexesForMove(const QList< int > &indexes, int from, int to, int count)
static void qquickmodelviewstestutil_move(int from, int to, int n, T *items)
QList< int > adjustIndexesForRemoveDisplaced(const QList< int > &indexes, int index, int count)
void flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration)
void moveAndPress(QQuickView *window, const QPoint &position)
void centerOnScreen(QQuickView *window, const QSize &size)
void moveMouseAway(QQuickView *window)
void moveAndRelease(QQuickView *window, const QPoint &position)
Combined button and popup list for selecting options.
MouseButton
Definition qnamespace.h:56
@ LeftButton
Definition qnamespace.h:58
@ UserRole
@ DisplayRole
@ NoModifier
QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem)
static const QMetaObjectPrivate * priv(const uint *data)
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1525
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat f
GLuint start
GLuint name
GLfloat n
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SLOTS
double qreal
Definition qtypes.h:187
static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &errorSource, qsizetype errorPosition)
Definition qurl.cpp:3517
QSqlQueryModel * model
[16]
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]
QList< QTreeWidgetItem * > items
aWidget window() -> setWindowTitle("New Window Title")
[2]
static ListChange remove(int index, int count=1)
enum QQuickViewTestUtils::ListChange::@719 type
static ListChange move(int index, int to, int count)
static ListChange setCurrent(int index)
static ListChange insert(int index, int count=1)
static ListChange setContentY(qreal pos)