Krita Source Code Documentation
Loading...
Searching...
No Matches
KisTagModelProvider.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Agata Cacko <cacko.azh@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
7
8#include <QMap>
9#include <QString>
10#include <memory>
11
13
15
16 std::map<QString, std::unique_ptr<KisTagModel>> tagModelsMap;
17 std::unique_ptr<KisTagResourceModel> tagResourceModel;
18
19};
20
25
26
31
32KisTagModel *KisTagModelProvider::tagModel(const QString& resourceType)
33{
34 std::map<QString, std::unique_ptr<KisTagModel> >::const_iterator found = s_instance->d->tagModelsMap.find(resourceType);
35
36 if (found == s_instance->d->tagModelsMap.end()) {
37 std::unique_ptr<KisTagModel> modelStorage(new KisTagModel(resourceType));
38 KisTagModel *model = modelStorage.get();
39 s_instance->d->tagModelsMap.insert(std::make_pair(resourceType, std::move(modelStorage)));
40 return model;
41 }
42 return found->second.get();
43}
44
46{
47 return s_instance->d->tagResourceModel.get();
48}
Q_GLOBAL_STATIC(KisStoragePluginRegistry, s_instance)
static KisTagModel * tagModel(const QString &resourceType)
static KisTagResourceModel * tagResourceModel(const QString &resourceType)
Private *const d
The KisTagResourceModel class makes it possible to retrieve the resources for certain tags or the tag...
std::map< QString, std::unique_ptr< KisTagModel > > tagModelsMap
std::unique_ptr< KisTagResourceModel > tagResourceModel