8#include "resourcelocatorurl.h"
10#include "parametermap_p.h"
15using namespace KContacts;
24 Private(
const Private &other)
27 mParamMap = other.mParamMap;
31 ParameterMap mParamMap;
35ResourceLocatorUrl::ResourceLocatorUrl()
45ResourceLocatorUrl::~ResourceLocatorUrl()
54static const url_type_name url_type_names[] = {
66 const auto it = d->mParamMap.findParam(
QLatin1String(
"type"));
67 if (it == d->mParamMap.cend()) {
72 for (
const QString &s : it->paramValues) {
73 const auto typeIt = std::find_if(std::begin(url_type_names), std::end(url_type_names), [&s](
const url_type_name &t) {
76 if (typeIt != std::end(url_type_names)) {
77 type |= (*typeIt).type;
85 const auto oldType = this->type();
87 const QString paramName(QStringLiteral(
"type"));
89 auto it = d->mParamMap.findParam(paramName);
90 if (it == d->mParamMap.end()) {
94 for (
const auto &t : url_type_names) {
95 if (((type ^ oldType) & t.type) == 0) {
101 it->paramValues.push_back(str);
103 it->paramValues.removeAll(str);
108bool ResourceLocatorUrl::isPreferred()
const
111 if (it != d->mParamMap.cend()) {
112 return !it->paramValues.isEmpty() && it->paramValues.at(0) ==
QLatin1Char(
'1');
116 if (it != d->mParamMap.cend()) {
125 if (preferred == isPreferred()) {
129 const QString paramName(QStringLiteral(
"type"));
131 auto it = d->mParamMap.findParam(paramName);
137 if (prefIt != d->mParamMap.end()) {
138 d->mParamMap.erase(prefIt);
147 it = d->mParamMap.findParam(paramName);
148 if (it != d->mParamMap.end()) {
149 it->paramValues = types;
157 return (d->mParamMap == other.d->mParamMap) && (d->url == other.url());
162 return !(other == *
this);
167 if (
this != &other) {
174QString ResourceLocatorUrl::toString()
const
177 str += QStringLiteral(
" url: %1\n").
arg(d->url.toString());
178 str += d->mParamMap.toString();
183void ResourceLocatorUrl::setParams(
const ParameterMap ¶ms)
185 d->mParamMap = params;
188ParameterMap ResourceLocatorUrl::params()
const
193bool ResourceLocatorUrl::isValid()
const
195 return d->url.isValid();
198void ResourceLocatorUrl::setUrl(
const QUrl &url)
203QUrl ResourceLocatorUrl::url()
const
210 return s << calUrl.d->mParamMap << calUrl.d->url;
215 s >> calUrl.d->mParamMap >> calUrl.d->url;
219#include "moc_resourcelocatorurl.cpp"
QString name(GameStandardAction id)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
void push_back(parameter_type value)
qsizetype removeAll(const AT &t)
QString arg(Args &&... args) const const