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 )
531 QVector<QgsCptCityDataItem *>
children;
542 QApplication::setOverrideCursor( Qt::WaitCursor );
545 const auto constChildren =
children;
553 QApplication::restoreOverrideCursor();
573 count += child->leafCount();
595 mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
603 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
624 const int i =
mChildren.indexOf( child );
635 const int i =
mChildren.indexOf( child );
650 for (
int i = 0; i < items.size(); i++ )
653 if ( items[i]->
equal( item ) )
663 QApplication::setOverrideCursor( Qt::WaitCursor );
668 QVector<QgsCptCityDataItem *> remove;
672 if (
findItem( items, child ) >= 0 )
674 remove.append( child );
676 const auto constRemove = remove;
683 const auto constItems = items;
695 QApplication::restoreOverrideCursor();
700 return ( metaObject()->className() == other->metaObject()->className() &&
707 const QString &
name,
const QString &
path,
const QString &variantName,
bool initialize )
719 const QString &
name,
const QString &
path,
const QStringList &variantList,
bool initialize )
722 ,
mRamp(
path, variantList, QString(), false )
740 QStringList variantList =
mRamp.variantList();
741 if (
mRamp.variantName().isNull() && ! variantList.isEmpty() )
742 mRamp.setVariantName( variantList[ variantList.count() / 2 ] );
747 if ( ! QFile::exists(
mRamp.fileName() ) )
753 if (
mRamp.count() > 0 )
755 if ( variantList.isEmpty() )
757 int count =
mRamp.count();
758 if (
mRamp.isDiscrete() )
760 mInfo = QString::number( count ) +
' ' + tr(
"colors" ) +
" - ";
761 if (
mRamp.isDiscrete() )
762 mInfo += tr(
"discrete" );
765 if ( !
mRamp.hasMultiStops() )
766 mInfo += tr(
"continuous" );
768 mInfo += tr(
"continuous (multi)" );
774 mInfo = QString::number( variantList.count() ) +
' ' + tr(
"variants" );
803 return icon( QSize( 100, 15 ) );
808 const auto constMIcons =
mIcons;
809 for (
const QIcon &
icon : constMIcons )
811 if (
icon.availableSizes().contains( size ) )
825 QPixmap blankPixmap( size );
826 blankPixmap.fill( Qt::white );
827 icon = QIcon( blankPixmap );
837 const QString &
name,
const QString &
path )
850 QVector< QgsCptCityDataItem * > rampItems;
851 QVector< QgsCptCityDataItem * > deleteItems;
856 const auto constChildren =
children();
861 QgsDebugMsgLevel( QStringLiteral(
"child path= %1 coll= %2 ramp = %3" ).arg( childItem->path() ).arg(
nullptr != collectionItem ).arg(
nullptr != rampItem ), 2 );
862 if ( collectionItem && recursive )
872 rampItems << rampItem;
874 deleteItems << rampItem;
883 const auto constDeleteItems = deleteItems;
886 QgsDebugError( QStringLiteral(
"item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
887 const int i =
mChildren.indexOf( deleteItem );
898 const QString &
name,
const QString &
path )
912 mPath +
'/' +
"DESC.xml";
914 if ( descMap.contains( QStringLiteral(
"name" ) ) )
915 mInfo = descMap.value( QStringLiteral(
"name" ) );
923 return QVector<QgsCptCityDataItem *>();
925 QVector<QgsCptCityDataItem *>
children;
928 QMapIterator< QString, QStringList> it(
rampsMap() );
929 while ( it.hasNext() )
943 for (
const QString &childPath : constDirEntries )
961 QString curName, prevName, curVariant, curSep, schemeName;
962 QStringList listVariant;
963 QStringList schemeNamesAll, schemeNames;
964 bool prevAdd, curAdd;
967 schemeNamesAll = dir.entryList( QStringList( QStringLiteral(
"*.svg" ) ), QDir::Files, QDir::Name );
970 for (
int i = 0; i < schemeNamesAll.count(); i++ )
973 schemeName = schemeNamesAll[i];
974 schemeName.chop( 4 );
976 curName = schemeName;
981 if ( schemeName.length() > 1 && schemeName.endsWith(
'a' ) && ! listVariant.isEmpty() &&
982 ( ( prevName + listVariant.last() +
'a' ) == curName ) )
985 curVariant = listVariant.last() +
'a';
989 const thread_local QRegularExpression rxVariant(
"^(.*[^\\d])(\\d{1,3})$" );
990 const QRegularExpressionMatch match = rxVariant.match( schemeName );
991 if ( match.hasMatch() )
993 curName = match.captured( 1 );
994 curVariant = match.captured( 2 );
998 curSep = curName.right( 1 );
999 if ( curSep == QLatin1String(
"-" ) || curSep == QLatin1String(
"_" ) )
1002 curVariant = curSep + curVariant;
1005 if ( prevName.isEmpty() )
1011 if ( curName.isEmpty() )
1012 curName = QStringLiteral(
"__empty__" );
1014 if ( curName == prevName )
1017 if ( i == schemeNamesAll.count() - 1 )
1019 listVariant << curVariant;
1023 if ( !prevName.isEmpty() )
1028 if ( i == schemeNamesAll.count() - 1 )
1037 if ( listVariant.isEmpty() )
1041 schemeNames << prevName;
1044 else if ( listVariant.count() <= 3 )
1047 for (
int j = 0; j < listVariant.count(); j++ )
1050 schemeNames << prevName + listVariant[j];
1051 mRampsMap[
mPath +
'/' + prevName + listVariant[j] ] = QStringList();
1058 schemeNames << prevName;
1060 listVariant.clear();
1064 if ( !curVariant.isEmpty() )
1065 curName += curVariant;
1066 schemeNames << curName;
1070 if ( prevAdd || curAdd )
1073 if ( !curVariant.isEmpty() )
1074 listVariant << curVariant;
1081 mSchemeMap[
path ] = schemeNames;
1082 schemeCount += schemeName.count();
1083 schemeNames.clear();
1084 listVariant.clear();
1093 '/' +
mPath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
1103 return (
path() == other->
path() );
1107 const QString &
name,
const QString &
path )
1113 if ( dirItem && ! dirItem->
isValid() )
1158 const QString &
name,
const QString &
path )
1170 return QVector<QgsCptCityDataItem *>();
1173 QVector<QgsCptCityDataItem *>
children;
1180 QgsDebugMsgLevel(
"childPath = " + childPath +
" name= " + QFileInfo( childPath ).baseName(), 2 );
1181 if ( childPath.endsWith(
'/' ) )
1183 childPath.chop( 1 );
1197 if ( !QFile::exists( fileName ) )
1221 QFile f( filename );
1222 if ( ! f.open( QFile::ReadOnly ) )
1230 QDomDocument doc( QStringLiteral(
"selection" ) );
1231 if ( !doc.setContent( &f, &errMsg ) )
1234 QgsDebugError(
"Couldn't parse file " + filename +
" : " + errMsg );
1240 const QDomElement docElem = doc.documentElement();
1241 if ( docElem.tagName() != QLatin1String(
"selection" ) )
1243 QgsDebugError(
"Incorrect root tag: " + docElem.tagName() );
1246 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
1247 if ( ! e.isNull() && ! e.text().isNull() )
1249 mInfo = docElem.firstChildElement( QStringLiteral(
"synopsis" ) ).text().simplified();
1252 const QDomElement collectsElem = docElem.firstChildElement( QStringLiteral(
"seealsocollects" ) );
1253 e = collectsElem.firstChildElement( QStringLiteral(
"collect" ) );
1254 while ( ! e.isNull() )
1256 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1259 const QString dir = e.attribute( QStringLiteral(
"dir" ) ) +
'/';
1265 e = e.nextSiblingElement();
1268 const QDomElement gradientsElem = docElem.firstChildElement( QStringLiteral(
"gradients" ) );
1269 e = gradientsElem.firstChildElement( QStringLiteral(
"gradient" ) );
1270 while ( ! e.isNull() )
1272 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1276 const QString dir = e.attribute( QStringLiteral(
"dir" ) );
1279 mSelectionsList << dir +
'/' + e.attribute( QStringLiteral(
"file" ) );
1282 e = e.nextSiblingElement();
1293 return (
path() == other->
path() );
1298 const QString &
name,
const QVector<QgsCptCityDataItem *> &items )
1310 return QVector<QgsCptCityDataItem *>();
1312 QVector<QgsCptCityDataItem *>
children;
1315 const auto constMItems =
mItems;
1330 : QAbstractItemModel(
parent )
1335 QgsDebugMsgLevel( QLatin1String(
"archiveName = " ) + archive->
archiveName() +
" viewType=" + QString::number(
static_cast< int >( viewType ) ), 2 );
1366 if ( !
index.isValid() )
1367 return Qt::ItemFlags();
1369 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
1376 if ( !
index.isValid() )
1385 else if ( role == Qt::DisplayRole )
1387 if (
index.column() == 0 )
1388 return item->
name();
1389 if (
index.column() == 1 )
1391 return item->
info();
1394 else if ( role == Qt::ToolTipRole )
1398 return QString( item->
path() +
'\n' + item->
info() );
1401 else if ( role == Qt::DecorationRole &&
index.column() == 1 &&
1407 else if ( role == Qt::FontRole &&
1408 qobject_cast< QgsCptCityCollectionItem * >( item ) )
1412 font.setPointSize( 11 );
1413 font.setBold(
true );
1427 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
1430 return QVariant( tr(
"Name" ) );
1431 else if ( section == 1 )
1432 return QVariant( tr(
"Info" ) );
1450 return item ? item->
rowCount() : 0;
1472 QModelIndex rootIndex;
1473 bool foundParent =
false, foundChild =
true;
1479 if ( path.isEmpty() )
1481 for (
int i = 0; i <
rowCount( rootIndex ); i++ )
1483 QModelIndex idx =
index( i, 0, rootIndex );
1486 return QModelIndex();
1488 itemPath = item->
path();
1490 if ( itemPath == path )
1498 while ( foundChild )
1504 if ( itemPath.isEmpty() )
1506 for ( ; i <
rowCount( rootIndex ); i++ )
1508 QModelIndex idx =
index( i, 0, rootIndex );
1511 return QModelIndex();
1513 itemPath = item->
path();
1515 if ( itemPath == path )
1521 if ( ! itemPath.endsWith(
'/' ) )
1524 foundParent =
false;
1535 for ( QString childPath : constSelectionsList )
1537 if ( childPath.endsWith(
'/' ) )
1538 childPath.chop( 1 );
1540 if ( path.startsWith( childPath ) )
1549 else if ( path.startsWith( itemPath ) )
1567 return QModelIndex();
1581 const QModelIndex idx =
findPath( path );
1582 if ( idx.isValid() )
1595 return item ? createIndex( row, column, item ) : QModelIndex();
1602 return QModelIndex();
1611 for (
int i = 0; i < items.size(); i++ )
1613 if ( items[i] == item )
1614 return createIndex( i, 0, item );
1616 QModelIndex childIndex =
findItem( item, items[i] );
1617 if ( childIndex.isValid() )
1621 return QModelIndex();
1639 if ( !idx.isValid() )
1642 beginInsertRows( idx, first, last );
1653 if ( !idx.isValid() )
1655 beginRemoveRows( idx, first, last );
1699 void *v = idx.internalPointer();
1701 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)