Changeset View
Changeset View
Standalone View
Standalone View
lib/semanticinfo/tagitemdelegate.cpp
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 118 | painter->setPen(option.palette.color(QPalette::Normal, | |||
---|---|---|---|---|---|
119 | selected | 119 | selected | ||
120 | ? QPalette::HighlightedText | 120 | ? QPalette::HighlightedText | ||
121 | : QPalette::Text)); | 121 | : QPalette::Text)); | ||
122 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, index.data().toString()); | 122 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, index.data().toString()); | ||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | QSize TagItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const | 125 | QSize TagItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const | ||
126 | { | 126 | { | ||
127 | const int width = option.fontMetrics.width(index.data().toString()); | 127 | const int width = option.fontMetrics.boundingRect(index.data().toString()).width(); | ||
128 | const int height = qMax(mButtonSize, option.fontMetrics.height()); | 128 | const int height = qMax(mButtonSize, option.fontMetrics.height()); | ||
129 | return QSize(width + 2 * mMargin, height + 2 * mMargin); | 129 | return QSize(width + 2 * mMargin, height + 2 * mMargin); | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | void TagItemDelegate::slotRemoveButtonClicked() | 132 | void TagItemDelegate::slotRemoveButtonClicked() | ||
133 | { | 133 | { | ||
134 | const QModelIndex index = focusedIndex(); | 134 | const QModelIndex index = focusedIndex(); | ||
135 | if (!index.isValid()) { | 135 | if (!index.isValid()) { | ||
Show All 17 Lines |