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 "GeoSceneDocument.h"
9#include "GeoSceneHead.h"
10
11#include <QIcon>
12#include <QStandardItemModel>
13#include <QDebug>
14
15MapThemeImageProvider::MapThemeImageProvider() :
17{
18 // nothing to do
19}
20
21QPixmap MapThemeImageProvider::requestPixmap( const QString &id, QSize *size, const QSize &requestedSize )
22{
23 QSize const resultSize = requestedSize.isValid() ? requestedSize : QSize( 128, 128 );
24 if ( size ) {
25 *size = resultSize;
26 }
27
28 QStandardItemModel *model = m_mapThemeManager.mapThemeModel();
29 for( int i = 0; i < model->rowCount(); ++i ) {
30 if ( model->data( model->index( i, 0 ), Qt::UserRole + 1 ) == id ) {
31 QIcon icon = model->data( model->index( i, 0 ), Qt::DecorationRole ).value<QIcon>();
32 QPixmap result = icon.pixmap( resultSize );
33 return result;
34 }
35 }
36
37 QPixmap empty( resultSize );
38 empty.fill();
39 return empty;
40}
41
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.
QPixmap pixmap(QWindow *window, const QSize &size, Mode mode, State state) const const
T qobject_cast(QObject *object)
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 Tue Mar 26 2024 11:18:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.