QMimeType: simplify implementation of filterString
As suggested by Ahmad Samir Change-Id: I7f3ef29436a7725b6dceab72bd0f8b01756bf930 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
071a9c9061
commit
549ed4fb24
@ -437,14 +437,8 @@ QString QMimeType::filterString() const
|
||||
const QStringList patterns = globPatterns();
|
||||
QString filter;
|
||||
|
||||
if (!patterns.empty()) {
|
||||
filter += comment() + " ("_L1;
|
||||
for (int i = 0; i < patterns.size(); ++i) {
|
||||
if (i != 0)
|
||||
filter += u' ';
|
||||
filter += patterns.at(i);
|
||||
}
|
||||
filter += u')';
|
||||
if (!patterns.isEmpty()) {
|
||||
filter = comment() + " ("_L1 + patterns.join(u' ') + u')';
|
||||
}
|
||||
|
||||
return filter;
|
||||
|
@ -782,6 +782,26 @@ void tst_QMimeDatabase::knownSuffix()
|
||||
QCOMPARE(db.suffixForFileName(QString::fromLatin1("foo.anim2")), QString()); // the glob is anim[0-9], no way to extract the extension without expensive regexp capturing
|
||||
}
|
||||
|
||||
void tst_QMimeDatabase::filterString_data()
|
||||
{
|
||||
QTest::addColumn<QString>("mimeType");
|
||||
QTest::addColumn<QString>("expectedFilterString");
|
||||
|
||||
QTest::newRow("single-pattern") << "application/pdf"
|
||||
<< "PDF document (*.pdf)";
|
||||
QTest::newRow("multiple-patterns-text-plain") << "text/plain"
|
||||
<< "plain text document (*.txt *.asc *,v)";
|
||||
}
|
||||
|
||||
void tst_QMimeDatabase::filterString()
|
||||
{
|
||||
QFETCH(QString, mimeType);
|
||||
QFETCH(QString, expectedFilterString);
|
||||
|
||||
QMimeDatabase db;
|
||||
QCOMPARE(db.mimeTypeForName(mimeType).filterString(), expectedFilterString);
|
||||
}
|
||||
|
||||
void tst_QMimeDatabase::symlinkToFifo() // QTBUG-48529
|
||||
{
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)
|
||||
|
@ -45,6 +45,8 @@ private slots:
|
||||
void suffixes_data();
|
||||
void suffixes();
|
||||
void knownSuffix();
|
||||
void filterString_data();
|
||||
void filterString();
|
||||
void symlinkToFifo();
|
||||
void fromThreads();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user