File indexing completed on 2024-05-05 03:49:16
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #include "DeclarativeMapThemeManager.h" 0007 0008 #include "GeoSceneDocument.h" 0009 #include "GeoSceneHead.h" 0010 0011 #include <QIcon> 0012 #include <QStandardItemModel> 0013 #include <QDebug> 0014 0015 MapThemeImageProvider::MapThemeImageProvider() : 0016 QQuickImageProvider( QQuickImageProvider::Pixmap ) 0017 { 0018 // nothing to do 0019 } 0020 0021 QPixmap MapThemeImageProvider::requestPixmap( const QString &id, QSize *size, const QSize &requestedSize ) 0022 { 0023 QSize const resultSize = requestedSize.isValid() ? requestedSize : QSize( 128, 128 ); 0024 if ( size ) { 0025 *size = resultSize; 0026 } 0027 0028 QStandardItemModel *model = m_mapThemeManager.mapThemeModel(); 0029 for( int i = 0; i < model->rowCount(); ++i ) { 0030 if ( model->data( model->index( i, 0 ), Qt::UserRole + 1 ) == id ) { 0031 QIcon icon = model->data( model->index( i, 0 ), Qt::DecorationRole ).value<QIcon>(); 0032 QPixmap result = icon.pixmap( resultSize ); 0033 return result; 0034 } 0035 } 0036 0037 QPixmap empty( resultSize ); 0038 empty.fill(); 0039 return empty; 0040 } 0041 0042 MapThemeManager::MapThemeManager( QObject *parent ) : QObject( parent ) 0043 { 0044 // nothing to do 0045 } 0046 0047 QStringList MapThemeManager::mapThemeIds() const 0048 { 0049 return m_mapThemeManager.mapThemeIds(); 0050 } 0051 0052 #include "moc_DeclarativeMapThemeManager.cpp"