Commit 017db930 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it compiles without deprecated method

parent 195095bf
......@@ -50,10 +50,12 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
KIO Plasma PlasmaQuick Service TextEditor WidgetsAddons DocTools)
#########################################################################
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
endif()
add_definitions(
-DQT_DEPRECATED_WARNINGS
-DQT_DISABLE_DEPRECATED_BEFORE=0x050900
-DQT_USE_QSTRINGBUILDER
-DQT_NO_CAST_TO_ASCII
# -DQT_NO_CAST_FROM_ASCII
......
......@@ -588,7 +588,7 @@ void KTreeViewSearchLineWidget::createWidgets()
QHBoxLayout* layout = new QHBoxLayout( this );
layout->setSpacing( 5 );
layout->setMargin( 0 );
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( label );
layout->addWidget( d->searchLine );
}
......
......@@ -53,13 +53,13 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
int maxWidth = 0;
foreach (int role, index.model()->roleNames().keys()) {
const QString text = index.model()->roleNames().value(role) + QLatin1String(": ");
maxWidth = qMax(maxWidth, fm.width(text));
maxWidth = qMax(maxWidth, fm.boundingRect(text).width());
}
int i = 2;
foreach (int role, index.model()->roleNames().keys()) {
const QString text = index.model()->roleNames().value(role) + QLatin1String(": ");
painter->drawText(option.rect.x() + maxWidth - fm.width(text), option.rect.y() + i*fm.height(), text);
painter->drawText(option.rect.x() + maxWidth - fm.boundingRect(text).width(), option.rect.y() + i*fm.height(), text);
if (index.data(role).canConvert<QIcon>()) {
index.data(role).value<QIcon>().paint(painter, option.rect.x() + maxWidth, option.rect.y() + (i-1)*fm.height(), 16, 16);
......@@ -81,7 +81,7 @@ QSize Delegate::sizeHint(const QStyleOptionViewItem &option,
}
QFontMetrics fm(option.font);
return QSize(fm.width("M") * 50, fm.height() * (index.model()->roleNames().count()+2));
return QSize(fm.boundingRect("M").width() * 50, fm.height() * (index.model()->roleNames().count()+2));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment