Warning, file /office/calligra/libs/pigment/KoHistogramProducer.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be> 0003 * 0004 * This library is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU Lesser General Public License as published by 0006 * the Free Software Foundation; either version 2.1 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "KoHistogramProducer.h" 0020 0021 #include <QList> 0022 #include <QGlobalStatic> 0023 0024 #include <KoID.h> 0025 0026 #include "KoBasicHistogramProducers.h" 0027 0028 #include "KoColorSpace.h" 0029 0030 Q_GLOBAL_STATIC(KoHistogramProducerFactoryRegistry, s_instance) 0031 0032 KoHistogramProducerFactoryRegistry::KoHistogramProducerFactoryRegistry() 0033 { 0034 } 0035 0036 KoHistogramProducerFactoryRegistry::~KoHistogramProducerFactoryRegistry() 0037 { 0038 qDeleteAll(values()); 0039 } 0040 0041 KoHistogramProducerFactoryRegistry* KoHistogramProducerFactoryRegistry::instance() 0042 { 0043 return s_instance; 0044 0045 } 0046 0047 QList<QString> KoHistogramProducerFactoryRegistry::keysCompatibleWith(const KoColorSpace* colorSpace) const 0048 { 0049 QList<QString> list; 0050 QList<float> preferredList; 0051 foreach(const QString &id, keys()) { 0052 KoHistogramProducerFactory *f = value(id); 0053 if (f->isCompatibleWith(colorSpace)) { 0054 float preferred = f->preferrednessLevelWith(colorSpace); 0055 QList<float>::iterator pit = preferredList.begin(); 0056 QList<float>::iterator pend = preferredList.end(); 0057 QList<QString>::iterator lit = list.begin(); 0058 0059 while (pit != pend && preferred <= *pit) { 0060 ++pit; 0061 ++lit; 0062 } 0063 0064 list.insert(lit, id); 0065 preferredList.insert(pit, preferred); 0066 } 0067 } 0068 return list; 0069 }