changeset 30 | 5dc02b23752f |
parent 19 | fcece45ef507 |
child 33 | 3e2da88830cd |
29:b72c6db6890b | 30:5dc02b23752f |
---|---|
67 #include <private/qdnd_p.h> |
67 #include <private/qdnd_p.h> |
68 #include <private/qtextengine_p.h> |
68 #include <private/qtextengine_p.h> |
69 #include <qdebug.h> |
69 #include <qdebug.h> |
70 #include <qlocale.h> |
70 #include <qlocale.h> |
71 #include <qdialog.h> |
71 #include <qdialog.h> |
72 #include <qmath.h> |
|
72 |
73 |
73 #include <limits.h> |
74 #include <limits.h> |
74 |
75 |
75 #ifndef DBL_DIG |
76 #ifndef DBL_DIG |
76 # define DBL_DIG 10 |
77 # define DBL_DIG 10 |
1021 } |
1022 } |
1022 |
1023 |
1023 // hacky but faster version of "QString::sprintf("%d-%d", i, enabled)" |
1024 // hacky but faster version of "QString::sprintf("%d-%d", i, enabled)" |
1024 static QString qPixmapSerial(quint64 i, bool enabled) |
1025 static QString qPixmapSerial(quint64 i, bool enabled) |
1025 { |
1026 { |
1026 ushort arr[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', '0' + enabled }; |
1027 ushort arr[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', ushort('0' + enabled) }; |
1027 ushort *ptr = &arr[16]; |
1028 ushort *ptr = &arr[16]; |
1028 |
1029 |
1029 while (i > 0) { |
1030 while (i > 0) { |
1030 // hey - it's our internal representation, so use the ascii character after '9' |
1031 // hey - it's our internal representation, so use the ascii character after '9' |
1031 // instead of 'a' for hex |
1032 // instead of 'a' for hex |
1146 Q_D(const QItemDelegate); |
1147 Q_D(const QItemDelegate); |
1147 d->textOption.setWrapMode(QTextOption::WordWrap); |
1148 d->textOption.setWrapMode(QTextOption::WordWrap); |
1148 d->textLayout.setTextOption(d->textOption); |
1149 d->textLayout.setTextOption(d->textOption); |
1149 d->textLayout.setFont(font); |
1150 d->textLayout.setFont(font); |
1150 d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text)); |
1151 d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text)); |
1151 const QSize size = d->doTextLayout(rect.width()).toSize(); |
1152 QSizeF fpSize = d->doTextLayout(rect.width()); |
1153 const QSize size = QSize(qCeil(fpSize.width()), qCeil(fpSize.height())); |
|
1152 // ###: textRectangle should take style option as argument |
1154 // ###: textRectangle should take style option as argument |
1153 const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1; |
1155 const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1; |
1154 return QRect(0, 0, size.width() + 2 * textMargin, size.height()); |
1156 return QRect(0, 0, size.width() + 2 * textMargin, size.height()); |
1155 } |
1157 } |
1156 |
1158 |