on xenial help sign in
Misc journal fixes
d3c71aaAlbert Astals
plugins/DashViews/abstractdashview.cpp+1−1
@@ -194,7 +194,7 @@ void AbstractDashView::createDelegateModel()
194
194
195void AbstractDashView::refill()
195void AbstractDashView::refill()
196{
196{
197− if (!isComponentComplete()) {
197+ if (!isComponentComplete() || height() < 0) {
198 return;
198 return;
199 }
199 }
200
200
plugins/DashViews/horizontaljournal.cpp+1
@@ -173,6 +173,7 @@ void HorizontalJournal::cleanupExistingItems()
173 m_visibleItems.clear();
173 m_visibleItems.clear();
174 m_lastInRowIndexPosition.clear();
174 m_lastInRowIndexPosition.clear();
175 m_firstVisibleIndex = -1;
175 m_firstVisibleIndex = -1;
176+ setImplicitHeightDirty();
176}
177}
177
178
178void HorizontalJournal::calculateImplicitHeight()
179void HorizontalJournal::calculateImplicitHeight()
plugins/DashViews/verticaljournal.cpp+2−1
@@ -79,7 +79,7 @@ void VerticalJournal::findBottomModelIndexToAdd(int *modelIndex, qreal *yPos)
79
79
80void VerticalJournal::findTopModelIndexToAdd(int *modelIndex, qreal *yPos)
80void VerticalJournal::findTopModelIndexToAdd(int *modelIndex, qreal *yPos)
81{
81{
82− *modelIndex = INT_MAX;
82+ *modelIndex = 0;
83 *yPos = std::numeric_limits<qreal>::lowest();
83 *yPos = std::numeric_limits<qreal>::lowest();
84 int columnToAddTo = -1;
84 int columnToAddTo = -1;
85
85
@@ -179,6 +179,7 @@ void VerticalJournal::cleanupExistingItems()
179 column.clear();
179 column.clear();
180 }
180 }
181 m_indexColumnMap.clear();
181 m_indexColumnMap.clear();
182+ setImplicitHeightDirty();
182}
183}
183
184
184void VerticalJournal::calculateImplicitHeight()
185void VerticalJournal::calculateImplicitHeight()
tests/plugins/DashViews/horizontaljournaltest.cpp+35−9
@@ -126,9 +126,9 @@ private Q_SLOTS:
126 view->engine()->addImportPath(BUILT_PLUGINS_DIR);
126 view->engine()->addImportPath(BUILT_PLUGINS_DIR);
127
127
128 model = new WidthModel();
128 model = new WidthModel();
129− QStringList heightList;
129+ QStringList widthList;
130− heightList << "100" << "50" << "125" << "10" << "40" << "70" << "200" << "110" << "160" << "20" << "20" << "65" << "80" << "200" << "300" << "130" << "400" << "300" << "500" << "10";
130+ widthList << "100" << "50" << "125" << "10" << "40" << "70" << "200" << "110" << "160" << "20" << "20" << "65" << "80" << "200" << "300" << "130" << "400" << "300" << "500" << "10";
131− model->setStringList(heightList);
131+ model->setStringList(widthList);
132
132
133 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/horizontaljournaltest.qml"));
133 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/horizontaljournaltest.qml"));
134
134
@@ -336,9 +336,9 @@ private Q_SLOTS:
336
336
337 void testModelReset()
337 void testModelReset()
338 {
338 {
339− QStringList heightList;
339+ QStringList widthList;
340− heightList << "100" << "50" << "125" << "25" << "50" << "50";
340+ widthList << "100" << "50" << "125" << "25" << "50" << "50";
341− model->setStringList(heightList);
341+ model->setStringList(widthList);
342
342
343 QTRY_COMPARE(hj->m_firstVisibleIndex, 0);
343 QTRY_COMPARE(hj->m_firstVisibleIndex, 0);
344 QTRY_COMPARE(hj->m_visibleItems.count(), 6);
344 QTRY_COMPARE(hj->m_visibleItems.count(), 6);
@@ -386,9 +386,9 @@ private Q_SLOTS:
386 void testModelAppendRemoveLast()
386 void testModelAppendRemoveLast()
387 {
387 {
388 WidthModel *model2 = new WidthModel();
388 WidthModel *model2 = new WidthModel();
389− QStringList heightList;
389+ QStringList widthList;
390− heightList << "100" << "50" << "125" << "25" << "50" << "50";
390+ widthList << "100" << "50" << "125" << "25" << "50" << "50";
391− model2->setStringList(heightList);
391+ model2->setStringList(widthList);
392 hj->setModel(model2);
392 hj->setModel(model2);
393 delete model;
393 delete model;
394 model = model2;
394 model = model2;
@@ -454,6 +454,32 @@ private Q_SLOTS:
454 QCOMPARE(hj->implicitHeight(), 310.);
454 QCOMPARE(hj->implicitHeight(), 310.);
455 }
455 }
456
456
457+ void testNegativeHeight()
458+ {
459+ QQuickItemPrivate::get(hj)->anchors()->resetFill();
460+ hj->setHeight(-8);
461+
462+ QStringList widthList;
463+ widthList << "100" << "50" << "125" << "25" << "50" << "50";
464+ model->setStringList(widthList);
465+
466+ QTRY_COMPARE(hj->m_visibleItems.count(), 0);
467+ QTRY_COMPARE(hj->implicitHeight(), 0.);
468+ }
469+
470+ void testNegativeDelegateCreationRange()
471+ {
472+ hj->setDelegateCreationBegin(0);
473+ hj->setDelegateCreationEnd(-100);
474+
475+ QStringList widthList;
476+ widthList << "100" << "50" << "50" << "30";
477+ model->setStringList(widthList);
478+
479+ QTRY_COMPARE(hj->m_visibleItems.count(), 0);
480+ QTRY_COMPARE(hj->implicitHeight(), 0.);
481+ }
482+
457private:
483private:
458 QQuickView *view;
484 QQuickView *view;
459 HorizontalJournal *hj;
485 HorizontalJournal *hj;
tests/plugins/DashViews/verticaljournaltest.cpp+32
@@ -459,6 +459,38 @@ private Q_SLOTS:
459 verifyItem(vj->m_columnVisibleItems[1][2], 7, 160, 120, true);
459 verifyItem(vj->m_columnVisibleItems[1][2], 7, 160, 120, true);
460 }
460 }
461
461
462+ void testNegativeHeight()
463+ {
464+ QQuickItemPrivate::get(vj)->anchors()->resetFill();
465+ vj->setHeight(-8);
466+
467+ QStringList heightList;
468+ heightList << "100" << "50" << "50" << "30";
469+ model->setStringList(heightList);
470+
471+ QTRY_COMPARE(vj->m_columnVisibleItems.count(), 3);
472+ QTRY_COMPARE(vj->m_columnVisibleItems[0].count(), 0);
473+ QTRY_COMPARE(vj->m_columnVisibleItems[1].count(), 0);
474+ QTRY_COMPARE(vj->m_columnVisibleItems[2].count(), 0);
475+ QTRY_COMPARE(vj->implicitHeight(), 0.);
476+ }
477+
478+ void testNegativeDelegateCreationRange()
479+ {
480+ vj->setDelegateCreationBegin(0);
481+ vj->setDelegateCreationEnd(-100);
482+
483+ QStringList heightList;
484+ heightList << "100" << "50" << "50" << "30";
485+ model->setStringList(heightList);
486+
487+ QTRY_COMPARE(vj->m_columnVisibleItems.count(), 3);
488+ QTRY_COMPARE(vj->m_columnVisibleItems[0].count(), 0);
489+ QTRY_COMPARE(vj->m_columnVisibleItems[1].count(), 0);
490+ QTRY_COMPARE(vj->m_columnVisibleItems[2].count(), 0);
491+ QTRY_COMPARE(vj->implicitHeight(), 0.);
492+ }
493+
462private:
494private:
463 QQuickView *view;
495 QQuickView *view;
464 VerticalJournal *vj;
496 VerticalJournal *vj;