on xenial help sign in
Remove support for Qt <= 5.2.1
49c9053Albert Astals
CMakeLists.txt+5−5
@@ -48,11 +48,11 @@ add_custom_target(cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2
48 ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
48 ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests)
49
49
50include(FindPkgConfig)
50include(FindPkgConfig)
51−find_package(Qt5Core)
51+find_package(Qt5Core 5.2 REQUIRED)
52−find_package(Qt5Qml)
52+find_package(Qt5Qml 5.2 REQUIRED)
53−find_package(Qt5Quick)
53+find_package(Qt5Quick 5.2 REQUIRED)
54−find_package(Qt5Gui)
54+find_package(Qt5Gui 5.2 REQUIRED)
55−find_package(Qt5DBus)
55+find_package(Qt5DBus 5.2 REQUIRED)
56
56
57# Standard install paths
57# Standard install paths
58include(GNUInstallDirs)
58include(GNUInstallDirs)
debian/control+2−2
@@ -26,10 +26,10 @@ Build-Depends: cmake,
26 python3-all:any,
26 python3-all:any,
27 python3-setuptools,
27 python3-setuptools,
28 qt5-default,
28 qt5-default,
29− qtbase5-dev,
29+ qtbase5-dev (>= 5.2.1),
30 qtbase5-dev-tools,
30 qtbase5-dev-tools,
31 qtbase5-private-dev,
31 qtbase5-private-dev,
32− qtdeclarative5-dev,
32+ qtdeclarative5-dev (>= 5.2.1),
33 qtdeclarative5-dev-tools,
33 qtdeclarative5-dev-tools,
34 qtdeclarative5-qtmultimedia-plugin,
34 qtdeclarative5-qtmultimedia-plugin,
35 qtdeclarative5-private-dev,
35 qtdeclarative5-private-dev,
plugins/DashViews/abstractdashview.cpp−34
@@ -46,17 +46,10 @@ void AbstractDashView::setModel(QAbstractItemModel *model)
46 if (!m_delegateModel) {
46 if (!m_delegateModel) {
47 createDelegateModel();
47 createDelegateModel();
48 } else {
48 } else {
49−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
50− disconnect(m_delegateModel, SIGNAL(modelUpdated(QQuickChangeSet,bool)), this, SLOT(onModelUpdated(QQuickChangeSet,bool)));
51− }
52− m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
53− connect(m_delegateModel, SIGNAL(modelUpdated(QQuickChangeSet,bool)), this, SLOT(onModelUpdated(QQuickChangeSet,bool)));
54−#else
55 disconnect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
49 disconnect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
56 }
50 }
57 m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
51 m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
58 connect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
52 connect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
59−#endif
60
53
61 cleanupExistingItems();
54 cleanupExistingItems();
62
55
@@ -181,13 +174,8 @@ void AbstractDashView::resetDelegateCreationEnd()
181
174
182void AbstractDashView::createDelegateModel()
175void AbstractDashView::createDelegateModel()
183{
176{
184−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
185− m_delegateModel = new QQuickVisualDataModel(qmlContext(this), this);
186− connect(m_delegateModel, SIGNAL(createdItem(int,QQuickItem*)), this, SLOT(itemCreated(int,QQuickItem*)));
187−#else
188 m_delegateModel = new QQmlDelegateModel(qmlContext(this), this);
177 m_delegateModel = new QQmlDelegateModel(qmlContext(this), this);
189 connect(m_delegateModel, SIGNAL(createdItem(int,QObject*)), this, SLOT(itemCreated(int,QObject*)));
178 connect(m_delegateModel, SIGNAL(createdItem(int,QObject*)), this, SLOT(itemCreated(int,QObject*)));
190−#endif
191 if (isComponentComplete())
179 if (isComponentComplete())
192 m_delegateModel->componentComplete();
180 m_delegateModel->componentComplete();
193}
181}
@@ -253,16 +241,9 @@ QQuickItem *AbstractDashView::createItem(int modelIndex, bool asynchronous)
253 return nullptr;
241 return nullptr;
254
242
255 m_asyncRequestedIndex = -1;
243 m_asyncRequestedIndex = -1;
256−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
257− QQuickItem *item = m_delegateModel->item(modelIndex, asynchronous);
258−#else
259 QObject* object = m_delegateModel->object(modelIndex, asynchronous);
244 QObject* object = m_delegateModel->object(modelIndex, asynchronous);
260 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
245 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
261−#endif
262 if (!item) {
246 if (!item) {
263−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
264− m_asyncRequestedIndex = modelIndex;
265−#else
266 if (object) {
247 if (object) {
267 m_delegateModel->release(object);
248 m_delegateModel->release(object);
268 if (!m_delegateValidated) {
249 if (!m_delegateValidated) {
@@ -273,7 +254,6 @@ QQuickItem *AbstractDashView::createItem(int modelIndex, bool asynchronous)
273 } else {
254 } else {
274 m_asyncRequestedIndex = modelIndex;
255 m_asyncRequestedIndex = modelIndex;
275 }
256 }
276−#endif
277 return nullptr;
257 return nullptr;
278 } else {
258 } else {
279 addItemToView(modelIndex, item);
259 addItemToView(modelIndex, item);
@@ -283,13 +263,8 @@ QQuickItem *AbstractDashView::createItem(int modelIndex, bool asynchronous)
283
263
284void AbstractDashView::releaseItem(QQuickItem *item)
264void AbstractDashView::releaseItem(QQuickItem *item)
285{
265{
286−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
287− QQuickVisualModel::ReleaseFlags flags = m_delegateModel->release(item);
288− if (flags & QQuickVisualModel::Destroyed) {
289−#else
290 QQmlDelegateModel::ReleaseFlags flags = m_delegateModel->release(item);
266 QQmlDelegateModel::ReleaseFlags flags = m_delegateModel->release(item);
291 if (flags & QQmlDelegateModel::Destroyed) {
267 if (flags & QQmlDelegateModel::Destroyed) {
292−#endif
293 item->setParentItem(nullptr);
268 item->setParentItem(nullptr);
294 }
269 }
295}
270}
@@ -299,10 +274,6 @@ void AbstractDashView::setImplicitHeightDirty()
299 m_implicitHeightDirty = true;
274 m_implicitHeightDirty = true;
300}
275}
301
276
302−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
303−void AbstractDashView::itemCreated(int modelIndex, QQuickItem *item)
304−{
305−#else
306void AbstractDashView::itemCreated(int modelIndex, QObject *object)
277void AbstractDashView::itemCreated(int modelIndex, QObject *object)
307{
278{
308 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
279 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
@@ -310,7 +281,6 @@ void AbstractDashView::itemCreated(int modelIndex, QObject *object)
310 qWarning() << "AbstractDashView::itemCreated got a non item for index" << modelIndex;
281 qWarning() << "AbstractDashView::itemCreated got a non item for index" << modelIndex;
311 return;
282 return;
312 }
283 }
313−#endif
314 item->setParentItem(this);
284 item->setParentItem(this);
315
285
316 // We only need to call createItem if we are here because of an asynchronous generation
286 // We only need to call createItem if we are here because of an asynchronous generation
@@ -325,11 +295,7 @@ void AbstractDashView::itemCreated(int modelIndex, QObject *object)
325 }
295 }
326}
296}
327
297
328−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
329−void AbstractDashView::onModelUpdated(const QQuickChangeSet &changeSet, bool reset)
330−#else
331void AbstractDashView::onModelUpdated(const QQmlChangeSet &changeSet, bool reset)
298void AbstractDashView::onModelUpdated(const QQmlChangeSet &changeSet, bool reset)
332−#endif
333{
299{
334 if (reset) {
300 if (reset) {
335 cleanupExistingItems();
301 cleanupExistingItems();
plugins/DashViews/abstractdashview.h−17
@@ -23,12 +23,8 @@ class QAbstractItemModel;
23class QQmlComponent;
23class QQmlComponent;
24#pragma GCC diagnostic push
24#pragma GCC diagnostic push
25#pragma GCC diagnostic ignored "-pedantic"
25#pragma GCC diagnostic ignored "-pedantic"
26−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
27−#include <private/qquickvisualdatamodel_p.h>
28−#else
29#include <private/qqmldelegatemodel_p.h>
26#include <private/qqmldelegatemodel_p.h>
30#include <qqmlinfo.h>
27#include <qqmlinfo.h>
31−#endif
32#pragma GCC diagnostic pop
28#pragma GCC diagnostic pop
33
29
34class AbstractDashView : public QQuickItem
30class AbstractDashView : public QQuickItem
@@ -94,13 +90,8 @@ protected:
94 void setImplicitHeightDirty();
90 void setImplicitHeightDirty();
95
91
96private Q_SLOTS:
92private Q_SLOTS:
97−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
98− void itemCreated(int modelIndex, QQuickItem *item);
99− void onModelUpdated(const QQuickChangeSet &changeSet, bool reset);
100−#else
101 void itemCreated(int modelIndex, QObject *object);
93 void itemCreated(int modelIndex, QObject *object);
102 void onModelUpdated(const QQmlChangeSet &changeSet, bool reset);
94 void onModelUpdated(const QQmlChangeSet &changeSet, bool reset);
103−#endif
104 void onHeightChanged();
95 void onHeightChanged();
105
96
106private:
97private:
@@ -117,17 +108,9 @@ private:
117 virtual void doRelayout() = 0;
108 virtual void doRelayout() = 0;
118 virtual void updateItemCulling(qreal visibleFromY, qreal visibleToY) = 0;
109 virtual void updateItemCulling(qreal visibleFromY, qreal visibleToY) = 0;
119 virtual void calculateImplicitHeight() = 0;
110 virtual void calculateImplicitHeight() = 0;
120−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
121− virtual void processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes) = 0;
122−#else
123 virtual void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) = 0;
111 virtual void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) = 0;
124−#endif
125
112
126−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
127− QQuickVisualDataModel *m_delegateModel;
128−#else
129 QQmlDelegateModel *m_delegateModel;
113 QQmlDelegateModel *m_delegateModel;
130−#endif
131
114
132 // Index we are waiting because we requested it asynchronously
115 // Index we are waiting because we requested it asynchronously
133 int m_asyncRequestedIndex;
116 int m_asyncRequestedIndex;
plugins/DashViews/horizontaljournal.cpp−12
@@ -28,12 +28,8 @@
28#include <qqmlengine.h>
28#include <qqmlengine.h>
29#pragma GCC diagnostic push
29#pragma GCC diagnostic push
30#pragma GCC diagnostic ignored "-pedantic"
30#pragma GCC diagnostic ignored "-pedantic"
31−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
32−#include <private/qquickvisualdatamodel_p.h>
33−#else
34#include <private/qqmldelegatemodel_p.h>
31#include <private/qqmldelegatemodel_p.h>
35#include <qqmlinfo.h>
32#include <qqmlinfo.h>
36−#endif
37#include <private/qquickitem_p.h>
33#include <private/qquickitem_p.h>
38#pragma GCC diagnostic pop
34#pragma GCC diagnostic pop
39
35
@@ -188,17 +184,9 @@ void HorizontalJournal::calculateImplicitHeight()
188 }
184 }
189}
185}
190
186
191−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
192−void HorizontalJournal::processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes)
193−#else
194void HorizontalJournal::processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes)
187void HorizontalJournal::processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes)
195−#endif
196{
188{
197−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
198− Q_FOREACH(const QQuickChangeSet::Remove &remove, removes) {
199−#else
200 Q_FOREACH(const QQmlChangeSet::Remove &remove, removes) {
189 Q_FOREACH(const QQmlChangeSet::Remove &remove, removes) {
201−#endif
202 for (int i = remove.count - 1; i >= 0; --i) {
190 for (int i = remove.count - 1; i >= 0; --i) {
203 const int indexToRemove = remove.index + i;
191 const int indexToRemove = remove.index + i;
204 // We only support removing from the end so
192 // We only support removing from the end so
plugins/DashViews/horizontaljournal.h−4
@@ -52,11 +52,7 @@ private:
52 void calculateImplicitHeight() override;
52 void calculateImplicitHeight() override;
53 void doRelayout() override;
53 void doRelayout() override;
54 void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
54 void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
55−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
56− void processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes) override;
57−#else
58 void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
55 void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
59−#endif
60
56
61 int m_firstVisibleIndex;
57 int m_firstVisibleIndex;
62 QList<QQuickItem*> m_visibleItems;
58 QList<QQuickItem*> m_visibleItems;
plugins/DashViews/listviewwithpageheader.cpp−50
@@ -97,11 +97,7 @@
97#include <qqmlengine.h>
97#include <qqmlengine.h>
98#pragma GCC diagnostic push
98#pragma GCC diagnostic push
99#pragma GCC diagnostic ignored "-pedantic"
99#pragma GCC diagnostic ignored "-pedantic"
100−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
101−#include <private/qquickvisualdatamodel_p.h>
102−#else
103#include <private/qqmldelegatemodel_p.h>
100#include <private/qqmldelegatemodel_p.h>
104−#endif
105#include <private/qqmlglobal_p.h>
101#include <private/qqmlglobal_p.h>
106#include <private/qquickitem_p.h>
102#include <private/qquickitem_p.h>
107#include <private/qquickanimation_p.h>
103#include <private/qquickanimation_p.h>
@@ -191,17 +187,10 @@ void ListViewWithPageHeader::setModel(QAbstractItemModel *model)
191 if (!m_delegateModel) {
187 if (!m_delegateModel) {
192 createDelegateModel();
188 createDelegateModel();
193 } else {
189 } else {
194−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
195− disconnect(m_delegateModel, SIGNAL(modelUpdated(QQuickChangeSet,bool)), this, SLOT(onModelUpdated(QQuickChangeSet,bool)));
196− }
197− m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
198− connect(m_delegateModel, SIGNAL(modelUpdated(QQuickChangeSet,bool)), this, SLOT(onModelUpdated(QQuickChangeSet,bool)));
199−#else
200 disconnect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
190 disconnect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
201 }
191 }
202 m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
192 m_delegateModel->setModel(QVariant::fromValue<QAbstractItemModel *>(model));
203 connect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
193 connect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
204−#endif
205 Q_EMIT modelChanged();
194 Q_EMIT modelChanged();
206 polish();
195 polish();
207 // TODO?
196 // TODO?
@@ -570,13 +559,8 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
570
559
571void ListViewWithPageHeader::createDelegateModel()
560void ListViewWithPageHeader::createDelegateModel()
572{
561{
573−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
574− m_delegateModel = new QQuickVisualDataModel(qmlContext(this), this);
575− connect(m_delegateModel, SIGNAL(createdItem(int,QQuickItem*)), this, SLOT(itemCreated(int,QQuickItem*)));
576−#else
577 m_delegateModel = new QQmlDelegateModel(qmlContext(this), this);
562 m_delegateModel = new QQmlDelegateModel(qmlContext(this), this);
578 connect(m_delegateModel, SIGNAL(createdItem(int,QObject*)), this, SLOT(itemCreated(int,QObject*)));
563 connect(m_delegateModel, SIGNAL(createdItem(int,QObject*)), this, SLOT(itemCreated(int,QObject*)));
579−#endif
580 if (isComponentComplete())
564 if (isComponentComplete())
581 m_delegateModel->componentComplete();
565 m_delegateModel->componentComplete();
582 updateWatchedRoles();
566 updateWatchedRoles();
@@ -657,13 +641,8 @@ bool ListViewWithPageHeader::addVisibleItems(qreal fillFrom, qreal fillTo, bool
657void ListViewWithPageHeader::reallyReleaseItem(ListItem *listItem)
641void ListViewWithPageHeader::reallyReleaseItem(ListItem *listItem)
658{
642{
659 QQuickItem *item = listItem->m_item;
643 QQuickItem *item = listItem->m_item;
660−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
661− QQuickVisualModel::ReleaseFlags flags = m_delegateModel->release(item);
662− if (flags & QQuickVisualModel::Destroyed) {
663−#else
664 QQmlDelegateModel::ReleaseFlags flags = m_delegateModel->release(item);
644 QQmlDelegateModel::ReleaseFlags flags = m_delegateModel->release(item);
665 if (flags & QQmlDelegateModel::Destroyed) {
645 if (flags & QQmlDelegateModel::Destroyed) {
666−#endif
667 item->setParentItem(nullptr);
646 item->setParentItem(nullptr);
668 }
647 }
669 delete listItem->m_sectionItem;
648 delete listItem->m_sectionItem;
@@ -796,16 +775,9 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
796 return nullptr;
775 return nullptr;
797
776
798 m_asyncRequestedIndex = -1;
777 m_asyncRequestedIndex = -1;
799−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
800− QQuickItem *item = m_delegateModel->item(modelIndex, asynchronous);
801−#else
802 QObject* object = m_delegateModel->object(modelIndex, asynchronous);
778 QObject* object = m_delegateModel->object(modelIndex, asynchronous);
803 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
779 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
804−#endif
805 if (!item) {
780 if (!item) {
806−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
807− m_asyncRequestedIndex = modelIndex;
808−#else
809 if (object) {
781 if (object) {
810 m_delegateModel->release(object);
782 m_delegateModel->release(object);
811 if (!m_delegateValidated) {
783 if (!m_delegateValidated) {
@@ -816,7 +788,6 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
816 } else {
788 } else {
817 m_asyncRequestedIndex = modelIndex;
789 m_asyncRequestedIndex = modelIndex;
818 }
790 }
819−#endif
820 return 0;
791 return 0;
821 } else {
792 } else {
822// qDebug() << "ListViewWithPageHeader::createItem::We have the item" << modelIndex << item;
793// qDebug() << "ListViewWithPageHeader::createItem::We have the item" << modelIndex << item;
@@ -872,10 +843,6 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
872 }
843 }
873}
844}
874
845
875−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
876−void ListViewWithPageHeader::itemCreated(int modelIndex, QQuickItem *item)
877−{
878−#else
879void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
846void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
880{
847{
881 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
848 QQuickItem *item = qmlobject_cast<QQuickItem*>(object);
@@ -883,7 +850,6 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
883 qWarning() << "ListViewWithPageHeader::itemCreated got a non item for index" << modelIndex;
850 qWarning() << "ListViewWithPageHeader::itemCreated got a non item for index" << modelIndex;
884 return;
851 return;
885 }
852 }
886−#endif
887// qDebug() << "ListViewWithPageHeader::itemCreated" << modelIndex << item;
853// qDebug() << "ListViewWithPageHeader::itemCreated" << modelIndex << item;
888 // Check we are not being taken down and don't paint anything
854 // Check we are not being taken down and don't paint anything
889 // TODO Check if we still need this in 5.2
855 // TODO Check if we still need this in 5.2
@@ -924,21 +890,13 @@ void ListViewWithPageHeader::onHeightChanged()
924}
890}
925
891
926
892
927−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
928−void ListViewWithPageHeader::onModelUpdated(const QQuickChangeSet &changeSet, bool /*reset*/)
929−#else
930void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool /*reset*/)
893void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool /*reset*/)
931−#endif
932{
894{
933 // TODO Do something with reset
895 // TODO Do something with reset
934// qDebug() << "ListViewWithPageHeader::onModelUpdated" << changeSet << reset;
896// qDebug() << "ListViewWithPageHeader::onModelUpdated" << changeSet << reset;
935 const auto oldFirstVisibleIndex = m_firstVisibleIndex;
897 const auto oldFirstVisibleIndex = m_firstVisibleIndex;
936
898
937−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
938− Q_FOREACH(const QQuickChangeSet::Remove &remove, changeSet.removes()) {
939−#else
940 Q_FOREACH(const QQmlChangeSet::Remove &remove, changeSet.removes()) {
899 Q_FOREACH(const QQmlChangeSet::Remove &remove, changeSet.removes()) {
941−#endif
942// qDebug() << "ListViewWithPageHeader::onModelUpdated Remove" << remove.index << remove.count;
900// qDebug() << "ListViewWithPageHeader::onModelUpdated Remove" << remove.index << remove.count;
943 if (remove.index + remove.count > m_firstVisibleIndex && remove.index < m_firstVisibleIndex + m_visibleItems.count()) {
901 if (remove.index + remove.count > m_firstVisibleIndex && remove.index < m_firstVisibleIndex + m_visibleItems.count()) {
944 const qreal oldFirstValidIndexPos = m_visibleItems.first()->y();
902 const qreal oldFirstValidIndexPos = m_visibleItems.first()->y();
@@ -992,11 +950,7 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
992 }
950 }
993 }
951 }
994
952
995−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
996− Q_FOREACH(const QQuickChangeSet::Insert &insert, changeSet.inserts()) {
997−#else
998 Q_FOREACH(const QQmlChangeSet::Insert &insert, changeSet.inserts()) {
953 Q_FOREACH(const QQmlChangeSet::Insert &insert, changeSet.inserts()) {
999−#endif
1000// qDebug() << "ListViewWithPageHeader::onModelUpdated Insert" << insert.index << insert.count;
954// qDebug() << "ListViewWithPageHeader::onModelUpdated Insert" << insert.index << insert.count;
1001 const bool insertingInValidIndexes = insert.index > m_firstVisibleIndex && insert.index < m_firstVisibleIndex + m_visibleItems.count();
955 const bool insertingInValidIndexes = insert.index > m_firstVisibleIndex && insert.index < m_firstVisibleIndex + m_visibleItems.count();
1002 const bool firstItemWithViewOnTop = insert.index == 0 && m_firstVisibleIndex == 0 && m_visibleItems.first()->y() + m_clipItem->y() > contentY();
956 const bool firstItemWithViewOnTop = insert.index == 0 && m_firstVisibleIndex == 0 && m_visibleItems.first()->y() + m_clipItem->y() > contentY();
@@ -1054,11 +1008,7 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
1054 }
1008 }
1055 }
1009 }
1056
1010
1057−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1058− Q_FOREACH(const QQuickChangeSet::Change &change, changeSet.changes()) {
1059−#else
1060 Q_FOREACH(const QQmlChangeSet::Change &change, changeSet.changes()) {
1011 Q_FOREACH(const QQmlChangeSet::Change &change, changeSet.changes()) {
1061−#endif
1062// qDebug() << "ListViewWithPageHeader::onModelUpdated Change" << change.index << change.count;
1012// qDebug() << "ListViewWithPageHeader::onModelUpdated Change" << change.index << change.count;
1063 for (int i = change.index; i < change.count; ++i) {
1013 for (int i = change.index; i < change.count; ++i) {
1064 ListItem *item = itemAtIndex(i);
1014 ListItem *item = itemAtIndex(i);
plugins/DashViews/listviewwithpageheader.h−20
@@ -17,21 +17,13 @@
17#ifndef LISTVIEWWITHPAGEHEADER_H
17#ifndef LISTVIEWWITHPAGEHEADER_H
18#define LISTVIEWWITHPAGEHEADER_H
18#define LISTVIEWWITHPAGEHEADER_H
19
19
20−#pragma GCC diagnostic push
21−#pragma GCC diagnostic ignored "-pedantic"
22#include <private/qquickitemchangelistener_p.h>
20#include <private/qquickitemchangelistener_p.h>
23#include <private/qquickflickable_p.h>
21#include <private/qquickflickable_p.h>
24−#pragma GCC diagnostic pop
25
22
26class QAbstractItemModel;
23class QAbstractItemModel;
27class QQuickNumberAnimation;
24class QQuickNumberAnimation;
28−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
29−class QQuickChangeSet;
30−class QQuickVisualDataModel;
31−#else
32class QQmlChangeSet;
25class QQmlChangeSet;
33class QQmlDelegateModel;
26class QQmlDelegateModel;
34−#endif
35
27
36
28
37/**
29/**
@@ -117,19 +109,11 @@ protected:
117 void updatePolish();
109 void updatePolish();
118
110
119private Q_SLOTS:
111private Q_SLOTS:
120−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
121− void itemCreated(int modelIndex, QQuickItem *item);
122−#else
123 void itemCreated(int modelIndex, QObject *object);
112 void itemCreated(int modelIndex, QObject *object);
124−#endif
125 void onContentHeightChanged();
113 void onContentHeightChanged();
126 void onContentWidthChanged();
114 void onContentWidthChanged();
127 void onHeightChanged();
115 void onHeightChanged();
128−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
129− void onModelUpdated(const QQuickChangeSet &changeSet, bool reset);
130−#else
131 void onModelUpdated(const QQmlChangeSet &changeSet, bool reset);
116 void onModelUpdated(const QQmlChangeSet &changeSet, bool reset);
132−#endif
133 void onShowHeaderAnimationFinished();
117 void onShowHeaderAnimationFinished();
134
118
135private:
119private:
@@ -168,11 +152,7 @@ private:
168 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
152 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
169 QQuickItem *getSectionItem(const QString &sectionText);
153 QQuickItem *getSectionItem(const QString &sectionText);
170
154
171−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
172− QQuickVisualDataModel *m_delegateModel;
173−#else
174 QQmlDelegateModel *m_delegateModel;
155 QQmlDelegateModel *m_delegateModel;
175−#endif
176
156
177 // Index we are waiting because we requested it asynchronously
157 // Index we are waiting because we requested it asynchronously
178 int m_asyncRequestedIndex;
158 int m_asyncRequestedIndex;
plugins/DashViews/organicgrid.cpp−8
@@ -237,17 +237,9 @@ void OrganicGrid::calculateImplicitHeight()
237 }
237 }
238}
238}
239
239
240−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
241−void OrganicGrid::processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes)
242−#else
243void OrganicGrid::processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes)
240void OrganicGrid::processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes)
244−#endif
245{
241{
246−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
247− Q_FOREACH(const QQuickChangeSet::Remove &remove, removes) {
248−#else
249 Q_FOREACH(const QQmlChangeSet::Remove &remove, removes) {
242 Q_FOREACH(const QQmlChangeSet::Remove &remove, removes) {
250−#endif
251 for (int i = remove.count - 1; i >= 0; --i) {
243 for (int i = remove.count - 1; i >= 0; --i) {
252 const int indexToRemove = remove.index + i;
244 const int indexToRemove = remove.index + i;
253 // We only support removing from the end
245 // We only support removing from the end
plugins/DashViews/organicgrid.h−4
@@ -79,11 +79,7 @@ private:
79 void doRelayout() override;
79 void doRelayout() override;
80 void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
80 void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
81 void calculateImplicitHeight() override;
81 void calculateImplicitHeight() override;
82−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
83− void processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes) override;
84−#else
85 void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
82 void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
86−#endif
87
83
88 QSizeF m_smallDelegateSize;
84 QSizeF m_smallDelegateSize;
89 QSizeF m_bigDelegateSize;
85 QSizeF m_bigDelegateSize;
plugins/DashViews/verticaljournal.cpp−8
@@ -239,17 +239,9 @@ void VerticalJournal::updateItemCulling(qreal visibleFromY, qreal visibleToY)
239 }
239 }
240}
240}
241
241
242−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
243−void VerticalJournal::processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes)
244−#else
245void VerticalJournal::processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes)
242void VerticalJournal::processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes)
246−#endif
247{
243{
248−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
249− Q_FOREACH(const QQuickChangeSet::Remove &remove, removes) {
250−#else
251 Q_FOREACH(const QQmlChangeSet::Remove &remove, removes) {
244 Q_FOREACH(const QQmlChangeSet::Remove &remove, removes) {
252−#endif
253 for (int i = remove.count - 1; i >= 0; --i) {
245 for (int i = remove.count - 1; i >= 0; --i) {
254 const int indexToRemove = remove.index + i;
246 const int indexToRemove = remove.index + i;
255 // Since we only support removing from the end, indexToRemove
247 // Since we only support removing from the end, indexToRemove
plugins/DashViews/verticaljournal.h−4
@@ -90,11 +90,7 @@ private:
90 void calculateImplicitHeight() override;
90 void calculateImplicitHeight() override;
91 void doRelayout() override;
91 void doRelayout() override;
92 void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
92 void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
93−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
94− void processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes) override;
95−#else
96 void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
93 void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
97−#endif
98
94
99 QVector<QList<ViewItem>> m_columnVisibleItems;
95 QVector<QList<ViewItem>> m_columnVisibleItems;
100 QHash<int, int> m_indexColumnMap;
96 QHash<int, int> m_indexColumnMap;
tests/plugins/DashViews/listviewwithpageheadertest.cpp−15
@@ -23,11 +23,7 @@
23#include <QtTestGui>
23#include <QtTestGui>
24#pragma GCC diagnostic push
24#pragma GCC diagnostic push
25#pragma GCC diagnostic ignored "-pedantic"
25#pragma GCC diagnostic ignored "-pedantic"
26−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
27−#include <private/qquicklistmodel_p.h>
28−#else
29#include <private/qqmllistmodel_p.h>
26#include <private/qqmllistmodel_p.h>
30−#endif
31#include <private/qquickanimation_p.h>
27#include <private/qquickanimation_p.h>
32#include <private/qquickitem_p.h>
28#include <private/qquickitem_p.h>
33#pragma GCC diagnostic pop
29#pragma GCC diagnostic pop
@@ -124,11 +120,7 @@ private Q_SLOTS:
124 view->engine()->addImportPath(BUILT_PLUGINS_DIR);
120 view->engine()->addImportPath(BUILT_PLUGINS_DIR);
125 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/listviewwithpageheadertest.qml"));
121 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/listviewwithpageheadertest.qml"));
126 lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
122 lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
127−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
128− model = view->rootObject()->findChild<QQuickListModel*>();
129−#else
130 model = view->rootObject()->findChild<QQmlListModel*>();
123 model = view->rootObject()->findChild<QQmlListModel*>();
131−#endif
132 otherDelegate = view->rootObject()->findChild<QQmlComponent*>();
124 otherDelegate = view->rootObject()->findChild<QQmlComponent*>();
133 QVERIFY(lvwph);
125 QVERIFY(lvwph);
134 QVERIFY(model);
126 QVERIFY(model);
@@ -1747,9 +1739,6 @@ private Q_SLOTS:
1747
1739
1748 void testMaximizeVisibleAreaMoveUpAndShowHeader()
1740 void testMaximizeVisibleAreaMoveUpAndShowHeader()
1749 {
1741 {
1750−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1751− QSKIP("This test is extremely unstable in 5.0.x");
1752−#endif
1753 model->setProperty(0, "size", 800);
1742 model->setProperty(0, "size", 800);
1754 verifyItem(0, 50., 800., false);
1743 verifyItem(0, 50., 800., false);
1755
1744
@@ -1913,11 +1902,7 @@ private Q_SLOTS:
1913private:
1902private:
1914 QQuickView *view;
1903 QQuickView *view;
1915 ListViewWithPageHeader *lvwph;
1904 ListViewWithPageHeader *lvwph;
1916−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1917− QQuickListModel *model;
1918−#else
1919 QQmlListModel *model;
1905 QQmlListModel *model;
1920−#endif
1921 QQmlComponent *otherDelegate;
1906 QQmlComponent *otherDelegate;
1922};
1907};
1923
1908
tests/plugins/DashViews/listviewwithpageheadertestsection.cpp−12
@@ -23,11 +23,7 @@
23#include <QtTestGui>
23#include <QtTestGui>
24#pragma GCC diagnostic push
24#pragma GCC diagnostic push
25#pragma GCC diagnostic ignored "-pedantic"
25#pragma GCC diagnostic ignored "-pedantic"
26−#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
27−#include <private/qquicklistmodel_p.h>
28−#else
29#include <private/qqmllistmodel_p.h>
26#include <private/qqmllistmodel_p.h>
30−#endif
31#include <private/qquickanimation_p.h>
27#include <private/qquickanimation_p.h>
32#include <private/qquickitem_p.h>
28#include <private/qquickitem_p.h>
33#pragma GCC diagnostic pop
29#pragma GCC diagnostic pop
@@ -135,11 +131,7 @@ private Q_SLOTS:
135 view->engine()->addImportPath(BUILT_PLUGINS_DIR);
131 view->engine()->addImportPath(BUILT_PLUGINS_DIR);
136 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/listviewwithpageheadertestsection.qml"));
132 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/listviewwithpageheadertestsection.qml"));
137 lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
133 lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
138−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
139− model = view->rootObject()->findChild<QQuickListModel*>();
140−#else
141 model = view->rootObject()->findChild<QQmlListModel*>();
134 model = view->rootObject()->findChild<QQmlListModel*>();
142−#endif
143 otherDelegate = view->rootObject()->findChild<QQmlComponent*>();
135 otherDelegate = view->rootObject()->findChild<QQmlComponent*>();
144 QVERIFY(lvwph);
136 QVERIFY(lvwph);
145 QVERIFY(model);
137 QVERIFY(model);
@@ -2156,11 +2148,7 @@ private Q_SLOTS:
2156private:
2148private:
2157 QQuickView *view;
2149 QQuickView *view;
2158 ListViewWithPageHeader *lvwph;
2150 ListViewWithPageHeader *lvwph;
2159−#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
2160− QQuickListModel *model;
2161−#else
2162 QQmlListModel *model;
2151 QQmlListModel *model;
2163−#endif
2164 QQmlComponent *otherDelegate;
2152 QQmlComponent *otherDelegate;
2165};
2153};
2166
2154
tests/plugins/DashViews/listviewwithpageheadertestsectionexternalmodel.cpp−4
@@ -24,11 +24,7 @@
24#include <QtTestGui>
24#include <QtTestGui>
25#pragma GCC diagnostic push
25#pragma GCC diagnostic push
26#pragma GCC diagnostic ignored "-pedantic"
26#pragma GCC diagnostic ignored "-pedantic"
27−#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
28−#include <private/qquicklistmodel_p.h>
29−#else
30#include <private/qqmllistmodel_p.h>
27#include <private/qqmllistmodel_p.h>
31−#endif
32#include <private/qquickanimation_p.h>
28#include <private/qquickanimation_p.h>
33#include <private/qquickitem_p.h>
29#include <private/qquickitem_p.h>
34#pragma GCC diagnostic pop
30#pragma GCC diagnostic pop