KFileMetaData

typeinfo.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#include "typeinfo.h"
8
9#include <KLocalizedString>
10
11using namespace KFileMetaData;
12
13class KFileMetaData::TypeInfoPrivate
14{
15public:
16 Type::Type type;
17 QString name;
18 QString displayName;
19};
20
21TypeInfo::TypeInfo(Type::Type type)
22 : d(new TypeInfoPrivate)
23{
24 d->type = type;
25
26 switch (type) {
27 case Type::Empty:
28 d->name = QStringLiteral("empty");
29 d->displayName = QString();
30 break;
31
32 case Type::Archive:
33 d->name = QStringLiteral("Archive");
34 d->displayName = i18nc("@label", "Archive");
35 break;
36
37 case Type::Audio:
38 d->name = QStringLiteral("Audio");
39 d->displayName = i18nc("@label", "Audio");
40 break;
41
42 case Type::Document:
43 d->name = QStringLiteral("Document");
44 d->displayName = i18nc("@label", "Document");
45 break;
46
47 case Type::Image:
48 d->name = QStringLiteral("Image");
49 d->displayName = i18nc("@label", "Image");
50 break;
51
52 case Type::Presentation:
53 d->name = QStringLiteral("Presentation");
54 d->displayName = i18nc("@label", "Presentation");
55 break;
56
57 case Type::Spreadsheet:
58 d->name = QStringLiteral("Spreadsheet");
59 d->displayName = i18nc("@label", "Spreadsheet");
60 break;
61
62 case Type::Text:
63 d->name = QStringLiteral("Text");
64 d->displayName = i18nc("@label", "Text");
65 break;
66
67 case Type::Video:
68 d->name = QStringLiteral("Video");
69 d->displayName = i18nc("@label", "Video");
70 break;
71
72 case Type::Folder:
73 d->name = QStringLiteral("Folder");
74 d->displayName = i18nc("@label", "Folder");
75 break;
76 case Type::Model:
77 d->name = QStringLiteral("Model");
78 d->displayName = i18nc("@label", "Model");
79 break;
80 default:
81 break;
82 }
83}
84
85TypeInfo::TypeInfo(const TypeInfo& ti)
86 : d(new TypeInfoPrivate(*ti.d))
87{
88}
89
90TypeInfo::~TypeInfo() = default;
91
92TypeInfo& TypeInfo::operator=(const TypeInfo& rhs)
93{
94 *d = *rhs.d;
95 return *this;
96}
97
98bool TypeInfo::operator==(const TypeInfo& rhs) const
99{
100 return std::tie(d->type, d->name, d->displayName) == std::tie(rhs.d->type, rhs.d->name, rhs.d->displayName);
101}
102
103QString TypeInfo::displayName() const
104{
105 return d->displayName;
106}
107
108QString TypeInfo::name() const
109{
110 return d->name;
111}
112
113Type::Type TypeInfo::type() const
114{
115 return d->type;
116}
117
118TypeInfo TypeInfo::fromName(const QString& name)
119{
120 for (int t = static_cast<int>(Type::FirstType); t <= static_cast<int>(Type::LastType); t++) {
121 TypeInfo ti(static_cast<Type::Type>(t));
122 if (ti.name().compare(name, Qt::CaseInsensitive) == 0) {
123 return ti;
124 }
125 }
126
127 return TypeInfo(Type::Empty);
128}
QString i18nc(const char *context, const char *text, const TYPE &arg...)
Type type(const QSqlDatabase &db)
CaseInsensitive
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:44:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.