ItemModels: replace QLatin1String with QStringLiteral

... wherever it allocates memory.

Since the string literal is used in more than one function, to
avoid duplication of .rodata, wrap the QStringLiteral in an
inline function.

Change-Id: If4fca7443b3150b1c8360c850da32f5c567c1065
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Anton Kudryavtsev 2016-02-26 12:01:36 +03:00
parent 26961e32f3
commit 13bcdc0f50
2 changed files with 9 additions and 4 deletions

View File

@ -1845,7 +1845,7 @@ bool QAbstractItemModel::setItemData(const QModelIndex &index, const QMap<int, Q
QStringList QAbstractItemModel::mimeTypes() const
{
QStringList types;
types << QLatin1String("application/x-qabstractitemmodeldatalist");
types << QStringLiteral("application/x-qabstractitemmodeldatalist");
return types;
}

View File

@ -57,6 +57,11 @@
QT_BEGIN_NAMESPACE
static inline QString qStandardItemModelDataListMimeType()
{
return QStringLiteral("application/x-qstandarditemmodeldatalist");
}
class QStandardItemModelLessThan
{
public:
@ -2977,7 +2982,7 @@ void QStandardItemModel::sort(int column, Qt::SortOrder order)
*/
QStringList QStandardItemModel::mimeTypes() const
{
return QAbstractItemModel::mimeTypes() << QLatin1String("application/x-qstandarditemmodeldatalist");
return QAbstractItemModel::mimeTypes() << qStandardItemModelDataListMimeType();
}
/*!
@ -2989,7 +2994,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
if(!data)
return 0;
QString format = QLatin1String("application/x-qstandarditemmodeldatalist");
const QString format = qStandardItemModelDataListMimeType();
if (!mimeTypes().contains(format))
return data;
QByteArray encoded;
@ -3084,7 +3089,7 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction))
return false;
// check if the format is supported
QString format = QLatin1String("application/x-qstandarditemmodeldatalist");
const QString format = qStandardItemModelDataListMimeType();
if (!data->hasFormat(format))
return QAbstractItemModel::dropMimeData(data, action, row, column, parent);