Merge remote-tracking branch 'origin/7.0'

Change-Id: If390b9264dba14c6c71752a0de84ab7ff881b2c5
This commit is contained in:
Eike Ziller
2022-03-01 08:59:05 +01:00
118 changed files with 639 additions and 486 deletions

View File

@@ -406,6 +406,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
if (hovered) {
if (index != m_previousIndex) {
m_previousIndex = index;
m_currentTagRects.clear();
m_blurredThumbnail = QPixmap();
m_startTime.start();
m_currentWidget = qobject_cast<QAbstractItemView *>(
@@ -524,10 +525,10 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
painter->drawText(tagsLabelRect, tagsLabelText);
painter->setPen(themeColor(Theme::Welcome_LinkColor));
m_currentTagRects.clear();
int emptyTagRowsLeft = 2;
int xx = 0;
int yy = 0;
const bool populateTagsRects = m_currentTagRects.empty();
for (const QString &tag : item->tags) {
const int ww = fm.horizontalAdvance(tag) + tagsHorSpacing;
if (xx + ww > textArea.width() - tagsLabelRect.width()) {
@@ -539,7 +540,8 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
const QRect tagRect = QRect(xx, yy, ww, tagsLabelRect.height())
.translated(tagsLabelRect.topRight());
painter->drawText(tagRect, tag);
m_currentTagRects.append({ tag, tagRect.translated(rc.topLeft()) });
if (populateTagsRects)
m_currentTagRects.append({ tag, tagRect });
xx += ww;
}
@@ -559,16 +561,16 @@ bool ListItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
return false;
if (index.isValid()) {
const QPoint pos = mev->pos();
if (pos.y() > option.rect.y() + TagsSeparatorY) {
//const QStringList tags = idx.data(Tags).toStringList();
for (const auto &it : qAsConst(m_currentTagRects)) {
if (it.second.contains(pos))
emit tagClicked(it.first);
}
} else {
const QPoint mousePos = mev->pos() - option.rect.topLeft();
const auto tagUnderMouse =
Utils::findOrDefault(m_currentTagRects,
[&mousePos](const QPair<QString, QRect> &tag) {
return tag.second.contains(mousePos);
});
if (!tagUnderMouse.first.isEmpty())
emit tagClicked(tagUnderMouse.first);
else
clickAction(item);
}
}
}
return QStyledItemDelegate::editorEvent(event, model, option, index);