summaryrefslogtreecommitdiffstats
path: root/src/mimetypes/qmimedatabase.h
blob: 47c59eb2bcb3475060d05fe077e235ab1592734f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/****************************************************************************
**
** This file is part of QMime
**
** Based on Qt Creator source code
**
** Qt Creator Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
****************************************************************************/

#ifndef QMIMEDATABASE_H_INCLUDED
#define QMIMEDATABASE_H_INCLUDED

#include "qmime_global.h"

#include "qmimetype.h"

#include <QtCore/QStringList>

// ------------------------------------------------------------------------------------------------

QT_BEGIN_NAMESPACE

class QByteArray;
class QFileInfo;
class QIODevice;
class QUrl;

struct QMimeDatabasePrivate;
class QMIME_EXPORT QMimeDatabase
{
    Q_DISABLE_COPY(QMimeDatabase)

public:
    QMimeDatabase();
    ~QMimeDatabase();

    QMimeType mimeTypeForName(const QString &nameOrAlias) const;

    enum MatchFlags {
        MatchDefault = 0x0,
        MatchExtension = 0x1,
        MatchContent = 0x2
    };

    QMimeType mimeTypeForFile(const QString &fileName, MatchFlags flags = MatchDefault) const;
    QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchFlags flags = MatchDefault) const;
    QList<QMimeType> findMimeTypesByFileName(const QString &fileName) const;

    QMimeType findByData(const QByteArray &data) const;
    QMimeType findByData(QIODevice *device) const;

    QMimeType findByUrl(const QUrl &url) const;
    QMimeType mimeTypeForNameAndData(const QString &fileName, QIODevice *device) const;
    QMimeType mimeTypeForNameAndData(const QString &fileName, const QByteArray &data) const;

    QString suffixForFileName(const QString &fileName) const;

    QList<QMimeType> allMimeTypes() const;

#if 0
    // This must be a huge list, why would anyone ever want this?
    QStringList filterStrings() const;
    QString allFiltersString(QString *allFilesFilter = 0) const;
#endif

    QMimeDatabasePrivate *data_ptr() { return d; }

private:
    QMimeDatabasePrivate *d;
};

QT_END_NAMESPACE

#endif   // QMIMEDATABASE_H_INCLUDED