return false;
}
-QString KStandardItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
+QString KStandardItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values, ForUsageAs forUsageAs) const
{
if (role == "rating") {
- // Always use an empty text, as the rating is shown by the image m_rating.
- return QString();
+ if (forUsageAs == ForUsageAs::DisplayedText) {
+ // Always use an empty text, as the rating is shown by the image m_rating.
+ return QString();
+ } else {
+ const int rating{values.value(role).toInt()};
+ // Check if there are half stars
+ if (rating % 2) {
+ return i18ncp("@accessible rating", "%1 and a half stars", "%1 and a half stars", rating / 2);
+ }
+ return i18ncp("@accessible rating", "%1 star", "%1 stars", rating / 2);
+ }
}
return values.value(role).toString();
}
if (current.isEmpty() || !parent || current != "text") {
if (m_roleEditor) {
Q_EMIT roleEditingCanceled(index(), current, data().value(current));
-
- disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled, this, &KStandardItemListWidget::slotRoleEditingCanceled);
- disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished, this, &KStandardItemListWidget::slotRoleEditingFinished);
-
- if (m_oldRoleEditor) {
- m_oldRoleEditor->deleteLater();
- }
- m_oldRoleEditor = m_roleEditor;
- m_roleEditor->hide();
- m_roleEditor = nullptr;
+ closeRoleEditor();
}
return;
}