KTextAddons

translator.cpp
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6#include "translator.h"
7
8Translator::Translator() = default;
9
10Translator::~Translator() = default;
11
12void Translator::parse(const QJsonObject &obj, bool remote)
13{
14 mUrl = obj[QLatin1String("url")].toString();
15 mModelName = obj[QLatin1String("modelName")].toString();
16 mShortName = obj[QLatin1String("shortName")].toString();
17 mCheckSum = obj[QLatin1String("checksum")].toString();
18 mRepository = obj[QLatin1String("repository")].toString();
19 mType = obj[QLatin1String("type")].toString();
20 mSource = obj[QLatin1String("src")].toString();
21 mTarget = obj[QLatin1String("trg")].toString();
22 mVersion = obj[QLatin1String("version")].toInt(-1);
23 mApi = obj[QLatin1String("API")].toInt(-1);
24 mRemote = remote;
25}
26
27QString Translator::shortName() const
28{
29 return mShortName;
30}
31
32bool Translator::operator==(const Translator &other) const
33{
34 return mShortName == other.mShortName && mModelName == other.mModelName && mSource == other.mSource && mTarget == other.mTarget
35 && mCheckSum == other.mCheckSum && mRepository == other.mRepository && mUrl == other.mUrl && mType == other.mType && mVersion == other.mVersion
36 && mApi == other.mApi && mRemote == other.mRemote;
37}
38
39bool Translator::remote() const
40{
41 return mRemote;
42}
43
44void Translator::setRemote(bool newRemote)
45{
46 mRemote = newRemote;
47}
48
49void Translator::setShortName(const QString &newShortName)
50{
51 mShortName = newShortName;
52}
53
54QString Translator::modelName() const
55{
56 return mModelName;
57}
58
59void Translator::setModelName(const QString &newModelName)
60{
61 mModelName = newModelName;
62}
63
64QString Translator::source() const
65{
66 return mSource;
67}
68
69void Translator::setSource(const QString &newSource)
70{
71 mSource = newSource;
72}
73
74QString Translator::checkSum() const
75{
76 return mCheckSum;
77}
78
79void Translator::setCheckSum(const QString &newCheckSum)
80{
81 mCheckSum = newCheckSum;
82}
83
84QString Translator::target() const
85{
86 return mTarget;
87}
88
89void Translator::setTarget(const QString &newTarget)
90{
91 mTarget = newTarget;
92}
93
94int Translator::version() const
95{
96 return mVersion;
97}
98
99void Translator::setVersion(int newVersion)
100{
101 mVersion = newVersion;
102}
103
104int Translator::api() const
105{
106 return mApi;
107}
108
109void Translator::setApi(int newApi)
110{
111 mApi = newApi;
112}
113
114QString Translator::url() const
115{
116 return mUrl;
117}
118
119void Translator::setUrl(const QString &newUrl)
120{
121 mUrl = newUrl;
122}
123
124QString Translator::repository() const
125{
126 return mRepository;
127}
128
129void Translator::setRepository(const QString &newRepository)
130{
131 mRepository = newRepository;
132}
133
134QString Translator::type() const
135{
136 return mType;
137}
138
139void Translator::setType(const QString &newType)
140{
141 mType = newType;
142}
143
144bool Translator::isValid() const
145{
146 if (mRemote) {
147 return !mUrl.isEmpty() && !mTarget.isEmpty() && !mSource.isEmpty();
148 } else {
149 return !mTarget.isEmpty() && !mSource.isEmpty();
150 }
151}
152
153QDebug operator<<(QDebug d, const Translator &t)
154{
155 d << "mShortName " << t.shortName();
156 d << "mModelName " << t.modelName();
157 d << "mSource " << t.source();
158 d << "mTarget " << t.target();
159 d << "mCheckSum " << t.checkSum();
160 d << "mRepository " << t.repository();
161 d << "mUrl " << t.url();
162 d << "mType " << t.type();
163 d << "mVersion " << t.version();
164 d << "mApi " << t.api();
165 d << "mRemote " << t.remote();
166 return d;
167}
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.