Commit 0fba02c2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port deprecated method

parent 399d76b7
......@@ -66,7 +66,7 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX EVENTVIEWS
add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
#add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
########### CMake Config Files ###########
......
......@@ -1240,7 +1240,7 @@ void AgendaView::createDayLabels(bool force)
QString veryLongStr = QLocale::system().toString(date, QLocale::LongFormat);
QString longstr = i18nc("short_weekday short_monthname date (e.g. Mon Aug 13)", "%1 %2 %3",
QLocale::system().dayName(dW, QLocale::ShortFormat),
QDate::shortMonthName(date.month()),
QLocale::system().monthName(date.month(), QLocale::ShortFormat),
date.day());
QString shortstr = QString::number(date.day());
......@@ -1468,12 +1468,12 @@ void AgendaView::updateTimeBarWidth()
int width = d->mTimeLabelsZone->preferedTimeLabelsWidth();
for (QLabel *l : qAsConst(d->mTimeBarHeaders)) {
foreach (const QString &word, l->text().split(QLatin1Char(' '))) {
width = qMax(width, fm.width(word));
width = qMax(width, fm.boundingRect(word).width());
}
}
setFont(oldFont);
width = width + fm.width(QLatin1Char('/'));
width = width + fm.boundingRect(QLatin1Char('/')).width();
const int timeBarWidth = width * d->mTimeBarHeaders.count();
......
......@@ -38,7 +38,7 @@ AlternateLabel::AlternateLabel(const QString &shortlabel, const QString &longlab
const QFontMetrics &fm = fontMetrics();
// We use at least averageCharWidth * 2 here to avoid misalignment
// for single char labels.
setMinimumWidth(qMax(fm.averageCharWidth() * 2, fm.width(shortlabel)) + getIndent());
setMinimumWidth(qMax(fm.averageCharWidth() * 2, fm.boundingRect(shortlabel).width()) + getIndent());
squeezeTextToLabel();
}
......@@ -82,8 +82,8 @@ void AlternateLabel::squeezeTextToLabel()
QFontMetrics fm(fontMetrics());
int labelWidth = size().width() - getIndent();
int textWidth = fm.width(mLongText);
int longTextWidth = fm.width(mExtensiveText);
int textWidth = fm.boundingRect(mLongText).width();
int longTextWidth = fm.boundingRect(mExtensiveText).width();
if (longTextWidth <= labelWidth) {
QLabel::setText(mExtensiveText);
this->setToolTip(QString());
......@@ -105,8 +105,8 @@ AlternateLabel::TextType AlternateLabel::largestFittingTextType() const
{
QFontMetrics fm(fontMetrics());
const int labelWidth = size().width() - getIndent();
const int longTextWidth = fm.width(mLongText);
const int extensiveTextWidth = fm.width(mExtensiveText);
const int longTextWidth = fm.boundingRect(mLongText).width();
const int extensiveTextWidth = fm.boundingRect(mExtensiveText).width();
if (extensiveTextWidth <= labelWidth) {
return Extensive;
} else if (longTextWidth <= labelWidth) {
......@@ -133,5 +133,5 @@ void AlternateLabel::setFixedType(TextType type)
int AlternateLabel::getIndent() const
{
return indent() == -1 ? fontMetrics().width(QStringLiteral("x")) / 2 : indent();
return indent() == -1 ? fontMetrics().boundingRect(QStringLiteral("x")).width() / 2 : indent();
}
......@@ -155,8 +155,8 @@ void DecorationLabel::squeezeContentsToLabel()
QFontMetrics fm(fontMetrics());
int labelWidth = size().width();
int longTextWidth = fm.width(mLongText);
int extensiveTextWidth = fm.width(mExtensiveText);
int longTextWidth = fm.boundingRect(mLongText).width();
int extensiveTextWidth = fm.boundingRect(mExtensiveText).width();
if (!mPixmap.isNull()) {
usePixmap(true);
......
......@@ -128,7 +128,7 @@ void TimeLabels::updateConfig()
if (use12Clock()) {
test = QStringLiteral("12");
}
mMiniWidth = fontMetrics().width(test);
mMiniWidth = fontMetrics().boundingRect(test).width();
if (use12Clock()) {
test = QStringLiteral("pm");
} else {
......@@ -137,7 +137,7 @@ void TimeLabels::updateConfig()
QFont sFont = font();
sFont.setPointSize(sFont.pointSize() / 2);
QFontMetrics fmS(sFont);
mMiniWidth += fmS.width(test) + frameWidth() * 2 + 4;
mMiniWidth += fmS.boundingRect(test).width() + frameWidth() * 2 + 4;
/** Can happen if all resources are disabled */
if (!mAgenda) {
......@@ -301,7 +301,7 @@ void TimeLabels::paintEvent(QPaintEvent *)
suffixFont.setPointSize(suffixFont.pointSize() / 2);
QFontMetrics fmS(suffixFont);
const int startW = cw - frameWidth() - 2;
const int tw2 = fmS.width(suffix);
const int tw2 = fmS.boundingRect(suffix).width();
const int divTimeHeight = (timeHeight - 1) / 2 - 1;
//testline
//p->drawLine(0,0,0,contentsHeight());
......@@ -324,7 +324,7 @@ void TimeLabels::paintEvent(QPaintEvent *)
// draw the time label
p.setPen(textColor);
const int timeWidth = fm.width(hour);
const int timeWidth = fm.boundingRect(hour).width();
int offset = startW - timeWidth - tw2 - 1;
p.setFont(hourFont);
p.drawText(offset, static_cast<int>(y + timeHeight), hour);
......
......@@ -817,5 +817,5 @@ void MultiAgendaView::Private::ElidedLabel::paintEvent(QPaintEvent *event)
QSize MultiAgendaView::Private::ElidedLabel::minimumSizeHint() const
{
const QFontMetrics &fm = fontMetrics();
return QSize(fm.width(QStringLiteral("...")), fm.height());
return QSize(fm.boundingRect(QStringLiteral("...")).width(), fm.height());
}
......@@ -88,8 +88,8 @@ TodoViewQuickSearch::TodoViewQuickSearch(const Akonadi::ETMCalendar::Ptr &calend
// Calculate a nice size for "Select Categories"
const int newPreferedWidth = currentPreferedWidth
-fm.width(QLatin1Char('x')) * 17
+fm.width(defaultText);
-fm.boundingRect(QLatin1Char('x')).width() * 17
+fm.boundingRect(defaultText).width();
const int pixelsToAdd = newPreferedWidth - mCategoryCombo->lineEdit()->width();
mCategoryCombo->setMinimumWidth(mCategoryCombo->width() + pixelsToAdd);
......
......@@ -117,7 +117,7 @@ QModelIndex TodoViewView::moveCursor(CursorAction cursorAction, Qt::KeyboardModi
// just below it if so
current = current.sibling(current.row(), 0);
if (isExpanded(current)) {
tmp = getNextEditableIndex(current.child(0, 0), 1);
tmp = getNextEditableIndex(model()->index(0, 0, current), 1);
if (tmp.isValid()) {
return tmp;
}
......@@ -153,7 +153,7 @@ QModelIndex TodoViewView::moveCursor(CursorAction cursorAction, Qt::KeyboardModi
// search on top of the item, also include expanded items
tmp = current.sibling(current.row() - 1, 0);
while (tmp.isValid() && isExpanded(tmp)) {
tmp = tmp.child(model()->rowCount(tmp) - 1, 0);
tmp = model()->index(model()->rowCount(tmp) - 1, 0, tmp);
}
if (tmp.isValid()) {
tmp = getNextEditableIndex(tmp.sibling(tmp.row(), lastCol), -1);
......
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