Commit d3839617 authored by Tom Lin's avatar Tom Lin Committed by Felix Ernst
Browse files

Full row highlight implementation

This commit implements full-row selection and hover highlights for the
details view mode.

This commit also contains fixes for 444680, 444753, both uncovered
during this change.

BUG: 181438
BUG: 444680
BUG: 444753
FIXED-IN: 22.04
parent a2865064
Pipeline #124257 passed with stage
in 5 minutes and 19 seconds
......@@ -574,7 +574,7 @@ bool KItemListController::mouseMoveEvent(QGraphicsSceneMouseEvent* event, const
return false;
}
if (m_pressedIndex.has_value()) {
if (m_pressedIndex.has_value() && !m_view->rubberBand()->isActive()) {
// Check whether a dragging should be started
if (event->buttons() & Qt::LeftButton) {
const QPointF pos = transform.map(event->pos());
......@@ -828,27 +828,76 @@ bool KItemListController::hoverMoveEvent(QGraphicsSceneHoverEvent* event, const
return false;
}
KItemListWidget* oldHoveredWidget = hoveredWidget();
const QPointF pos = transform.map(event->pos());
KItemListWidget* newHoveredWidget = widgetForPos(pos);
// We identify the widget whose expansionArea had been hovered before this hoverMoveEvent() triggered.
// we can't use hoveredWidget() here (it handles the icon+text rect, not the expansion rect)
// like hoveredWidget(), we find the hovered widget for the expansion rect
const auto visibleItemListWidgets = m_view->visibleItemListWidgets();
const auto oldHoveredExpansionWidgetIterator = std::find_if(visibleItemListWidgets.begin(), visibleItemListWidgets.end(), [](auto &widget) {
return widget->expansionAreaHovered();
});
const auto oldHoveredExpansionWidget = oldHoveredExpansionWidgetIterator == visibleItemListWidgets.end() ?
std::nullopt : std::make_optional(*oldHoveredExpansionWidgetIterator);
if (oldHoveredWidget != newHoveredWidget) {
if (oldHoveredWidget) {
const auto unhoverOldHoveredWidget = [&]() {
if (auto oldHoveredWidget = hoveredWidget(); oldHoveredWidget) {
// handle the text+icon one
oldHoveredWidget->setHovered(false);
Q_EMIT itemUnhovered(oldHoveredWidget->index());
}
};
if (newHoveredWidget) {
newHoveredWidget->setHovered(true);
const QPointF mappedPos = newHoveredWidget->mapFromItem(m_view, pos);
newHoveredWidget->setHoverPosition(mappedPos);
Q_EMIT itemHovered(newHoveredWidget->index());
const auto unhoverOldExpansionWidget = [&]() {
if (oldHoveredExpansionWidget) {
// then the expansion toggle
(*oldHoveredExpansionWidget)->setExpansionAreaHovered(false);
}
} else if (oldHoveredWidget) {
const QPointF mappedPos = oldHoveredWidget->mapFromItem(m_view, pos);
oldHoveredWidget->setHoverPosition(mappedPos);
}
};
const QPointF pos = transform.map(event->pos());
if (KItemListWidget *newHoveredWidget = widgetForPos(pos); newHoveredWidget) {
// something got hovered, work out which part and set hover for the appropriate widget
const auto mappedPos = newHoveredWidget->mapFromItem(m_view, pos);
const bool isOnExpansionToggle = newHoveredWidget->expansionToggleRect().contains(mappedPos);
if (isOnExpansionToggle) {
// make sure we unhover the old one first if old!=new
if (oldHoveredExpansionWidget && *oldHoveredExpansionWidget != newHoveredWidget) {
(*oldHoveredExpansionWidget)->setExpansionAreaHovered(false);
}
// we also unhover any old icon+text hovers, in case the mouse movement from icon+text to expansion toggle is too fast (i.e. newHoveredWidget is never null between the transition)
unhoverOldHoveredWidget();
newHoveredWidget->setExpansionAreaHovered(true);
} else {
// make sure we unhover the old one first if old!=new
if (auto oldHoveredWidget = hoveredWidget(); oldHoveredWidget && oldHoveredWidget != newHoveredWidget) {
oldHoveredWidget->setHovered(false);
Q_EMIT itemUnhovered(oldHoveredWidget->index());
}
// we also unhover any old expansion toggle hovers, in case the mouse movement from expansion toggle to icon+text is too fast (i.e. newHoveredWidget is never null between the transition)
unhoverOldExpansionWidget();
const bool isOverIconAndText = newHoveredWidget->iconRect().contains(mappedPos) || newHoveredWidget->textRect().contains(mappedPos);
const bool hasMultipleSelection = m_selectionManager->selectedItems().count() > 1;
if (hasMultipleSelection && !isOverIconAndText) {
// In case we have multiple selections, clicking on any row will deselect the selection.
// So, as a visual cue for signalling that clicking anywhere won't select, but clear current highlights,
// we disable hover of the *row*(i.e. blank space to the right of the icon+text)
// (no-op in this branch for masked hover)
} else {
newHoveredWidget->setHovered(true);
newHoveredWidget->setHoverPosition(mappedPos);
Q_EMIT itemHovered(newHoveredWidget->index());
}
}
} else {
// unhover any currently hovered expansion and text+icon widgets
unhoverOldHoveredWidget();
unhoverOldExpansionWidget();
}
return false;
}
......@@ -1303,10 +1352,7 @@ KItemListWidget* KItemListController::widgetForPos(const QPointF& pos) const
const auto widgets = m_view->visibleItemListWidgets();
for (KItemListWidget* widget : widgets) {
const QPointF mappedPos = widget->mapFromItem(m_view, pos);
const bool hovered = widget->contains(mappedPos) &&
!widget->expansionToggleRect().contains(mappedPos);
if (hovered) {
if (widget->contains(mappedPos) || widget->selectionRect().contains(mappedPos)) {
return widget;
}
}
......@@ -1447,6 +1493,7 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
const bool shiftPressed = modifiers & Qt::ShiftModifier;
const bool controlPressed = modifiers & Qt::ControlModifier;
const bool rightClick = buttons & Qt::RightButton;
// The previous selection is cleared if either
// 1. The selection mode is SingleSelection, or
......@@ -1459,8 +1506,32 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
const bool pressedItemAlreadySelected = m_pressedIndex.has_value() && m_selectionManager->isSelected(m_pressedIndex.value());
const bool clearSelection = m_selectionBehavior == SingleSelection ||
(!shiftOrControlPressed && !pressedItemAlreadySelected);
// When this method returns false, a rubberBand selection is created using KItemListController::startRubberBand via the caller.
if (clearSelection) {
const int selectedItemsCount = m_selectionManager->selectedItems().count();
m_selectionManager->clearSelection();
// clear and bail when we got an existing multi-selection
if (selectedItemsCount > 1 && m_pressedIndex.has_value()) {
const auto row = m_view->m_visibleItems.value(m_pressedIndex.value());
const auto mappedPos = row->mapFromItem(m_view, pos);
if (pressedItemAlreadySelected || row->iconRect().contains(mappedPos) || row->textRect().contains(mappedPos)) {
// we are indeed inside the text/icon rect, keep m_pressedIndex what it is
// and short-circuit for single-click activation (it will then propagate to onRelease and activate the item)
// or we just keep going for double-click activation
if (m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) {
return true; // event handled, don't create rubber band
}
} else {
// we're not inside the text/icon rect, as we've already cleared the selection
// we can just stop here and make sure handlers down the line (i.e. onRelease) don't activate
m_pressedIndex.reset();
// we don't stop event propagation and proceed to create a rubber band and let onRelease
// decide (based on m_pressedIndex) whether we're in a drag (drag => new rubber band, click => don't select the item)
return false;
}
}
} else if (pressedItemAlreadySelected && !shiftOrControlPressed && (buttons & Qt::LeftButton)) {
// The user might want to start dragging multiple items, but if he clicks the item
// in order to trigger it instead, the other selected items must be deselected.
......@@ -1479,7 +1550,14 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
m_selectionManager->endAnchoredSelection();
}
if (buttons & Qt::RightButton) {
if (rightClick) {
// Do header hit check and short circuit before commencing any state changing effects
if (m_view->headerBoundaries().contains(pos)) {
Q_EMIT headerContextMenuRequested(screenPos);
return true;
}
// Stop rubber band from persisting after right-clicks
KItemListRubberBand* rubberBand = m_view->rubberBand();
if (rubberBand->isActive()) {
......@@ -1491,6 +1569,17 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
if (m_pressedIndex.has_value()) {
m_selectionManager->setCurrentItem(m_pressedIndex.value());
const auto row = m_view->m_visibleItems.value(m_pressedIndex.value()); // anything outside of row.contains() will be the empty region of the row rect
const bool hitTargetIsRowEmptyRegion = !row->contains(row->mapFromItem(m_view, pos));
// again, when this method returns false, a rubberBand selection is created as the event is not consumed;
// createRubberBand here tells us whether to return true or false.
bool createRubberBand = (hitTargetIsRowEmptyRegion && m_selectionManager->selectedItems().isEmpty());
if (rightClick && hitTargetIsRowEmptyRegion) {
// we got a right click outside the text rect, default to action on the current url and not the pressed item
Q_EMIT itemContextMenuRequested(m_pressedIndex.value(), screenPos);
return true;
}
switch (m_selectionBehavior) {
case NoSelection:
......@@ -1504,6 +1593,7 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
if (controlPressed && !shiftPressed) {
m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
m_selectionManager->beginAnchoredSelection(m_pressedIndex.value());
createRubberBand = false; // multi selection, don't propagate any further
} else if (!shiftPressed || !m_selectionManager->isAnchoredSelectionActive()) {
// Select the pressed item and start a new anchored selection
m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Select);
......@@ -1516,20 +1606,16 @@ bool KItemListController::onPress(const QPoint& screenPos, const QPointF& pos, c
break;
}
if (buttons & Qt::RightButton) {
if (rightClick) {
Q_EMIT itemContextMenuRequested(m_pressedIndex.value(), screenPos);
}
return true;
return !createRubberBand;
}
if (buttons & Qt::RightButton) {
const QRectF headerBounds = m_view->headerBoundaries();
if (headerBounds.contains(pos)) {
Q_EMIT headerContextMenuRequested(screenPos);
} else {
Q_EMIT viewContextMenuRequested(screenPos);
}
if (rightClick) {
// header right click handling would have been done before this so just normal context
// menu here is fine
Q_EMIT viewContextMenuRequested(screenPos);
return true;
}
......@@ -1554,16 +1640,35 @@ bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifi
const bool shiftOrControlPressed = modifiers & Qt::ShiftModifier ||
controlPressed;
const std::optional<int> index = m_view->itemAt(pos);
KItemListRubberBand* rubberBand = m_view->rubberBand();
bool rubberBandRelease = false;
if (rubberBand->isActive()) {
disconnect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged);
rubberBand->setActive(false);
m_oldSelection.clear();
m_view->setAutoScroll(false);
rubberBandRelease = true;
// We check for actual rubber band drag here: if delta between start and end is less than drag threshold,
// then we have a single click on one of the rows
if ((rubberBand->endPosition() - rubberBand->startPosition()).manhattanLength() < QApplication::startDragDistance()) {
rubberBandRelease = false; // since we're only selecting, unmark rubber band release flag
// m_pressedIndex will have no value if we came from a multi-selection clearing onPress
// in that case, we don't select anything
if (index.has_value() && m_pressedIndex.has_value()) {
if (controlPressed && m_selectionBehavior == MultiSelection) {
m_selectionManager->setSelected(m_pressedIndex.value(), 1, KItemListSelectionManager::Toggle);
} else {
m_selectionManager->setSelected(index.value());
}
if (!m_selectionManager->isAnchoredSelectionActive()) {
m_selectionManager->beginAnchoredSelection(index.value());
}
}
}
}
const std::optional<int> index = m_view->itemAt(pos);
if (index.has_value() && index == m_pressedIndex) {
// The release event is done above the same item as the press event
......@@ -1587,11 +1692,13 @@ bool KItemListController::onRelease(const QPointF& pos, const Qt::KeyboardModifi
// The mouse click should only update the selection, not trigger the item, except when
// we are in single selection mode
emitItemActivated = false;
} else if (!(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced)) {
if (touch) {
emitItemActivated = true;
} else {
const bool singleClickActivation = m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced;
if (!singleClickActivation) {
emitItemActivated = touch;
} else {
emitItemActivated = false;
// activate on single click only if we didn't come from a rubber band release
emitItemActivated = !rubberBandRelease;
}
}
if (emitItemActivated) {
......
......@@ -61,6 +61,20 @@ qreal KItemListHeader::preferredColumnWidth(const QByteArray& role) const
return m_headerWidget->preferredColumnWidth(role);
}
void KItemListHeader::setLeadingPadding(qreal width){
if (m_headerWidget->leadingPadding() != width) {
m_headerWidget->setLeadingPadding(width);
if (m_headerWidget->automaticColumnResizing()) {
m_view->applyAutomaticColumnWidths();
}
m_view->doLayout(KItemListView::NoAnimation);
}
}
qreal KItemListHeader::leadingPadding() const{
return m_headerWidget->leadingPadding();
}
KItemListHeader::KItemListHeader(KItemListView* listView) :
QObject(listView),
m_view(listView)
......@@ -72,5 +86,7 @@ KItemListHeader::KItemListHeader(KItemListView* listView) :
this, &KItemListHeader::columnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChangeFinished,
this, &KItemListHeader::columnWidthChangeFinished);
connect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
this, &KItemListHeader::leadingPaddingChanged);
}
......@@ -58,7 +58,16 @@ public:
*/
qreal preferredColumnWidth(const QByteArray& role) const;
/**
* Sets the width of the column *before* the first column.
* This is intended to facilitate an empty region for deselection in the main viewport.
*/
void setLeadingPadding(qreal width);
qreal leadingPadding() const;
Q_SIGNALS:
void leadingPaddingChanged(qreal width);
/**
* Is emitted if the width of a column has been adjusted by the user with the mouse
* (no signal is emitted if KItemListHeader::setColumnWidth() is invoked).
......
......@@ -397,7 +397,7 @@ std::optional<int> KItemListView::itemAt(const QPointF& pos) const
const KItemListWidget* widget = it.value();
const QPointF mappedPos = widget->mapFromItem(this, pos);
if (widget->contains(mappedPos)) {
if (widget->contains(mappedPos) || widget->selectionRect().contains(mappedPos)) {
return it.key();
}
}
......@@ -477,6 +477,32 @@ bool KItemListView::supportsItemExpanding() const
return m_supportsItemExpanding;
}
void KItemListView::setHighlightEntireRow(bool highlightEntireRow)
{
if (m_highlightEntireRow != highlightEntireRow) {
m_highlightEntireRow = highlightEntireRow;
onHighlightEntireRowChanged(highlightEntireRow);
}
}
bool KItemListView::highlightEntireRow() const
{
return m_highlightEntireRow;
}
void KItemListView::setAlternateBackgrounds(bool alternate)
{
if (m_alternateBackgrounds != alternate) {
m_alternateBackgrounds = alternate;
updateAlternateBackgrounds();
}
}
bool KItemListView::alternateBackgrounds() const
{
return m_alternateBackgrounds;
}
QRectF KItemListView::itemRect(int index) const
{
return m_layouter->itemRect(index);
......@@ -581,6 +607,8 @@ void KItemListView::setHeaderVisible(bool visible)
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
this, &KItemListView::slotLeadingPaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
......@@ -593,6 +621,8 @@ void KItemListView::setHeaderVisible(bool visible)
} else if (!visible && m_headerWidget->isVisible()) {
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
this, &KItemListView::slotLeadingPaddingChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
......@@ -753,7 +783,7 @@ void KItemListView::setItemSize(const QSizeF& size)
size,
m_layouter->itemMargin());
const bool alternateBackgroundsChanged = (m_visibleRoles.count() > 1) &&
const bool alternateBackgroundsChanged = m_alternateBackgrounds &&
(( m_itemSize.isEmpty() && !size.isEmpty()) ||
(!m_itemSize.isEmpty() && size.isEmpty()));
......@@ -929,6 +959,11 @@ void KItemListView::onStyleOptionChanged(const KItemListStyleOption& current, co
Q_UNUSED(previous)
}
void KItemListView::onHighlightEntireRowChanged(bool highlightEntireRow)
{
Q_UNUSED(highlightEntireRow)
}
void KItemListView::onSupportsItemExpandingChanged(bool supportsExpanding)
{
Q_UNUSED(supportsExpanding)
......@@ -1521,6 +1556,16 @@ void KItemListView::slotHeaderColumnWidthChanged(const QByteArray& role,
doLayout(NoAnimation);
}
void KItemListView::slotLeadingPaddingChanged(qreal width)
{
Q_UNUSED(width)
if (m_headerWidget->automaticColumnResizing()) {
applyAutomaticColumnWidths();
}
applyColumnWidthsFromHeader();
doLayout(NoAnimation);
}
void KItemListView::slotHeaderColumnMoved(const QByteArray& role,
int currentIndex,
int previousIndex)
......@@ -2225,7 +2270,7 @@ void KItemListView::updateAlternateBackgroundForWidget(KItemListWidget* widget)
bool KItemListView::useAlternateBackgrounds() const
{
return m_itemSize.isEmpty() && m_visibleRoles.count() > 1;
return m_alternateBackgrounds && m_itemSize.isEmpty();
}
QHash<QByteArray, qreal> KItemListView::preferredColumnWidths(const KItemRangeList& itemRanges) const
......@@ -2283,7 +2328,7 @@ QHash<QByteArray, qreal> KItemListView::preferredColumnWidths(const KItemRangeLi
void KItemListView::applyColumnWidthsFromHeader()
{
// Apply the new size to the layouter
const qreal requiredWidth = columnWidthsSum();
const qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding();
const QSizeF dynamicItemSize(qMax(size().width(), requiredWidth),
m_itemSize.height());
m_layouter->setItemSize(dynamicItemSize);
......@@ -2301,6 +2346,7 @@ void KItemListView::updateWidgetColumnWidths(KItemListWidget* widget)
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
widget->setColumnWidth(role, m_headerWidget->columnWidth(role));
}
widget->setLeadingPadding(m_headerWidget->leadingPadding());
}
void KItemListView::updatePreferredColumnWidths(const KItemRangeList& itemRanges)
......@@ -2378,7 +2424,7 @@ void KItemListView::applyAutomaticColumnWidths()
qreal firstColumnWidth = m_headerWidget->columnWidth(firstRole);
QSizeF dynamicItemSize = m_itemSize;
qreal requiredWidth = columnWidthsSum();
qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding();
const qreal availableWidth = size().width();
if (requiredWidth < availableWidth) {
// Stretch the first column to use the whole remaining width
......
......@@ -205,6 +205,12 @@ public:
void setSupportsItemExpanding(bool supportsExpanding);
bool supportsItemExpanding() const;
void setHighlightEntireRow(bool highlightEntireRow);
bool highlightEntireRow() const;
void setAlternateBackgrounds(bool alternate);
bool alternateBackgrounds() const;
/**
* @return The rectangle of the item relative to the top/left of
* the currently visible area (see KItemListView::offset()).
......@@ -374,6 +380,7 @@ protected:
virtual void onScrollOffsetChanged(qreal current, qreal previous);
virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
virtual void onHighlightEntireRowChanged(bool highlightEntireRow);
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
virtual void onTransactionBegin();
......@@ -426,6 +433,8 @@ private Q_SLOTS:
qreal currentWidth,
qreal previousWidth);
void slotLeadingPaddingChanged(qreal width);
/**
* Is invoked if a column has been moved by the user. Applies
* the moved role to the view.
......@@ -707,6 +716,8 @@ private:
private:
bool m_enabledSelectionToggles;
bool m_grouped;
bool m_highlightEntireRow;
bool m_alternateBackgrounds;
bool m_supportsItemExpanding;
bool m_editingRole;
int m_activeTransactions; // Counter for beginTransaction()/endTransaction()
......
......@@ -34,6 +34,7 @@ KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsI
m_selected(false),
m_current(false),
m_hovered(false),
m_expansionAreaHovered(false),
m_alternateBackground(false),
m_enabledSelectionToggle(false),
m_data(),
......@@ -180,6 +181,18 @@ qreal KItemListWidget::columnWidth(const QByteArray& role) const
return m_columnWidths.value(role);
}
qreal KItemListWidget::leadingPadding() const {
return m_leadingPadding;
}
void KItemListWidget::setLeadingPadding(qreal width) {
if (m_leadingPadding != width){
m_leadingPadding = width;
leadingPaddingChanged(width);
update();
}
}
void KItemListWidget::setStyleOption(const KItemListStyleOption& option)
{
if (m_styleOption == option) {
......@@ -280,6 +293,20 @@ bool KItemListWidget::isHovered() const
return m_hovered;
}
void KItemListWidget::setExpansionAreaHovered(bool hovered)
{
if (hovered == m_expansionAreaHovered) {
return;
}
m_expansionAreaHovered = hovered;
update();
}
bool KItemListWidget::expansionAreaHovered() const
{
return m_expansionAreaHovered;
}
void KItemListWidget::setHoverPosition(const QPointF& pos)
{
if (m_selectionToggle) {
......@@ -416,6 +443,11 @@ void KItemListWidget::columnWidthChanged(const QByteArray& role,
Q_UNUSED(previous)
}
void KItemListWidget::leadingPaddingChanged(qreal width)
{
Q_UNUSED(width)
}
void KItemListWidget::styleOptionChanged(const KItemListStyleOption& current,
const KItemListStyleOption& previous)
{
......
......@@ -80,6 +80,9 @@ public:
void setColumnWidth(const QByteArray& role, qreal width);
qreal columnWidth(const QByteArray& role) const;
void setLeadingPadding(qreal width);
qreal leadingPadding() const;
void setStyleOption(const KItemListStyleOption& option);
const KItemListStyleOption& styleOption() const;
......@@ -94,6 +97,9 @@ public:
void setHovered(bool hovered);
bool isHovered() const;
void setExpansionAreaHovered(bool hover);
bool expansionAreaHovered() const;
void setHoverPosition(const QPointF& pos);
void setAlternateBackground(bool enable);
......@@ -182,6 +188,7 @@ protected:
virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
virtual void leadingPaddingChanged(qreal width);
virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
virtual void currentChanged(bool current);
virtual void selectedChanged(bool selected);
......@@ -190,6 +197,7 @@ protected:
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous);
void resizeEvent(QGraphicsSceneResizeEvent* event) override;
void clearHoverCache();
/**
* Called when the user starts hovering this item.
......@@ -225,7 +233,6 @@ private Q_SLOTS:
private:
void initializeSelectionToggle();
void setHoverOpacity(qreal opacity);
void clearHoverCache();
void drawItemStyleOption(QPainter* painter, QWidget* widget, QStyle::State styleState);
private:
......@@ -236,11 +243,13 @@ private:
bool m_selected;
bool m_current;
bool m_hovered;
bool m_expansionAreaHovered;
bool m_alternateBackground;
bool m_enabledSelectionToggle;
QHash<QByteArray, QVariant> m_data;
QList<QByteArray> m_visibleRoles;
QHash<QByteArray, qreal> m_columnWidths;
qreal m_leadingPadding;
KItemListStyleOption m_styleOption;
QBitArray m_siblingsInfo;