29#include <QApplication>
32#include <QDomDocument>
35#include <QRegularExpression>
39#include "moc_qgscptcityarchive.cpp"
50 return *sArchiveRegistry();
61 const auto constEntryList = QDir( mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
62 for (
const QString &path : constEntryList )
64 if ( path == QLatin1String(
"selections" ) )
69 mRootItems << dirItem;
76 const QDir seldir( mBaseDir +
'/' +
"selections" );
78 const QStringList fileList = seldir.entryList( QStringList() << QStringLiteral(
"*.xml" ), QDir::Files );
79 for (
const QString &selfile : fileList )
83 seldir.dirName() +
'/' + selfile );
86 mSelectionItems << selItem;
95 mRootItems.prepend( allRampsItem );
98 mSelectionItems.prepend( allRampsItem );
103 const auto constMRootItems = mRootItems;
106 const auto constMSelectionItems = mSelectionItems;
110 mSelectionItems.clear();
117 if ( ! mBaseDir.isNull() )
129 return archive->baseDir();
140 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
153 if ( startDir.isEmpty() || ! startDir.startsWith(
baseDir ) )
156 QDir dir = QDir( startDir );
158 while ( ! dir.exists( target ) && dir.path() !=
baseDir )
163 if ( ! dir.exists( target ) )
166 return dir.path() +
'/' + target;
186 if ( fileName.isNull() )
189 if ( sCopyingInfoMap()->contains( fileName ) )
191 QgsDebugMsgLevel(
"found copying info in copyingInfoMap, file = " + fileName, 2 );
192 return sCopyingInfoMap()->value( fileName );
199 if ( !f.open( QFile::ReadOnly ) )
206 QDomDocument doc( QStringLiteral(
"license" ) );
207 if ( !doc.setContent( &f ) )
216 const QDomElement docElem = doc.documentElement();
217 if ( docElem.tagName() != QLatin1String(
"copying" ) )
224 const QDomElement authorsElement = docElem.firstChildElement( QStringLiteral(
"authors" ) );
225 if ( authorsElement.isNull() )
231 QDomElement e = authorsElement.firstChildElement();
233 while ( ! e.isNull() )
235 if ( e.tagName() == QLatin1String(
"author" ) )
237 if ( ! e.firstChildElement( QStringLiteral(
"name" ) ).isNull() )
238 authors << e.firstChildElement( QStringLiteral(
"name" ) ).text().simplified();
241 e = e.nextSiblingElement();
243 copyingMap[ QStringLiteral(
"authors" )] = authors.join( QLatin1String(
", " ) );
247 const QDomElement licenseElement = docElem.firstChildElement( QStringLiteral(
"license" ) );
248 if ( licenseElement.isNull() )
254 QDomElement e = licenseElement.firstChildElement( QStringLiteral(
"informal" ) );
256 copyingMap[ QStringLiteral(
"license/informal" )] = e.text().simplified();
257 e = licenseElement.firstChildElement( QStringLiteral(
"year" ) );
259 copyingMap[ QStringLiteral(
"license/year" )] = e.text().simplified();
260 e = licenseElement.firstChildElement( QStringLiteral(
"text" ) );
261 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
262 copyingMap[ QStringLiteral(
"license/url" )] = e.attribute( QStringLiteral(
"href" ) );
266 const QDomElement element = docElem.firstChildElement( QStringLiteral(
"src" ) );
267 if ( element.isNull() )
273 const QDomElement e = element.firstChildElement( QStringLiteral(
"link" ) );
274 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
275 copyingMap[ QStringLiteral(
"src/link" )] = e.attribute( QStringLiteral(
"href" ) );
279 ( *sCopyingInfoMap() )[ fileName ] = copyingMap;
290 if ( ! f.open( QFile::ReadOnly ) )
292 QgsDebugMsgLevel(
"description file " + fileName +
" ] does not exist", 2 );
298 QDomDocument doc( QStringLiteral(
"description" ) );
299 if ( !doc.setContent( &f, &errMsg ) )
302 QgsDebugError(
"Couldn't parse file " + fileName +
" : " + errMsg );
308 const QDomElement docElem = doc.documentElement();
309 if ( docElem.tagName() != QLatin1String(
"description" ) )
316 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
321 descMap[ QStringLiteral(
"name" )] = e.text().simplified();
322 e = docElem.firstChildElement( QStringLiteral(
"full" ) );
327 descMap[ QStringLiteral(
"full" )] = e.text().simplified();
334 QMap< double, QPair<QColor, QColor> > colorMap;
338 if ( !f.open( QFile::ReadOnly ) )
345 QDomDocument doc( QStringLiteral(
"gradient" ) );
346 if ( !doc.setContent( &f ) )
354 const QDomElement docElem = doc.documentElement();
356 if ( docElem.tagName() != QLatin1String(
"svg" ) )
363 QDomElement rampsElement = docElem.firstChildElement( QStringLiteral(
"linearGradient" ) );
364 if ( rampsElement.isNull() )
366 const QDomNodeList nodeList = docElem.elementsByTagName( QStringLiteral(
"linearGradient" ) );
367 if ( ! nodeList.isEmpty() )
368 rampsElement = nodeList.at( 0 ).toElement();
370 if ( rampsElement.isNull() )
372 QgsDebugError( QStringLiteral(
"linearGradient tag missing" ) );
377 QDomElement e = rampsElement.firstChildElement();
379 while ( !e.isNull() )
381 if ( e.tagName() == QLatin1String(
"stop" ) )
385 QString offsetStr = e.attribute( QStringLiteral(
"offset" ) );
386 const QString colorStr = e.attribute( QStringLiteral(
"stop-color" ), QString() );
387 const QString opacityStr = e.attribute( QStringLiteral(
"stop-opacity" ), QStringLiteral(
"1.0" ) );
388 if ( offsetStr.endsWith(
'%' ) )
389 offset = offsetStr.remove( offsetStr.size() - 1, 1 ).toDouble() / 100.0;
391 offset = offsetStr.toDouble();
394 if ( colorStr.isEmpty() )
397 color = QColor( 0, 0, 0 );
404 if ( color.isValid() )
406 const int alpha = opacityStr.toDouble() * 255;
407 color.setAlpha( alpha );
408 if ( colorMap.contains( offset ) )
409 colorMap[offset].second = color;
411 colorMap[offset] = qMakePair( color, color );
415 QgsDebugError( QStringLiteral(
"at offset=%1 invalid color \"%2\"" ).arg( offset ).arg( colorStr ) );
423 e = e.nextSiblingElement();
431 return ( mRootItems.isEmpty() );
439 if ( sArchiveRegistry()->contains( *sDefaultArchiveName() ) )
440 return sArchiveRegistry()->value( *sDefaultArchiveName() );
458 const QString
baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
463 if ( ! sArchiveRegistry()->contains( defArchiveName ) )
470 QString
baseDir, defArchiveName;
474 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
483 const QStringList fileList = dir.entryList( QStringList() << QStringLiteral(
"cpt-city*" ), QDir::Dirs );
484 for (
const QString &entry : fileList )
486 if ( QFile::exists(
baseDir +
'/' + entry +
"/VERSION.xml" ) )
487 archivesMap[ entry ] =
baseDir +
'/' + entry;
492 archivesMap[ defArchiveName ] =
baseDir +
'/' + defArchiveName;
495 for ( QgsStringMap::iterator it = archivesMap.begin();
496 it != archivesMap.end(); ++it )
498 if ( QDir( it.value() ).exists() )
502 QgsDebugError( QStringLiteral(
"not loading archive [%1] because dir %2 does not exist " ).arg( it.key(), it.value() ) );
505 *sDefaultArchiveName() = defArchiveName;
510 qDeleteAll( *sArchiveRegistry() );
511 sArchiveRegistry()->clear();
518 const QString &
name,
const QString &
path )
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 )
717 const QString &
name,
const QString &
path,
const QStringList &variantList,
bool initialize )
720 ,
mRamp(
path, variantList, QString(), false )
738 QStringList variantList =
mRamp.variantList();
739 if (
mRamp.variantName().isNull() && ! variantList.isEmpty() )
740 mRamp.setVariantName( variantList[ variantList.count() / 2 ] );
745 if ( ! QFile::exists(
mRamp.fileName() ) )
751 if (
mRamp.count() > 0 )
753 if ( variantList.isEmpty() )
755 int count =
mRamp.count();
756 if (
mRamp.isDiscrete() )
758 mInfo = QString::number( count ) +
' ' + tr(
"colors" ) +
" - ";
759 if (
mRamp.isDiscrete() )
760 mInfo += tr(
"discrete" );
763 if ( !
mRamp.hasMultiStops() )
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 )
847 QVector< QgsCptCityDataItem * > rampItems;
848 QVector< QgsCptCityDataItem * > deleteItems;
853 const auto constChildren =
children();
858 QgsDebugMsgLevel( QStringLiteral(
"child path= %1 coll= %2 ramp = %3" ).arg( childItem->path() ).arg(
nullptr != collectionItem ).arg(
nullptr != rampItem ), 2 );
859 if ( collectionItem && recursive )
869 rampItems << rampItem;
871 deleteItems << rampItem;
880 const auto constDeleteItems = deleteItems;
883 QgsDebugError( QStringLiteral(
"item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
884 const int i =
mChildren.indexOf( deleteItem );
895 const QString &
name,
const QString &
path )
909 mPath +
'/' +
"DESC.xml";
911 if ( descMap.contains( QStringLiteral(
"name" ) ) )
912 mInfo = descMap.value( QStringLiteral(
"name" ) );
920 return QVector<QgsCptCityDataItem *>();
922 QVector<QgsCptCityDataItem *>
children;
925 QMapIterator< QString, QStringList> it(
rampsMap() );
926 while ( it.hasNext() )
940 for (
const QString &childPath : constDirEntries )
958 QString curName, prevName, curVariant, curSep, schemeName;
959 QStringList listVariant;
960 QStringList schemeNamesAll, schemeNames;
961 bool prevAdd, curAdd;
964 schemeNamesAll = dir.entryList( QStringList( QStringLiteral(
"*.svg" ) ), QDir::Files, QDir::Name );
967 for (
int i = 0; i < schemeNamesAll.count(); i++ )
970 schemeName = schemeNamesAll[i];
971 schemeName.chop( 4 );
973 curName = schemeName;
978 if ( schemeName.length() > 1 && schemeName.endsWith(
'a' ) && ! listVariant.isEmpty() &&
979 ( ( prevName + listVariant.last() +
'a' ) == curName ) )
982 curVariant = listVariant.last() +
'a';
986 const thread_local QRegularExpression rxVariant(
"^(.*[^\\d])(\\d{1,3})$" );
987 const QRegularExpressionMatch match = rxVariant.match( schemeName );
988 if ( match.hasMatch() )
990 curName = match.captured( 1 );
991 curVariant = match.captured( 2 );
995 curSep = curName.right( 1 );
996 if ( curSep == QLatin1String(
"-" ) || curSep == QLatin1String(
"_" ) )
999 curVariant = curSep + curVariant;
1002 if ( prevName.isEmpty() )
1008 if ( curName.isEmpty() )
1009 curName = QStringLiteral(
"__empty__" );
1011 if ( curName == prevName )
1014 if ( i == schemeNamesAll.count() - 1 )
1016 listVariant << curVariant;
1020 if ( !prevName.isEmpty() )
1025 if ( i == schemeNamesAll.count() - 1 )
1034 if ( listVariant.isEmpty() )
1038 schemeNames << prevName;
1041 else if ( listVariant.count() <= 3 )
1044 for (
int j = 0; j < listVariant.count(); j++ )
1047 schemeNames << prevName + listVariant[j];
1048 mRampsMap[
mPath +
'/' + prevName + listVariant[j] ] = QStringList();
1055 schemeNames << prevName;
1057 listVariant.clear();
1061 if ( !curVariant.isEmpty() )
1062 curName += curVariant;
1063 schemeNames << curName;
1067 if ( prevAdd || curAdd )
1070 if ( !curVariant.isEmpty() )
1071 listVariant << curVariant;
1078 mSchemeMap[
path ] = schemeNames;
1079 schemeCount += schemeName.count();
1080 schemeNames.clear();
1081 listVariant.clear();
1090 '/' +
mPath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
1100 return (
path() == other->
path() );
1104 const QString &
name,
const QString &
path )
1110 if ( dirItem && ! dirItem->
isValid() )
1155 const QString &
name,
const QString &
path )
1167 return QVector<QgsCptCityDataItem *>();
1170 QVector<QgsCptCityDataItem *>
children;
1177 QgsDebugMsgLevel(
"childPath = " + childPath +
" name= " + QFileInfo( childPath ).baseName(), 2 );
1178 if ( childPath.endsWith(
'/' ) )
1180 childPath.chop( 1 );
1194 if ( !QFile::exists( fileName ) )
1218 QFile f( filename );
1219 if ( ! f.open( QFile::ReadOnly ) )
1227 QDomDocument doc( QStringLiteral(
"selection" ) );
1228 if ( !doc.setContent( &f, &errMsg ) )
1231 QgsDebugError(
"Couldn't parse file " + filename +
" : " + errMsg );
1237 const QDomElement docElem = doc.documentElement();
1238 if ( docElem.tagName() != QLatin1String(
"selection" ) )
1240 QgsDebugError(
"Incorrect root tag: " + docElem.tagName() );
1243 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
1244 if ( ! e.isNull() && ! e.text().isNull() )
1246 mInfo = docElem.firstChildElement( QStringLiteral(
"synopsis" ) ).text().simplified();
1249 const QDomElement collectsElem = docElem.firstChildElement( QStringLiteral(
"seealsocollects" ) );
1250 e = collectsElem.firstChildElement( QStringLiteral(
"collect" ) );
1251 while ( ! e.isNull() )
1253 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1256 const QString dir = e.attribute( QStringLiteral(
"dir" ) ) +
'/';
1262 e = e.nextSiblingElement();
1265 const QDomElement gradientsElem = docElem.firstChildElement( QStringLiteral(
"gradients" ) );
1266 e = gradientsElem.firstChildElement( QStringLiteral(
"gradient" ) );
1267 while ( ! e.isNull() )
1269 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1273 const QString dir = e.attribute( QStringLiteral(
"dir" ) );
1276 mSelectionsList << dir +
'/' + e.attribute( QStringLiteral(
"file" ) );
1279 e = e.nextSiblingElement();
1290 return (
path() == other->
path() );
1295 const QString &
name,
const QVector<QgsCptCityDataItem *> &items )
1307 return QVector<QgsCptCityDataItem *>();
1309 QVector<QgsCptCityDataItem *>
children;
1312 const auto constMItems =
mItems;
1327 : QAbstractItemModel(
parent )
1332 QgsDebugMsgLevel( QLatin1String(
"archiveName = " ) + archive->
archiveName() +
" viewType=" + QString::number(
static_cast< int >( viewType ) ), 2 );
1363 if ( !
index.isValid() )
1364 return Qt::ItemFlags();
1366 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
1373 if ( !
index.isValid() )
1382 else if ( role == Qt::DisplayRole )
1384 if (
index.column() == 0 )
1385 return item->
name();
1386 if (
index.column() == 1 )
1388 return item->
info();
1391 else if ( role == Qt::ToolTipRole )
1395 return QString( item->
path() +
'\n' + item->
info() );
1398 else if ( role == Qt::DecorationRole &&
index.column() == 1 &&
1404 else if ( role == Qt::FontRole &&
1405 qobject_cast< QgsCptCityCollectionItem * >( item ) )
1409 font.setPointSize( 11 );
1410 font.setBold(
true );
1424 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
1427 return QVariant( tr(
"Name" ) );
1428 else if ( section == 1 )
1429 return QVariant( tr(
"Info" ) );
1447 return item ? item->
rowCount() : 0;
1469 QModelIndex rootIndex;
1470 bool foundParent =
false, foundChild =
true;
1476 if ( path.isEmpty() )
1478 for (
int i = 0; i <
rowCount( rootIndex ); i++ )
1480 QModelIndex idx =
index( i, 0, rootIndex );
1483 return QModelIndex();
1485 itemPath = item->
path();
1487 if ( itemPath == path )
1495 while ( foundChild )
1501 if ( itemPath.isEmpty() )
1503 for ( ; i <
rowCount( rootIndex ); i++ )
1505 QModelIndex idx =
index( i, 0, rootIndex );
1508 return QModelIndex();
1510 itemPath = item->
path();
1512 if ( itemPath == path )
1518 if ( ! itemPath.endsWith(
'/' ) )
1521 foundParent =
false;
1532 for ( QString childPath : constSelectionsList )
1534 if ( childPath.endsWith(
'/' ) )
1535 childPath.chop( 1 );
1537 if ( path.startsWith( childPath ) )
1546 else if ( path.startsWith( itemPath ) )
1564 return QModelIndex();
1578 const QModelIndex idx =
findPath( path );
1579 if ( idx.isValid() )
1592 return item ? createIndex( row, column, item ) : QModelIndex();
1599 return QModelIndex();
1608 for (
int i = 0; i < items.size(); i++ )
1610 if ( items[i] == item )
1611 return createIndex( i, 0, item );
1613 QModelIndex childIndex =
findItem( item, items[i] );
1614 if ( childIndex.isValid() )
1618 return QModelIndex();
1636 if ( !idx.isValid() )
1639 beginInsertRows( idx, first, last );
1650 if ( !idx.isValid() )
1652 beginRemoveRows( idx, first, last );
1696 void *v = idx.internalPointer();
1698 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)
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< QString, QgsCptCityArchive * > archiveRegistry()
static QMap< double, QPair< QColor, QColor > > gradientColorMap(const QString &fileName)
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
~QgsCptCityCollectionItem() override
QgsCptCityCollectionItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
QVector< QgsCptCityDataItem * > childrenRamps(bool recursive)
An item that represents a layer that can be opened with one of the providers for a QgsCptCityBrowserM...
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
static QString fileNameForVariant(const QString &schema, const QString &variant)
Returns the source file name for a CPT schema and variant.
QString variantName() const
Base class for all items in a QgsCptCityBrowserModel 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 * mParent
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 which contains subdirectories and color ramps for use in QgsCptCityBrowserModel.
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 which contains subdirectories and color ramps for use in QgsCptCityBrowserModel.
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
Stores settings for use within QGIS.
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)