Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kitemlistview.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
68 | 68 | | |||
69 | KItemListView::KItemListView(QGraphicsWidget* parent) : | 69 | KItemListView::KItemListView(QGraphicsWidget* parent) : | ||
70 | QGraphicsWidget(parent), | 70 | QGraphicsWidget(parent), | ||
71 | m_enabledSelectionToggles(false), | 71 | m_enabledSelectionToggles(false), | ||
72 | m_grouped(false), | 72 | m_grouped(false), | ||
73 | m_supportsItemExpanding(false), | 73 | m_supportsItemExpanding(false), | ||
74 | m_editingRole(false), | 74 | m_editingRole(false), | ||
75 | m_activeTransactions(0), | 75 | m_activeTransactions(0), | ||
76 | m_endTransactionAnimationHint(Animation), | 76 | m_endTransactionAnimationHint(LayoutAnimationHint::Animation), | ||
77 | m_itemSize(), | 77 | m_itemSize(), | ||
78 | m_controller(nullptr), | 78 | m_controller(nullptr), | ||
79 | m_model(nullptr), | 79 | m_model(nullptr), | ||
80 | m_visibleRoles(), | 80 | m_visibleRoles(), | ||
81 | m_widgetCreator(nullptr), | 81 | m_widgetCreator(nullptr), | ||
82 | m_groupHeaderCreator(nullptr), | 82 | m_groupHeaderCreator(nullptr), | ||
83 | m_styleOption(), | 83 | m_styleOption(), | ||
84 | m_visibleItems(), | 84 | m_visibleItems(), | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 149 | { | |||
157 | } | 157 | } | ||
158 | 158 | | |||
159 | m_layouter->setScrollOffset(offset); | 159 | m_layouter->setScrollOffset(offset); | ||
160 | m_animation->setScrollOffset(offset); | 160 | m_animation->setScrollOffset(offset); | ||
161 | 161 | | |||
162 | // Don't check whether the m_layoutTimer is active: Changing the | 162 | // Don't check whether the m_layoutTimer is active: Changing the | ||
163 | // scroll offset must always trigger a synchronous layout, otherwise | 163 | // scroll offset must always trigger a synchronous layout, otherwise | ||
164 | // the smooth-scrolling might get jerky. | 164 | // the smooth-scrolling might get jerky. | ||
165 | doLayout(NoAnimation); | 165 | doLayout(LayoutAnimationHint::NoAnimation); | ||
166 | onScrollOffsetChanged(offset, previousOffset); | 166 | onScrollOffsetChanged(offset, previousOffset); | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | qreal KItemListView::scrollOffset() const | 169 | qreal KItemListView::scrollOffset() const | ||
170 | { | 170 | { | ||
171 | return m_layouter->scrollOffset(); | 171 | return m_layouter->scrollOffset(); | ||
172 | } | 172 | } | ||
173 | 173 | | |||
Show All 11 Lines | 180 | { | |||
185 | m_layouter->setItemOffset(offset); | 185 | m_layouter->setItemOffset(offset); | ||
186 | if (m_headerWidget->isVisible()) { | 186 | if (m_headerWidget->isVisible()) { | ||
187 | m_headerWidget->setOffset(offset); | 187 | m_headerWidget->setOffset(offset); | ||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | // Don't check whether the m_layoutTimer is active: Changing the | 190 | // Don't check whether the m_layoutTimer is active: Changing the | ||
191 | // item offset must always trigger a synchronous layout, otherwise | 191 | // item offset must always trigger a synchronous layout, otherwise | ||
192 | // the smooth-scrolling might get jerky. | 192 | // the smooth-scrolling might get jerky. | ||
193 | doLayout(NoAnimation); | 193 | doLayout(LayoutAnimationHint::NoAnimation); | ||
194 | } | 194 | } | ||
195 | 195 | | |||
196 | qreal KItemListView::itemOffset() const | 196 | qreal KItemListView::itemOffset() const | ||
197 | { | 197 | { | ||
198 | return m_layouter->itemOffset(); | 198 | return m_layouter->itemOffset(); | ||
199 | } | 199 | } | ||
200 | 200 | | |||
201 | qreal KItemListView::maximumItemOffset() const | 201 | qreal KItemListView::maximumItemOffset() const | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 242 | while (it.hasNext()) { | |||
243 | it.next(); | 243 | it.next(); | ||
244 | KItemListWidget* widget = it.value(); | 244 | KItemListWidget* widget = it.value(); | ||
245 | widget->setVisibleRoles(roles); | 245 | widget->setVisibleRoles(roles); | ||
246 | if (alternateBackgroundsChanged) { | 246 | if (alternateBackgroundsChanged) { | ||
247 | updateAlternateBackgroundForWidget(widget); | 247 | updateAlternateBackgroundForWidget(widget); | ||
248 | } | 248 | } | ||
249 | } | 249 | } | ||
250 | 250 | | |||
251 | doLayout(NoAnimation); | 251 | doLayout(LayoutAnimationHint::NoAnimation); | ||
252 | } | 252 | } | ||
253 | 253 | | |||
254 | QList<QByteArray> KItemListView::visibleRoles() const | 254 | QList<QByteArray> KItemListView::visibleRoles() const | ||
255 | { | 255 | { | ||
256 | return m_visibleRoles; | 256 | return m_visibleRoles; | ||
257 | } | 257 | } | ||
258 | 258 | | |||
259 | void KItemListView::setAutoScroll(bool enabled) | 259 | void KItemListView::setAutoScroll(bool enabled) | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 361 | } else { | |||
363 | const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth), | 363 | const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth), | ||
364 | m_itemSize.height()); | 364 | m_itemSize.height()); | ||
365 | m_layouter->setItemSize(dynamicItemSize); | 365 | m_layouter->setItemSize(dynamicItemSize); | ||
366 | } | 366 | } | ||
367 | 367 | | |||
368 | // Triggering a synchronous layout is fine from a performance point of view, | 368 | // Triggering a synchronous layout is fine from a performance point of view, | ||
369 | // as with dynamic item sizes no moving animation must be done. | 369 | // as with dynamic item sizes no moving animation must be done. | ||
370 | m_layouter->setSize(newSize); | 370 | m_layouter->setSize(newSize); | ||
371 | doLayout(NoAnimation); | 371 | doLayout(LayoutAnimationHint::NoAnimation); | ||
372 | } else { | 372 | } else { | ||
373 | const bool animate = !changesItemGridLayout(newSize, | 373 | const bool animate = !changesItemGridLayout(newSize, | ||
374 | m_layouter->itemSize(), | 374 | m_layouter->itemSize(), | ||
375 | m_layouter->itemMargin()); | 375 | m_layouter->itemMargin()); | ||
376 | m_layouter->setSize(newSize); | 376 | m_layouter->setSize(newSize); | ||
377 | 377 | | |||
378 | if (animate) { | 378 | if (animate) { | ||
379 | // Trigger an asynchronous relayout with m_layoutTimer to prevent | 379 | // Trigger an asynchronous relayout with m_layoutTimer to prevent | ||
380 | // performance bottlenecks. If the timer is exceeded, an animated layout | 380 | // performance bottlenecks. If the timer is exceeded, an animated layout | ||
381 | // will be triggered. | 381 | // will be triggered. | ||
382 | if (!m_layoutTimer->isActive()) { | 382 | if (!m_layoutTimer->isActive()) { | ||
383 | m_layoutTimer->start(); | 383 | m_layoutTimer->start(); | ||
384 | } | 384 | } | ||
385 | } else { | 385 | } else { | ||
386 | m_layoutTimer->stop(); | 386 | m_layoutTimer->stop(); | ||
387 | doLayout(NoAnimation); | 387 | doLayout(LayoutAnimationHint::NoAnimation); | ||
388 | } | 388 | } | ||
389 | } | 389 | } | ||
390 | } | 390 | } | ||
391 | 391 | | |||
392 | qreal KItemListView::verticalPageStep() const | 392 | qreal KItemListView::verticalPageStep() const | ||
393 | { | 393 | { | ||
394 | qreal headerHeight = 0; | 394 | qreal headerHeight = 0; | ||
395 | if (m_headerWidget->isVisible()) { | 395 | if (m_headerWidget->isVisible()) { | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 551 | { | |||
553 | if (m_activeTransactions < 0) { | 553 | if (m_activeTransactions < 0) { | ||
554 | m_activeTransactions = 0; | 554 | m_activeTransactions = 0; | ||
555 | qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()"; | 555 | qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()"; | ||
556 | } | 556 | } | ||
557 | 557 | | |||
558 | if (m_activeTransactions == 0) { | 558 | if (m_activeTransactions == 0) { | ||
559 | onTransactionEnd(); | 559 | onTransactionEnd(); | ||
560 | doLayout(m_endTransactionAnimationHint); | 560 | doLayout(m_endTransactionAnimationHint); | ||
561 | m_endTransactionAnimationHint = Animation; | 561 | m_endTransactionAnimationHint = LayoutAnimationHint::Animation; | ||
562 | } | 562 | } | ||
563 | } | 563 | } | ||
564 | 564 | | |||
565 | bool KItemListView::isTransactionActive() const | 565 | bool KItemListView::isTransactionActive() const | ||
566 | { | 566 | { | ||
567 | return m_activeTransactions > 0; | 567 | return m_activeTransactions > 0; | ||
568 | } | 568 | } | ||
569 | 569 | | |||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 737 | } else { | |||
741 | const QSizeF newSize(currentWidth, size.height()); | 741 | const QSizeF newSize(currentWidth, size.height()); | ||
742 | m_layouter->setItemSize(newSize); | 742 | m_layouter->setItemSize(newSize); | ||
743 | } | 743 | } | ||
744 | } else { | 744 | } else { | ||
745 | m_layouter->setItemSize(size); | 745 | m_layouter->setItemSize(size); | ||
746 | } | 746 | } | ||
747 | 747 | | |||
748 | m_sizeHintResolver->clearCache(); | 748 | m_sizeHintResolver->clearCache(); | ||
749 | doLayout(animate ? Animation : NoAnimation); | 749 | doLayout(animate ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation); | ||
750 | onItemSizeChanged(size, previousSize); | 750 | onItemSizeChanged(size, previousSize); | ||
751 | } | 751 | } | ||
752 | 752 | | |||
753 | void KItemListView::setStyleOption(const KItemListStyleOption& option) | 753 | void KItemListView::setStyleOption(const KItemListStyleOption& option) | ||
754 | { | 754 | { | ||
755 | const KItemListStyleOption previousOption = m_styleOption; | 755 | const KItemListStyleOption previousOption = m_styleOption; | ||
756 | m_styleOption = option; | 756 | m_styleOption = option; | ||
757 | 757 | | |||
Show All 23 Lines | |||||
781 | QHashIterator<int, KItemListWidget*> it(m_visibleItems); | 781 | QHashIterator<int, KItemListWidget*> it(m_visibleItems); | ||
782 | while (it.hasNext()) { | 782 | while (it.hasNext()) { | ||
783 | it.next(); | 783 | it.next(); | ||
784 | it.value()->setStyleOption(option); | 784 | it.value()->setStyleOption(option); | ||
785 | } | 785 | } | ||
786 | 786 | | |||
787 | m_sizeHintResolver->clearCache(); | 787 | m_sizeHintResolver->clearCache(); | ||
788 | m_layouter->markAsDirty(); | 788 | m_layouter->markAsDirty(); | ||
789 | doLayout(animate ? Animation : NoAnimation); | 789 | doLayout(animate ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation); | ||
790 | 790 | | |||
791 | if (m_itemSize.isEmpty()) { | 791 | if (m_itemSize.isEmpty()) { | ||
792 | updatePreferredColumnWidths(); | 792 | updatePreferredColumnWidths(); | ||
793 | } | 793 | } | ||
794 | 794 | | |||
795 | onStyleOptionChanged(option, previousOption); | 795 | onStyleOptionChanged(option, previousOption); | ||
796 | } | 796 | } | ||
797 | 797 | | |||
Show All 13 Lines | 809 | if (m_grouped) { | |||
811 | while (it.hasNext()) { | 811 | while (it.hasNext()) { | ||
812 | it.next(); | 812 | it.next(); | ||
813 | it.value()->setScrollOrientation(orientation); | 813 | it.value()->setScrollOrientation(orientation); | ||
814 | } | 814 | } | ||
815 | updateGroupHeaderHeight(); | 815 | updateGroupHeaderHeight(); | ||
816 | 816 | | |||
817 | } | 817 | } | ||
818 | 818 | | |||
819 | doLayout(NoAnimation); | 819 | doLayout(LayoutAnimationHint::NoAnimation); | ||
820 | 820 | | |||
821 | onScrollOrientationChanged(orientation, previousOrientation); | 821 | onScrollOrientationChanged(orientation, previousOrientation); | ||
822 | emit scrollOrientationChanged(orientation, previousOrientation); | 822 | emit scrollOrientationChanged(orientation, previousOrientation); | ||
823 | } | 823 | } | ||
824 | 824 | | |||
825 | Qt::Orientation KItemListView::scrollOrientation() const | 825 | Qt::Orientation KItemListView::scrollOrientation() const | ||
826 | { | 826 | { | ||
827 | return m_layouter->scrollOrientation(); | 827 | return m_layouter->scrollOrientation(); | ||
▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Line(s) | 1060 | if (decreaseLayouterSize) { | |||
1071 | } else { | 1071 | } else { | ||
1072 | layouterSize.rheight() -= scrollBarExtent + scrollbarSpacing; | 1072 | layouterSize.rheight() -= scrollBarExtent + scrollbarSpacing; | ||
1073 | } | 1073 | } | ||
1074 | m_layouter->setSize(layouterSize); | 1074 | m_layouter->setSize(layouterSize); | ||
1075 | } | 1075 | } | ||
1076 | } | 1076 | } | ||
1077 | 1077 | | |||
1078 | if (!hasMultipleRanges) { | 1078 | if (!hasMultipleRanges) { | ||
1079 | doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, count); | 1079 | doLayout(animateChangedItemCount(count) ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation, index, count); | ||
1080 | updateSiblingsInformation(); | 1080 | updateSiblingsInformation(); | ||
1081 | } | 1081 | } | ||
1082 | } | 1082 | } | ||
1083 | 1083 | | |||
1084 | if (m_controller) { | 1084 | if (m_controller) { | ||
1085 | m_controller->selectionManager()->itemsInserted(itemRanges); | 1085 | m_controller->selectionManager()->itemsInserted(itemRanges); | ||
1086 | } | 1086 | } | ||
1087 | 1087 | | |||
1088 | if (hasMultipleRanges) { | 1088 | if (hasMultipleRanges) { | ||
1089 | m_endTransactionAnimationHint = NoAnimation; | 1089 | m_endTransactionAnimationHint = LayoutAnimationHint::NoAnimation; | ||
1090 | endTransaction(); | 1090 | endTransaction(); | ||
1091 | 1091 | | |||
1092 | updateSiblingsInformation(); | 1092 | updateSiblingsInformation(); | ||
1093 | } | 1093 | } | ||
1094 | 1094 | | |||
1095 | if (m_grouped && (hasMultipleRanges || itemRanges.first().count < m_model->count())) { | 1095 | if (m_grouped && (hasMultipleRanges || itemRanges.first().count < m_model->count())) { | ||
1096 | // In case if items of the same group have been inserted before an item that | 1096 | // In case if items of the same group have been inserted before an item that | ||
1097 | // currently represents the first item of the group, the group header of | 1097 | // currently represents the first item of the group, the group header of | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 1124 | for (int i = itemRanges.count() - 1; i >= 0; --i) { | |||
1187 | 1187 | | |||
1188 | if (!hasMultipleRanges) { | 1188 | if (!hasMultipleRanges) { | ||
1189 | // The decrease-layout-size optimization in KItemListView::slotItemsInserted() | 1189 | // The decrease-layout-size optimization in KItemListView::slotItemsInserted() | ||
1190 | // assumes an updated geometry. If items are removed during an active transaction, | 1190 | // assumes an updated geometry. If items are removed during an active transaction, | ||
1191 | // the transaction will be temporary deactivated so that doLayout() triggers a | 1191 | // the transaction will be temporary deactivated so that doLayout() triggers a | ||
1192 | // geometry update if necessary. | 1192 | // geometry update if necessary. | ||
1193 | const int activeTransactions = m_activeTransactions; | 1193 | const int activeTransactions = m_activeTransactions; | ||
1194 | m_activeTransactions = 0; | 1194 | m_activeTransactions = 0; | ||
1195 | doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, -count); | 1195 | doLayout(animateChangedItemCount(count) ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation, index, -count); | ||
1196 | m_activeTransactions = activeTransactions; | 1196 | m_activeTransactions = activeTransactions; | ||
1197 | updateSiblingsInformation(); | 1197 | updateSiblingsInformation(); | ||
1198 | } | 1198 | } | ||
1199 | } | 1199 | } | ||
1200 | 1200 | | |||
1201 | if (m_controller) { | 1201 | if (m_controller) { | ||
1202 | m_controller->selectionManager()->itemsRemoved(itemRanges); | 1202 | m_controller->selectionManager()->itemsRemoved(itemRanges); | ||
1203 | } | 1203 | } | ||
1204 | 1204 | | |||
1205 | if (hasMultipleRanges) { | 1205 | if (hasMultipleRanges) { | ||
1206 | m_endTransactionAnimationHint = NoAnimation; | 1206 | m_endTransactionAnimationHint = LayoutAnimationHint::NoAnimation; | ||
1207 | endTransaction(); | 1207 | endTransaction(); | ||
1208 | updateSiblingsInformation(); | 1208 | updateSiblingsInformation(); | ||
1209 | } | 1209 | } | ||
1210 | 1210 | | |||
1211 | if (m_grouped && (hasMultipleRanges || m_model->count() > 0)) { | 1211 | if (m_grouped && (hasMultipleRanges || m_model->count() > 0)) { | ||
1212 | // In case if the first item of a group has been removed, the group header | 1212 | // In case if the first item of a group has been removed, the group header | ||
1213 | // must be applied to the next visible item. | 1213 | // must be applied to the next visible item. | ||
1214 | updateVisibleGroupHeaders(); | 1214 | updateVisibleGroupHeaders(); | ||
Show All 19 Lines | 1223 | { | |||
1234 | for (int index = firstVisibleMovedIndex; index <= lastVisibleMovedIndex; ++index) { | 1234 | for (int index = firstVisibleMovedIndex; index <= lastVisibleMovedIndex; ++index) { | ||
1235 | KItemListWidget* widget = m_visibleItems.value(index); | 1235 | KItemListWidget* widget = m_visibleItems.value(index); | ||
1236 | if (widget) { | 1236 | if (widget) { | ||
1237 | updateWidgetProperties(widget, index); | 1237 | updateWidgetProperties(widget, index); | ||
1238 | initializeItemListWidget(widget); | 1238 | initializeItemListWidget(widget); | ||
1239 | } | 1239 | } | ||
1240 | } | 1240 | } | ||
1241 | 1241 | | |||
1242 | doLayout(NoAnimation); | 1242 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1243 | updateSiblingsInformation(); | 1243 | updateSiblingsInformation(); | ||
1244 | } | 1244 | } | ||
1245 | 1245 | | |||
1246 | void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, | 1246 | void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, | ||
1247 | const QSet<QByteArray>& roles) | 1247 | const QSet<QByteArray>& roles) | ||
1248 | { | 1248 | { | ||
1249 | const bool updateSizeHints = itemSizeHintUpdateRequired(roles); | 1249 | const bool updateSizeHints = itemSizeHintUpdateRequired(roles); | ||
1250 | if (updateSizeHints && m_itemSize.isEmpty()) { | 1250 | if (updateSizeHints && m_itemSize.isEmpty()) { | ||
Show All 21 Lines | 1271 | if (widget) { | |||
1272 | widget->setData(m_model->data(i), roles); | 1272 | widget->setData(m_model->data(i), roles); | ||
1273 | } | 1273 | } | ||
1274 | } | 1274 | } | ||
1275 | 1275 | | |||
1276 | if (m_grouped && roles.contains(m_model->sortRole())) { | 1276 | if (m_grouped && roles.contains(m_model->sortRole())) { | ||
1277 | // The sort-role has been changed which might result | 1277 | // The sort-role has been changed which might result | ||
1278 | // in modified group headers | 1278 | // in modified group headers | ||
1279 | updateVisibleGroupHeaders(); | 1279 | updateVisibleGroupHeaders(); | ||
1280 | doLayout(NoAnimation); | 1280 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1281 | } | 1281 | } | ||
1282 | 1282 | | |||
1283 | QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged); | 1283 | QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged); | ||
1284 | ev.setFirstRow(itemRange.index); | 1284 | ev.setFirstRow(itemRange.index); | ||
1285 | ev.setLastRow(itemRange.index + itemRange.count); | 1285 | ev.setLastRow(itemRange.index + itemRange.count); | ||
1286 | QAccessible::updateAccessibility(&ev); | 1286 | QAccessible::updateAccessibility(&ev); | ||
1287 | } | 1287 | } | ||
1288 | } | 1288 | } | ||
1289 | 1289 | | |||
1290 | void KItemListView::slotGroupsChanged() | 1290 | void KItemListView::slotGroupsChanged() | ||
1291 | { | 1291 | { | ||
1292 | updateVisibleGroupHeaders(); | 1292 | updateVisibleGroupHeaders(); | ||
1293 | doLayout(NoAnimation); | 1293 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1294 | updateSiblingsInformation(); | 1294 | updateSiblingsInformation(); | ||
1295 | } | 1295 | } | ||
1296 | 1296 | | |||
1297 | void KItemListView::slotGroupedSortingChanged(bool current) | 1297 | void KItemListView::slotGroupedSortingChanged(bool current) | ||
1298 | { | 1298 | { | ||
1299 | m_grouped = current; | 1299 | m_grouped = current; | ||
1300 | m_layouter->markAsDirty(); | 1300 | m_layouter->markAsDirty(); | ||
1301 | 1301 | | |||
Show All 13 Lines | |||||
1315 | 1315 | | |||
1316 | if (useAlternateBackgrounds()) { | 1316 | if (useAlternateBackgrounds()) { | ||
1317 | // Changing the group mode requires to update the alternate backgrounds | 1317 | // Changing the group mode requires to update the alternate backgrounds | ||
1318 | // as with the enabled group mode the altering is done on base of the first | 1318 | // as with the enabled group mode the altering is done on base of the first | ||
1319 | // group item. | 1319 | // group item. | ||
1320 | updateAlternateBackgrounds(); | 1320 | updateAlternateBackgrounds(); | ||
1321 | } | 1321 | } | ||
1322 | updateSiblingsInformation(); | 1322 | updateSiblingsInformation(); | ||
1323 | doLayout(NoAnimation); | 1323 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1324 | } | 1324 | } | ||
1325 | 1325 | | |||
1326 | void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) | 1326 | void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) | ||
1327 | { | 1327 | { | ||
1328 | Q_UNUSED(current); | 1328 | Q_UNUSED(current); | ||
1329 | Q_UNUSED(previous); | 1329 | Q_UNUSED(previous); | ||
1330 | if (m_grouped) { | 1330 | if (m_grouped) { | ||
1331 | updateVisibleGroupHeaders(); | 1331 | updateVisibleGroupHeaders(); | ||
1332 | doLayout(NoAnimation); | 1332 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1333 | } | 1333 | } | ||
1334 | } | 1334 | } | ||
1335 | 1335 | | |||
1336 | void KItemListView::slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) | 1336 | void KItemListView::slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) | ||
1337 | { | 1337 | { | ||
1338 | Q_UNUSED(current); | 1338 | Q_UNUSED(current); | ||
1339 | Q_UNUSED(previous); | 1339 | Q_UNUSED(previous); | ||
1340 | if (m_grouped) { | 1340 | if (m_grouped) { | ||
1341 | updateVisibleGroupHeaders(); | 1341 | updateVisibleGroupHeaders(); | ||
1342 | doLayout(NoAnimation); | 1342 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1343 | } | 1343 | } | ||
1344 | } | 1344 | } | ||
1345 | 1345 | | |||
1346 | void KItemListView::slotCurrentChanged(int current, int previous) | 1346 | void KItemListView::slotCurrentChanged(int current, int previous) | ||
1347 | { | 1347 | { | ||
1348 | Q_UNUSED(previous); | 1348 | Q_UNUSED(previous); | ||
1349 | 1349 | | |||
1350 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | 1350 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | ||
1351 | // always the selected item. It is not necessary to highlight the current item then. | 1351 | // always the selected item. It is not necessary to highlight the current item then. | ||
1352 | if (m_controller->selectionBehavior() != KItemListController::SingleSelection) { | 1352 | if (m_controller->selectionBehavior() != KItemListController::SelectionBehavior::SingleSelection) { | ||
1353 | KItemListWidget* previousWidget = m_visibleItems.value(previous, 0); | 1353 | KItemListWidget* previousWidget = m_visibleItems.value(previous, 0); | ||
1354 | if (previousWidget) { | 1354 | if (previousWidget) { | ||
1355 | previousWidget->setCurrent(false); | 1355 | previousWidget->setCurrent(false); | ||
1356 | } | 1356 | } | ||
1357 | 1357 | | |||
1358 | KItemListWidget* currentWidget = m_visibleItems.value(current, 0); | 1358 | KItemListWidget* currentWidget = m_visibleItems.value(current, 0); | ||
1359 | if (currentWidget) { | 1359 | if (currentWidget) { | ||
1360 | currentWidget->setCurrent(true); | 1360 | currentWidget->setCurrent(true); | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 1384 | { | |||
1414 | 1414 | | |||
1415 | default: break; | 1415 | default: break; | ||
1416 | } | 1416 | } | ||
1417 | } | 1417 | } | ||
1418 | 1418 | | |||
1419 | void KItemListView::slotLayoutTimerFinished() | 1419 | void KItemListView::slotLayoutTimerFinished() | ||
1420 | { | 1420 | { | ||
1421 | m_layouter->setSize(geometry().size()); | 1421 | m_layouter->setSize(geometry().size()); | ||
1422 | doLayout(Animation); | 1422 | doLayout(LayoutAnimationHint::Animation); | ||
1423 | } | 1423 | } | ||
1424 | 1424 | | |||
1425 | void KItemListView::slotRubberBandPosChanged() | 1425 | void KItemListView::slotRubberBandPosChanged() | ||
1426 | { | 1426 | { | ||
1427 | update(); | 1427 | update(); | ||
1428 | } | 1428 | } | ||
1429 | 1429 | | |||
1430 | void KItemListView::slotRubberBandActivationChanged(bool active) | 1430 | void KItemListView::slotRubberBandActivationChanged(bool active) | ||
Show All 16 Lines | 1445 | void KItemListView::slotHeaderColumnWidthChanged(const QByteArray& role, | |||
1447 | qreal previousWidth) | 1447 | qreal previousWidth) | ||
1448 | { | 1448 | { | ||
1449 | Q_UNUSED(role); | 1449 | Q_UNUSED(role); | ||
1450 | Q_UNUSED(currentWidth); | 1450 | Q_UNUSED(currentWidth); | ||
1451 | Q_UNUSED(previousWidth); | 1451 | Q_UNUSED(previousWidth); | ||
1452 | 1452 | | |||
1453 | m_headerWidget->setAutomaticColumnResizing(false); | 1453 | m_headerWidget->setAutomaticColumnResizing(false); | ||
1454 | applyColumnWidthsFromHeader(); | 1454 | applyColumnWidthsFromHeader(); | ||
1455 | doLayout(NoAnimation); | 1455 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1456 | } | 1456 | } | ||
1457 | 1457 | | |||
1458 | void KItemListView::slotHeaderColumnMoved(const QByteArray& role, | 1458 | void KItemListView::slotHeaderColumnMoved(const QByteArray& role, | ||
1459 | int currentIndex, | 1459 | int currentIndex, | ||
1460 | int previousIndex) | 1460 | int previousIndex) | ||
1461 | { | 1461 | { | ||
1462 | Q_ASSERT(m_visibleRoles[previousIndex] == role); | 1462 | Q_ASSERT(m_visibleRoles[previousIndex] == role); | ||
1463 | 1463 | | |||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | |||||
1645 | 1645 | | |||
1646 | void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount) | 1646 | void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount) | ||
1647 | { | 1647 | { | ||
1648 | if (m_layoutTimer->isActive()) { | 1648 | if (m_layoutTimer->isActive()) { | ||
1649 | m_layoutTimer->stop(); | 1649 | m_layoutTimer->stop(); | ||
1650 | } | 1650 | } | ||
1651 | 1651 | | |||
1652 | if (m_activeTransactions > 0) { | 1652 | if (m_activeTransactions > 0) { | ||
1653 | if (hint == NoAnimation) { | 1653 | if (hint == LayoutAnimationHint::NoAnimation) { | ||
1654 | // As soon as at least one property change should be done without animation, | 1654 | // As soon as at least one property change should be done without animation, | ||
1655 | // the whole transaction will be marked as not animated. | 1655 | // the whole transaction will be marked as not animated. | ||
1656 | m_endTransactionAnimationHint = NoAnimation; | 1656 | m_endTransactionAnimationHint = LayoutAnimationHint::NoAnimation; | ||
1657 | } | 1657 | } | ||
1658 | return; | 1658 | return; | ||
1659 | } | 1659 | } | ||
1660 | 1660 | | |||
1661 | if (!m_model || m_model->count() < 0) { | 1661 | if (!m_model || m_model->count() < 0) { | ||
1662 | return; | 1662 | return; | ||
1663 | } | 1663 | } | ||
1664 | 1664 | | |||
Show All 19 Lines | |||||
1684 | int lastSibblingIndex = -1; | 1684 | int lastSibblingIndex = -1; | ||
1685 | const bool supportsExpanding = supportsItemExpanding(); | 1685 | const bool supportsExpanding = supportsItemExpanding(); | ||
1686 | 1686 | | |||
1687 | QList<int> reusableItems = recycleInvisibleItems(firstVisibleIndex, lastVisibleIndex, hint); | 1687 | QList<int> reusableItems = recycleInvisibleItems(firstVisibleIndex, lastVisibleIndex, hint); | ||
1688 | 1688 | | |||
1689 | // Assure that for each visible item a KItemListWidget is available. KItemListWidget | 1689 | // Assure that for each visible item a KItemListWidget is available. KItemListWidget | ||
1690 | // instances from invisible items are reused. If no reusable items are | 1690 | // instances from invisible items are reused. If no reusable items are | ||
1691 | // found then new KItemListWidget instances get created. | 1691 | // found then new KItemListWidget instances get created. | ||
1692 | const bool animate = (hint == Animation); | 1692 | const bool animate = (hint == LayoutAnimationHint::Animation); | ||
1693 | for (int i = firstVisibleIndex; i <= lastVisibleIndex; ++i) { | 1693 | for (int i = firstVisibleIndex; i <= lastVisibleIndex; ++i) { | ||
1694 | bool applyNewPos = true; | 1694 | bool applyNewPos = true; | ||
1695 | bool wasHidden = false; | 1695 | bool wasHidden = false; | ||
1696 | 1696 | | |||
1697 | const QRectF itemBounds = m_layouter->itemRect(i); | 1697 | const QRectF itemBounds = m_layouter->itemRect(i); | ||
1698 | const QPointF newPos = itemBounds.topLeft(); | 1698 | const QPointF newPos = itemBounds.topLeft(); | ||
1699 | KItemListWidget* widget = m_visibleItems.value(i); | 1699 | KItemListWidget* widget = m_visibleItems.value(i); | ||
1700 | if (!widget) { | 1700 | if (!widget) { | ||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 1842 | while (it.hasNext()) { | |||
1843 | it.next(); | 1843 | it.next(); | ||
1844 | 1844 | | |||
1845 | KItemListWidget* widget = it.value(); | 1845 | KItemListWidget* widget = it.value(); | ||
1846 | const int index = widget->index(); | 1846 | const int index = widget->index(); | ||
1847 | const bool invisible = (index < firstVisibleIndex) || (index > lastVisibleIndex); | 1847 | const bool invisible = (index < firstVisibleIndex) || (index > lastVisibleIndex); | ||
1848 | 1848 | | |||
1849 | if (invisible) { | 1849 | if (invisible) { | ||
1850 | if (m_animation->isStarted(widget)) { | 1850 | if (m_animation->isStarted(widget)) { | ||
1851 | if (hint == NoAnimation) { | 1851 | if (hint == LayoutAnimationHint::NoAnimation) { | ||
1852 | // Stopping the animation will call KItemListView::slotAnimationFinished() | 1852 | // Stopping the animation will call KItemListView::slotAnimationFinished() | ||
1853 | // and the widget will be recycled if necessary there. | 1853 | // and the widget will be recycled if necessary there. | ||
1854 | m_animation->stop(widget); | 1854 | m_animation->stop(widget); | ||
1855 | } | 1855 | } | ||
1856 | } else { | 1856 | } else { | ||
1857 | widget->setVisible(false); | 1857 | widget->setVisible(false); | ||
1858 | items.append(index); | 1858 | items.append(index); | ||
1859 | 1859 | | |||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 1972 | { | |||
1982 | if (updateCell) { | 1982 | if (updateCell) { | ||
1983 | m_visibleCells.insert(index, newCell); | 1983 | m_visibleCells.insert(index, newCell); | ||
1984 | } | 1984 | } | ||
1985 | } | 1985 | } | ||
1986 | 1986 | | |||
1987 | void KItemListView::setLayouterSize(const QSizeF& size, SizeType sizeType) | 1987 | void KItemListView::setLayouterSize(const QSizeF& size, SizeType sizeType) | ||
1988 | { | 1988 | { | ||
1989 | switch (sizeType) { | 1989 | switch (sizeType) { | ||
1990 | case LayouterSize: m_layouter->setSize(size); break; | 1990 | case SizeType::LayouterSize: m_layouter->setSize(size); break; | ||
1991 | case ItemSize: m_layouter->setItemSize(size); break; | 1991 | case SizeType::ItemSize: m_layouter->setItemSize(size); break; | ||
1992 | default: break; | 1992 | default: break; | ||
1993 | } | 1993 | } | ||
1994 | } | 1994 | } | ||
1995 | 1995 | | |||
1996 | void KItemListView::updateWidgetProperties(KItemListWidget* widget, int index) | 1996 | void KItemListView::updateWidgetProperties(KItemListWidget* widget, int index) | ||
1997 | { | 1997 | { | ||
1998 | widget->setVisibleRoles(m_visibleRoles); | 1998 | widget->setVisibleRoles(m_visibleRoles); | ||
1999 | updateWidgetColumnWidths(widget); | 1999 | updateWidgetColumnWidths(widget); | ||
2000 | widget->setStyleOption(m_styleOption); | 2000 | widget->setStyleOption(m_styleOption); | ||
2001 | 2001 | | |||
2002 | const KItemListSelectionManager* selectionManager = m_controller->selectionManager(); | 2002 | const KItemListSelectionManager* selectionManager = m_controller->selectionManager(); | ||
2003 | 2003 | | |||
2004 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | 2004 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | ||
2005 | // always the selected item. It is not necessary to highlight the current item then. | 2005 | // always the selected item. It is not necessary to highlight the current item then. | ||
2006 | if (m_controller->selectionBehavior() != KItemListController::SingleSelection) { | 2006 | if (m_controller->selectionBehavior() != KItemListController::SelectionBehavior::SingleSelection) { | ||
2007 | widget->setCurrent(index == selectionManager->currentItem()); | 2007 | widget->setCurrent(index == selectionManager->currentItem()); | ||
2008 | } | 2008 | } | ||
2009 | widget->setSelected(selectionManager->isSelected(index)); | 2009 | widget->setSelected(selectionManager->isSelected(index)); | ||
2010 | widget->setHovered(false); | 2010 | widget->setHovered(false); | ||
2011 | widget->setEnabledSelectionToggle(enabledSelectionToggles()); | 2011 | widget->setEnabledSelectionToggle(enabledSelectionToggles()); | ||
2012 | widget->setIndex(index); | 2012 | widget->setIndex(index); | ||
2013 | widget->setData(m_model->data(index)); | 2013 | widget->setData(m_model->data(index)); | ||
2014 | widget->setSiblingsInformation(QBitArray()); | 2014 | widget->setSiblingsInformation(QBitArray()); | ||
▲ Show 20 Lines • Show All 726 Lines • Show Last 20 Lines |