Changeset View
Changeset View
Standalone View
Standalone View
korganizer/views/collectionview/calendardelegate.cpp
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | QList<StyledCalendarDelegate::Action> StyledCalendarDelegate::getActions(const QStyleOptionViewItem &option, const QModelIndex &index) const | ||||
} | } | ||||
return buttons; | return buttons; | ||||
} | } | ||||
void StyledCalendarDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const | void StyledCalendarDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const | ||||
{ | { | ||||
Q_ASSERT(index.isValid()); | Q_ASSERT(index.isValid()); | ||||
const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index); | Akonadi::Collection col = CalendarSupport::collectionFromIndex(index); | ||||
//We display the toolbuttons while hovering | //We display the toolbuttons while hovering | ||||
const bool showButtons = option.state & QStyle::State_MouseOver; | const bool showButtons = option.state & QStyle::State_MouseOver; | ||||
// const bool enabled = col.shouldList(Akonadi::Collection::ListDisplay); | // const bool enabled = col.shouldList(Akonadi::Collection::ListDisplay); | ||||
Qt::CheckState enabled = static_cast<Qt::CheckState>(index.data(EnabledRole).toInt()); | Qt::CheckState enabled = static_cast<Qt::CheckState>(index.data(EnabledRole).toInt()); | ||||
QStyleOptionViewItemV4 opt = option; | QStyleOptionViewItemV4 opt = option; | ||||
initStyleOption(&opt, index); | initStyleOption(&opt, index); | ||||
QStyledItemDelegate::paint(painter, opt, index); | QStyledItemDelegate::paint(painter, opt, index); | ||||
Show All 29 Lines | void StyledCalendarDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const | ||||
//Color indicator | //Color indicator | ||||
if (opt.checkState){ | if (opt.checkState){ | ||||
QColor color = KOHelper::resourceColorKnown(col); | QColor color = KOHelper::resourceColorKnown(col); | ||||
if (!color.isValid() && isChildOfPersonCollection(index)){ | if (!color.isValid() && isChildOfPersonCollection(index)){ | ||||
const Akonadi::Collection parentCol = personCollection(index); | const Akonadi::Collection parentCol = personCollection(index); | ||||
if (parentCol.isValid()) { | if (parentCol.isValid()) { | ||||
color = KOHelper::resourceColor(parentCol); | color = KOHelper::resourceColor(parentCol); | ||||
KOHelper::setResourceColor(col, color); | |||||
} else { | } else { | ||||
color = KOHelper::resourceColor(col); | color = KOHelper::resourceColor(col); | ||||
} | } | ||||
} else { | } else { | ||||
color = KOHelper::resourceColor(col); | color = KOHelper::resourceColor(col); | ||||
} | } | ||||
if (color.isValid()){ | if (color.isValid()){ | ||||
painter->save(); | painter->save(); | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |