From: David Faure Date: Mon, 14 May 2012 17:42:10 +0000 (+0200) Subject: Rename QMimeDatabase method for consistency. X-Git-Tag: 071012110112~1012 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c241d8921ea6384c30a1731a036aec8edc7609ab;p=profile%2Fivi%2Fqtbase.git Rename QMimeDatabase method for consistency. Name is about mimetype names, while FileName is about, well, file names. Task-number: QTBUG-25748 Change-Id: I34a9ac1a5fc06dc3e3855365e19c4dc7a1aa2671 Reviewed-by: Wolf-Michael Bolle --- diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 2ac1978..75d6cb9 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -165,7 +165,7 @@ QMimeType QMimeDatabasePrivate::findByData(const QByteArray &data, int *accuracy return mimeTypeForName(defaultMimeType()); } -QMimeType QMimeDatabasePrivate::mimeTypeForNameAndData(const QString &fileName, QIODevice *device, int *accuracyPtr) +QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *accuracyPtr) { // First, glob patterns are evaluated. If there is a match with max weight, // this one is selected and we are done. Otherwise, the file contents are @@ -385,7 +385,7 @@ QMimeType QMimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mo switch (mode) { case MatchDefault: file.open(QIODevice::ReadOnly); // isOpen() will be tested by method below - return d->mimeTypeForNameAndData(fileInfo.absoluteFilePath(), &file, &priority); + return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority); case MatchExtension: locker.unlock(); return mimeTypeForFile(fileInfo.absoluteFilePath(), mode); @@ -437,7 +437,7 @@ QMimeType QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode This function does not try to open the file. To also use the content when determining the MIME type, use mimeTypeForFile() or - mimeTypeForNameAndData() instead. + mimeTypeForFileNameAndData() instead. \sa mimeTypeForFile */ @@ -551,13 +551,13 @@ QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const but the contents will be used if the file extension is unknown, or matches multiple MIME types. */ -QMimeType QMimeDatabase::mimeTypeForNameAndData(const QString &fileName, QIODevice *device) const +QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const { DBG() << "fileName" << fileName; int accuracy = 0; const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly); - const QMimeType result = d->mimeTypeForNameAndData(fileName, device, &accuracy); + const QMimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy); if (openedByUs) device->close(); return result; @@ -579,14 +579,14 @@ QMimeType QMimeDatabase::mimeTypeForNameAndData(const QString &fileName, QIODevi but the contents will be used if the file extension is unknown, or matches multiple MIME types. */ -QMimeType QMimeDatabase::mimeTypeForNameAndData(const QString &fileName, const QByteArray &data) const +QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, const QByteArray &data) const { DBG() << "fileName" << fileName; QBuffer buffer(const_cast(&data)); buffer.open(QIODevice::ReadOnly); int accuracy = 0; - return d->mimeTypeForNameAndData(fileName, &buffer, &accuracy); + return d->mimeTypeForFileNameAndData(fileName, &buffer, &accuracy); } /*! diff --git a/src/corelib/mimetypes/qmimedatabase.h b/src/corelib/mimetypes/qmimedatabase.h index eff706e..96ddee7 100644 --- a/src/corelib/mimetypes/qmimedatabase.h +++ b/src/corelib/mimetypes/qmimedatabase.h @@ -77,8 +77,17 @@ public: QMimeType mimeTypeForData(QIODevice *device) const; QMimeType mimeTypeForUrl(const QUrl &url) const; - QMimeType mimeTypeForNameAndData(const QString &fileName, QIODevice *device) const; - QMimeType mimeTypeForNameAndData(const QString &fileName, const QByteArray &data) const; + QMimeType mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const; + QMimeType mimeTypeForFileNameAndData(const QString &fileName, const QByteArray &data) const; + +#if QT_DEPRECATED_SINCE(5,0) + QT_DEPRECATED QMimeType mimeTypeForNameAndData(const QString &fileName, QIODevice *device) const { + return mimeTypeForFileNameAndData(fileName, device); + } + QT_DEPRECATED QMimeType mimeTypeForNameAndData(const QString &fileName, const QByteArray &data) const { + return mimeTypeForFileNameAndData(fileName, data); + } +#endif QString suffixForFileName(const QString &fileName) const; diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h index 8f2db32..aec387f 100644 --- a/src/corelib/mimetypes/qmimedatabase_p.h +++ b/src/corelib/mimetypes/qmimedatabase_p.h @@ -75,7 +75,7 @@ public: QMimeType mimeTypeForName(const QString &nameOrAlias); - QMimeType mimeTypeForNameAndData(const QString &fileName, QIODevice *device, int *priorityPtr); + QMimeType mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device, int *priorityPtr); QMimeType findByData(const QByteArray &data, int *priorityPtr); QStringList mimeTypeForFileName(const QString &fileName, QString *foundSuffix = 0); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index ecea1a9..e6def6e 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -486,14 +486,14 @@ void tst_QMimeDatabase::mimeTypeForFileAndContent() QFETCH(QString, expectedMimeTypeName); QMimeDatabase db; - QCOMPARE(db.mimeTypeForNameAndData(name, data).name(), expectedMimeTypeName); + QCOMPARE(db.mimeTypeForFileNameAndData(name, data).name(), expectedMimeTypeName); QBuffer buffer(&data); - QCOMPARE(db.mimeTypeForNameAndData(name, &buffer).name(), expectedMimeTypeName); + QCOMPARE(db.mimeTypeForFileNameAndData(name, &buffer).name(), expectedMimeTypeName); QVERIFY(!buffer.isOpen()); // initial state was restored QVERIFY(buffer.open(QIODevice::ReadOnly)); - QCOMPARE(db.mimeTypeForNameAndData(name, &buffer).name(), expectedMimeTypeName); + QCOMPARE(db.mimeTypeForFileNameAndData(name, &buffer).name(), expectedMimeTypeName); QVERIFY(buffer.isOpen()); QCOMPARE(buffer.pos(), qint64(0)); }