Commit 5ed6f0a7 authored by Kevin Funk's avatar Kevin Funk

collectionview: Show correct tooltip

Prior to this patch Korganizer showed tooltips for the wrong
collections. Simplified this code to generate the tooltip string on
demand as well, this also fixes the issue.
parent 3b09f962
Pipeline #44456 canceled with stage
......@@ -335,6 +335,16 @@ protected:
}
return true;
}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
{
if (role == Qt::ToolTipRole) {
const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
return CalendarSupport::toolTipString(col);
}
return QSortFilterProxyModel::data(index, role);
};
};
class CalendarDelegateModel : public QSortFilterProxyModel
......
......@@ -54,6 +54,8 @@ static QStyle *style(const QStyleOptionViewItem &option)
static QStyleOptionButton buttonOpt(const QStyleOptionViewItem &opt, const QPixmap &pixmap, const QModelIndex &index, int pos = 1)
{
Q_UNUSED(index);
QStyleOptionButton option;
option.icon = pixmap;
QRect r = opt.rect;
......@@ -61,11 +63,6 @@ static QStyleOptionButton buttonOpt(const QStyleOptionViewItem &opt, const QPixm
option.rect = enableButtonRect(r, pos);
option.state = QStyle::State_Active | QStyle::State_Enabled;
option.iconSize = QSize(h, h);
auto *w = const_cast<QWidget *>(opt.widget);
if (w) {
const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
w->setToolTip(CalendarSupport::toolTipString(col));
}
return option;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment