- qreal previousWidth = m_visibleRolesWidths.value(pressedRole);
- qreal currentWidth = previousWidth;
- currentWidth += event->pos().x() - event->lastPos().x();
- currentWidth = qMax(minimumRoleWidth(), currentWidth);
-
- m_visibleRolesWidths.insert(pressedRole, currentWidth);
- update();
-
- emit visibleRoleWidthChanged(pressedRole, currentWidth, previousWidth);
- } else if ((event->pos() - m_pressedMousePos).manhattanLength() >= QApplication::startDragDistance()) {
- kDebug() << "Moving of role not supported yet";
- m_roleOperation = MoveRoleOperation;
- }
-}
-
-void KItemListHeader::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
-{
- QGraphicsWidget::hoverEnterEvent(event);
- updateHoveredRoleIndex(event->pos());
-}
-
-void KItemListHeader::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
-{
- QGraphicsWidget::hoverLeaveEvent(event);
- if (m_hoveredRoleIndex != -1) {
- m_hoveredRoleIndex = -1;
- update();
- }
-}
-
-void KItemListHeader::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
-{
- QGraphicsWidget::hoverMoveEvent(event);
-
- const QPointF& pos = event->pos();
- updateHoveredRoleIndex(pos);
- if (m_hoveredRoleIndex >= 0 && isAboveRoleGrip(pos, m_hoveredRoleIndex)) {
- setCursor(Qt::SplitHCursor);
- } else {
- unsetCursor();
- }
-}
-
-void KItemListHeader::slotSortRoleChanged(const QByteArray& current, const QByteArray& previous)
-{
- Q_UNUSED(current);
- Q_UNUSED(previous);
- update();
-}
-
-void KItemListHeader::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
-{
- Q_UNUSED(current);
- Q_UNUSED(previous);
- update();
-}
-
-void KItemListHeader::paintRole(QPainter* painter,
- const QByteArray& role,
- const QRectF& rect,
- int orderIndex)
-{
- // The following code is based on the code from QHeaderView::paintSection().
- // Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- QStyleOptionHeader option;
- option.section = orderIndex;
- option.state = QStyle::State_None | QStyle::State_Raised | QStyle::State_Horizontal;
- if (isEnabled()) {
- option.state |= QStyle::State_Enabled;
- }
- if (window() && window()->isActiveWindow()) {
- option.state |= QStyle::State_Active;
- }
- if (m_hoveredRoleIndex == orderIndex) {
- option.state |= QStyle::State_MouseOver;
- }
- if (m_pressedRoleIndex == orderIndex) {
- option.state |= QStyle::State_Sunken;