QErrorMessage: avoid some code duplication
...by using the predicate from nextPending() in the two showMessage() functions, too, which thus become identical, when substituting type -> QString(). Also saves around 250B in text size. Change-Id: Ibf5d081dbec3438b7b1be4e240879e26d0455d6b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
parent
3cb7a1b957
commit
bb7b20b446
@ -75,6 +75,7 @@ public:
|
|||||||
QString currentMessage;
|
QString currentMessage;
|
||||||
QString currentType;
|
QString currentType;
|
||||||
|
|
||||||
|
bool isMessageToBeShown(const QString &message, const QString &type) const;
|
||||||
bool nextPending();
|
bool nextPending();
|
||||||
void retranslateStrings();
|
void retranslateStrings();
|
||||||
};
|
};
|
||||||
@ -304,6 +305,12 @@ QErrorMessage * QErrorMessage::qtHandler()
|
|||||||
|
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
|
|
||||||
|
bool QErrorMessagePrivate::isMessageToBeShown(const QString &message, const QString &type) const
|
||||||
|
{
|
||||||
|
return !message.isEmpty()
|
||||||
|
&& (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type));
|
||||||
|
}
|
||||||
|
|
||||||
bool QErrorMessagePrivate::nextPending()
|
bool QErrorMessagePrivate::nextPending()
|
||||||
{
|
{
|
||||||
while (!pending.empty()) {
|
while (!pending.empty()) {
|
||||||
@ -311,7 +318,7 @@ bool QErrorMessagePrivate::nextPending()
|
|||||||
QString message = qMove(pendingMessage.first);
|
QString message = qMove(pendingMessage.first);
|
||||||
QString type = qMove(pendingMessage.second);
|
QString type = qMove(pendingMessage.second);
|
||||||
pending.pop();
|
pending.pop();
|
||||||
if (!message.isEmpty() && ((type.isEmpty() && !doNotShow.contains(message)) || (!type.isEmpty() && !doNotShowType.contains(type)))) {
|
if (isMessageToBeShown(message, type)) {
|
||||||
#ifndef QT_NO_TEXTHTMLPARSER
|
#ifndef QT_NO_TEXTHTMLPARSER
|
||||||
errors->setHtml(message);
|
errors->setHtml(message);
|
||||||
#else
|
#else
|
||||||
@ -337,12 +344,7 @@ bool QErrorMessagePrivate::nextPending()
|
|||||||
|
|
||||||
void QErrorMessage::showMessage(const QString &message)
|
void QErrorMessage::showMessage(const QString &message)
|
||||||
{
|
{
|
||||||
Q_D(QErrorMessage);
|
showMessage(message, QString());
|
||||||
if (d->doNotShow.contains(message))
|
|
||||||
return;
|
|
||||||
d->pending.push(qMakePair(message,QString()));
|
|
||||||
if (!isVisible() && d->nextPending())
|
|
||||||
show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -362,9 +364,9 @@ void QErrorMessage::showMessage(const QString &message)
|
|||||||
void QErrorMessage::showMessage(const QString &message, const QString &type)
|
void QErrorMessage::showMessage(const QString &message, const QString &type)
|
||||||
{
|
{
|
||||||
Q_D(QErrorMessage);
|
Q_D(QErrorMessage);
|
||||||
if (d->doNotShow.contains(message) && d->doNotShowType.contains(type))
|
if (!d->isMessageToBeShown(message, type))
|
||||||
return;
|
return;
|
||||||
d->pending.push(qMakePair(message,type));
|
d->pending.push(qMakePair(message, type));
|
||||||
if (!isVisible() && d->nextPending())
|
if (!isVisible() && d->nextPending())
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user