Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kitemlistview.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
73 | 73 | | |||
74 | KItemListView::KItemListView(QGraphicsWidget* parent) : | 74 | KItemListView::KItemListView(QGraphicsWidget* parent) : | ||
75 | QGraphicsWidget(parent), | 75 | QGraphicsWidget(parent), | ||
76 | m_enabledSelectionToggles(false), | 76 | m_enabledSelectionToggles(false), | ||
77 | m_grouped(false), | 77 | m_grouped(false), | ||
78 | m_supportsItemExpanding(false), | 78 | m_supportsItemExpanding(false), | ||
79 | m_editingRole(false), | 79 | m_editingRole(false), | ||
80 | m_activeTransactions(0), | 80 | m_activeTransactions(0), | ||
81 | m_endTransactionAnimationHint(Animation), | 81 | m_endTransactionAnimationHint(LayoutAnimationHint::Animation), | ||
82 | m_itemSize(), | 82 | m_itemSize(), | ||
83 | m_controller(nullptr), | 83 | m_controller(nullptr), | ||
84 | m_model(nullptr), | 84 | m_model(nullptr), | ||
85 | m_visibleRoles(), | 85 | m_visibleRoles(), | ||
86 | m_widgetCreator(nullptr), | 86 | m_widgetCreator(nullptr), | ||
87 | m_groupHeaderCreator(nullptr), | 87 | m_groupHeaderCreator(nullptr), | ||
88 | m_styleOption(), | 88 | m_styleOption(), | ||
89 | m_visibleItems(), | 89 | m_visibleItems(), | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 154 | { | |||
162 | } | 162 | } | ||
163 | 163 | | |||
164 | m_layouter->setScrollOffset(offset); | 164 | m_layouter->setScrollOffset(offset); | ||
165 | m_animation->setScrollOffset(offset); | 165 | m_animation->setScrollOffset(offset); | ||
166 | 166 | | |||
167 | // Don't check whether the m_layoutTimer is active: Changing the | 167 | // Don't check whether the m_layoutTimer is active: Changing the | ||
168 | // scroll offset must always trigger a synchronous layout, otherwise | 168 | // scroll offset must always trigger a synchronous layout, otherwise | ||
169 | // the smooth-scrolling might get jerky. | 169 | // the smooth-scrolling might get jerky. | ||
170 | doLayout(NoAnimation); | 170 | doLayout(LayoutAnimationHint::NoAnimation); | ||
171 | onScrollOffsetChanged(offset, previousOffset); | 171 | onScrollOffsetChanged(offset, previousOffset); | ||
172 | } | 172 | } | ||
173 | 173 | | |||
174 | qreal KItemListView::scrollOffset() const | 174 | qreal KItemListView::scrollOffset() const | ||
175 | { | 175 | { | ||
176 | return m_layouter->scrollOffset(); | 176 | return m_layouter->scrollOffset(); | ||
177 | } | 177 | } | ||
178 | 178 | | |||
Show All 11 Lines | 185 | { | |||
190 | m_layouter->setItemOffset(offset); | 190 | m_layouter->setItemOffset(offset); | ||
191 | if (m_headerWidget->isVisible()) { | 191 | if (m_headerWidget->isVisible()) { | ||
192 | m_headerWidget->setOffset(offset); | 192 | m_headerWidget->setOffset(offset); | ||
193 | } | 193 | } | ||
194 | 194 | | |||
195 | // Don't check whether the m_layoutTimer is active: Changing the | 195 | // Don't check whether the m_layoutTimer is active: Changing the | ||
196 | // item offset must always trigger a synchronous layout, otherwise | 196 | // item offset must always trigger a synchronous layout, otherwise | ||
197 | // the smooth-scrolling might get jerky. | 197 | // the smooth-scrolling might get jerky. | ||
198 | doLayout(NoAnimation); | 198 | doLayout(LayoutAnimationHint::NoAnimation); | ||
199 | } | 199 | } | ||
200 | 200 | | |||
201 | qreal KItemListView::itemOffset() const | 201 | qreal KItemListView::itemOffset() const | ||
202 | { | 202 | { | ||
203 | return m_layouter->itemOffset(); | 203 | return m_layouter->itemOffset(); | ||
204 | } | 204 | } | ||
205 | 205 | | |||
206 | qreal KItemListView::maximumItemOffset() const | 206 | qreal KItemListView::maximumItemOffset() const | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 247 | while (it.hasNext()) { | |||
248 | it.next(); | 248 | it.next(); | ||
249 | KItemListWidget* widget = it.value(); | 249 | KItemListWidget* widget = it.value(); | ||
250 | widget->setVisibleRoles(roles); | 250 | widget->setVisibleRoles(roles); | ||
251 | if (alternateBackgroundsChanged) { | 251 | if (alternateBackgroundsChanged) { | ||
252 | updateAlternateBackgroundForWidget(widget); | 252 | updateAlternateBackgroundForWidget(widget); | ||
253 | } | 253 | } | ||
254 | } | 254 | } | ||
255 | 255 | | |||
256 | doLayout(NoAnimation); | 256 | doLayout(LayoutAnimationHint::NoAnimation); | ||
257 | } | 257 | } | ||
258 | 258 | | |||
259 | QList<QByteArray> KItemListView::visibleRoles() const | 259 | QList<QByteArray> KItemListView::visibleRoles() const | ||
260 | { | 260 | { | ||
261 | return m_visibleRoles; | 261 | return m_visibleRoles; | ||
262 | } | 262 | } | ||
263 | 263 | | |||
264 | void KItemListView::setAutoScroll(bool enabled) | 264 | void KItemListView::setAutoScroll(bool enabled) | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 366 | } else { | |||
368 | const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth), | 368 | const QSizeF dynamicItemSize(qMax(newSize.width(), requiredWidth), | ||
369 | m_itemSize.height()); | 369 | m_itemSize.height()); | ||
370 | m_layouter->setItemSize(dynamicItemSize); | 370 | m_layouter->setItemSize(dynamicItemSize); | ||
371 | } | 371 | } | ||
372 | 372 | | |||
373 | // Triggering a synchronous layout is fine from a performance point of view, | 373 | // Triggering a synchronous layout is fine from a performance point of view, | ||
374 | // as with dynamic item sizes no moving animation must be done. | 374 | // as with dynamic item sizes no moving animation must be done. | ||
375 | m_layouter->setSize(newSize); | 375 | m_layouter->setSize(newSize); | ||
376 | doLayout(NoAnimation); | 376 | doLayout(LayoutAnimationHint::NoAnimation); | ||
377 | } else { | 377 | } else { | ||
378 | const bool animate = !changesItemGridLayout(newSize, | 378 | const bool animate = !changesItemGridLayout(newSize, | ||
379 | m_layouter->itemSize(), | 379 | m_layouter->itemSize(), | ||
380 | m_layouter->itemMargin()); | 380 | m_layouter->itemMargin()); | ||
381 | m_layouter->setSize(newSize); | 381 | m_layouter->setSize(newSize); | ||
382 | 382 | | |||
383 | if (animate) { | 383 | if (animate) { | ||
384 | // Trigger an asynchronous relayout with m_layoutTimer to prevent | 384 | // Trigger an asynchronous relayout with m_layoutTimer to prevent | ||
385 | // performance bottlenecks. If the timer is exceeded, an animated layout | 385 | // performance bottlenecks. If the timer is exceeded, an animated layout | ||
386 | // will be triggered. | 386 | // will be triggered. | ||
387 | if (!m_layoutTimer->isActive()) { | 387 | if (!m_layoutTimer->isActive()) { | ||
388 | m_layoutTimer->start(); | 388 | m_layoutTimer->start(); | ||
389 | } | 389 | } | ||
390 | } else { | 390 | } else { | ||
391 | m_layoutTimer->stop(); | 391 | m_layoutTimer->stop(); | ||
392 | doLayout(NoAnimation); | 392 | doLayout(LayoutAnimationHint::NoAnimation); | ||
393 | } | 393 | } | ||
394 | } | 394 | } | ||
395 | } | 395 | } | ||
396 | 396 | | |||
397 | qreal KItemListView::verticalPageStep() const | 397 | qreal KItemListView::verticalPageStep() const | ||
398 | { | 398 | { | ||
399 | qreal headerHeight = 0; | 399 | qreal headerHeight = 0; | ||
400 | if (m_headerWidget->isVisible()) { | 400 | if (m_headerWidget->isVisible()) { | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 556 | { | |||
558 | if (m_activeTransactions < 0) { | 558 | if (m_activeTransactions < 0) { | ||
559 | m_activeTransactions = 0; | 559 | m_activeTransactions = 0; | ||
560 | qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()"; | 560 | qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()"; | ||
561 | } | 561 | } | ||
562 | 562 | | |||
563 | if (m_activeTransactions == 0) { | 563 | if (m_activeTransactions == 0) { | ||
564 | onTransactionEnd(); | 564 | onTransactionEnd(); | ||
565 | doLayout(m_endTransactionAnimationHint); | 565 | doLayout(m_endTransactionAnimationHint); | ||
566 | m_endTransactionAnimationHint = Animation; | 566 | m_endTransactionAnimationHint = LayoutAnimationHint::Animation; | ||
567 | } | 567 | } | ||
568 | } | 568 | } | ||
569 | 569 | | |||
570 | bool KItemListView::isTransactionActive() const | 570 | bool KItemListView::isTransactionActive() const | ||
571 | { | 571 | { | ||
572 | return m_activeTransactions > 0; | 572 | return m_activeTransactions > 0; | ||
573 | } | 573 | } | ||
574 | 574 | | |||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 742 | } else { | |||
746 | const QSizeF newSize(currentWidth, size.height()); | 746 | const QSizeF newSize(currentWidth, size.height()); | ||
747 | m_layouter->setItemSize(newSize); | 747 | m_layouter->setItemSize(newSize); | ||
748 | } | 748 | } | ||
749 | } else { | 749 | } else { | ||
750 | m_layouter->setItemSize(size); | 750 | m_layouter->setItemSize(size); | ||
751 | } | 751 | } | ||
752 | 752 | | |||
753 | m_sizeHintResolver->clearCache(); | 753 | m_sizeHintResolver->clearCache(); | ||
754 | doLayout(animate ? Animation : NoAnimation); | 754 | doLayout(animate ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation); | ||
755 | onItemSizeChanged(size, previousSize); | 755 | onItemSizeChanged(size, previousSize); | ||
756 | } | 756 | } | ||
757 | 757 | | |||
758 | void KItemListView::setStyleOption(const KItemListStyleOption& option) | 758 | void KItemListView::setStyleOption(const KItemListStyleOption& option) | ||
759 | { | 759 | { | ||
760 | const KItemListStyleOption previousOption = m_styleOption; | 760 | const KItemListStyleOption previousOption = m_styleOption; | ||
761 | m_styleOption = option; | 761 | m_styleOption = option; | ||
762 | 762 | | |||
Show All 23 Lines | |||||
786 | QHashIterator<int, KItemListWidget*> it(m_visibleItems); | 786 | QHashIterator<int, KItemListWidget*> it(m_visibleItems); | ||
787 | while (it.hasNext()) { | 787 | while (it.hasNext()) { | ||
788 | it.next(); | 788 | it.next(); | ||
789 | it.value()->setStyleOption(option); | 789 | it.value()->setStyleOption(option); | ||
790 | } | 790 | } | ||
791 | 791 | | |||
792 | m_sizeHintResolver->clearCache(); | 792 | m_sizeHintResolver->clearCache(); | ||
793 | m_layouter->markAsDirty(); | 793 | m_layouter->markAsDirty(); | ||
794 | doLayout(animate ? Animation : NoAnimation); | 794 | doLayout(animate ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation); | ||
795 | 795 | | |||
796 | if (m_itemSize.isEmpty()) { | 796 | if (m_itemSize.isEmpty()) { | ||
797 | updatePreferredColumnWidths(); | 797 | updatePreferredColumnWidths(); | ||
798 | } | 798 | } | ||
799 | 799 | | |||
800 | onStyleOptionChanged(option, previousOption); | 800 | onStyleOptionChanged(option, previousOption); | ||
801 | } | 801 | } | ||
802 | 802 | | |||
Show All 13 Lines | 814 | if (m_grouped) { | |||
816 | while (it.hasNext()) { | 816 | while (it.hasNext()) { | ||
817 | it.next(); | 817 | it.next(); | ||
818 | it.value()->setScrollOrientation(orientation); | 818 | it.value()->setScrollOrientation(orientation); | ||
819 | } | 819 | } | ||
820 | updateGroupHeaderHeight(); | 820 | updateGroupHeaderHeight(); | ||
821 | 821 | | |||
822 | } | 822 | } | ||
823 | 823 | | |||
824 | doLayout(NoAnimation); | 824 | doLayout(LayoutAnimationHint::NoAnimation); | ||
825 | 825 | | |||
826 | onScrollOrientationChanged(orientation, previousOrientation); | 826 | onScrollOrientationChanged(orientation, previousOrientation); | ||
827 | emit scrollOrientationChanged(orientation, previousOrientation); | 827 | emit scrollOrientationChanged(orientation, previousOrientation); | ||
828 | } | 828 | } | ||
829 | 829 | | |||
830 | Qt::Orientation KItemListView::scrollOrientation() const | 830 | Qt::Orientation KItemListView::scrollOrientation() const | ||
831 | { | 831 | { | ||
832 | return m_layouter->scrollOrientation(); | 832 | return m_layouter->scrollOrientation(); | ||
▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Line(s) | 1065 | if (decreaseLayouterSize) { | |||
1076 | } else { | 1076 | } else { | ||
1077 | layouterSize.rheight() -= scrollBarExtent + scrollbarSpacing; | 1077 | layouterSize.rheight() -= scrollBarExtent + scrollbarSpacing; | ||
1078 | } | 1078 | } | ||
1079 | m_layouter->setSize(layouterSize); | 1079 | m_layouter->setSize(layouterSize); | ||
1080 | } | 1080 | } | ||
1081 | } | 1081 | } | ||
1082 | 1082 | | |||
1083 | if (!hasMultipleRanges) { | 1083 | if (!hasMultipleRanges) { | ||
1084 | doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, count); | 1084 | doLayout(animateChangedItemCount(count) ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation, index, count); | ||
1085 | updateSiblingsInformation(); | 1085 | updateSiblingsInformation(); | ||
1086 | } | 1086 | } | ||
1087 | } | 1087 | } | ||
1088 | 1088 | | |||
1089 | if (m_controller) { | 1089 | if (m_controller) { | ||
1090 | m_controller->selectionManager()->itemsInserted(itemRanges); | 1090 | m_controller->selectionManager()->itemsInserted(itemRanges); | ||
1091 | } | 1091 | } | ||
1092 | 1092 | | |||
1093 | if (hasMultipleRanges) { | 1093 | if (hasMultipleRanges) { | ||
1094 | m_endTransactionAnimationHint = NoAnimation; | 1094 | m_endTransactionAnimationHint = LayoutAnimationHint::NoAnimation; | ||
1095 | endTransaction(); | 1095 | endTransaction(); | ||
1096 | 1096 | | |||
1097 | updateSiblingsInformation(); | 1097 | updateSiblingsInformation(); | ||
1098 | } | 1098 | } | ||
1099 | 1099 | | |||
1100 | if (m_grouped && (hasMultipleRanges || itemRanges.first().count < m_model->count())) { | 1100 | if (m_grouped && (hasMultipleRanges || itemRanges.first().count < m_model->count())) { | ||
1101 | // In case if items of the same group have been inserted before an item that | 1101 | // In case if items of the same group have been inserted before an item that | ||
1102 | // currently represents the first item of the group, the group header of | 1102 | // currently represents the first item of the group, the group header of | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 1145 | foreach (KItemListWidget* widget, m_visibleItems) { | |||
1165 | } else { | 1165 | } else { | ||
1166 | // Animate the removing of the items. Special case: When removing an item there | 1166 | // Animate the removing of the items. Special case: When removing an item there | ||
1167 | // is no valid model index available anymore. For the | 1167 | // is no valid model index available anymore. For the | ||
1168 | // remove-animation the item gets removed from m_visibleItems but the widget | 1168 | // remove-animation the item gets removed from m_visibleItems but the widget | ||
1169 | // will stay alive until the animation has been finished and will | 1169 | // will stay alive until the animation has been finished and will | ||
1170 | // be recycled (deleted) in KItemListView::slotAnimationFinished(). | 1170 | // be recycled (deleted) in KItemListView::slotAnimationFinished(). | ||
1171 | m_visibleItems.remove(i); | 1171 | m_visibleItems.remove(i); | ||
1172 | widget->setIndex(-1); | 1172 | widget->setIndex(-1); | ||
1173 | m_animation->start(widget, KItemListViewAnimation::DeleteAnimation); | 1173 | m_animation->start(widget, KItemListViewAnimation::AnimationType::Delete); | ||
1174 | } | 1174 | } | ||
1175 | } | 1175 | } | ||
1176 | 1176 | | |||
1177 | // Update the indexes of all KItemListWidget instances that are located | 1177 | // Update the indexes of all KItemListWidget instances that are located | ||
1178 | // after the deleted items. It is important to update them in ascending | 1178 | // after the deleted items. It is important to update them in ascending | ||
1179 | // order to prevent overlaps when setting the new index. | 1179 | // order to prevent overlaps when setting the new index. | ||
1180 | std::sort(itemsToMove.begin(), itemsToMove.end()); | 1180 | std::sort(itemsToMove.begin(), itemsToMove.end()); | ||
1181 | foreach (int i, itemsToMove) { | 1181 | foreach (int i, itemsToMove) { | ||
Show All 10 Lines | |||||
1192 | 1192 | | |||
1193 | if (!hasMultipleRanges) { | 1193 | if (!hasMultipleRanges) { | ||
1194 | // The decrease-layout-size optimization in KItemListView::slotItemsInserted() | 1194 | // The decrease-layout-size optimization in KItemListView::slotItemsInserted() | ||
1195 | // assumes an updated geometry. If items are removed during an active transaction, | 1195 | // assumes an updated geometry. If items are removed during an active transaction, | ||
1196 | // the transaction will be temporary deactivated so that doLayout() triggers a | 1196 | // the transaction will be temporary deactivated so that doLayout() triggers a | ||
1197 | // geometry update if necessary. | 1197 | // geometry update if necessary. | ||
1198 | const int activeTransactions = m_activeTransactions; | 1198 | const int activeTransactions = m_activeTransactions; | ||
1199 | m_activeTransactions = 0; | 1199 | m_activeTransactions = 0; | ||
1200 | doLayout(animateChangedItemCount(count) ? Animation : NoAnimation, index, -count); | 1200 | doLayout(animateChangedItemCount(count) ? LayoutAnimationHint::Animation : LayoutAnimationHint::NoAnimation, index, -count); | ||
1201 | m_activeTransactions = activeTransactions; | 1201 | m_activeTransactions = activeTransactions; | ||
1202 | updateSiblingsInformation(); | 1202 | updateSiblingsInformation(); | ||
1203 | } | 1203 | } | ||
1204 | } | 1204 | } | ||
1205 | 1205 | | |||
1206 | if (m_controller) { | 1206 | if (m_controller) { | ||
1207 | m_controller->selectionManager()->itemsRemoved(itemRanges); | 1207 | m_controller->selectionManager()->itemsRemoved(itemRanges); | ||
1208 | } | 1208 | } | ||
1209 | 1209 | | |||
1210 | if (hasMultipleRanges) { | 1210 | if (hasMultipleRanges) { | ||
1211 | m_endTransactionAnimationHint = NoAnimation; | 1211 | m_endTransactionAnimationHint = LayoutAnimationHint::NoAnimation; | ||
1212 | endTransaction(); | 1212 | endTransaction(); | ||
1213 | updateSiblingsInformation(); | 1213 | updateSiblingsInformation(); | ||
1214 | } | 1214 | } | ||
1215 | 1215 | | |||
1216 | if (m_grouped && (hasMultipleRanges || m_model->count() > 0)) { | 1216 | if (m_grouped && (hasMultipleRanges || m_model->count() > 0)) { | ||
1217 | // In case if the first item of a group has been removed, the group header | 1217 | // In case if the first item of a group has been removed, the group header | ||
1218 | // must be applied to the next visible item. | 1218 | // must be applied to the next visible item. | ||
1219 | updateVisibleGroupHeaders(); | 1219 | updateVisibleGroupHeaders(); | ||
Show All 19 Lines | 1228 | { | |||
1239 | for (int index = firstVisibleMovedIndex; index <= lastVisibleMovedIndex; ++index) { | 1239 | for (int index = firstVisibleMovedIndex; index <= lastVisibleMovedIndex; ++index) { | ||
1240 | KItemListWidget* widget = m_visibleItems.value(index); | 1240 | KItemListWidget* widget = m_visibleItems.value(index); | ||
1241 | if (widget) { | 1241 | if (widget) { | ||
1242 | updateWidgetProperties(widget, index); | 1242 | updateWidgetProperties(widget, index); | ||
1243 | initializeItemListWidget(widget); | 1243 | initializeItemListWidget(widget); | ||
1244 | } | 1244 | } | ||
1245 | } | 1245 | } | ||
1246 | 1246 | | |||
1247 | doLayout(NoAnimation); | 1247 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1248 | updateSiblingsInformation(); | 1248 | updateSiblingsInformation(); | ||
1249 | } | 1249 | } | ||
1250 | 1250 | | |||
1251 | void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, | 1251 | void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges, | ||
1252 | const QSet<QByteArray>& roles) | 1252 | const QSet<QByteArray>& roles) | ||
1253 | { | 1253 | { | ||
1254 | const bool updateSizeHints = itemSizeHintUpdateRequired(roles); | 1254 | const bool updateSizeHints = itemSizeHintUpdateRequired(roles); | ||
1255 | if (updateSizeHints && m_itemSize.isEmpty()) { | 1255 | if (updateSizeHints && m_itemSize.isEmpty()) { | ||
Show All 21 Lines | 1276 | if (widget) { | |||
1277 | widget->setData(m_model->data(i), roles); | 1277 | widget->setData(m_model->data(i), roles); | ||
1278 | } | 1278 | } | ||
1279 | } | 1279 | } | ||
1280 | 1280 | | |||
1281 | if (m_grouped && roles.contains(m_model->sortRole())) { | 1281 | if (m_grouped && roles.contains(m_model->sortRole())) { | ||
1282 | // The sort-role has been changed which might result | 1282 | // The sort-role has been changed which might result | ||
1283 | // in modified group headers | 1283 | // in modified group headers | ||
1284 | updateVisibleGroupHeaders(); | 1284 | updateVisibleGroupHeaders(); | ||
1285 | doLayout(NoAnimation); | 1285 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1286 | } | 1286 | } | ||
1287 | 1287 | | |||
1288 | QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged); | 1288 | QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged); | ||
1289 | ev.setFirstRow(itemRange.index); | 1289 | ev.setFirstRow(itemRange.index); | ||
1290 | ev.setLastRow(itemRange.index + itemRange.count); | 1290 | ev.setLastRow(itemRange.index + itemRange.count); | ||
1291 | QAccessible::updateAccessibility(&ev); | 1291 | QAccessible::updateAccessibility(&ev); | ||
1292 | } | 1292 | } | ||
1293 | } | 1293 | } | ||
1294 | 1294 | | |||
1295 | void KItemListView::slotGroupsChanged() | 1295 | void KItemListView::slotGroupsChanged() | ||
1296 | { | 1296 | { | ||
1297 | updateVisibleGroupHeaders(); | 1297 | updateVisibleGroupHeaders(); | ||
1298 | doLayout(NoAnimation); | 1298 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1299 | updateSiblingsInformation(); | 1299 | updateSiblingsInformation(); | ||
1300 | } | 1300 | } | ||
1301 | 1301 | | |||
1302 | void KItemListView::slotGroupedSortingChanged(bool current) | 1302 | void KItemListView::slotGroupedSortingChanged(bool current) | ||
1303 | { | 1303 | { | ||
1304 | m_grouped = current; | 1304 | m_grouped = current; | ||
1305 | m_layouter->markAsDirty(); | 1305 | m_layouter->markAsDirty(); | ||
1306 | 1306 | | |||
Show All 13 Lines | |||||
1320 | 1320 | | |||
1321 | if (useAlternateBackgrounds()) { | 1321 | if (useAlternateBackgrounds()) { | ||
1322 | // Changing the group mode requires to update the alternate backgrounds | 1322 | // Changing the group mode requires to update the alternate backgrounds | ||
1323 | // as with the enabled group mode the altering is done on base of the first | 1323 | // as with the enabled group mode the altering is done on base of the first | ||
1324 | // group item. | 1324 | // group item. | ||
1325 | updateAlternateBackgrounds(); | 1325 | updateAlternateBackgrounds(); | ||
1326 | } | 1326 | } | ||
1327 | updateSiblingsInformation(); | 1327 | updateSiblingsInformation(); | ||
1328 | doLayout(NoAnimation); | 1328 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1329 | } | 1329 | } | ||
1330 | 1330 | | |||
1331 | void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) | 1331 | void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) | ||
1332 | { | 1332 | { | ||
1333 | Q_UNUSED(current); | 1333 | Q_UNUSED(current); | ||
1334 | Q_UNUSED(previous); | 1334 | Q_UNUSED(previous); | ||
1335 | if (m_grouped) { | 1335 | if (m_grouped) { | ||
1336 | updateVisibleGroupHeaders(); | 1336 | updateVisibleGroupHeaders(); | ||
1337 | doLayout(NoAnimation); | 1337 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1338 | } | 1338 | } | ||
1339 | } | 1339 | } | ||
1340 | 1340 | | |||
1341 | void KItemListView::slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) | 1341 | void KItemListView::slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) | ||
1342 | { | 1342 | { | ||
1343 | Q_UNUSED(current); | 1343 | Q_UNUSED(current); | ||
1344 | Q_UNUSED(previous); | 1344 | Q_UNUSED(previous); | ||
1345 | if (m_grouped) { | 1345 | if (m_grouped) { | ||
1346 | updateVisibleGroupHeaders(); | 1346 | updateVisibleGroupHeaders(); | ||
1347 | doLayout(NoAnimation); | 1347 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1348 | } | 1348 | } | ||
1349 | } | 1349 | } | ||
1350 | 1350 | | |||
1351 | void KItemListView::slotCurrentChanged(int current, int previous) | 1351 | void KItemListView::slotCurrentChanged(int current, int previous) | ||
1352 | { | 1352 | { | ||
1353 | Q_UNUSED(previous); | 1353 | Q_UNUSED(previous); | ||
1354 | 1354 | | |||
1355 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | 1355 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | ||
1356 | // always the selected item. It is not necessary to highlight the current item then. | 1356 | // always the selected item. It is not necessary to highlight the current item then. | ||
1357 | if (m_controller->selectionBehavior() != KItemListController::SingleSelection) { | 1357 | if (m_controller->selectionBehavior() != KItemListController::SelectionBehavior::SingleSelection) { | ||
1358 | KItemListWidget* previousWidget = m_visibleItems.value(previous, 0); | 1358 | KItemListWidget* previousWidget = m_visibleItems.value(previous, 0); | ||
1359 | if (previousWidget) { | 1359 | if (previousWidget) { | ||
1360 | previousWidget->setCurrent(false); | 1360 | previousWidget->setCurrent(false); | ||
1361 | } | 1361 | } | ||
1362 | 1362 | | |||
1363 | KItemListWidget* currentWidget = m_visibleItems.value(current, 0); | 1363 | KItemListWidget* currentWidget = m_visibleItems.value(current, 0); | ||
1364 | if (currentWidget) { | 1364 | if (currentWidget) { | ||
1365 | currentWidget->setCurrent(true); | 1365 | currentWidget->setCurrent(true); | ||
Show All 20 Lines | |||||
1386 | 1386 | | |||
1387 | void KItemListView::slotAnimationFinished(QGraphicsWidget* widget, | 1387 | void KItemListView::slotAnimationFinished(QGraphicsWidget* widget, | ||
1388 | KItemListViewAnimation::AnimationType type) | 1388 | KItemListViewAnimation::AnimationType type) | ||
1389 | { | 1389 | { | ||
1390 | KItemListWidget* itemListWidget = qobject_cast<KItemListWidget*>(widget); | 1390 | KItemListWidget* itemListWidget = qobject_cast<KItemListWidget*>(widget); | ||
1391 | Q_ASSERT(itemListWidget); | 1391 | Q_ASSERT(itemListWidget); | ||
1392 | 1392 | | |||
1393 | switch (type) { | 1393 | switch (type) { | ||
1394 | case KItemListViewAnimation::DeleteAnimation: { | 1394 | case KItemListViewAnimation::AnimationType::Delete: { | ||
1395 | // As we recycle the widget in this case it is important to assure that no | 1395 | // As we recycle the widget in this case it is important to assure that no | ||
1396 | // other animation has been started. This is a convention in KItemListView and | 1396 | // other animation has been started. This is a convention in KItemListView and | ||
1397 | // not a requirement defined by KItemListViewAnimation. | 1397 | // not a requirement defined by KItemListViewAnimation. | ||
1398 | Q_ASSERT(!m_animation->isStarted(itemListWidget)); | 1398 | Q_ASSERT(!m_animation->isStarted(itemListWidget)); | ||
1399 | 1399 | | |||
1400 | // All KItemListWidgets that are animated by the DeleteAnimation are not maintained | 1400 | // All KItemListWidgets that are animated by the DeleteAnimation are not maintained | ||
1401 | // by m_visibleWidgets and must be deleted manually after the animation has | 1401 | // by m_visibleWidgets and must be deleted manually after the animation has | ||
1402 | // been finished. | 1402 | // been finished. | ||
1403 | recycleGroupHeaderForWidget(itemListWidget); | 1403 | recycleGroupHeaderForWidget(itemListWidget); | ||
1404 | widgetCreator()->recycle(itemListWidget); | 1404 | widgetCreator()->recycle(itemListWidget); | ||
1405 | break; | 1405 | break; | ||
1406 | } | 1406 | } | ||
1407 | 1407 | | |||
1408 | case KItemListViewAnimation::CreateAnimation: | 1408 | case KItemListViewAnimation::AnimationType::Create: | ||
1409 | case KItemListViewAnimation::MovingAnimation: | 1409 | case KItemListViewAnimation::AnimationType::Moving: | ||
1410 | case KItemListViewAnimation::ResizeAnimation: { | 1410 | case KItemListViewAnimation::AnimationType::Resize: { | ||
1411 | const int index = itemListWidget->index(); | 1411 | const int index = itemListWidget->index(); | ||
1412 | const bool invisible = (index < m_layouter->firstVisibleIndex()) || | 1412 | const bool invisible = (index < m_layouter->firstVisibleIndex()) || | ||
1413 | (index > m_layouter->lastVisibleIndex()); | 1413 | (index > m_layouter->lastVisibleIndex()); | ||
1414 | if (invisible && !m_animation->isStarted(itemListWidget)) { | 1414 | if (invisible && !m_animation->isStarted(itemListWidget)) { | ||
1415 | recycleWidget(itemListWidget); | 1415 | recycleWidget(itemListWidget); | ||
1416 | } | 1416 | } | ||
1417 | break; | 1417 | break; | ||
1418 | } | 1418 | } | ||
1419 | 1419 | | |||
1420 | default: break; | 1420 | default: break; | ||
1421 | } | 1421 | } | ||
1422 | } | 1422 | } | ||
1423 | 1423 | | |||
1424 | void KItemListView::slotLayoutTimerFinished() | 1424 | void KItemListView::slotLayoutTimerFinished() | ||
1425 | { | 1425 | { | ||
1426 | m_layouter->setSize(geometry().size()); | 1426 | m_layouter->setSize(geometry().size()); | ||
1427 | doLayout(Animation); | 1427 | doLayout(LayoutAnimationHint::Animation); | ||
1428 | } | 1428 | } | ||
1429 | 1429 | | |||
1430 | void KItemListView::slotRubberBandPosChanged() | 1430 | void KItemListView::slotRubberBandPosChanged() | ||
1431 | { | 1431 | { | ||
1432 | update(); | 1432 | update(); | ||
1433 | } | 1433 | } | ||
1434 | 1434 | | |||
1435 | void KItemListView::slotRubberBandActivationChanged(bool active) | 1435 | void KItemListView::slotRubberBandActivationChanged(bool active) | ||
Show All 16 Lines | 1450 | void KItemListView::slotHeaderColumnWidthChanged(const QByteArray& role, | |||
1452 | qreal previousWidth) | 1452 | qreal previousWidth) | ||
1453 | { | 1453 | { | ||
1454 | Q_UNUSED(role); | 1454 | Q_UNUSED(role); | ||
1455 | Q_UNUSED(currentWidth); | 1455 | Q_UNUSED(currentWidth); | ||
1456 | Q_UNUSED(previousWidth); | 1456 | Q_UNUSED(previousWidth); | ||
1457 | 1457 | | |||
1458 | m_headerWidget->setAutomaticColumnResizing(false); | 1458 | m_headerWidget->setAutomaticColumnResizing(false); | ||
1459 | applyColumnWidthsFromHeader(); | 1459 | applyColumnWidthsFromHeader(); | ||
1460 | doLayout(NoAnimation); | 1460 | doLayout(LayoutAnimationHint::NoAnimation); | ||
1461 | } | 1461 | } | ||
1462 | 1462 | | |||
1463 | void KItemListView::slotHeaderColumnMoved(const QByteArray& role, | 1463 | void KItemListView::slotHeaderColumnMoved(const QByteArray& role, | ||
1464 | int currentIndex, | 1464 | int currentIndex, | ||
1465 | int previousIndex) | 1465 | int previousIndex) | ||
1466 | { | 1466 | { | ||
1467 | Q_ASSERT(m_visibleRoles[previousIndex] == role); | 1467 | Q_ASSERT(m_visibleRoles[previousIndex] == role); | ||
1468 | 1468 | | |||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | |||||
1650 | 1650 | | |||
1651 | void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount) | 1651 | void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount) | ||
1652 | { | 1652 | { | ||
1653 | if (m_layoutTimer->isActive()) { | 1653 | if (m_layoutTimer->isActive()) { | ||
1654 | m_layoutTimer->stop(); | 1654 | m_layoutTimer->stop(); | ||
1655 | } | 1655 | } | ||
1656 | 1656 | | |||
1657 | if (m_activeTransactions > 0) { | 1657 | if (m_activeTransactions > 0) { | ||
1658 | if (hint == NoAnimation) { | 1658 | if (hint == LayoutAnimationHint::NoAnimation) { | ||
1659 | // As soon as at least one property change should be done without animation, | 1659 | // As soon as at least one property change should be done without animation, | ||
1660 | // the whole transaction will be marked as not animated. | 1660 | // the whole transaction will be marked as not animated. | ||
1661 | m_endTransactionAnimationHint = NoAnimation; | 1661 | m_endTransactionAnimationHint = LayoutAnimationHint::NoAnimation; | ||
1662 | } | 1662 | } | ||
1663 | return; | 1663 | return; | ||
1664 | } | 1664 | } | ||
1665 | 1665 | | |||
1666 | if (!m_model || m_model->count() < 0) { | 1666 | if (!m_model || m_model->count() < 0) { | ||
1667 | return; | 1667 | return; | ||
1668 | } | 1668 | } | ||
1669 | 1669 | | |||
Show All 19 Lines | |||||
1689 | int lastSibblingIndex = -1; | 1689 | int lastSibblingIndex = -1; | ||
1690 | const bool supportsExpanding = supportsItemExpanding(); | 1690 | const bool supportsExpanding = supportsItemExpanding(); | ||
1691 | 1691 | | |||
1692 | QList<int> reusableItems = recycleInvisibleItems(firstVisibleIndex, lastVisibleIndex, hint); | 1692 | QList<int> reusableItems = recycleInvisibleItems(firstVisibleIndex, lastVisibleIndex, hint); | ||
1693 | 1693 | | |||
1694 | // Assure that for each visible item a KItemListWidget is available. KItemListWidget | 1694 | // Assure that for each visible item a KItemListWidget is available. KItemListWidget | ||
1695 | // instances from invisible items are reused. If no reusable items are | 1695 | // instances from invisible items are reused. If no reusable items are | ||
1696 | // found then new KItemListWidget instances get created. | 1696 | // found then new KItemListWidget instances get created. | ||
1697 | const bool animate = (hint == Animation); | 1697 | const bool animate = (hint == LayoutAnimationHint::Animation); | ||
1698 | for (int i = firstVisibleIndex; i <= lastVisibleIndex; ++i) { | 1698 | for (int i = firstVisibleIndex; i <= lastVisibleIndex; ++i) { | ||
1699 | bool applyNewPos = true; | 1699 | bool applyNewPos = true; | ||
1700 | bool wasHidden = false; | 1700 | bool wasHidden = false; | ||
1701 | 1701 | | |||
1702 | const QRectF itemBounds = m_layouter->itemRect(i); | 1702 | const QRectF itemBounds = m_layouter->itemRect(i); | ||
1703 | const QPointF newPos = itemBounds.topLeft(); | 1703 | const QPointF newPos = itemBounds.topLeft(); | ||
1704 | KItemListWidget* widget = m_visibleItems.value(i); | 1704 | KItemListWidget* widget = m_visibleItems.value(i); | ||
1705 | if (!widget) { | 1705 | if (!widget) { | ||
Show All 34 Lines | 1739 | if (supportsExpanding && changedCount == 0) { | |||
1740 | if (firstSibblingIndex < 0) { | 1740 | if (firstSibblingIndex < 0) { | ||
1741 | firstSibblingIndex = i; | 1741 | firstSibblingIndex = i; | ||
1742 | } | 1742 | } | ||
1743 | lastSibblingIndex = i; | 1743 | lastSibblingIndex = i; | ||
1744 | } | 1744 | } | ||
1745 | } | 1745 | } | ||
1746 | 1746 | | |||
1747 | if (animate) { | 1747 | if (animate) { | ||
1748 | if (m_animation->isStarted(widget, KItemListViewAnimation::MovingAnimation)) { | 1748 | if (m_animation->isStarted(widget, KItemListViewAnimation::AnimationType::Moving)) { | ||
1749 | m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos); | 1749 | m_animation->start(widget, KItemListViewAnimation::AnimationType::Moving, newPos); | ||
1750 | applyNewPos = false; | 1750 | applyNewPos = false; | ||
1751 | } | 1751 | } | ||
1752 | 1752 | | |||
1753 | const bool itemsRemoved = (changedCount < 0); | 1753 | const bool itemsRemoved = (changedCount < 0); | ||
1754 | const bool itemsInserted = (changedCount > 0); | 1754 | const bool itemsInserted = (changedCount > 0); | ||
1755 | if (itemsRemoved && (i >= changedIndex)) { | 1755 | if (itemsRemoved && (i >= changedIndex)) { | ||
1756 | // The item is located after the removed items. Animate the moving of the position. | 1756 | // The item is located after the removed items. Animate the moving of the position. | ||
1757 | applyNewPos = !moveWidget(widget, newPos); | 1757 | applyNewPos = !moveWidget(widget, newPos); | ||
1758 | } else if (itemsInserted && i >= changedIndex) { | 1758 | } else if (itemsInserted && i >= changedIndex) { | ||
1759 | // The item is located after the first inserted item | 1759 | // The item is located after the first inserted item | ||
1760 | if (i <= changedIndex + changedCount - 1) { | 1760 | if (i <= changedIndex + changedCount - 1) { | ||
1761 | // The item is an inserted item. Animate the appearing of the item. | 1761 | // The item is an inserted item. Animate the appearing of the item. | ||
1762 | // For performance reasons no animation is done when changedCount is equal | 1762 | // For performance reasons no animation is done when changedCount is equal | ||
1763 | // to all available items. | 1763 | // to all available items. | ||
1764 | if (changedCount < m_model->count()) { | 1764 | if (changedCount < m_model->count()) { | ||
1765 | m_animation->start(widget, KItemListViewAnimation::CreateAnimation); | 1765 | m_animation->start(widget, KItemListViewAnimation::AnimationType::Create); | ||
1766 | } | 1766 | } | ||
1767 | } else if (!m_animation->isStarted(widget, KItemListViewAnimation::CreateAnimation)) { | 1767 | } else if (!m_animation->isStarted(widget, KItemListViewAnimation::AnimationType::Create)) { | ||
1768 | // The item was already there before, so animate the moving of the position. | 1768 | // The item was already there before, so animate the moving of the position. | ||
1769 | // No moving animation is done if the item is animated by a create animation: This | 1769 | // No moving animation is done if the item is animated by a create animation: This | ||
1770 | // prevents a "move animation mess" when inserting several ranges in parallel. | 1770 | // prevents a "move animation mess" when inserting several ranges in parallel. | ||
1771 | applyNewPos = !moveWidget(widget, newPos); | 1771 | applyNewPos = !moveWidget(widget, newPos); | ||
1772 | } | 1772 | } | ||
1773 | } else if (!itemsRemoved && !itemsInserted && !wasHidden) { | 1773 | } else if (!itemsRemoved && !itemsInserted && !wasHidden) { | ||
1774 | // The size of the view might have been changed. Animate the moving of the position. | 1774 | // The size of the view might have been changed. Animate the moving of the position. | ||
1775 | applyNewPos = !moveWidget(widget, newPos); | 1775 | applyNewPos = !moveWidget(widget, newPos); | ||
Show All 16 Lines | 1790 | if (animate) { | |||
1792 | // of the dynamic size. | 1792 | // of the dynamic size. | ||
1793 | if (m_itemSize.width() <= 0) { | 1793 | if (m_itemSize.width() <= 0) { | ||
1794 | // The width is dynamic, apply the new width without animation. | 1794 | // The width is dynamic, apply the new width without animation. | ||
1795 | widget->resize(itemBounds.width(), widget->size().height()); | 1795 | widget->resize(itemBounds.width(), widget->size().height()); | ||
1796 | } else if (m_itemSize.height() <= 0) { | 1796 | } else if (m_itemSize.height() <= 0) { | ||
1797 | // The height is dynamic, apply the new height without animation. | 1797 | // The height is dynamic, apply the new height without animation. | ||
1798 | widget->resize(widget->size().width(), itemBounds.height()); | 1798 | widget->resize(widget->size().width(), itemBounds.height()); | ||
1799 | } | 1799 | } | ||
1800 | m_animation->start(widget, KItemListViewAnimation::ResizeAnimation, itemBounds.size()); | 1800 | m_animation->start(widget, KItemListViewAnimation::AnimationType::Resize, itemBounds.size()); | ||
1801 | } else { | 1801 | } else { | ||
1802 | widget->resize(itemBounds.size()); | 1802 | widget->resize(itemBounds.size()); | ||
1803 | } | 1803 | } | ||
1804 | } | 1804 | } | ||
1805 | 1805 | | |||
1806 | // Updating the cell-information must be done as last step: The decision whether the | 1806 | // Updating the cell-information must be done as last step: The decision whether the | ||
1807 | // moving-animation should be started at all is based on the previous cell-information. | 1807 | // moving-animation should be started at all is based on the previous cell-information. | ||
1808 | const Cell cell(m_layouter->itemColumn(i), m_layouter->itemRow(i)); | 1808 | const Cell cell(m_layouter->itemColumn(i), m_layouter->itemRow(i)); | ||
Show All 39 Lines | 1847 | while (it.hasNext()) { | |||
1848 | it.next(); | 1848 | it.next(); | ||
1849 | 1849 | | |||
1850 | KItemListWidget* widget = it.value(); | 1850 | KItemListWidget* widget = it.value(); | ||
1851 | const int index = widget->index(); | 1851 | const int index = widget->index(); | ||
1852 | const bool invisible = (index < firstVisibleIndex) || (index > lastVisibleIndex); | 1852 | const bool invisible = (index < firstVisibleIndex) || (index > lastVisibleIndex); | ||
1853 | 1853 | | |||
1854 | if (invisible) { | 1854 | if (invisible) { | ||
1855 | if (m_animation->isStarted(widget)) { | 1855 | if (m_animation->isStarted(widget)) { | ||
1856 | if (hint == NoAnimation) { | 1856 | if (hint == LayoutAnimationHint::NoAnimation) { | ||
1857 | // Stopping the animation will call KItemListView::slotAnimationFinished() | 1857 | // Stopping the animation will call KItemListView::slotAnimationFinished() | ||
1858 | // and the widget will be recycled if necessary there. | 1858 | // and the widget will be recycled if necessary there. | ||
1859 | m_animation->stop(widget); | 1859 | m_animation->stop(widget); | ||
1860 | } | 1860 | } | ||
1861 | } else { | 1861 | } else { | ||
1862 | widget->setVisible(false); | 1862 | widget->setVisible(false); | ||
1863 | items.append(index); | 1863 | items.append(index); | ||
1864 | 1864 | | |||
Show All 30 Lines | 1894 | if (scrollOrientation() == Qt::Vertical) { | |||
1895 | startMovingAnim = (cell.row == m_layouter->itemRow(index)); | 1895 | startMovingAnim = (cell.row == m_layouter->itemRow(index)); | ||
1896 | } else { | 1896 | } else { | ||
1897 | startMovingAnim = (cell.column == m_layouter->itemColumn(index)); | 1897 | startMovingAnim = (cell.column == m_layouter->itemColumn(index)); | ||
1898 | } | 1898 | } | ||
1899 | } | 1899 | } | ||
1900 | } | 1900 | } | ||
1901 | 1901 | | |||
1902 | if (startMovingAnim) { | 1902 | if (startMovingAnim) { | ||
1903 | m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos); | 1903 | m_animation->start(widget, KItemListViewAnimation::AnimationType::Moving, newPos); | ||
1904 | return true; | 1904 | return true; | ||
1905 | } | 1905 | } | ||
1906 | 1906 | | |||
1907 | m_animation->stop(widget); | 1907 | m_animation->stop(widget); | ||
1908 | m_animation->start(widget, KItemListViewAnimation::CreateAnimation); | 1908 | m_animation->start(widget, KItemListViewAnimation::AnimationType::Create); | ||
1909 | return false; | 1909 | return false; | ||
1910 | } | 1910 | } | ||
1911 | 1911 | | |||
1912 | void KItemListView::emitOffsetChanges() | 1912 | void KItemListView::emitOffsetChanges() | ||
1913 | { | 1913 | { | ||
1914 | const qreal newScrollOffset = m_layouter->scrollOffset(); | 1914 | const qreal newScrollOffset = m_layouter->scrollOffset(); | ||
1915 | if (m_oldScrollOffset != newScrollOffset) { | 1915 | if (m_oldScrollOffset != newScrollOffset) { | ||
1916 | emit scrollOffsetChanged(newScrollOffset, m_oldScrollOffset); | 1916 | emit scrollOffsetChanged(newScrollOffset, m_oldScrollOffset); | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 1977 | { | |||
1987 | if (updateCell) { | 1987 | if (updateCell) { | ||
1988 | m_visibleCells.insert(index, newCell); | 1988 | m_visibleCells.insert(index, newCell); | ||
1989 | } | 1989 | } | ||
1990 | } | 1990 | } | ||
1991 | 1991 | | |||
1992 | void KItemListView::setLayouterSize(const QSizeF& size, SizeType sizeType) | 1992 | void KItemListView::setLayouterSize(const QSizeF& size, SizeType sizeType) | ||
1993 | { | 1993 | { | ||
1994 | switch (sizeType) { | 1994 | switch (sizeType) { | ||
1995 | case LayouterSize: m_layouter->setSize(size); break; | 1995 | case SizeType::LayouterSize: m_layouter->setSize(size); break; | ||
1996 | case ItemSize: m_layouter->setItemSize(size); break; | 1996 | case SizeType::ItemSize: m_layouter->setItemSize(size); break; | ||
1997 | default: break; | 1997 | default: break; | ||
1998 | } | 1998 | } | ||
1999 | } | 1999 | } | ||
2000 | 2000 | | |||
2001 | void KItemListView::updateWidgetProperties(KItemListWidget* widget, int index) | 2001 | void KItemListView::updateWidgetProperties(KItemListWidget* widget, int index) | ||
2002 | { | 2002 | { | ||
2003 | widget->setVisibleRoles(m_visibleRoles); | 2003 | widget->setVisibleRoles(m_visibleRoles); | ||
2004 | updateWidgetColumnWidths(widget); | 2004 | updateWidgetColumnWidths(widget); | ||
2005 | widget->setStyleOption(m_styleOption); | 2005 | widget->setStyleOption(m_styleOption); | ||
2006 | 2006 | | |||
2007 | const KItemListSelectionManager* selectionManager = m_controller->selectionManager(); | 2007 | const KItemListSelectionManager* selectionManager = m_controller->selectionManager(); | ||
2008 | 2008 | | |||
2009 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | 2009 | // In SingleSelection mode (e.g., in the Places Panel), the current item is | ||
2010 | // always the selected item. It is not necessary to highlight the current item then. | 2010 | // always the selected item. It is not necessary to highlight the current item then. | ||
2011 | if (m_controller->selectionBehavior() != KItemListController::SingleSelection) { | 2011 | if (m_controller->selectionBehavior() != KItemListController::SelectionBehavior::SingleSelection) { | ||
2012 | widget->setCurrent(index == selectionManager->currentItem()); | 2012 | widget->setCurrent(index == selectionManager->currentItem()); | ||
2013 | } | 2013 | } | ||
2014 | widget->setSelected(selectionManager->isSelected(index)); | 2014 | widget->setSelected(selectionManager->isSelected(index)); | ||
2015 | widget->setHovered(false); | 2015 | widget->setHovered(false); | ||
2016 | widget->setEnabledSelectionToggle(enabledSelectionToggles()); | 2016 | widget->setEnabledSelectionToggle(enabledSelectionToggles()); | ||
2017 | widget->setIndex(index); | 2017 | widget->setIndex(index); | ||
2018 | widget->setData(m_model->data(index)); | 2018 | widget->setData(m_model->data(index)); | ||
2019 | widget->setSiblingsInformation(QBitArray()); | 2019 | widget->setSiblingsInformation(QBitArray()); | ||
▲ Show 20 Lines • Show All 726 Lines • Show Last 20 Lines |