Marble

DeclarativeMapThemeManager.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#include "DeclarativeMapThemeManager.h"
7
8#include "GeoSceneHead.h"
9
10#include <QDebug>
11#include <QIcon>
12#include <QStandardItemModel>
13
14MapThemeImageProvider::MapThemeImageProvider()
16{
17 // nothing to do
18}
19
20QPixmap MapThemeImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
21{
22 QSize const resultSize = requestedSize.isValid() ? requestedSize : QSize(128, 128);
23 if (size) {
24 *size = resultSize;
25 }
26
27 QStandardItemModel *model = m_mapThemeManager.mapThemeModel();
28 for (int i = 0; i < model->rowCount(); ++i) {
29 if (model->data(model->index(i, 0), Qt::UserRole + 1) == id) {
30 auto icon = model->data(model->index(i, 0), Qt::DecorationRole).value<QIcon>();
31 QPixmap result = icon.pixmap(resultSize);
32 return result;
33 }
34 }
35
36 QPixmap empty(resultSize);
37 empty.fill();
38 return empty;
39}
40
42 : QObject(parent)
43{
44 // nothing to do
45}
46
48{
49 return m_mapThemeManager.mapThemeIds();
50}
51
52#include "moc_DeclarativeMapThemeManager.cpp"
QStringList mapThemeIds() const
A list of all installed map theme ids, each entry has the form "planet/themeid/themeid....
MapThemeManager(QObject *parent=nullptr)
Constructor.
QStandardItemModel * mapThemeModel()
Provides a model of the locally existing themes.
QStringList mapThemeIds() const
Returns a list of all locally available map theme IDs.
bool isValid() const const
virtual QVariant data(const QModelIndex &index, int role) const const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
virtual int rowCount(const QModelIndex &parent) const const override
UserRole
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.