blob: b1c84a779701e399b28a5cf9fe779247a4d5e974 (
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
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MIMETYPEMODEL_H
#define MIMETYPEMODEL_H
#include <QStandardItemModel>
#include <QHash>
QT_FORWARD_DECLARE_CLASS(QMimeType)
class MimetypeModel : public QStandardItemModel
{
Q_OBJECT
public:
enum Columns { NameColumn, ColumnCount };
explicit MimetypeModel(QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role) const override;
QMimeType mimeType(const QModelIndex &) const;
QModelIndex indexForMimeType(const QString &name) const
{ return m_nameIndexHash.value(name); }
static QString formatMimeTypeInfo(const QMimeType &);
private:
typedef QHash<QString, QModelIndex> NameIndexHash;
void populate();
NameIndexHash m_nameIndexHash;
};
#endif // MIMETYPEMODEL_H
|