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