on xenial help sign in
Merge lp:~aacid/unity8/qlimitproxyfiltersetsamemodeltwice
commitbc55d282e531fdc6cc3a84a416baba249e36d1d9 authorAlbert Astals <albert.astals@canonical.com> dateTue 2 Jul 2013, 17:24 (13 years ago) parentd89488639fd092
3 files changed+23−4
Components/DragHandle.qml+4 plugins/Utils/qlimitproxymodelqml.cpp+4−4 tests/plugins/Utils/qlimitproxymodeltest.cpp+15
Components/DragHandle.qml+4
@@ -48,6 +48,10 @@ EdgeDragArea {
4848 id: dragArea
4949 objectName: "dragHandle"
5050
51+ // Disable gesture detection by default when hinting is used.
52+ // It doesn't make sense to have both.
53+ distanceThreshold: hintDisplacement > 0 ? 0 : units.gu(1.5)
54+
5155 property bool stretch: false
5256
5357 property alias autoCompleteDragThreshold: dragEvaluator.dragThreshold
plugins/Utils/qlimitproxymodelqml.cpp+4−4
@@ -39,11 +39,11 @@ QHash<int, QByteArray> QLimitProxyModelQML::roleNames() const
3939void
4040QLimitProxyModelQML::setModel(QAbstractItemModel *itemModel)
4141{
42− if (sourceModel() != NULL) {
43− sourceModel()->disconnect(this);
44− }
45−
4642 if (itemModel != sourceModel()) {
43+ if (sourceModel() != NULL) {
44+ sourceModel()->disconnect(this);
45+ }
46+
4747 setSourceModel(itemModel);
4848
4949 if (sourceModel() != NULL) {
tests/plugins/Utils/qlimitproxymodeltest.cpp+15
@@ -446,6 +446,7 @@ private Q_SLOTS:
446446
447447 ModelTest t1(&proxy);
448448 }
449+
449450 void testModelChanged() {
450451 QLimitProxyModelQML proxy;
451452 MockListModel model, model2;
@@ -464,6 +465,20 @@ private Q_SLOTS:
464465 proxy.setModel(&model);
465466 QCOMPARE(spyOnModelChanged.count(), 3);
466467 }
468+
469+ void setSameModelTwice() {
470+ QLimitProxyModelQML proxy;
471+ MockListModel model;
472+
473+ proxy.setModel(&model);
474+ proxy.setModel(&model);
475+
476+ QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged()));
477+
478+ model.insertRows(0, 5);
479+ QCOMPARE(proxy.rowCount(), 5);
480+ QCOMPARE(spyOnCountChanged.count(), 1);
481+ }
467482};
468483
469484QTEST_MAIN(QLimitProxyModelTest)