Marble

DeclarativeMapThemeManager.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <[email protected]>
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 
15 MapThemeImageProvider::MapThemeImageProvider() :
17 {
18  // nothing to do
19 }
20 
21 QPixmap 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
Returns a list of all locally available map theme IDs.
UserRole
bool isValid() const const
T value() const const
QStringList mapThemeIds() const
A list of all installed map theme ids, each entry has the form "planet/themeid/themeid....
MapThemeManager(QObject *parent=nullptr)
Constructor.
virtual QVariant data(const QModelIndex &index, int role) const const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) const const
virtual int rowCount(const QModelIndex &parent) const const override
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 04:10:36 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.