RabbitCommon v2.3.3
Loading...
Searching...
No Matches
mimetypemodel.h
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#ifndef MIMETYPEMODEL_H
5#define MIMETYPEMODEL_H
6
7#include <QCoreApplication>
8#include <QHash>
9#include <QMimeType>
10#include <QStandardItemModel>
11
12class MimetypeModel : public QStandardItemModel
13{
14 Q_DECLARE_TR_FUNCTIONS(MimetypeModel)
15public:
16 enum Columns { NameColumn, ColumnCount };
17
18 explicit MimetypeModel(QObject *parent = nullptr);
19
20 QVariant data(const QModelIndex &index, int role) const override;
21
22 QMimeType mimeType(const QModelIndex &) const;
23
24 QModelIndex indexForMimeType(const QString &name) const
25 { return m_nameIndexHash.value(name); }
26
27 static QString formatMimeTypeInfo(const QMimeType &);
28
29private:
30 typedef QHash<QString, QModelIndex> NameIndexHash;
31
32 void populate();
33
34 NameIndexHash m_nameIndexHash;
35};
36
37#endif // MIMETYPEMODEL_H