remove obsolete QAbstractItemDelegate::elidedText() method

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-06 10:08:39 +03:00
parent fc51b22ea2
commit caee5d2ff5
2 changed files with 28 additions and 45 deletions

View file

@ -209,7 +209,7 @@ QWidget *QAbstractItemDelegate::createEditor(QWidget *,
const QStyleOptionViewItem &, const QStyleOptionViewItem &,
const QModelIndex &) const const QModelIndex &) const
{ {
return 0; return nullptr;
} }
/*! /*!
@ -283,26 +283,6 @@ bool QAbstractItemDelegate::editorEvent(QEvent *,
return false; return false;
} }
/*!
\obsolete
Use QFontMetrics::elidedText() instead.
\oldcode
QFontMetrics fm = ...
QString str = QAbstractItemDelegate::elidedText(fm, width, mode, text);
\newcode
QFontMetrics fm = ...
QString str = fm.elidedText(text, mode, width);
\endcode
*/
QString QAbstractItemDelegate::elidedText(const QFontMetrics &fontMetrics, int width,
Qt::TextElideMode mode, const QString &text)
{
return fontMetrics.elidedText(text, mode, width);
}
/*! /*!
\since 4.3 \since 4.3
Whenever a help event occurs, this function is called with the \a event Whenever a help event occurs, this function is called with the \a event
@ -326,8 +306,9 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
{ {
Q_UNUSED(option); Q_UNUSED(option);
if (!event || !view) if (!event || !view) {
return false; return false;
}
switch (event->type()) { switch (event->type()) {
#ifndef QT_NO_TOOLTIP #ifndef QT_NO_TOOLTIP
case QEvent::ToolTip: { case QEvent::ToolTip: {
@ -337,13 +318,16 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
QToolTip::showText(he->globalPos(), tooltip.toString(), view); QToolTip::showText(he->globalPos(), tooltip.toString(), view);
return true; return true;
} }
break;} break;
}
#endif #endif
#ifndef QT_NO_WHATSTHIS #ifndef QT_NO_WHATSTHIS
case QEvent::QueryWhatsThis: { case QEvent::QueryWhatsThis: {
if (index.data(Qt::WhatsThisRole).isValid()) if (index.data(Qt::WhatsThisRole).isValid()) {
return true; return true;
break; } }
break;
}
case QEvent::WhatsThis: { case QEvent::WhatsThis: {
QHelpEvent *he = static_cast<QHelpEvent*>(event); QHelpEvent *he = static_cast<QHelpEvent*>(event);
QVariant whatsthis = index.data(Qt::WhatsThisRole); QVariant whatsthis = index.data(Qt::WhatsThisRole);
@ -351,11 +335,13 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
QWhatsThis::showText(he->globalPos(), whatsthis.toString(), view); QWhatsThis::showText(he->globalPos(), whatsthis.toString(), view);
return true; return true;
} }
break ; }
#endif
default:
break; break;
} }
#endif
default: {
break;
}
}
return false; return false;
} }

View file

@ -82,9 +82,6 @@ public:
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
const QModelIndex &index); const QModelIndex &index);
static QString elidedText(const QFontMetrics &fontMetrics, int width,
Qt::TextElideMode mode, const QString &text);
public Q_SLOTS: public Q_SLOTS:
bool helpEvent(QHelpEvent *event, bool helpEvent(QHelpEvent *event,
QAbstractItemView *view, QAbstractItemView *view,