mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-13 10:32:11 +01:00
[LocationCompleter] Fixes performance when drawing really long urls.
data: urls can get really long (> 1000000 characters), so don't save them in history from now on.
This commit is contained in:
parent
36e73949c2
commit
76849082e4
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -68,7 +68,10 @@ void History::addHistoryEntry(const QUrl &url, QString title)
|
||||||
if (!m_isSaving) {
|
if (!m_isSaving) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (url.scheme() == QLatin1String("qupzilla") || url.scheme() == QLatin1String("about") || url.isEmpty()) {
|
if (url.scheme() == QLatin1String("qupzilla") ||
|
||||||
|
url.scheme() == QLatin1String("about") ||
|
||||||
|
url.scheme() == QLatin1String("data") ||
|
||||||
|
url.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (title.isEmpty()) {
|
if (title.isEmpty()) {
|
||||||
|
|
|
@ -108,7 +108,11 @@ void LocationCompleterDelegate::paint(QPainter* painter, const QStyleOptionViewI
|
||||||
// Draw link
|
// Draw link
|
||||||
const int infoYPos = titleRect.bottom() + opt.fontMetrics.leading() + 2;
|
const int infoYPos = titleRect.bottom() + opt.fontMetrics.leading() + 2;
|
||||||
QRect linkRect(titleRect.x(), infoYPos, titleRect.width(), opt.fontMetrics.height());
|
QRect linkRect(titleRect.x(), infoYPos, titleRect.width(), opt.fontMetrics.height());
|
||||||
QString link(opt.fontMetrics.elidedText(index.data(Qt::DisplayRole).toString(), Qt::ElideRight, linkRect.width()));
|
// Let's assume that more than 500 characters won't fit in line on any display...
|
||||||
|
// Fixes performance when trying to get elidedText for a really long
|
||||||
|
// (length() > 1000000) urls - data: urls can get that long
|
||||||
|
const QString &linkUrl = index.data(Qt::DisplayRole).toString().left(500);
|
||||||
|
QString link(opt.fontMetrics.elidedText(linkUrl, Qt::ElideRight, linkRect.width()));
|
||||||
painter->setFont(opt.font);
|
painter->setFont(opt.font);
|
||||||
TabPosition pos = index.data(LocationCompleterModel::TabPositionRole).value<TabPosition>();
|
TabPosition pos = index.data(LocationCompleterModel::TabPositionRole).value<TabPosition>();
|
||||||
if (m_drawSwitchToTab && pos.windowIndex != -1) {
|
if (m_drawSwitchToTab && pos.windowIndex != -1) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user