Warning, file /frameworks/kquickcharts/src/datasource/MapProxySource.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "MapProxySource.h" 0008 0009 MapProxySource::MapProxySource(QObject *parent) 0010 : ChartDataSource(parent) 0011 { 0012 connect(this, &MapProxySource::sourceChanged, this, &ChartDataSource::dataChanged); 0013 connect(this, &MapProxySource::mapChanged, this, &ChartDataSource::dataChanged); 0014 } 0015 0016 int MapProxySource::itemCount() const 0017 { 0018 if (m_source) { 0019 return m_source->itemCount(); 0020 } 0021 0022 return 0; 0023 } 0024 0025 QVariant MapProxySource::minimum() const 0026 { 0027 auto itr = std::min_element(m_map.cbegin(), m_map.cend(), variantCompare); 0028 if (itr != m_map.cend()) { 0029 return *itr; 0030 } 0031 return QVariant{}; 0032 } 0033 0034 QVariant MapProxySource::maximum() const 0035 { 0036 auto itr = std::max_element(m_map.cbegin(), m_map.cend(), variantCompare); 0037 if (itr != m_map.cend()) { 0038 return *itr; 0039 } 0040 return QVariant{}; 0041 } 0042 0043 QVariant MapProxySource::item(int index) const 0044 { 0045 if (!m_source) { 0046 return QVariant{}; 0047 } 0048 0049 auto mapIndex = m_source->item(index).toString(); 0050 if (mapIndex.isEmpty()) { 0051 return QVariant{}; 0052 } 0053 0054 return m_map.value(mapIndex); 0055 } 0056 0057 ChartDataSource *MapProxySource::source() const 0058 { 0059 return m_source; 0060 } 0061 0062 void MapProxySource::setSource(ChartDataSource *newSource) 0063 { 0064 if (newSource == m_source) { 0065 return; 0066 } 0067 0068 if (m_source) { 0069 m_source->disconnect(this); 0070 } 0071 0072 m_source = newSource; 0073 if (m_source) { 0074 connect(m_source, &ChartDataSource::dataChanged, this, &ChartDataSource::dataChanged); 0075 } 0076 Q_EMIT sourceChanged(); 0077 } 0078 0079 QVariantMap MapProxySource::map() const 0080 { 0081 return m_map; 0082 } 0083 0084 void MapProxySource::setMap(const QVariantMap &newMap) 0085 { 0086 if (newMap == m_map) { 0087 return; 0088 } 0089 0090 m_map = newMap; 0091 0092 Q_EMIT mapChanged(); 0093 } 0094 0095 #include "moc_MapProxySource.cpp"