QErrorMessage: replace a QPair with a struct

Instead of the incomprehensible "names" .first and .second, the code
can now use .content and .type.

Change-Id: I7fe320ded33a07fb8ff77ac96c17fc5ee1079da3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Marc Mutz 2017-02-22 11:24:15 +01:00
parent 494ee2aa8d
commit 9fbe3a9262

View File

@ -62,6 +62,13 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace {
struct Message {
QString content;
QString type;
};
}
class QErrorMessagePrivate : public QDialogPrivate class QErrorMessagePrivate : public QDialogPrivate
{ {
Q_DECLARE_PUBLIC(QErrorMessage) Q_DECLARE_PUBLIC(QErrorMessage)
@ -70,7 +77,7 @@ public:
QCheckBox * again; QCheckBox * again;
QTextEdit * errors; QTextEdit * errors;
QLabel * icon; QLabel * icon;
std::queue<QPair<QString, QString> > pending; std::queue<Message> pending;
QSet<QString> doNotShow; QSet<QString> doNotShow;
QSet<QString> doNotShowType; QSet<QString> doNotShowType;
QString currentMessage; QString currentMessage;
@ -303,9 +310,8 @@ bool QErrorMessagePrivate::isMessageToBeShown(const QString &message, const QStr
bool QErrorMessagePrivate::nextPending() bool QErrorMessagePrivate::nextPending()
{ {
while (!pending.empty()) { while (!pending.empty()) {
QPair<QString,QString> &pendingMessage = pending.front(); QString message = std::move(pending.front().content);
QString message = qMove(pendingMessage.first); QString type = std::move(pending.front().type);
QString type = qMove(pendingMessage.second);
pending.pop(); pending.pop();
if (isMessageToBeShown(message, type)) { if (isMessageToBeShown(message, type)) {
#ifndef QT_NO_TEXTHTMLPARSER #ifndef QT_NO_TEXTHTMLPARSER
@ -355,7 +361,7 @@ void QErrorMessage::showMessage(const QString &message, const QString &type)
Q_D(QErrorMessage); Q_D(QErrorMessage);
if (!d->isMessageToBeShown(message, type)) if (!d->isMessageToBeShown(message, type))
return; return;
d->pending.push(qMakePair(message, type)); d->pending.push({message, type});
if (!isVisible() && d->nextPending()) if (!isVisible() && d->nextPending())
show(); show();
} }