forked from qt-creator/qt-creator
Fix Qt 5.13 deprecation warning about QFontMetrics::width()
Replace by QFontMetrics::horizontalAdvance(), fixing: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] Change-Id: I9991ffefe6e87e872dc35ba291d562e06b28ca64 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -181,7 +181,7 @@ public:
|
|||||||
QAbstractItemModel *m = q->model();
|
QAbstractItemModel *m = q->model();
|
||||||
for (int i = 0; i < 100 && a.isValid(); ++i) {
|
for (int i = 0; i < 100 && a.isValid(); ++i) {
|
||||||
const QString s = m->data(a).toString();
|
const QString s = m->data(a).toString();
|
||||||
int w = fm.width(s) + 10;
|
int w = fm.horizontalAdvance(s) + 10;
|
||||||
if (column == 0) {
|
if (column == 0) {
|
||||||
for (QModelIndex b = a.parent(); b.isValid(); b = b.parent())
|
for (QModelIndex b = a.parent(); b.isValid(); b = b.parent())
|
||||||
w += ind;
|
w += ind;
|
||||||
@@ -202,7 +202,8 @@ public:
|
|||||||
QTC_ASSERT(m, return -1);
|
QTC_ASSERT(m, return -1);
|
||||||
|
|
||||||
QFontMetrics fm = q->fontMetrics();
|
QFontMetrics fm = q->fontMetrics();
|
||||||
int minimum = fm.width(m->headerData(column, Qt::Horizontal).toString()) + 2 * fm.width(QLatin1Char('m'));
|
int minimum = fm.horizontalAdvance(m->headerData(column, Qt::Horizontal).toString())
|
||||||
|
+ 2 * fm.horizontalAdvance(QLatin1Char('m'));
|
||||||
considerItems(column, q->indexAt(QPoint(1, 1)), &minimum, false);
|
considerItems(column, q->indexAt(QPoint(1, 1)), &minimum, false);
|
||||||
|
|
||||||
QVariant extraIndices = m->data(QModelIndex(), BaseTreeView::ExtraIndicesForColumnWidth);
|
QVariant extraIndices = m->data(QModelIndex(), BaseTreeView::ExtraIndicesForColumnWidth);
|
||||||
@@ -252,8 +253,8 @@ public:
|
|||||||
// when we have that size already, in that case minimize.
|
// when we have that size already, in that case minimize.
|
||||||
if (currentSize == suggestedSize) {
|
if (currentSize == suggestedSize) {
|
||||||
QFontMetrics fm = q->fontMetrics();
|
QFontMetrics fm = q->fontMetrics();
|
||||||
int headerSize = fm.width(q->model()->headerData(logicalIndex, Qt::Horizontal).toString());
|
int headerSize = fm.horizontalAdvance(q->model()->headerData(logicalIndex, Qt::Horizontal).toString());
|
||||||
int minSize = 10 * fm.width(QLatin1Char('x'));
|
int minSize = 10 * fm.horizontalAdvance(QLatin1Char('x'));
|
||||||
targetSize = qMax(minSize, headerSize);
|
targetSize = qMax(minSize, headerSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ void AnnotatedItemDelegate::paint(QPainter *painter,
|
|||||||
painter->save();
|
painter->save();
|
||||||
painter->setPen(disabled.color(QPalette::WindowText));
|
painter->setPen(disabled.color(QPalette::WindowText));
|
||||||
|
|
||||||
static int extra = opt.fontMetrics.width(m_delimiter) + 10;
|
static int extra = opt.fontMetrics.horizontalAdvance(m_delimiter) + 10;
|
||||||
const QPixmap &pixmap = opt.icon.pixmap(opt.decorationSize);
|
const QPixmap &pixmap = opt.icon.pixmap(opt.decorationSize);
|
||||||
const QRect &iconRect = style->itemPixmapRect(opt.rect, opt.decorationAlignment, pixmap);
|
const QRect &iconRect = style->itemPixmapRect(opt.rect, opt.decorationAlignment, pixmap);
|
||||||
const QRect &displayRect = style->itemTextRect(opt.fontMetrics, opt.rect,
|
const QRect &displayRect = style->itemTextRect(opt.fontMetrics, opt.rect,
|
||||||
|
@@ -79,7 +79,7 @@ DetailsButton::DetailsButton(QWidget *parent) : QAbstractButton(parent), m_fader
|
|||||||
QSize DetailsButton::sizeHint() const
|
QSize DetailsButton::sizeHint() const
|
||||||
{
|
{
|
||||||
// TODO: Adjust this when icons become available!
|
// TODO: Adjust this when icons become available!
|
||||||
const int w = fontMetrics().width(text()) + 32;
|
const int w = fontMetrics().horizontalAdvance(text()) + 32;
|
||||||
if (HostOsInfo::isMacHost())
|
if (HostOsInfo::isMacHost())
|
||||||
return QSize(w, 34);
|
return QSize(w, 34);
|
||||||
return QSize(w, 22);
|
return QSize(w, 22);
|
||||||
|
@@ -66,7 +66,7 @@ void ElidingLabel::paintEvent(QPaintEvent *)
|
|||||||
QRect contents = contentsRect().adjusted(m, m, -m, -m);
|
QRect contents = contentsRect().adjusted(m, m, -m, -m);
|
||||||
QFontMetrics fm = fontMetrics();
|
QFontMetrics fm = fontMetrics();
|
||||||
QString txt = text();
|
QString txt = text();
|
||||||
if (txt.length() > 4 && fm.width(txt) > contents.width()) {
|
if (txt.length() > 4 && fm.horizontalAdvance(txt) > contents.width()) {
|
||||||
setToolTip(txt);
|
setToolTip(txt);
|
||||||
txt = fm.elidedText(txt, m_elideMode, contents.width());
|
txt = fm.elidedText(txt, m_elideMode, contents.width());
|
||||||
} else {
|
} else {
|
||||||
|
@@ -114,7 +114,8 @@ int HighlightingItemDelegate::drawLineNumber(QPainter *painter, const QStyleOpti
|
|||||||
const bool isSelected = option.state & QStyle::State_Selected;
|
const bool isSelected = option.state & QStyle::State_Selected;
|
||||||
const QString lineText = QString::number(lineNumber);
|
const QString lineText = QString::number(lineNumber);
|
||||||
const int minimumLineNumberDigits = qMax(kMinimumLineNumberDigits, lineText.count());
|
const int minimumLineNumberDigits = qMax(kMinimumLineNumberDigits, lineText.count());
|
||||||
const int fontWidth = painter->fontMetrics().width(QString(minimumLineNumberDigits, '0'));
|
const int fontWidth =
|
||||||
|
painter->fontMetrics().horizontalAdvance(QString(minimumLineNumberDigits, '0'));
|
||||||
const int lineNumberAreaWidth = lineNumberAreaHorizontalPadding + fontWidth
|
const int lineNumberAreaWidth = lineNumberAreaHorizontalPadding + fontWidth
|
||||||
+ lineNumberAreaHorizontalPadding;
|
+ lineNumberAreaHorizontalPadding;
|
||||||
QRect lineNumberAreaRect(rect);
|
QRect lineNumberAreaRect(rect);
|
||||||
|
@@ -173,7 +173,7 @@ public:
|
|||||||
|
|
||||||
// topRight
|
// topRight
|
||||||
auto drawTopRight = [&](const QString text, const QFontMetrics &fm) {
|
auto drawTopRight = [&](const QString text, const QFontMetrics &fm) {
|
||||||
painter->drawText(opt.rect.right() - fm.width(text) - 6 , 2 + opt.rect.top() + fm.ascent(), text);
|
painter->drawText(opt.rect.right() - fm.horizontalAdvance(text) - 6 , 2 + opt.rect.top() + fm.ascent(), text);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (device.type == AndroidDeviceInfo::Hardware) {
|
if (device.type == AndroidDeviceInfo::Hardware) {
|
||||||
|
@@ -65,7 +65,7 @@ private:
|
|||||||
m_maxFileLength = srcModel->maxWidthOfFileName(options.font);
|
m_maxFileLength = srcModel->maxWidthOfFileName(options.font);
|
||||||
m_maxLineLength = srcModel->maxWidthOfLineNumber(options.font);
|
m_maxLineLength = srcModel->maxWidthOfLineNumber(options.font);
|
||||||
m_realFileLength = m_maxFileLength;
|
m_realFileLength = m_maxFileLength;
|
||||||
m_typeAreaWidth = QFontMetrics(options.font).width("XXXXXXXX");
|
m_typeAreaWidth = QFontMetrics(options.font).horizontalAdvance("XXXXXXXX");
|
||||||
m_indentation = options.widget ? options.widget->style()->pixelMetric(
|
m_indentation = options.widget ? options.widget->style()->pixelMetric(
|
||||||
QStyle::PM_TreeViewIndentation, &options) : 0;
|
QStyle::PM_TreeViewIndentation, &options) : 0;
|
||||||
|
|
||||||
|
@@ -305,7 +305,7 @@ void TestResultModel::recalculateMaxWidthOfFileName(const QFont &font)
|
|||||||
m_maxWidthOfFileName = 0;
|
m_maxWidthOfFileName = 0;
|
||||||
for (const QString &fileName : m_fileNames) {
|
for (const QString &fileName : m_fileNames) {
|
||||||
int pos = fileName.lastIndexOf('/');
|
int pos = fileName.lastIndexOf('/');
|
||||||
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.width(fileName.mid(pos + 1)));
|
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ void TestResultModel::addFileName(const QString &fileName)
|
|||||||
{
|
{
|
||||||
const QFontMetrics fm(m_measurementFont);
|
const QFontMetrics fm(m_measurementFont);
|
||||||
int pos = fileName.lastIndexOf('/');
|
int pos = fileName.lastIndexOf('/');
|
||||||
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.width(fileName.mid(pos + 1)));
|
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1)));
|
||||||
m_fileNames.insert(fileName);
|
m_fileNames.insert(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
|
|||||||
if (m_widthOfLineNumber == 0 || font != m_measurementFont) {
|
if (m_widthOfLineNumber == 0 || font != m_measurementFont) {
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
m_measurementFont = font;
|
m_measurementFont = font;
|
||||||
m_widthOfLineNumber = fm.width("88888");
|
m_widthOfLineNumber = fm.horizontalAdvance("88888");
|
||||||
}
|
}
|
||||||
return m_widthOfLineNumber;
|
return m_widthOfLineNumber;
|
||||||
}
|
}
|
||||||
|
@@ -185,35 +185,35 @@ void BinEditorWidget::init()
|
|||||||
m_descent = fm.descent();
|
m_descent = fm.descent();
|
||||||
m_ascent = fm.ascent();
|
m_ascent = fm.ascent();
|
||||||
m_lineHeight = fm.lineSpacing();
|
m_lineHeight = fm.lineSpacing();
|
||||||
m_charWidth = fm.width(QChar(QLatin1Char('M')));
|
m_charWidth = fm.horizontalAdvance(QChar(QLatin1Char('M')));
|
||||||
m_margin = m_charWidth;
|
m_margin = m_charWidth;
|
||||||
m_columnWidth = 2 * m_charWidth + fm.width(QChar(QLatin1Char(' ')));
|
m_columnWidth = 2 * m_charWidth + fm.horizontalAdvance(QChar(QLatin1Char(' ')));
|
||||||
m_numLines = m_size / m_bytesPerLine + 1;
|
m_numLines = m_size / m_bytesPerLine + 1;
|
||||||
m_numVisibleLines = viewport()->height() / m_lineHeight;
|
m_numVisibleLines = viewport()->height() / m_lineHeight;
|
||||||
m_textWidth = m_bytesPerLine * m_charWidth + m_charWidth;
|
m_textWidth = m_bytesPerLine * m_charWidth + m_charWidth;
|
||||||
int numberWidth = fm.width(QChar(QLatin1Char('9')));
|
int numberWidth = fm.horizontalAdvance(QChar(QLatin1Char('9')));
|
||||||
m_labelWidth = 2*m_addressBytes * numberWidth + (m_addressBytes - 1)/2 * m_charWidth;
|
m_labelWidth = 2*m_addressBytes * numberWidth + (m_addressBytes - 1)/2 * m_charWidth;
|
||||||
|
|
||||||
int expectedCharWidth = m_columnWidth / 3;
|
int expectedCharWidth = m_columnWidth / 3;
|
||||||
const char *hex = "0123456789abcdef";
|
const char *hex = "0123456789abcdef";
|
||||||
m_isMonospacedFont = true;
|
m_isMonospacedFont = true;
|
||||||
while (*hex) {
|
while (*hex) {
|
||||||
if (fm.width(QLatin1Char(*hex)) != expectedCharWidth) {
|
if (fm.horizontalAdvance(QLatin1Char(*hex)) != expectedCharWidth) {
|
||||||
m_isMonospacedFont = false;
|
m_isMonospacedFont = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++hex;
|
++hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_isMonospacedFont && fm.width(QLatin1String("M M ")) != m_charWidth * 4) {
|
if (m_isMonospacedFont && fm.horizontalAdvance(QLatin1String("M M ")) != m_charWidth * 4) {
|
||||||
// On Qt/Mac, monospace font widths may have a fractional component
|
// On Qt/Mac, monospace font widths may have a fractional component
|
||||||
// This breaks the assumption that width("MMM") == width('M') * 3
|
// This breaks the assumption that width("MMM") == width('M') * 3
|
||||||
|
|
||||||
m_isMonospacedFont = false;
|
m_isMonospacedFont = false;
|
||||||
m_columnWidth = fm.width(QLatin1String("MMM"));
|
m_columnWidth = fm.horizontalAdvance(QLatin1String("MMM"));
|
||||||
m_labelWidth = m_addressBytes == 4
|
m_labelWidth = m_addressBytes == 4
|
||||||
? fm.width(QLatin1String("MMMM:MMMM"))
|
? fm.horizontalAdvance(QLatin1String("MMMM:MMMM"))
|
||||||
: fm.width(QLatin1String("MMMM:MMMM:MMMM:MMMM"));
|
: fm.horizontalAdvance(QLatin1String("MMMM:MMMM:MMMM:MMMM"));
|
||||||
}
|
}
|
||||||
|
|
||||||
horizontalScrollBar()->setRange(0, 2 * m_margin + m_bytesPerLine * m_columnWidth
|
horizontalScrollBar()->setRange(0, 2 * m_margin + m_bytesPerLine * m_columnWidth
|
||||||
@@ -568,7 +568,7 @@ Utils::optional<qint64> BinEditorWidget::posAt(const QPoint &pos, bool includeEm
|
|||||||
QChar qc(QLatin1Char(dataAt(dataPos)));
|
QChar qc(QLatin1Char(dataAt(dataPos)));
|
||||||
if (!qc.isPrint())
|
if (!qc.isPrint())
|
||||||
qc = 0xB7;
|
qc = 0xB7;
|
||||||
x -= fontMetrics().width(qc);
|
x -= fontMetrics().horizontalAdvance(qc);
|
||||||
if (x <= 0)
|
if (x <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -913,18 +913,18 @@ void BinEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
if (color.isValid()) {
|
if (color.isValid()) {
|
||||||
painter.fillRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight, color);
|
painter.fillRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight, color);
|
||||||
int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth
|
int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth
|
||||||
+ fm.width(printable.left(c));
|
+ fm.horizontalAdvance(printable.left(c));
|
||||||
painter.fillRect(printable_item_x, y-m_ascent,
|
painter.fillRect(printable_item_x, y-m_ascent,
|
||||||
fm.width(printable.at(c)),
|
fm.horizontalAdvance(printable.at(c)),
|
||||||
m_lineHeight, color);
|
m_lineHeight, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFullySelected && pos >= selStart && pos <= selEnd) {
|
if (!isFullySelected && pos >= selStart && pos <= selEnd) {
|
||||||
selectionRect |= QRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight);
|
selectionRect |= QRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight);
|
||||||
int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth
|
int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth
|
||||||
+ fm.width(printable.left(c));
|
+ fm.horizontalAdvance(printable.left(c));
|
||||||
printableSelectionRect |= QRect(printable_item_x, y-m_ascent,
|
printableSelectionRect |= QRect(printable_item_x, y-m_ascent,
|
||||||
fm.width(printable.at(c)),
|
fm.horizontalAdvance(printable.at(c)),
|
||||||
m_lineHeight);
|
m_lineHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -958,7 +958,7 @@ void BinEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
paintCursorBorder(&painter, cursorRect);
|
paintCursorBorder(&painter, cursorRect);
|
||||||
if (m_hexCursor && m_cursorVisible) {
|
if (m_hexCursor && m_cursorVisible) {
|
||||||
if (m_lowNibble)
|
if (m_lowNibble)
|
||||||
cursorRect.adjust(fm.width(itemString.left(1)), 0, 0, 0);
|
cursorRect.adjust(fm.horizontalAdvance(itemString.left(1)), 0, 0, 0);
|
||||||
painter.fillRect(cursorRect, Qt::red);
|
painter.fillRect(cursorRect, Qt::red);
|
||||||
painter.save();
|
painter.save();
|
||||||
painter.setClipRect(cursorRect);
|
painter.setClipRect(cursorRect);
|
||||||
@@ -972,7 +972,7 @@ void BinEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
if (isFullySelected) {
|
if (isFullySelected) {
|
||||||
painter.save();
|
painter.save();
|
||||||
painter.fillRect(text_x, y-m_ascent, fm.width(printable), m_lineHeight,
|
painter.fillRect(text_x, y-m_ascent, fm.horizontalAdvance(printable), m_lineHeight,
|
||||||
palette().highlight());
|
palette().highlight());
|
||||||
painter.setPen(palette().highlightedText().color());
|
painter.setPen(palette().highlightedText().color());
|
||||||
painter.drawText(text_x, y, printable);
|
painter.drawText(text_x, y, printable);
|
||||||
@@ -990,9 +990,9 @@ void BinEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cursor >= 0 && !printable.isEmpty()) {
|
if (cursor >= 0 && !printable.isEmpty()) {
|
||||||
QRect cursorRect(text_x + fm.width(printable.left(cursor)),
|
QRect cursorRect(text_x + fm.horizontalAdvance(printable.left(cursor)),
|
||||||
y-m_ascent,
|
y-m_ascent,
|
||||||
fm.width(printable.at(cursor)),
|
fm.horizontalAdvance(printable.at(cursor)),
|
||||||
m_lineHeight);
|
m_lineHeight);
|
||||||
if (m_hexCursor || !m_cursorVisible) {
|
if (m_hexCursor || !m_cursorVisible) {
|
||||||
paintCursorBorder(&painter, cursorRect);
|
paintCursorBorder(&painter, cursorRect);
|
||||||
|
@@ -119,7 +119,7 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
QFontMetrics fm(opt.font);
|
QFontMetrics fm(opt.font);
|
||||||
static int lwidth = fm.width(QLatin1String("8888")) + 18;
|
static int lwidth = fm.horizontalAdvance(QLatin1String("8888")) + 18;
|
||||||
|
|
||||||
QColor backgroundColor;
|
QColor backgroundColor;
|
||||||
QColor textColor;
|
QColor textColor;
|
||||||
@@ -155,13 +155,14 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||||||
|
|
||||||
QString topRight = index.data(BookmarkManager::LineNumber).toString();
|
QString topRight = index.data(BookmarkManager::LineNumber).toString();
|
||||||
// Check whether we need to be fancy and paint some background
|
// Check whether we need to be fancy and paint some background
|
||||||
int fwidth = fm.width(topLeft);
|
int fwidth = fm.horizontalAdvance(topLeft);
|
||||||
if (fwidth + lwidth > opt.rect.width()) {
|
if (fwidth + lwidth > opt.rect.width()) {
|
||||||
int left = opt.rect.right() - lwidth;
|
int left = opt.rect.right() - lwidth;
|
||||||
painter->drawPixmap(left, opt.rect.top(), selected ? m_selectedPixmap : m_normalPixmap);
|
painter->drawPixmap(left, opt.rect.top(), selected ? m_selectedPixmap : m_normalPixmap);
|
||||||
}
|
}
|
||||||
// topRight
|
// topRight
|
||||||
painter->drawText(opt.rect.right() - fm.width(topRight) - 6 , 2 + opt.rect.top() + fm.ascent(), topRight);
|
painter->drawText(opt.rect.right() - fm.horizontalAdvance(topRight) - 6,
|
||||||
|
2 + opt.rect.top() + fm.ascent(), topRight);
|
||||||
|
|
||||||
// Directory
|
// Directory
|
||||||
QColor mix;
|
QColor mix;
|
||||||
|
@@ -102,19 +102,19 @@ static QVector<QString> splitInTwoLines(const QString &text,
|
|||||||
nextSplitPos = rx.lastIndexIn(text, nextSplitPos - text.length() - 1);
|
nextSplitPos = rx.lastIndexIn(text, nextSplitPos - text.length() - 1);
|
||||||
if (nextSplitPos != -1) {
|
if (nextSplitPos != -1) {
|
||||||
int splitCandidate = nextSplitPos + rx.matchedLength();
|
int splitCandidate = nextSplitPos + rx.matchedLength();
|
||||||
if (fontMetrics.width(text.mid(splitCandidate)) <= availableWidth)
|
if (fontMetrics.horizontalAdvance(text.mid(splitCandidate)) <= availableWidth)
|
||||||
splitPos = splitCandidate;
|
splitPos = splitCandidate;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (nextSplitPos > 0 && fontMetrics.width(text.left(nextSplitPos)) > availableWidth);
|
} while (nextSplitPos > 0 && fontMetrics.horizontalAdvance(text.left(nextSplitPos)) > availableWidth);
|
||||||
// check if we could split at white space at all
|
// check if we could split at white space at all
|
||||||
if (splitPos < 0) {
|
if (splitPos < 0) {
|
||||||
splitLines[0] = fontMetrics.elidedText(text, Qt::ElideRight, int(availableWidth));
|
splitLines[0] = fontMetrics.elidedText(text, Qt::ElideRight, int(availableWidth));
|
||||||
QString common = Utils::commonPrefix(QStringList({splitLines[0], text}));
|
QString common = Utils::commonPrefix(QStringList({splitLines[0], text}));
|
||||||
splitLines[1] = text.mid(common.length());
|
splitLines[1] = text.mid(common.length());
|
||||||
// elide the second line even if it fits, since it is cut off in mid-word
|
// elide the second line even if it fits, since it is cut off in mid-word
|
||||||
while (fontMetrics.width(QChar(0x2026) /*'...'*/ + splitLines[1]) > availableWidth
|
while (fontMetrics.horizontalAdvance(QChar(0x2026) /*'...'*/ + splitLines[1]) > availableWidth
|
||||||
&& splitLines[1].length() > 3
|
&& splitLines[1].length() > 3
|
||||||
/*keep at least three original characters (should not happen)*/) {
|
/*keep at least three original characters (should not happen)*/) {
|
||||||
splitLines[1].remove(0, 1);
|
splitLines[1].remove(0, 1);
|
||||||
@@ -222,7 +222,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
|
|||||||
painter.setFont(boldFont);
|
painter.setFont(boldFont);
|
||||||
QVector<QString> splitBuildConfiguration(2);
|
QVector<QString> splitBuildConfiguration(2);
|
||||||
const QString buildConfiguration = defaultAction()->property("subtitle").toString();
|
const QString buildConfiguration = defaultAction()->property("subtitle").toString();
|
||||||
if (boldFm.width(buildConfiguration) <= availableWidth)
|
if (boldFm.horizontalAdvance(buildConfiguration) <= availableWidth)
|
||||||
// text fits in one line
|
// text fits in one line
|
||||||
splitBuildConfiguration[0] = buildConfiguration;
|
splitBuildConfiguration[0] = buildConfiguration;
|
||||||
else
|
else
|
||||||
|
@@ -98,7 +98,7 @@ QSize FancyTabBar::tabSizeHint(bool minimum) const
|
|||||||
const int width = 60 + spacing + 2;
|
const int width = 60 + spacing + 2;
|
||||||
int maxLabelwidth = 0;
|
int maxLabelwidth = 0;
|
||||||
for (auto tab : qAsConst(m_tabs)) {
|
for (auto tab : qAsConst(m_tabs)) {
|
||||||
const int width = fm.width(tab->text);
|
const int width = fm.horizontalAdvance(tab->text);
|
||||||
if (width > maxLabelwidth)
|
if (width > maxLabelwidth)
|
||||||
maxLabelwidth = width;
|
maxLabelwidth = width;
|
||||||
}
|
}
|
||||||
|
@@ -114,7 +114,7 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle
|
|||||||
const bool isSelected = option.state & QStyle::State_Selected;
|
const bool isSelected = option.state & QStyle::State_Selected;
|
||||||
QString lineText = QString::number(lineNumber);
|
QString lineText = QString::number(lineNumber);
|
||||||
int minimumLineNumberDigits = qMax((int)m_minimumLineNumberDigits, lineText.count());
|
int minimumLineNumberDigits = qMax((int)m_minimumLineNumberDigits, lineText.count());
|
||||||
int fontWidth = painter->fontMetrics().width(QString(minimumLineNumberDigits, QLatin1Char('0')));
|
int fontWidth = painter->fontMetrics().horizontalAdvance(QString(minimumLineNumberDigits, QLatin1Char('0')));
|
||||||
int lineNumberAreaWidth = lineNumberAreaHorizontalPadding + fontWidth + lineNumberAreaHorizontalPadding;
|
int lineNumberAreaWidth = lineNumberAreaHorizontalPadding + fontWidth + lineNumberAreaHorizontalPadding;
|
||||||
QRect lineNumberAreaRect(rect);
|
QRect lineNumberAreaRect(rect);
|
||||||
lineNumberAreaRect.setWidth(lineNumberAreaWidth);
|
lineNumberAreaRect.setWidth(lineNumberAreaWidth);
|
||||||
@@ -168,8 +168,8 @@ void SearchResultTreeItemDelegate::drawText(QPainter *painter,
|
|||||||
const QString textBefore = text.left(searchTermStart).replace(QLatin1Char('\t'), m_tabString);
|
const QString textBefore = text.left(searchTermStart).replace(QLatin1Char('\t'), m_tabString);
|
||||||
const QString textHighlight = text.mid(searchTermStart, searchTermLength).replace(QLatin1Char('\t'), m_tabString);
|
const QString textHighlight = text.mid(searchTermStart, searchTermLength).replace(QLatin1Char('\t'), m_tabString);
|
||||||
const QString textAfter = text.mid(searchTermStart + searchTermLength).replace(QLatin1Char('\t'), m_tabString);
|
const QString textAfter = text.mid(searchTermStart + searchTermLength).replace(QLatin1Char('\t'), m_tabString);
|
||||||
int searchTermStartPixels = painter->fontMetrics().width(textBefore);
|
int searchTermStartPixels = painter->fontMetrics().horizontalAdvance(textBefore);
|
||||||
int searchTermLengthPixels = painter->fontMetrics().width(textHighlight);
|
int searchTermLengthPixels = painter->fontMetrics().horizontalAdvance(textHighlight);
|
||||||
|
|
||||||
// rects
|
// rects
|
||||||
QRect beforeHighlightRect(rect);
|
QRect beforeHighlightRect(rect);
|
||||||
|
@@ -72,8 +72,8 @@ public:
|
|||||||
QSize sizeHint() const override
|
QSize sizeHint() const override
|
||||||
{
|
{
|
||||||
QSize sh = QLineEdit::minimumSizeHint();
|
QSize sh = QLineEdit::minimumSizeHint();
|
||||||
sh.rwidth() += qMax(25 * fontMetrics().width(QLatin1Char('x')),
|
sh.rwidth() += qMax(25 * fontMetrics().horizontalAdvance(QLatin1Char('x')),
|
||||||
fontMetrics().width(text()));
|
fontMetrics().horizontalAdvance(text()));
|
||||||
return sh;
|
return sh;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -721,11 +721,11 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
|||||||
|
|
||||||
bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
|
bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
|
||||||
&& cb->currentText.endsWith(asterisk)
|
&& cb->currentText.endsWith(asterisk)
|
||||||
&& option->fontMetrics.width(cb->currentText) > elideWidth;
|
&& option->fontMetrics.horizontalAdvance(cb->currentText) > elideWidth;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
if (notElideAsterisk) {
|
if (notElideAsterisk) {
|
||||||
elideWidth -= option->fontMetrics.width(asterisk);
|
elideWidth -= option->fontMetrics.horizontalAdvance(asterisk);
|
||||||
text = asterisk;
|
text = asterisk;
|
||||||
}
|
}
|
||||||
text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth));
|
text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth));
|
||||||
@@ -979,7 +979,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9);
|
QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9);
|
||||||
|
|
||||||
if (!alignarrow) {
|
if (!alignarrow) {
|
||||||
int labelwidth = option->fontMetrics.width(cb->currentText);
|
int labelwidth = option->fontMetrics.horizontalAdvance(cb->currentText);
|
||||||
if (reverse)
|
if (reverse)
|
||||||
arrowRect.moveLeft(qMax(rect.width() - labelwidth - menuButtonWidth - 2, 4));
|
arrowRect.moveLeft(qMax(rect.width() - labelwidth - menuButtonWidth - 2, 4));
|
||||||
else
|
else
|
||||||
|
@@ -324,7 +324,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
|||||||
|
|
||||||
m_opToolBarWidgets->addWidget(toolButtonsContainer);
|
m_opToolBarWidgets->addWidget(toolButtonsContainer);
|
||||||
|
|
||||||
minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName()));
|
minTitleWidth = qMax(minTitleWidth, titleFm.horizontalAdvance(outPane->displayName()));
|
||||||
|
|
||||||
QString suffix = outPane->displayName().simplified();
|
QString suffix = outPane->displayName().simplified();
|
||||||
suffix.remove(QLatin1Char(' '));
|
suffix.remove(QLatin1Char(' '));
|
||||||
@@ -667,7 +667,7 @@ void OutputPaneToggleButton::paintEvent(QPaintEvent*)
|
|||||||
{
|
{
|
||||||
const QFontMetrics fm = fontMetrics();
|
const QFontMetrics fm = fontMetrics();
|
||||||
const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent();
|
const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent();
|
||||||
const int numberWidth = fm.width(m_number);
|
const int numberWidth = fm.horizontalAdvance(m_number);
|
||||||
|
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
|
|
||||||
|
@@ -177,7 +177,7 @@ QSize ProgressBar::sizeHint() const
|
|||||||
int height = PROGRESSBAR_HEIGHT + 5;
|
int height = PROGRESSBAR_HEIGHT + 5;
|
||||||
if (m_titleVisible) {
|
if (m_titleVisible) {
|
||||||
QFontMetrics fm(titleFont());
|
QFontMetrics fm(titleFont());
|
||||||
width = qMax(width, fm.width(m_title) + 16);
|
width = qMax(width, fm.horizontalAdvance(m_title) + 16);
|
||||||
height += fm.height() + 5;
|
height += fm.height() + 5;
|
||||||
}
|
}
|
||||||
if (m_separatorVisible)
|
if (m_separatorVisible)
|
||||||
|
@@ -43,7 +43,7 @@ ColumnIndicatorTextEdit::ColumnIndicatorTextEdit(QWidget *parent) :
|
|||||||
setSizePolicy(sizePolicy);
|
setSizePolicy(sizePolicy);
|
||||||
int cmx = 0, cmy = 0, cmw = 0, cmh = 0;
|
int cmx = 0, cmy = 0, cmw = 0, cmh = 0;
|
||||||
getContentsMargins(&cmx, &cmy, &cmw, &cmh);
|
getContentsMargins(&cmx, &cmy, &cmw, &cmh);
|
||||||
m_columnIndicator = QFontMetrics(font).width(QLatin1Char('W')) * 100 + cmx + 1;
|
m_columnIndicator = QFontMetrics(font).horizontalAdvance(QLatin1Char('W')) * 100 + cmx + 1;
|
||||||
m_columnIndicatorFont.setFamily(QLatin1String("Times"));
|
m_columnIndicatorFont.setFamily(QLatin1String("Times"));
|
||||||
m_columnIndicatorFont.setPointSizeF(7.0);
|
m_columnIndicatorFont.setPointSizeF(7.0);
|
||||||
}
|
}
|
||||||
|
@@ -186,7 +186,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
|||||||
const int pos = file.lastIndexOf('/');
|
const int pos = file.lastIndexOf('/');
|
||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
file = file.mid(pos +1);
|
file = file.mid(pos +1);
|
||||||
const int realFileWidth = fm.width(file);
|
const int realFileWidth = fm.horizontalAdvance(file);
|
||||||
painter->setClipRect(positions.fileArea());
|
painter->setClipRect(positions.fileArea());
|
||||||
painter->drawText(positions.fileAreaLeft(), positions.adjustedTop() + fm.ascent(),
|
painter->drawText(positions.fileAreaLeft(), positions.adjustedTop() + fm.ascent(),
|
||||||
file);
|
file);
|
||||||
@@ -203,7 +203,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
|||||||
// Paint LineArea
|
// Paint LineArea
|
||||||
QString lineText = index.data(ConsoleItem::LineRole).toString();
|
QString lineText = index.data(ConsoleItem::LineRole).toString();
|
||||||
painter->setClipRect(positions.lineArea());
|
painter->setClipRect(positions.lineArea());
|
||||||
const int realLineWidth = fm.width(lineText);
|
const int realLineWidth = fm.horizontalAdvance(lineText);
|
||||||
painter->drawText(positions.lineAreaRight() - realLineWidth,
|
painter->drawText(positions.lineAreaRight() - realLineWidth,
|
||||||
positions.adjustedTop() + fm.ascent(), lineText);
|
positions.adjustedTop() + fm.ascent(), lineText);
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font)
|
|||||||
filename = filename.mid(pos + 1);
|
filename = filename.mid(pos + 1);
|
||||||
|
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename));
|
m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.horizontalAdvance(filename));
|
||||||
|
|
||||||
return m_maxSizeOfFileName;
|
return m_maxSizeOfFileName;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ int ConsoleItemModel::sizeOfFile(const QFont &font)
|
|||||||
int ConsoleItemModel::sizeOfLineNumber(const QFont &font)
|
int ConsoleItemModel::sizeOfLineNumber(const QFont &font)
|
||||||
{
|
{
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
return fm.width("88888");
|
return fm.horizontalAdvance("88888");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
@@ -137,7 +137,7 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent)
|
|||||||
m_centralWidgetStack = new QStackedWidget;
|
m_centralWidgetStack = new QStackedWidget;
|
||||||
m_statusLabel = new Utils::StatusLabel;
|
m_statusLabel = new Utils::StatusLabel;
|
||||||
m_statusLabel->setProperty("panelwidget", true);
|
m_statusLabel->setProperty("panelwidget", true);
|
||||||
m_statusLabel->setIndent(2 * QFontMetrics(q->font()).width(QChar('x')));
|
m_statusLabel->setIndent(2 * QFontMetrics(q->font()).horizontalAdvance(QChar('x')));
|
||||||
m_editorPlaceHolder = new EditorManagerPlaceHolder;
|
m_editorPlaceHolder = new EditorManagerPlaceHolder;
|
||||||
|
|
||||||
m_perspectiveChooser = new QComboBox;
|
m_perspectiveChooser = new QComboBox;
|
||||||
@@ -423,7 +423,8 @@ void DebuggerMainWindowPrivate::selectPerspective(Perspective *perspective)
|
|||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
m_perspectiveChooser->setCurrentIndex(index);
|
m_perspectiveChooser->setCurrentIndex(index);
|
||||||
|
|
||||||
const int contentWidth = m_perspectiveChooser->fontMetrics().width(perspective->d->m_name);
|
const int contentWidth =
|
||||||
|
m_perspectiveChooser->fontMetrics().horizontalAdvance(perspective->d->m_name);
|
||||||
QStyleOptionComboBox option;
|
QStyleOptionComboBox option;
|
||||||
option.initFrom(m_perspectiveChooser);
|
option.initFrom(m_perspectiveChooser);
|
||||||
const QSize sz(contentWidth, 1);
|
const QSize sz(contentWidth, 1);
|
||||||
|
@@ -362,7 +362,8 @@ void EngineManagerPrivate::selectUiForCurrentEngine()
|
|||||||
row = m_engineModel.rootItem()->indexOf(m_currentItem);
|
row = m_engineModel.rootItem()->indexOf(m_currentItem);
|
||||||
|
|
||||||
m_engineChooser->setCurrentIndex(row);
|
m_engineChooser->setCurrentIndex(row);
|
||||||
const int contentWidth = m_engineChooser->fontMetrics().width(m_engineChooser->currentText() + "xx");
|
const int contentWidth =
|
||||||
|
m_engineChooser->fontMetrics().horizontalAdvance(m_engineChooser->currentText() + "xx");
|
||||||
QStyleOptionComboBox option;
|
QStyleOptionComboBox option;
|
||||||
option.initFrom(m_engineChooser);
|
option.initFrom(m_engineChooser);
|
||||||
const QSize sz(contentWidth, 1);
|
const QSize sz(contentWidth, 1);
|
||||||
|
@@ -119,7 +119,7 @@ public:
|
|||||||
painter->setPen(lightColor);
|
painter->setPen(lightColor);
|
||||||
// FIXME: performance? this changes only on real font changes.
|
// FIXME: performance? this changes only on real font changes.
|
||||||
QFontMetrics fm(option.font);
|
QFontMetrics fm(option.font);
|
||||||
int charWidth = qMax(fm.width('x'), fm.width('0'));
|
int charWidth = qMax(fm.horizontalAdvance('x'), fm.horizontalAdvance('0'));
|
||||||
QString str = index.data(Qt::DisplayRole).toString();
|
QString str = index.data(Qt::DisplayRole).toString();
|
||||||
int x = option.rect.x();
|
int x = option.rect.x();
|
||||||
bool light = !paintRed;
|
bool light = !paintRed;
|
||||||
|
@@ -401,7 +401,7 @@ void SideDiffEditorWidget::paintSeparator(QPainter &painter,
|
|||||||
painter.setPen(foreground);
|
painter.setPen(foreground);
|
||||||
|
|
||||||
const QString replacementText = " {" + foldReplacementText(block) + "}; ";
|
const QString replacementText = " {" + foldReplacementText(block) + "}; ";
|
||||||
const int replacementTextWidth = fontMetrics().width(replacementText) + 24;
|
const int replacementTextWidth = fontMetrics().horizontalAdvance(replacementText) + 24;
|
||||||
int x = replacementTextWidth + int(offset.x());
|
int x = replacementTextWidth + int(offset.x());
|
||||||
if (x < document()->documentMargin()
|
if (x < document()->documentMargin()
|
||||||
|| !TextDocumentLayout::isFolded(block)) {
|
|| !TextDocumentLayout::isFolded(block)) {
|
||||||
|
@@ -2686,7 +2686,7 @@ void FakeVimHandler::Private::ensureCursorVisible()
|
|||||||
|
|
||||||
void FakeVimHandler::Private::updateEditor()
|
void FakeVimHandler::Private::updateEditor()
|
||||||
{
|
{
|
||||||
const int charWidth = QFontMetrics(EDITOR(font())).width(' ');
|
const int charWidth = QFontMetrics(EDITOR(font())).horizontalAdvance(' ');
|
||||||
EDITOR(setTabStopWidth(charWidth * config(ConfigTabStop).toInt()));
|
EDITOR(setTabStopWidth(charWidth * config(ConfigTabStop).toInt()));
|
||||||
setupCharClass();
|
setupCharClass();
|
||||||
}
|
}
|
||||||
@@ -2695,7 +2695,7 @@ void FakeVimHandler::Private::restoreWidget(int tabSize)
|
|||||||
{
|
{
|
||||||
//EDITOR(removeEventFilter(q));
|
//EDITOR(removeEventFilter(q));
|
||||||
//EDITOR(setReadOnly(m_wasReadOnly));
|
//EDITOR(setReadOnly(m_wasReadOnly));
|
||||||
const int charWidth = QFontMetrics(EDITOR(font())).width(' ');
|
const int charWidth = QFontMetrics(EDITOR(font())).horizontalAdvance(' ');
|
||||||
EDITOR(setTabStopWidth(charWidth * tabSize));
|
EDITOR(setTabStopWidth(charWidth * tabSize));
|
||||||
g.visualMode = NoVisualMode;
|
g.visualMode = NoVisualMode;
|
||||||
// Force "ordinary" cursor.
|
// Force "ordinary" cursor.
|
||||||
|
@@ -296,7 +296,7 @@ void ProjectListWidget::addProject(Project *project)
|
|||||||
setCurrentItem(item);
|
setCurrentItem(item);
|
||||||
|
|
||||||
QFontMetrics fn(font());
|
QFontMetrics fn(font());
|
||||||
int width = fn.width(displayName) + padding();
|
int width = fn.horizontalAdvance(displayName) + padding();
|
||||||
if (width > optimalWidth())
|
if (width > optimalWidth())
|
||||||
setOptimalWidth(width);
|
setOptimalWidth(width);
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ void ProjectListWidget::removeProject(Project *project)
|
|||||||
// recheck optimal width
|
// recheck optimal width
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for (int i = 0; i < count(); ++i)
|
for (int i = 0; i < count(); ++i)
|
||||||
width = qMax(fn.width(item(i)->text()) + padding(), width);
|
width = qMax(fn.horizontalAdvance(item(i)->text()) + padding(), width);
|
||||||
setOptimalWidth(width);
|
setOptimalWidth(width);
|
||||||
|
|
||||||
m_ignoreIndexChange = false;
|
m_ignoreIndexChange = false;
|
||||||
@@ -375,7 +375,7 @@ void ProjectListWidget::projectDisplayNameChanged(Project *project)
|
|||||||
QFontMetrics fn(font());
|
QFontMetrics fn(font());
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for (int i = 0; i < count(); ++i)
|
for (int i = 0; i < count(); ++i)
|
||||||
width = qMax(fn.width(item(i)->text()) + padding(), width);
|
width = qMax(fn.horizontalAdvance(item(i)->text()) + padding(), width);
|
||||||
setOptimalWidth(width);
|
setOptimalWidth(width);
|
||||||
|
|
||||||
m_ignoreIndexChange = false;
|
m_ignoreIndexChange = false;
|
||||||
@@ -422,7 +422,7 @@ void GenericListWidget::setProjectConfigurations(const QList<ProjectConfiguratio
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
foreach (ProjectConfiguration *pc, list) {
|
foreach (ProjectConfiguration *pc, list) {
|
||||||
addProjectConfiguration(pc);
|
addProjectConfiguration(pc);
|
||||||
width = qMax(width, fn.width(pc->displayName()) + padding());
|
width = qMax(width, fn.horizontalAdvance(pc->displayName()) + padding());
|
||||||
}
|
}
|
||||||
setOptimalWidth(width);
|
setOptimalWidth(width);
|
||||||
setActiveProjectConfiguration(active);
|
setActiveProjectConfiguration(active);
|
||||||
@@ -461,7 +461,7 @@ void GenericListWidget::addProjectConfiguration(ProjectConfiguration *pc)
|
|||||||
connect(pc, &ProjectConfiguration::toolTipChanged, this, &GenericListWidget::toolTipChanged);
|
connect(pc, &ProjectConfiguration::toolTipChanged, this, &GenericListWidget::toolTipChanged);
|
||||||
|
|
||||||
QFontMetrics fn(font());
|
QFontMetrics fn(font());
|
||||||
int width = fn.width(pc->displayName()) + padding();
|
int width = fn.horizontalAdvance(pc->displayName()) + padding();
|
||||||
if (width > optimalWidth())
|
if (width > optimalWidth())
|
||||||
setOptimalWidth(width);
|
setOptimalWidth(width);
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ void GenericListWidget::removeProjectConfiguration(ProjectConfiguration *pc)
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i) {
|
||||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||||
width = qMax(width, fn.width(p->displayName()) + padding());
|
width = qMax(width, fn.horizontalAdvance(p->displayName()) + padding());
|
||||||
}
|
}
|
||||||
setOptimalWidth(width);
|
setOptimalWidth(width);
|
||||||
|
|
||||||
@@ -532,7 +532,7 @@ void GenericListWidget::displayNameChanged()
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i) {
|
||||||
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
auto *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
||||||
width = qMax(width, fn.width(p->displayName()) + padding());
|
width = qMax(width, fn.horizontalAdvance(p->displayName()) + padding());
|
||||||
}
|
}
|
||||||
setOptimalWidth(width);
|
setOptimalWidth(width);
|
||||||
|
|
||||||
|
@@ -340,7 +340,7 @@ public:
|
|||||||
};
|
};
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
const QString &action = actions.at(i);
|
const QString &action = actions.at(i);
|
||||||
const int ww = fm.width(action);
|
const int ww = fm.horizontalAdvance(action);
|
||||||
const QRect actionRect(xx, yy - 10, ww, 15);
|
const QRect actionRect(xx, yy - 10, ww, 15);
|
||||||
const bool isForcedDisabled = (i != 0 && sessionName == "default");
|
const bool isForcedDisabled = (i != 0 && sessionName == "default");
|
||||||
const bool isActive = actionRect.contains(mousePos) && !isForcedDisabled;
|
const bool isActive = actionRect.contains(mousePos) && !isForcedDisabled;
|
||||||
@@ -475,7 +475,8 @@ public:
|
|||||||
QString projectName = idx.data(Qt::DisplayRole).toString();
|
QString projectName = idx.data(Qt::DisplayRole).toString();
|
||||||
QString projectPath = idx.data(ProjectModel::FilePathRole).toString();
|
QString projectPath = idx.data(ProjectModel::FilePathRole).toString();
|
||||||
QFontMetrics fm(sizedFont(13, option.widget));
|
QFontMetrics fm(sizedFont(13, option.widget));
|
||||||
int width = std::max(fm.width(projectName), fm.width(projectPath)) + 36;
|
int width = std::max(fm.horizontalAdvance(projectName),
|
||||||
|
fm.horizontalAdvance(projectPath)) + 36;
|
||||||
return QSize(width, 48);
|
return QSize(width, 48);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -294,7 +294,7 @@ int TaskModel::sizeOfFile(const QFont &font)
|
|||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
filename = filename.mid(pos +1);
|
filename = filename.mid(pos +1);
|
||||||
|
|
||||||
m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename));
|
m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.horizontalAdvance(filename));
|
||||||
}
|
}
|
||||||
m_lastMaxSizeIndex = count - 1;
|
m_lastMaxSizeIndex = count - 1;
|
||||||
return m_maxSizeOfFileName;
|
return m_maxSizeOfFileName;
|
||||||
@@ -305,7 +305,7 @@ int TaskModel::sizeOfLineNumber(const QFont &font)
|
|||||||
if (m_sizeOfLineNumber == 0 || font != m_lineMeasurementFont) {
|
if (m_sizeOfLineNumber == 0 || font != m_lineMeasurementFont) {
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
m_lineMeasurementFont = font;
|
m_lineMeasurementFont = font;
|
||||||
m_sizeOfLineNumber = fm.width(QLatin1String("88888"));
|
m_sizeOfLineNumber = fm.horizontalAdvance(QLatin1String("88888"));
|
||||||
}
|
}
|
||||||
return m_sizeOfLineNumber;
|
return m_sizeOfLineNumber;
|
||||||
}
|
}
|
||||||
|
@@ -786,7 +786,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
QString bottom = index.data(TaskModel::Description).toString().split(QLatin1Char('\n')).first();
|
QString bottom = index.data(TaskModel::Description).toString().split(QLatin1Char('\n')).first();
|
||||||
painter->setClipRect(positions.textArea());
|
painter->setClipRect(positions.textArea());
|
||||||
painter->drawText(positions.textAreaLeft(), positions.top() + fm.ascent(), bottom);
|
painter->drawText(positions.textAreaLeft(), positions.top() + fm.ascent(), bottom);
|
||||||
if (fm.width(bottom) > positions.textAreaWidth()) {
|
if (fm.horizontalAdvance(bottom) > positions.textAreaWidth()) {
|
||||||
// draw a gradient to mask the text
|
// draw a gradient to mask the text
|
||||||
int gradientStart = positions.textAreaRight() - ELLIPSIS_GRADIENT_WIDTH + 1;
|
int gradientStart = positions.textAreaRight() - ELLIPSIS_GRADIENT_WIDTH + 1;
|
||||||
QLinearGradient lg(gradientStart, 0, gradientStart + ELLIPSIS_GRADIENT_WIDTH, 0);
|
QLinearGradient lg(gradientStart, 0, gradientStart + ELLIPSIS_GRADIENT_WIDTH, 0);
|
||||||
@@ -840,7 +840,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
const int pos = file.lastIndexOf(QLatin1Char('/'));
|
const int pos = file.lastIndexOf(QLatin1Char('/'));
|
||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
file = file.mid(pos +1);
|
file = file.mid(pos +1);
|
||||||
const int realFileWidth = fm.width(file);
|
const int realFileWidth = fm.horizontalAdvance(file);
|
||||||
painter->setClipRect(positions.fileArea());
|
painter->setClipRect(positions.fileArea());
|
||||||
painter->drawText(qMin(positions.fileAreaLeft(), positions.fileAreaRight() - realFileWidth),
|
painter->drawText(qMin(positions.fileAreaLeft(), positions.fileAreaRight() - realFileWidth),
|
||||||
positions.top() + fm.ascent(), file);
|
positions.top() + fm.ascent(), file);
|
||||||
@@ -877,7 +877,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||||||
}
|
}
|
||||||
|
|
||||||
painter->setClipRect(positions.lineArea());
|
painter->setClipRect(positions.lineArea());
|
||||||
const int realLineWidth = fm.width(lineText);
|
const int realLineWidth = fm.horizontalAdvance(lineText);
|
||||||
painter->drawText(positions.lineAreaRight() - realLineWidth, positions.top() + fm.ascent(), lineText);
|
painter->drawText(positions.lineAreaRight() - realLineWidth, positions.top() + fm.ascent(), lineText);
|
||||||
painter->setClipRect(opt.rect);
|
painter->setClipRect(opt.rect);
|
||||||
|
|
||||||
|
@@ -260,7 +260,7 @@ static void paintTextInPlaceHolderForInvisbleItem(QPainter *painter,
|
|||||||
|
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
painter->rotate(90);
|
painter->rotate(90);
|
||||||
if (fm.width(displayText) > (boundingRect.height() - 32) && displayText.length() > 4) {
|
if (fm.horizontalAdvance(displayText) > (boundingRect.height() - 32) && displayText.length() > 4) {
|
||||||
|
|
||||||
displayText = fm.elidedText(displayText, Qt::ElideRight, boundingRect.height() - 32, Qt::TextShowMnemonic);
|
displayText = fm.elidedText(displayText, Qt::ElideRight, boundingRect.height() - 32, Qt::TextShowMnemonic);
|
||||||
}
|
}
|
||||||
|
@@ -137,7 +137,7 @@ static QRect drawText(QPainter *painter,
|
|||||||
|
|
||||||
displayString = styleOption.fontMetrics.elidedText(displayString, Qt::ElideMiddle, styleOption.rect.width() - extraSpace);
|
displayString = styleOption.fontMetrics.elidedText(displayString, Qt::ElideMiddle, styleOption.rect.width() - extraSpace);
|
||||||
displayStringOffset = QPoint(5 + iconOffset, -5);
|
displayStringOffset = QPoint(5 + iconOffset, -5);
|
||||||
width = styleOption.fontMetrics.width(displayString);
|
width = styleOption.fontMetrics.horizontalAdvance(displayString);
|
||||||
|
|
||||||
QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset;
|
QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset;
|
||||||
painter->drawText(textPosition, displayString);
|
painter->drawText(textPosition, displayString);
|
||||||
|
@@ -54,7 +54,7 @@ CanvasStyleDialog::CanvasStyleDialog(const CanvasStyle &style, QWidget *parent)
|
|||||||
m_handleLineWidth->setValue(style.handleLineWidth);
|
m_handleLineWidth->setValue(style.handleLineWidth);
|
||||||
m_curveWidth->setValue(style.curveWidth);
|
m_curveWidth->setValue(style.curveWidth);
|
||||||
|
|
||||||
int labelWidth = QFontMetrics(this->font()).width("Inter Handle ColorXX");
|
int labelWidth = QFontMetrics(this->font()).horizontalAdvance("Inter Handle ColorXX");
|
||||||
auto addControl = [labelWidth](QVBoxLayout *layout, const QString &name, QWidget *control) {
|
auto addControl = [labelWidth](QVBoxLayout *layout, const QString &name, QWidget *control) {
|
||||||
auto *hbox = new QHBoxLayout;
|
auto *hbox = new QHBoxLayout;
|
||||||
|
|
||||||
|
@@ -703,7 +703,7 @@ void TimelineRulerSectionItem::paintTicks(QPainter *painter)
|
|||||||
|
|
||||||
QFontMetrics fm(painter->font());
|
QFontMetrics fm(painter->font());
|
||||||
|
|
||||||
int minSpacingText = fm.width(QString("X%1X").arg(rulerDuration()));
|
int minSpacingText = fm.horizontalAdvance(QString("X%1X").arg(rulerDuration()));
|
||||||
int minSpacingLine = 5;
|
int minSpacingLine = 5;
|
||||||
|
|
||||||
int deltaText = 0;
|
int deltaText = 0;
|
||||||
|
@@ -544,7 +544,7 @@ public:
|
|||||||
int xx = 0;
|
int xx = 0;
|
||||||
int yy = y + tagsBase;
|
int yy = y + tagsBase;
|
||||||
for (const QString &tag : item.tags) {
|
for (const QString &tag : item.tags) {
|
||||||
const int ww = tagsFontMetrics.width(tag) + 5;
|
const int ww = tagsFontMetrics.horizontalAdvance(tag) + 5;
|
||||||
if (xx + ww > w - 30) {
|
if (xx + ww > w - 30) {
|
||||||
yy += 15;
|
yy += 15;
|
||||||
xx = 0;
|
xx = 0;
|
||||||
|
@@ -81,8 +81,9 @@ void RefactorOverlay::paintMarker(const RefactorMarker& marker, QPainter *painte
|
|||||||
icon = m_icon;
|
icon = m_icon;
|
||||||
|
|
||||||
const qreal devicePixelRatio = painter->device()->devicePixelRatio();
|
const qreal devicePixelRatio = painter->device()->devicePixelRatio();
|
||||||
const QSize proposedIconSize = QSize(m_editor->fontMetrics().width(QLatin1Char(' ')) + 3,
|
const QSize proposedIconSize =
|
||||||
cursorRect.height()) * devicePixelRatio;
|
QSize(m_editor->fontMetrics().horizontalAdvance(QLatin1Char(' ')) + 3,
|
||||||
|
cursorRect.height()) * devicePixelRatio;
|
||||||
const QSize actualIconSize = icon.actualSize(proposedIconSize) / devicePixelRatio;
|
const QSize actualIconSize = icon.actualSize(proposedIconSize) / devicePixelRatio;
|
||||||
|
|
||||||
const int y = cursorRect.top() + ((cursorRect.height() - actualIconSize.height()) / 2);
|
const int y = cursorRect.top() + ((cursorRect.height() - actualIconSize.height()) / 2);
|
||||||
|
@@ -3722,7 +3722,7 @@ QTextBlock TextEditorWidgetPrivate::foldedBlockAt(const QPoint &pos, QRect *box)
|
|||||||
|
|
||||||
QRectF collapseRect(lineRect.right() + 12,
|
QRectF collapseRect(lineRect.right() + 12,
|
||||||
lineRect.top(),
|
lineRect.top(),
|
||||||
q->fontMetrics().width(replacement),
|
q->fontMetrics().horizontalAdvance(replacement),
|
||||||
lineRect.height());
|
lineRect.height());
|
||||||
if (collapseRect.contains(pos)) {
|
if (collapseRect.contains(pos)) {
|
||||||
QTextBlock result = block;
|
QTextBlock result = block;
|
||||||
@@ -4213,7 +4213,7 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data,
|
|||||||
|
|
||||||
const qreal itemOffset = q->fontMetrics().lineSpacing();
|
const qreal itemOffset = q->fontMetrics().lineSpacing();
|
||||||
const qreal initialOffset = m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines ? itemOffset / 2 : itemOffset * 2;
|
const qreal initialOffset = m_displaySettings.m_annotationAlignment == AnnotationAlignment::BetweenLines ? itemOffset / 2 : itemOffset * 2;
|
||||||
const qreal minimalContentWidth = q->fontMetrics().width('X')
|
const qreal minimalContentWidth = q->fontMetrics().horizontalAdvance('X')
|
||||||
* m_displaySettings.m_minimalAnnotationContent;
|
* m_displaySettings.m_minimalAnnotationContent;
|
||||||
qreal offset = initialOffset;
|
qreal offset = initialOffset;
|
||||||
qreal x = 0;
|
qreal x = 0;
|
||||||
@@ -4529,7 +4529,7 @@ void TextEditorWidgetPrivate::paintBlockSelection(const PaintEventData &data, QP
|
|||||||
QString text = data.block.text();
|
QString text = data.block.text();
|
||||||
const TabSettings tabSettings = m_document->tabSettings();
|
const TabSettings tabSettings = m_document->tabSettings();
|
||||||
const qreal spacew = QFontMetricsF(q->font()).width(QLatin1Char(' '));
|
const qreal spacew = QFontMetricsF(q->font()).width(QLatin1Char(' '));
|
||||||
const int cursorw = q->overwriteMode() ? QFontMetrics(q->font()).width(QLatin1Char(' '))
|
const int cursorw = q->overwriteMode() ? QFontMetrics(q->font()).horizontalAdvance(QLatin1Char(' '))
|
||||||
: q->cursorWidth();
|
: q->cursorWidth();
|
||||||
|
|
||||||
int startOffset = 0;
|
int startOffset = 0;
|
||||||
@@ -4688,7 +4688,7 @@ void TextEditorWidgetPrivate::paintReplacement(PaintEventData &data, QPainter &p
|
|||||||
|
|
||||||
QRectF collapseRect(lineRect.right() + 12,
|
QRectF collapseRect(lineRect.right() + 12,
|
||||||
lineRect.top(),
|
lineRect.top(),
|
||||||
q->fontMetrics().width(rectReplacement),
|
q->fontMetrics().horizontalAdvance(rectReplacement),
|
||||||
lineRect.height());
|
lineRect.height());
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.translate(.5, .5);
|
painter.translate(.5, .5);
|
||||||
@@ -5084,7 +5084,7 @@ int TextEditorWidget::extraAreaWidth(int *markWidthPtr) const
|
|||||||
fnt.setItalic(currentLineNumberFormat.font().italic());
|
fnt.setItalic(currentLineNumberFormat.font().italic());
|
||||||
const QFontMetrics linefm(fnt);
|
const QFontMetrics linefm(fnt);
|
||||||
|
|
||||||
space += linefm.width(QLatin1Char('9')) * lineNumberDigits();
|
space += linefm.horizontalAdvance(QLatin1Char('9')) * lineNumberDigits();
|
||||||
}
|
}
|
||||||
int markWidth = 0;
|
int markWidth = 0;
|
||||||
|
|
||||||
@@ -6620,7 +6620,7 @@ void TextEditorAnimator::init(const QTextCursor &cursor, const QFont &f, const Q
|
|||||||
m_palette = pal;
|
m_palette = pal;
|
||||||
m_text = cursor.selectedText();
|
m_text = cursor.selectedText();
|
||||||
QFontMetrics fm(m_font);
|
QFontMetrics fm(m_font);
|
||||||
m_size = QSizeF(fm.width(m_text), fm.height());
|
m_size = QSizeF(fm.horizontalAdvance(m_text), fm.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorAnimator::draw(QPainter *p, const QPointF &pos)
|
void TextEditorAnimator::draw(QPainter *p, const QPointF &pos)
|
||||||
@@ -6630,7 +6630,7 @@ void TextEditorAnimator::draw(QPainter *p, const QPointF &pos)
|
|||||||
QFont f = m_font;
|
QFont f = m_font;
|
||||||
f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2));
|
f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2));
|
||||||
QFontMetrics fm(f);
|
QFontMetrics fm(f);
|
||||||
int width = fm.width(m_text);
|
int width = fm.horizontalAdvance(m_text);
|
||||||
QRectF r((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height());
|
QRectF r((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height());
|
||||||
r.translate(pos);
|
r.translate(pos);
|
||||||
p->fillRect(r, m_palette.base());
|
p->fillRect(r, m_palette.base());
|
||||||
@@ -6648,7 +6648,7 @@ QRectF TextEditorAnimator::rect() const
|
|||||||
QFont f = m_font;
|
QFont f = m_font;
|
||||||
f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2));
|
f.setPointSizeF(f.pointSizeF() * (1.0 + m_value/2));
|
||||||
QFontMetrics fm(f);
|
QFontMetrics fm(f);
|
||||||
int width = fm.width(m_text);
|
int width = fm.horizontalAdvance(m_text);
|
||||||
return QRectF((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height());
|
return QRectF((m_size.width()-width)/2, (m_size.height() - fm.height())/2, width, fm.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -182,7 +182,7 @@ TextMark::AnnotationRects TextMark::annotationRects(const QRectF &boundingRect,
|
|||||||
if (drawIcon)
|
if (drawIcon)
|
||||||
rects.iconRect.setWidth(rects.iconRect.height() * m_widthFactor);
|
rects.iconRect.setWidth(rects.iconRect.height() * m_widthFactor);
|
||||||
rects.textRect = QRectF(rects.iconRect.right() + margin, boundingRect.top(),
|
rects.textRect = QRectF(rects.iconRect.right() + margin, boundingRect.top(),
|
||||||
qreal(fm.width(rects.text)), boundingRect.height());
|
qreal(fm.horizontalAdvance(rects.text)), boundingRect.height());
|
||||||
rects.annotationRect.setRight(rects.textRect.right() + margin);
|
rects.annotationRect.setRight(rects.textRect.right() + margin);
|
||||||
if (rects.annotationRect.right() > boundingRect.right()) {
|
if (rects.annotationRect.right() > boundingRect.right()) {
|
||||||
rects.textRect.setRight(boundingRect.right() - margin);
|
rects.textRect.setRight(boundingRect.right() - margin);
|
||||||
|
@@ -154,7 +154,7 @@ QSize CostDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInd
|
|||||||
initStyleOption(&opt, index);
|
initStyleOption(&opt, index);
|
||||||
|
|
||||||
const QString text = d->displayText(index, opt.locale);
|
const QString text = d->displayText(index, opt.locale);
|
||||||
const QSize size = QSize(option.fontMetrics.width(text),
|
const QSize size = QSize(option.fontMetrics.horizontalAdvance(text),
|
||||||
option.fontMetrics.height());
|
option.fontMetrics.height());
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@@ -139,7 +139,7 @@ void FunctionGraphicsTextItem::paint(QPainter *painter,
|
|||||||
painter->save();
|
painter->save();
|
||||||
int textLeft = 0;
|
int textLeft = 0;
|
||||||
int textTop = 0;
|
int textTop = 0;
|
||||||
const int textWidth = painter->fontMetrics().width(m_staticText.text());
|
const int textWidth = painter->fontMetrics().horizontalAdvance(m_staticText.text());
|
||||||
textLeft = -textWidth/2;
|
textLeft = -textWidth/2;
|
||||||
textTop = (maxHeight - textHeight)/2;
|
textTop = (maxHeight - textHeight)/2;
|
||||||
painter->drawStaticText(textLeft, textTop, m_staticText);
|
painter->drawStaticText(textLeft, textTop, m_staticText);
|
||||||
|
Reference in New Issue
Block a user