path: root/src/corelib/mimetypes
diff options
authorDavid Faure <>2012-05-14 19:42:10 +0200
committerQt by Nokia <>2012-05-15 14:25:37 +0200
commitc241d8921ea6384c30a1731a036aec8edc7609ab (patch)
treed8fd21a2f15c66457004ea9151e771cf7865adf2 /src/corelib/mimetypes
parentf3476d3ae2380bb10781371c9e07ebeaea9c9b86 (diff)
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 <>
Diffstat (limited to 'src/corelib/mimetypes')
3 files changed, 19 insertions, 10 deletions
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 2ac1978c2a..75d6cb95ac 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:; // isOpen() will be tested by method below
- return d->mimeTypeForNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
+ return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
case MatchExtension:
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)
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<QByteArray *>(&data));;
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 eff706e1b5..96ddee73c4 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;
+ 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);
+ }
QString suffixForFileName(const QString &fileName) const;
diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h
index 8f2db32513..aec387fe7a 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);