QString cleanup

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2018-02-13 01:31:12 +00:00
parent 07180913bf
commit c67561d60c
9 changed files with 25 additions and 43 deletions

View file

@ -296,8 +296,6 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
hashHaystack -= (a) << sl_minus_1; \
hashHaystack <<= 1
const QString::Null QString::null = { };
/*!
\macro QT_NO_CAST_FROM_ASCII
\relates QString

View file

@ -90,6 +90,7 @@ public:
inline int count() const { return d->size; }
inline int length() const;
inline bool isEmpty() const;
inline bool isNull() const;
void resize(int size);
QString &fill(QChar c, int size = -1);
@ -475,14 +476,6 @@ public:
inline QStdWString toStdWString() const;
#endif // QT_NO_STL_WCHAR
// compatibility
struct Null { };
static const Null null;
inline QString(const Null &): d(&shared_null) { d->ref.ref(); }
inline QString &operator=(const Null &) { *this = QString(); return *this; }
inline bool isNull() const { return d == &shared_null; }
bool isSimpleText() const;
bool isRightToLeft() const;
@ -594,6 +587,8 @@ inline const QChar QString::operator[](uint i) const
{ Q_ASSERT(i < uint(size())); return d->data[i]; }
inline bool QString::isEmpty() const
{ return d->size == 0; }
inline bool QString::isNull() const
{ return d == &shared_null; }
inline const QChar *QString::unicode() const
{ return reinterpret_cast<const QChar*>(d->data); }
inline const QChar *QString::data() const
@ -770,14 +765,6 @@ inline QString::const_iterator QString::end() const
inline QString::const_iterator QString::constEnd() const
{ return reinterpret_cast<const QChar*>(d->data + d->size); }
inline bool operator==(QString::Null, QString::Null) { return true; }
inline bool operator==(QString::Null, const QString &s) { return s.isNull(); }
inline bool operator==(const QString &s, QString::Null) { return s.isNull(); }
inline bool operator!=(QString::Null, QString::Null) { return false; }
inline bool operator!=(QString::Null, const QString &s) { return !s.isNull(); }
inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); }
#ifndef QT_NO_CAST_FROM_ASCII
inline bool qStringComparisonHelper(const QString &s1, const char *s2)
{

View file

@ -51,9 +51,6 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QRegExp;
typedef QListIterator<QString> QStringListIterator;
typedef QMutableListIterator<QString> QMutableStringListIterator;

View file

@ -129,7 +129,7 @@ QDesignerMetaEnumInterface::~QDesignerMetaEnumInterface()
/*!
\fn QString QDesignerMetaEnumInterface::valueToKey(int value) const
Returns the string that is used as the name of the given enumeration \a value, or QString::null if value is not defined.
Returns the string that is used as the name of the given enumeration \a value, or null QString if value is not defined.
*/
/*!

View file

@ -1803,7 +1803,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar()
topLevelWindow->removeEventFilter(q);
if (baseWidget && !drawTitleBarWhenMaximized())
topLevelWindow->setWindowModified(false);
originalTitle = QString::null;
originalTitle = QString();
}
#endif // QT_NO_MENUBAR
@ -2658,7 +2658,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event)
#ifndef QT_NO_MENUBAR
} else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar()
->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) {
d->originalTitle = QString::null;
d->originalTitle = QString();
if (d->baseWidget && d->baseWidget->windowTitle() == windowTitle())
d->updateWindowTitle(true);
else

View file

@ -617,7 +617,7 @@ QString QAccessibleDisplay::imageDescription()
#ifndef QT_NO_TOOLTIP
return widget()->toolTip();
#else
return QString::null;
return QString();
#endif
}

View file

@ -354,46 +354,46 @@ void QScriptSyntaxHighlighter::highlightBlock(const QString &text)
makeLastStandard = false;
if (input != InputAlpha) {
highlightWord(i, buffer);
buffer = QString::null;
buffer = QString();
}
} break;
case StateCommentStart1:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = true;
buffer = QString::null;
buffer = QString();
break;
case StateCCommentStart2:
setFormat(i - 1, 2, m_formats[ScriptCommentFormat]);
makeLastStandard = false;
// parentheses.push_back(Parenthesis(Parenthesis::Opened, QLatin1Char('/'), i-1));
buffer = QString::null;
buffer = QString();
break;
case StateScriptCommentStart2:
setFormat(i - 1, 2, m_formats[ScriptCommentFormat]);
makeLastStandard = false;
buffer = QString::null;
buffer = QString();
break;
case StateCComment:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptCommentFormat]);
buffer = QString::null;
buffer = QString();
break;
case StateScriptComment:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptCommentFormat]);
buffer = QString::null;
buffer = QString();
break;
case StateCCommentEnd1:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptCommentFormat]);
buffer = QString::null;
buffer = QString();
break;
case StateCCommentEnd2:
if (makeLastStandard)
@ -401,63 +401,63 @@ void QScriptSyntaxHighlighter::highlightBlock(const QString &text)
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptCommentFormat]);
// parentheses.push_back(Parenthesis(Parenthesis::Closed, QLatin1Char('/'), i));
buffer = QString::null;
buffer = QString();
break;
case StateStringStart:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, emptyFormat);
buffer = QString::null;
buffer = QString();
break;
case StateString:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptStringFormat]);
buffer = QString::null;
buffer = QString();
break;
case StateStringEnd:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, emptyFormat);
buffer = QString::null;
buffer = QString();
break;
case StateString2Start:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, emptyFormat);
buffer = QString::null;
buffer = QString();
break;
case StateString2:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptStringFormat]);
buffer = QString::null;
buffer = QString();
break;
case StateString2End:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, emptyFormat);
buffer = QString::null;
buffer = QString();
break;
case StateNumber:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptNumberFormat]);
buffer = QString::null;
buffer = QString();
break;
case StatePreProcessor:
if (makeLastStandard)
setFormat(i - 1, 1, emptyFormat);
makeLastStandard = false;
setFormat(i, 1, m_formats[ScriptPreprocessorFormat]);
buffer = QString::null;
buffer = QString();
break;
}

View file

@ -293,7 +293,7 @@ void tst_QLocale::ctor()
TEST_CTOR("zz...", C, AnyCountry)
TEST_CTOR("", C, AnyCountry)
TEST_CTOR("en/", C, AnyCountry)
TEST_CTOR(QString::null, C, AnyCountry)
TEST_CTOR(QString(), C, AnyCountry)
TEST_CTOR("en", English, UnitedStates)
TEST_CTOR("en", English, UnitedStates)
TEST_CTOR("en.", English, UnitedStates)

View file

@ -1617,7 +1617,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093()
CHECK_DATABASE(db);
// select a record with NULL value
QSqlQuery q(QString::null, db);
QSqlQuery q(QString(), db);
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__) + " where id = 4"));
QVERIFY_SQL(q, next());