mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-15 18:01:11 +00:00
Fix header index are colIndex and not roleIndex
This commit is contained in:
parent
6e7a5760b4
commit
7a682f5e9c
|
@ -21,7 +21,7 @@ KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget *parent)
|
|||
, m_columns()
|
||||
, m_columnWidths()
|
||||
, m_preferredColumnWidths()
|
||||
, m_hoveredRoleIndex(-1)
|
||||
, m_hoveredIndex(-1)
|
||||
, m_pressedRoleIndex(-1)
|
||||
, m_roleOperation(NoRoleOperation)
|
||||
, m_pressedMousePos()
|
||||
|
@ -365,15 +365,15 @@ void KItemListHeaderWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
|
|||
void KItemListHeaderWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QGraphicsWidget::hoverEnterEvent(event);
|
||||
updateHoveredRoleIndex(event->pos());
|
||||
updateHoveredIndex(event->pos());
|
||||
}
|
||||
|
||||
void KItemListHeaderWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QGraphicsWidget::hoverLeaveEvent(event);
|
||||
if (m_hoveredRoleIndex != -1) {
|
||||
Q_EMIT columnUnHovered(m_hoveredRoleIndex);
|
||||
m_hoveredRoleIndex = -1;
|
||||
if (m_hoveredIndex != -1) {
|
||||
Q_EMIT columnUnHovered(m_hoveredIndex);
|
||||
m_hoveredIndex = -1;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -383,8 +383,8 @@ void KItemListHeaderWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|||
QGraphicsWidget::hoverMoveEvent(event);
|
||||
|
||||
const QPointF &pos = event->pos();
|
||||
updateHoveredRoleIndex(pos);
|
||||
if ((m_hoveredRoleIndex >= 0 && isAboveRoleGrip(pos, m_hoveredRoleIndex)) || isAbovePaddingGrip(pos, PaddingGrip::Leading)
|
||||
updateHoveredIndex(pos);
|
||||
if ((m_hoveredIndex >= 0 && isAboveRoleGrip(pos, m_hoveredIndex)) || isAbovePaddingGrip(pos, PaddingGrip::Leading)
|
||||
|| isAbovePaddingGrip(pos, PaddingGrip::Trailing)) {
|
||||
setCursor(Qt::SplitHCursor);
|
||||
} else {
|
||||
|
@ -424,7 +424,7 @@ void KItemListHeaderWidget::paintRole(QPainter *painter, const QByteArray &role,
|
|||
if (window() && window()->isActiveWindow()) {
|
||||
option.state |= QStyle::State_Active;
|
||||
}
|
||||
if (m_hoveredRoleIndex == orderIndex) {
|
||||
if (m_hoveredIndex == orderIndex) {
|
||||
option.state |= QStyle::State_MouseOver;
|
||||
}
|
||||
if (m_pressedRoleIndex == orderIndex) {
|
||||
|
@ -486,17 +486,17 @@ void KItemListHeaderWidget::updatePressedRoleIndex(const QPointF &pos)
|
|||
}
|
||||
}
|
||||
|
||||
void KItemListHeaderWidget::updateHoveredRoleIndex(const QPointF &pos)
|
||||
void KItemListHeaderWidget::updateHoveredIndex(const QPointF &pos)
|
||||
{
|
||||
const int hoverIndex = roleIndexAt(pos);
|
||||
|
||||
if (m_hoveredRoleIndex != hoverIndex) {
|
||||
if (m_hoveredRoleIndex != -1) {
|
||||
Q_EMIT columnUnHovered(m_hoveredRoleIndex);
|
||||
if (m_hoveredIndex != hoverIndex) {
|
||||
if (m_hoveredIndex != -1) {
|
||||
Q_EMIT columnUnHovered(m_hoveredIndex);
|
||||
}
|
||||
m_hoveredRoleIndex = hoverIndex;
|
||||
if (m_hoveredRoleIndex != -1) {
|
||||
Q_EMIT columnHovered(m_hoveredRoleIndex);
|
||||
m_hoveredIndex = hoverIndex;
|
||||
if (m_hoveredIndex != -1) {
|
||||
Q_EMIT columnHovered(m_hoveredIndex);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ Q_SIGNALS:
|
|||
*/
|
||||
void sortRoleChanged(const QByteArray ¤t, const QByteArray &previous);
|
||||
|
||||
void columnUnHovered(int roleIndex);
|
||||
void columnHovered(int roleIndex);
|
||||
void columnUnHovered(int columnIndex);
|
||||
void columnHovered(int columnIndex);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
@ -118,7 +118,7 @@ private:
|
|||
void paintRole(QPainter *painter, const QByteArray &role, const QRectF &rect, int orderIndex, QWidget *widget = nullptr) const;
|
||||
|
||||
void updatePressedRoleIndex(const QPointF &pos);
|
||||
void updateHoveredRoleIndex(const QPointF &pos);
|
||||
void updateHoveredIndex(const QPointF &pos);
|
||||
int roleIndexAt(const QPointF &pos) const;
|
||||
bool isAboveRoleGrip(const QPointF &pos, int roleIndex) const;
|
||||
bool isAbovePaddingGrip(const QPointF &pos, PaddingGrip paddingGrip) const;
|
||||
|
@ -151,7 +151,7 @@ private:
|
|||
QHash<QByteArray, qreal> m_columnWidths;
|
||||
QHash<QByteArray, qreal> m_preferredColumnWidths;
|
||||
|
||||
int m_hoveredRoleIndex;
|
||||
int m_hoveredIndex;
|
||||
int m_pressedRoleIndex;
|
||||
RoleOperation m_roleOperation;
|
||||
QPointF m_pressedMousePos;
|
||||
|
|
|
@ -211,12 +211,11 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
|
|||
connect(m_view, &DolphinItemListView::visibleRolesChanged, this, &DolphinView::slotVisibleRolesChangedByHeader);
|
||||
connect(m_view, &DolphinItemListView::roleEditingCanceled, this, &DolphinView::slotRoleEditingCanceled);
|
||||
|
||||
connect(m_view, &DolphinItemListView::columnHovered, this, [this](int roleIndex) {
|
||||
m_hoveredColumnHeaderRoleIndex = roleIndex;
|
||||
connect(m_view, &DolphinItemListView::columnHovered, this, [this](int columnIndex) {
|
||||
m_hoveredColumnHeaderIndex = columnIndex;
|
||||
});
|
||||
connect(m_view, &DolphinItemListView::columnUnHovered, this, [this](int roleIndex) {
|
||||
Q_UNUSED(roleIndex)
|
||||
m_hoveredColumnHeaderRoleIndex = std::nullopt;
|
||||
connect(m_view, &DolphinItemListView::columnUnHovered, this, [this](int /* columnIndex */) {
|
||||
m_hoveredColumnHeaderIndex = std::nullopt;
|
||||
});
|
||||
connect(m_view->header(), &KItemListHeader::columnWidthChangeFinished, this, &DolphinView::slotHeaderColumnWidthChangeFinished);
|
||||
connect(m_view->header(), &KItemListHeader::sidePaddingChanged, this, &DolphinView::slotSidePaddingWidthChanged);
|
||||
|
@ -974,10 +973,16 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event)
|
|||
if (tryShowNameToolTip(helpEvent)) {
|
||||
return true;
|
||||
|
||||
} else if (m_hoveredColumnHeaderRoleIndex) {
|
||||
const auto roleInfo = KFileItemModel::rolesInformation().at(*m_hoveredColumnHeaderRoleIndex);
|
||||
QToolTip::showText(helpEvent->globalPos(), roleInfo.tooltip, this);
|
||||
return true;
|
||||
} else if (m_hoveredColumnHeaderIndex) {
|
||||
const auto rolesInfo = KFileItemModel::rolesInformation();
|
||||
const auto visibleRole = m_visibleRoles.value(*m_hoveredColumnHeaderIndex);
|
||||
|
||||
for (const KFileItemModel::RoleInfo &info : rolesInfo) {
|
||||
if (visibleRole == info.role) {
|
||||
QToolTip::showText(helpEvent->globalPos(), info.tooltip, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -940,7 +940,7 @@ private:
|
|||
QTimer *m_showLoadingPlaceholderTimer;
|
||||
|
||||
/// The information roleIndex of the list column header currently hovered
|
||||
std::optional<int> m_hoveredColumnHeaderRoleIndex;
|
||||
std::optional<int> m_hoveredColumnHeaderIndex;
|
||||
|
||||
/// Used for selection mode. @see setSelectionMode()
|
||||
std::unique_ptr<QProxyStyle> m_proxyStyle;
|
||||
|
|
Loading…
Reference in a new issue