summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qitemdelegate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/itemviews/qitemdelegate.cpp')
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index 68c02e9edb..91122283a4 100644
--- a/src/widgets/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
@@ -94,10 +94,7 @@ public:
inline static QString replaceNewLine(QString text)
{
- const QChar nl = QLatin1Char('\n');
- for (int i = 0; i < text.count(); ++i)
- if (text.at(i) == nl)
- text[i] = QChar::LineSeparator;
+ text.replace(QLatin1Char('\n'), QChar::LineSeparator);
return text;
}
@@ -806,11 +803,14 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
const bool hasCheck = checkRect->isValid();
const bool hasPixmap = pixmapRect->isValid();
const bool hasText = textRect->isValid();
- const int textMargin = hasText ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
- const int pixmapMargin = hasPixmap ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
- const int checkMargin = hasCheck ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
- int x = option.rect.left();
- int y = option.rect.top();
+ const bool hasMargin = (hasText | hasPixmap | hasCheck);
+ const int frameHMargin = hasMargin ?
+ style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
+ const int textMargin = hasText ? frameHMargin : 0;
+ const int pixmapMargin = hasPixmap ? frameHMargin : 0;
+ const int checkMargin = hasCheck ? frameHMargin : 0;
+ const int x = option.rect.left();
+ const int y = option.rect.top();
int w, h;
textRect->adjust(-textMargin, 0, textMargin, 0); // add width padding
@@ -845,7 +845,7 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
if (option.direction == Qt::RightToLeft) {
check.setRect(x + w - cw, y, cw, h);
} else {
- check.setRect(x + checkMargin, y, cw, h);
+ check.setRect(x, y, cw, h);
}
}
@@ -988,7 +988,7 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette,
painter.end();
QPixmap selected = QPixmap(QPixmap::fromImage(img));
- int n = (img.byteCount() >> 10) + 1;
+ int n = (img.sizeInBytes() >> 10) + 1;
if (QPixmapCache::cacheLimit() < n)
QPixmapCache::setCacheLimit(n);
@@ -1090,7 +1090,7 @@ QRect QItemDelegate::textRectangle(QPainter * /*painter*/, const QRect &rect,
\endlist
In the case of \uicontrol Tab, \uicontrol Backtab, \uicontrol Enter and \uicontrol Return
- key press events, the \a editor's data is comitted to the model
+ key press events, the \a editor's data is committed to the model
and the editor is closed. If the \a event is a \uicontrol Tab key press
the view will open an editor on the next item in the
view. Likewise, if the \a event is a \uicontrol Backtab key press the