20#include "moc_qgscptcityarchive.cpp"
29#include <QApplication>
35#include <QDomDocument>
37#include <QRegularExpression>
48 return *sArchiveRegistry();
52 : mArchiveName( archiveName )
59 const auto constEntryList = QDir( mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
60 for (
const QString &path : constEntryList )
62 if ( path == QLatin1String(
"selections" ) )
67 mRootItems << dirItem;
74 const QDir seldir( mBaseDir +
'/' +
"selections" );
76 const QStringList fileList = seldir.entryList( QStringList() << QStringLiteral(
"*.xml" ), QDir::Files );
77 for (
const QString &selfile : fileList )
81 seldir.dirName() +
'/' + selfile );
84 mSelectionItems << selItem;
93 mRootItems.prepend( allRampsItem );
96 mSelectionItems.prepend( allRampsItem );
101 const auto constMRootItems = mRootItems;
104 const auto constMSelectionItems = mSelectionItems;
108 mSelectionItems.clear();
115 if ( ! mBaseDir.isNull() )
127 return archive->baseDir();
138 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
151 if ( startDir.isEmpty() || ! startDir.startsWith(
baseDir ) )
154 QDir dir = QDir( startDir );
156 while ( ! dir.exists( target ) && dir.path() !=
baseDir )
161 if ( ! dir.exists( target ) )
164 return dir.path() +
'/' + target;
184 if ( fileName.isNull() )
187 if ( sCopyingInfoMap()->contains( fileName ) )
189 QgsDebugMsgLevel(
"found copying info in copyingInfoMap, file = " + fileName, 2 );
190 return sCopyingInfoMap()->value( fileName );
197 if ( !f.open( QFile::ReadOnly ) )
204 QDomDocument doc( QStringLiteral(
"license" ) );
205 if ( !doc.setContent( &f ) )
214 const QDomElement docElem = doc.documentElement();
215 if ( docElem.tagName() != QLatin1String(
"copying" ) )
222 const QDomElement authorsElement = docElem.firstChildElement( QStringLiteral(
"authors" ) );
223 if ( authorsElement.isNull() )
229 QDomElement e = authorsElement.firstChildElement();
231 while ( ! e.isNull() )
233 if ( e.tagName() == QLatin1String(
"author" ) )
235 if ( ! e.firstChildElement( QStringLiteral(
"name" ) ).isNull() )
236 authors << e.firstChildElement( QStringLiteral(
"name" ) ).text().simplified();
239 e = e.nextSiblingElement();
241 copyingMap[ QStringLiteral(
"authors" )] = authors.join( QLatin1String(
", " ) );
245 const QDomElement licenseElement = docElem.firstChildElement( QStringLiteral(
"license" ) );
246 if ( licenseElement.isNull() )
252 QDomElement e = licenseElement.firstChildElement( QStringLiteral(
"informal" ) );
254 copyingMap[ QStringLiteral(
"license/informal" )] = e.text().simplified();
255 e = licenseElement.firstChildElement( QStringLiteral(
"year" ) );
257 copyingMap[ QStringLiteral(
"license/year" )] = e.text().simplified();
258 e = licenseElement.firstChildElement( QStringLiteral(
"text" ) );
259 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
260 copyingMap[ QStringLiteral(
"license/url" )] = e.attribute( QStringLiteral(
"href" ) );
264 const QDomElement element = docElem.firstChildElement( QStringLiteral(
"src" ) );
265 if ( element.isNull() )
271 const QDomElement e = element.firstChildElement( QStringLiteral(
"link" ) );
272 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
273 copyingMap[ QStringLiteral(
"src/link" )] = e.attribute( QStringLiteral(
"href" ) );
277 ( *sCopyingInfoMap() )[ fileName ] = copyingMap;
288 if ( ! f.open( QFile::ReadOnly ) )
290 QgsDebugMsgLevel(
"description file " + fileName +
" ] does not exist", 2 );
296 QDomDocument doc( QStringLiteral(
"description" ) );
297 if ( !doc.setContent( &f, &errMsg ) )
300 QgsDebugError(
"Couldn't parse file " + fileName +
" : " + errMsg );
306 const QDomElement docElem = doc.documentElement();
307 if ( docElem.tagName() != QLatin1String(
"description" ) )
314 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
319 descMap[ QStringLiteral(
"name" )] = e.text().simplified();
320 e = docElem.firstChildElement( QStringLiteral(
"full" ) );
325 descMap[ QStringLiteral(
"full" )] = e.text().simplified();
332 QMap< double, QPair<QColor, QColor> > colorMap;
336 if ( !f.open( QFile::ReadOnly ) )
343 QDomDocument doc( QStringLiteral(
"gradient" ) );
344 if ( !doc.setContent( &f ) )
352 const QDomElement docElem = doc.documentElement();
354 if ( docElem.tagName() != QLatin1String(
"svg" ) )
361 QDomElement rampsElement = docElem.firstChildElement( QStringLiteral(
"linearGradient" ) );
362 if ( rampsElement.isNull() )
364 const QDomNodeList nodeList = docElem.elementsByTagName( QStringLiteral(
"linearGradient" ) );
365 if ( ! nodeList.isEmpty() )
366 rampsElement = nodeList.at( 0 ).toElement();
368 if ( rampsElement.isNull() )
370 QgsDebugError( QStringLiteral(
"linearGradient tag missing" ) );
375 QDomElement e = rampsElement.firstChildElement();
377 while ( !e.isNull() )
379 if ( e.tagName() == QLatin1String(
"stop" ) )
383 QString offsetStr = e.attribute( QStringLiteral(
"offset" ) );
384 const QString colorStr = e.attribute( QStringLiteral(
"stop-color" ), QString() );
385 const QString opacityStr = e.attribute( QStringLiteral(
"stop-opacity" ), QStringLiteral(
"1.0" ) );
386 if ( offsetStr.endsWith(
'%' ) )
387 offset = offsetStr.remove( offsetStr.size() - 1, 1 ).toDouble() / 100.0;
389 offset = offsetStr.toDouble();
392 if ( colorStr.isEmpty() )
395 color = QColor( 0, 0, 0 );
402 if ( color.isValid() )
404 const int alpha = opacityStr.toDouble() * 255;
405 color.setAlpha( alpha );
406 if ( colorMap.contains( offset ) )
407 colorMap[offset].second = color;
409 colorMap[offset] = qMakePair( color, color );
413 QgsDebugError( QStringLiteral(
"at offset=%1 invalid color \"%2\"" ).arg( offset ).arg( colorStr ) );
421 e = e.nextSiblingElement();
429 return ( mRootItems.isEmpty() );
437 if ( sArchiveRegistry()->contains( *sDefaultArchiveName() ) )
438 return sArchiveRegistry()->value( *sDefaultArchiveName() );
456 const QString
baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
461 if ( ! sArchiveRegistry()->contains( defArchiveName ) )
468 QString
baseDir, defArchiveName;
472 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
481 const QStringList fileList = dir.entryList( QStringList() << QStringLiteral(
"cpt-city*" ), QDir::Dirs );
482 for (
const QString &entry : fileList )
484 if ( QFile::exists(
baseDir +
'/' + entry +
"/VERSION.xml" ) )
485 archivesMap[ entry ] =
baseDir +
'/' + entry;
490 archivesMap[ defArchiveName ] =
baseDir +
'/' + defArchiveName;
493 for ( QgsStringMap::iterator it = archivesMap.begin();
494 it != archivesMap.end(); ++it )
496 if ( QDir( it.value() ).exists() )
500 QgsDebugError( QStringLiteral(
"not loading archive [%1] because dir %2 does not exist " ).arg( it.key(), it.value() ) );
503 *sDefaultArchiveName() = defArchiveName;
508 qDeleteAll( *sArchiveRegistry() );
509 sArchiveRegistry()->clear();
516 const QString &name,
const QString &path )
520 , mPopulated( false )
529 QVector<QgsCptCityDataItem *>
children;
540 QApplication::setOverrideCursor( Qt::WaitCursor );
543 const auto constChildren =
children;
551 QApplication::restoreOverrideCursor();
571 count += child->leafCount();
593 mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
601 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
622 const int i =
mChildren.indexOf( child );
633 const int i =
mChildren.indexOf( child );
648 for (
int i = 0; i < items.size(); i++ )
651 if ( items[i]->
equal( item ) )
661 QApplication::setOverrideCursor( Qt::WaitCursor );
666 QVector<QgsCptCityDataItem *> remove;
670 if (
findItem( items, child ) >= 0 )
672 remove.append( child );
674 const auto constRemove = remove;
681 const auto constItems = items;
693 QApplication::restoreOverrideCursor();
698 return ( metaObject()->className() == other->metaObject()->className() &&
705 const QString &name,
const QString &path,
const QString &variantName,
bool initialize )
707 , mInitialized( false )
708 , mRamp( path, variantName, false )
717 const QString &name,
const QString &path,
const QStringList &variantList,
bool initialize )
719 , mInitialized( false )
720 , mRamp( path, variantList, QString(), false )
753 if ( variantList.isEmpty() )
758 mInfo = QString::number( count ) +
' ' + tr(
"colors" ) +
" - ";
760 mInfo += tr(
"discrete" );
764 mInfo += tr(
"continuous" );
766 mInfo += tr(
"continuous (multi)" );
772 mInfo = QString::number( variantList.count() ) +
' ' + tr(
"variants" );
801 return icon( QSize( 100, 15 ) );
806 const auto constMIcons =
mIcons;
807 for (
const QIcon &
icon : constMIcons )
809 if (
icon.availableSizes().contains( size ) )
823 QPixmap blankPixmap( size );
824 blankPixmap.fill( Qt::white );
825 icon = QIcon( blankPixmap );
835 const QString &name,
const QString &path )
837 , mPopulatedRamps( false )
848 QVector< QgsCptCityDataItem * > rampItems;
849 QVector< QgsCptCityDataItem * > deleteItems;
854 const auto constChildren =
children();
859 QgsDebugMsgLevel( QStringLiteral(
"child path= %1 coll= %2 ramp = %3" ).arg( childItem->path() ).arg(
nullptr != collectionItem ).arg(
nullptr != rampItem ), 2 );
860 if ( collectionItem && recursive )
870 rampItems << rampItem;
872 deleteItems << rampItem;
881 const auto constDeleteItems = deleteItems;
884 QgsDebugError( QStringLiteral(
"item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
885 const int i =
mChildren.indexOf( deleteItem );
896 const QString &name,
const QString &path )
910 mPath +
'/' +
"DESC.xml";
912 if ( descMap.contains( QStringLiteral(
"name" ) ) )
913 mInfo = descMap.value( QStringLiteral(
"name" ) );
921 return QVector<QgsCptCityDataItem *>();
923 QVector<QgsCptCityDataItem *>
children;
926 QMapIterator< QString, QStringList> it(
rampsMap() );
927 while ( it.hasNext() )
941 for (
const QString &childPath : constDirEntries )
959 QString curName, prevName, curVariant, curSep, schemeName;
960 QStringList listVariant;
961 QStringList schemeNamesAll, schemeNames;
962 bool prevAdd, curAdd;
965 schemeNamesAll = dir.entryList( QStringList( QStringLiteral(
"*.svg" ) ), QDir::Files, QDir::Name );
968 for (
int i = 0; i < schemeNamesAll.count(); i++ )
971 schemeName = schemeNamesAll[i];
972 schemeName.chop( 4 );
974 curName = schemeName;
979 if ( schemeName.length() > 1 && schemeName.endsWith(
'a' ) && ! listVariant.isEmpty() &&
980 ( ( prevName + listVariant.last() +
'a' ) == curName ) )
983 curVariant = listVariant.last() +
'a';
987 const thread_local QRegularExpression rxVariant(
"^(.*[^\\d])(\\d{1,3})$" );
988 const QRegularExpressionMatch match = rxVariant.match( schemeName );
989 if ( match.hasMatch() )
991 curName = match.captured( 1 );
992 curVariant = match.captured( 2 );
996 curSep = curName.right( 1 );
997 if ( curSep == QLatin1String(
"-" ) || curSep == QLatin1String(
"_" ) )
1000 curVariant = curSep + curVariant;
1003 if ( prevName.isEmpty() )
1009 if ( curName.isEmpty() )
1010 curName = QStringLiteral(
"__empty__" );
1012 if ( curName == prevName )
1015 if ( i == schemeNamesAll.count() - 1 )
1017 listVariant << curVariant;
1021 if ( !prevName.isEmpty() )
1026 if ( i == schemeNamesAll.count() - 1 )
1035 if ( listVariant.isEmpty() )
1039 schemeNames << prevName;
1042 else if ( listVariant.count() <= 3 )
1045 for (
int j = 0; j < listVariant.count(); j++ )
1048 schemeNames << prevName + listVariant[j];
1049 mRampsMap[
mPath +
'/' + prevName + listVariant[j] ] = QStringList();
1056 schemeNames << prevName;
1058 listVariant.clear();
1062 if ( !curVariant.isEmpty() )
1063 curName += curVariant;
1064 schemeNames << curName;
1068 if ( prevAdd || curAdd )
1071 if ( !curVariant.isEmpty() )
1072 listVariant << curVariant;
1079 mSchemeMap[
path ] = schemeNames;
1080 schemeCount += schemeName.count();
1081 schemeNames.clear();
1082 listVariant.clear();
1091 '/' +
mPath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
1101 return (
path() == other->
path() );
1105 const QString &name,
const QString &path )
1111 if ( dirItem && ! dirItem->
isValid() )
1156 const QString &name,
const QString &path )
1168 return QVector<QgsCptCityDataItem *>();
1171 QVector<QgsCptCityDataItem *>
children;
1178 QgsDebugMsgLevel(
"childPath = " + childPath +
" name= " + QFileInfo( childPath ).baseName(), 2 );
1179 if ( childPath.endsWith(
'/' ) )
1181 childPath.chop( 1 );
1195 if ( !QFile::exists( fileName ) )
1219 QFile f( filename );
1220 if ( ! f.open( QFile::ReadOnly ) )
1228 QDomDocument doc( QStringLiteral(
"selection" ) );
1229 if ( !doc.setContent( &f, &errMsg ) )
1232 QgsDebugError(
"Couldn't parse file " + filename +
" : " + errMsg );
1238 const QDomElement docElem = doc.documentElement();
1239 if ( docElem.tagName() != QLatin1String(
"selection" ) )
1241 QgsDebugError(
"Incorrect root tag: " + docElem.tagName() );
1244 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
1245 if ( ! e.isNull() && ! e.text().isNull() )
1247 mInfo = docElem.firstChildElement( QStringLiteral(
"synopsis" ) ).text().simplified();
1250 const QDomElement collectsElem = docElem.firstChildElement( QStringLiteral(
"seealsocollects" ) );
1251 e = collectsElem.firstChildElement( QStringLiteral(
"collect" ) );
1252 while ( ! e.isNull() )
1254 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1257 const QString dir = e.attribute( QStringLiteral(
"dir" ) ) +
'/';
1263 e = e.nextSiblingElement();
1266 const QDomElement gradientsElem = docElem.firstChildElement( QStringLiteral(
"gradients" ) );
1267 e = gradientsElem.firstChildElement( QStringLiteral(
"gradient" ) );
1268 while ( ! e.isNull() )
1270 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1274 const QString dir = e.attribute( QStringLiteral(
"dir" ) );
1277 mSelectionsList << dir +
'/' + e.attribute( QStringLiteral(
"file" ) );
1280 e = e.nextSiblingElement();
1291 return (
path() == other->
path() );
1296 const QString &name,
const QVector<QgsCptCityDataItem *> &items )
1308 return QVector<QgsCptCityDataItem *>();
1310 QVector<QgsCptCityDataItem *>
children;
1313 const auto constMItems =
mItems;
1328 : QAbstractItemModel( parent )
1329 , mArchive( archive )
1330 , mViewType( viewType )
1333 QgsDebugMsgLevel( QLatin1String(
"archiveName = " ) + archive->
archiveName() +
" viewType=" + QString::number(
static_cast< int >( viewType ) ), 2 );
1364 if ( !
index.isValid() )
1365 return Qt::ItemFlags();
1367 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
1374 if ( !
index.isValid() )
1383 else if ( role == Qt::DisplayRole )
1385 if (
index.column() == 0 )
1386 return item->
name();
1387 if (
index.column() == 1 )
1389 return item->
info();
1392 else if ( role == Qt::ToolTipRole )
1396 return QString( item->
path() +
'\n' + item->
info() );
1399 else if ( role == Qt::DecorationRole &&
index.column() == 1 &&
1405 else if ( role == Qt::FontRole &&
1406 qobject_cast< QgsCptCityCollectionItem * >( item ) )
1410 font.setPointSize( 11 );
1411 font.setBold(
true );
1425 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
1428 return QVariant( tr(
"Name" ) );
1429 else if ( section == 1 )
1430 return QVariant( tr(
"Info" ) );
1448 return item ? item->
rowCount() : 0;
1470 QModelIndex rootIndex;
1471 bool foundParent =
false, foundChild =
true;
1477 if ( path.isEmpty() )
1479 for (
int i = 0; i <
rowCount( rootIndex ); i++ )
1481 QModelIndex idx =
index( i, 0, rootIndex );
1484 return QModelIndex();
1486 itemPath = item->
path();
1488 if ( itemPath == path )
1496 while ( foundChild )
1502 if ( itemPath.isEmpty() )
1504 for ( ; i <
rowCount( rootIndex ); i++ )
1506 QModelIndex idx =
index( i, 0, rootIndex );
1509 return QModelIndex();
1511 itemPath = item->
path();
1513 if ( itemPath == path )
1519 if ( ! itemPath.endsWith(
'/' ) )
1522 foundParent =
false;
1533 for ( QString childPath : constSelectionsList )
1535 if ( childPath.endsWith(
'/' ) )
1536 childPath.chop( 1 );
1538 if ( path.startsWith( childPath ) )
1547 else if ( path.startsWith( itemPath ) )
1565 return QModelIndex();
1579 const QModelIndex idx =
findPath( path );
1580 if ( idx.isValid() )
1593 return item ? createIndex( row, column, item ) : QModelIndex();
1600 return QModelIndex();
1609 for (
int i = 0; i < items.size(); i++ )
1611 if ( items[i] == item )
1612 return createIndex( i, 0, item );
1614 QModelIndex childIndex =
findItem( item, items[i] );
1615 if ( childIndex.isValid() )
1619 return QModelIndex();
1637 if ( !idx.isValid() )
1640 beginInsertRows( idx, first, last );
1651 if ( !idx.isValid() )
1653 beginRemoveRows( idx, first, last );
1697 void *v = idx.internalPointer();
1699 Q_ASSERT( !v || d );
static QString pkgDataPath()
Returns the common root path of all application data directories.
An "All ramps item", which contains all items in a flat hierarchy.
QgsCptCityAllRampsItem(QgsCptCityDataItem *parent, const QString &name, const QVector< QgsCptCityDataItem * > &items)
QVector< QgsCptCityDataItem * > mItems
QVector< QgsCptCityDataItem * > createChildren() override
Returns a vector of children items.
Represents a CPT City color scheme.
static void clearArchives()
static void initArchive(const QString &archiveName, const QString &archiveBaseDir)
QString descFileName(const QString &dirName) const
static QString defaultBaseDir()
static QMap< QString, QString > copyingInfo(const QString &fileName)
QVector< QgsCptCityDataItem * > rootItems() const
QString archiveName() const
static QgsCptCityArchive * defaultArchive()
QString copyingFileName(const QString &dirName) const
bool isEmpty() const
Returns true if archive is empty.
static void initDefaultArchive()
QgsCptCityArchive(const QString &archiveName=DEFAULT_CPTCITY_ARCHIVE, const QString &baseDir=QString())
static QString findFileName(const QString &target, const QString &startDir, const QString &baseDir)
static QMap< QString, QString > description(const QString &fileName)
static void initArchives(bool loadAll=false)
static QMap< double, QPair< QColor, QColor > > gradientColorMap(const QString &fileName)
QVector< QgsCptCityDataItem * > selectionItems() const
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void refresh(const QString &path)
Refresh the item specified by path.
void beginRemoveItems(QgsCptCityDataItem *parent, int first, int last)
QModelIndex findPath(const QString &path)
Returns index of a path.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QgsCptCityDataItem * dataItem(const QModelIndex &idx) const
Returns the data item corresponding to the given index.
void reload()
Reload the whole model.
void connectItem(QgsCptCityDataItem *item)
QgsCptCityArchive * mArchive
QModelIndex parent(const QModelIndex &index) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QgsCptCityBrowserModel(QObject *parent=nullptr, QgsCptCityArchive *archive=QgsCptCityArchive::defaultArchive(), ViewType Type=Authors)
void beginInsertItems(QgsCptCityDataItem *parent, int first, int last)
void fetchMore(const QModelIndex &parent) override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
~QgsCptCityBrowserModel() override
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
bool canFetchMore(const QModelIndex &parent) const override
QModelIndex findItem(QgsCptCityDataItem *item, QgsCptCityDataItem *parent=nullptr) const
QVector< QgsCptCityDataItem * > mRootItems
A Collection: logical collection of subcollections and color ramps.
~QgsCptCityCollectionItem() override
QgsCptCityCollectionItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
QVector< QgsCptCityDataItem * > childrenRamps(bool recursive)
Item that represents a layer that can be opened with one of the providers.
const QgsCptCityColorRamp & ramp() const
bool equal(const QgsCptCityDataItem *other) override
Returns true if this item is equal to an other item.
QgsCptCityColorRampItem(QgsCptCityDataItem *parent, const QString &name, const QString &path, const QString &variantName=QString(), bool initialize=false)
QgsCptCityColorRamp mRamp
QStringList variantList() const
static QString fileNameForVariant(const QString &schema, const QString &variant)
Returns the source file name for a CPT schema and variant.
void setVariantName(const QString &variantName)
bool hasMultiStops() const
QString variantName() const
Base class for all items in the model.
QgsCptCityDataItem * parent() const
virtual void addChildItem(QgsCptCityDataItem *child, bool refresh=false)
Inserts a new child using alphabetical order based on mName, emits necessary signal to model before a...
void beginRemoveItems(QgsCptCityDataItem *parent, int first, int last)
Emitted before child items are removed from this data item.
virtual QVector< QgsCptCityDataItem * > createChildren()
Returns a vector of children items.
virtual QgsCptCityDataItem * removeChildItem(QgsCptCityDataItem *child)
Removes a child item but doesn't delete it, signals to browser are emitted.
void endRemoveItems()
Emitted after child items have been removed from this data item.
bool isPopulated()
Returns true if the item is already populated.
static int findItem(QVector< QgsCptCityDataItem * > items, QgsCptCityDataItem *item)
Finds a child index in vector of items using '==' operator.
QVector< QgsCptCityDataItem * > mChildren
void endInsertItems()
Emitted after child items have been added to this data item.
void setParent(QgsCptCityDataItem *parent)
virtual void populate()
Populates children using children vector created by createChildren().
virtual void deleteChildItem(QgsCptCityDataItem *child)
Removes and deletes a child item, signals to browser are emitted.
virtual bool equal(const QgsCptCityDataItem *other)
Returns true if this item is equal to an other item.
QgsCptCityDataItem(QgsCptCityDataItem::Type type, QgsCptCityDataItem *parent, const QString &name, const QString &path)
QVector< QgsCptCityDataItem * > children() const
void beginInsertItems(QgsCptCityDataItem *parent, int first, int last)
Emitted before child items are added to this item.
virtual int leafCount() const
Returns the total count of "leaf" items (all children which are end nodes).
A directory: contains subdirectories and color ramps.
QStringList dirEntries() const
static QgsCptCityDataItem * dataItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
QVector< QgsCptCityDataItem * > createChildren() override
Returns a vector of children items.
QgsCptCityDirectoryItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
QMap< QString, QStringList > mRampsMap
bool equal(const QgsCptCityDataItem *other) override
Returns true if this item is equal to an other item.
QMap< QString, QStringList > rampsMap()
A selection: contains subdirectories and color ramps.
QVector< QgsCptCityDataItem * > createChildren() override
Returns a vector of children items.
QgsCptCitySelectionItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
bool equal(const QgsCptCityDataItem *other) override
Returns true if this item is equal to an other item.
QStringList mSelectionsList
QStringList selectionsList() const
bool isDiscrete() const
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating betw...
int count() const override
Returns number of defined colors, or -1 if undefined.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static QColor parseColor(const QString &colorStr, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes,...
static QIcon colorRampPreviewIcon(QgsColorRamp *ramp, QSize size, int padding=0)
Returns an icon preview for a color ramp.
QMap< QString, QString > QgsStringMap
QMap< QString, QMap< QString, QString > > CopyingInfoMap
QMap< QString, QgsCptCityArchive * > ArchiveRegistry
#define DEFAULT_CPTCITY_ARCHIVE
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)