18 #include <QApplication>
24 #include <QDomDocument>
25 #include <QDomElement>
27 #include "qgssettings.h"
32 #include "qgsconfig.h"
46 return *sArchiveRegistry();
50 : mArchiveName( archiveName )
57 const auto constEntryList = QDir( mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
58 for (
const QString &path : constEntryList )
60 if ( path == QLatin1String(
"selections" ) )
65 mRootItems << dirItem;
72 QDir seldir( mBaseDir +
'/' +
"selections" );
73 QgsDebugMsg(
"populating selection from " + seldir.path() );
74 const QStringList fileList = seldir.entryList( QStringList() << QStringLiteral(
"*.xml" ), QDir::Files );
75 for (
const QString &selfile : fileList )
77 QgsDebugMsg(
"file= " + seldir.path() +
'/' + selfile );
79 seldir.dirName() +
'/' + selfile );
82 mSelectionItems << selItem;
91 mRootItems.prepend( allRampsItem );
94 mSelectionItems.prepend( allRampsItem );
99 const auto constMRootItems = mRootItems;
102 const auto constMSelectionItems = mSelectionItems;
106 mSelectionItems.clear();
113 if ( ! mBaseDir.isNull() )
125 return archive->baseDir();
133 QgsSettings settings;
136 baseDir = settings.value( QStringLiteral(
"CptCity/baseDir" ),
149 if ( startDir.isEmpty() || ! startDir.startsWith(
baseDir ) )
152 QDir dir = QDir( startDir );
154 while ( ! dir.exists( target ) && dir.path() !=
baseDir )
159 if ( ! dir.exists( target ) )
162 return dir.path() +
'/' + target;
182 if ( fileName.isNull() )
185 if ( sCopyingInfoMap()->contains( fileName ) )
187 QgsDebugMsg(
"found copying info in copyingInfoMap, file = " + fileName );
188 return sCopyingInfoMap()->value( fileName );
195 if ( !f.open( QFile::ReadOnly ) )
197 QgsDebugMsg(
"Couldn't open xml file: " + fileName );
202 QDomDocument doc( QStringLiteral(
"license" ) );
203 if ( !doc.setContent( &f ) )
206 QgsDebugMsg(
"Couldn't parse xml file: " + fileName );
212 QDomElement docElem = doc.documentElement();
213 if ( docElem.tagName() != QLatin1String(
"copying" ) )
215 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
220 QDomElement authorsElement = docElem.firstChildElement( QStringLiteral(
"authors" ) );
221 if ( authorsElement.isNull() )
223 QgsDebugMsg( QStringLiteral(
"authors tag missing" ) );
227 QDomElement e = authorsElement.firstChildElement();
229 while ( ! e.isNull() )
231 if ( e.tagName() == QLatin1String(
"author" ) )
233 if ( ! e.firstChildElement( QStringLiteral(
"name" ) ).isNull() )
234 authors << e.firstChildElement( QStringLiteral(
"name" ) ).text().simplified();
237 e = e.nextSiblingElement();
239 copyingMap[ QStringLiteral(
"authors" )] = authors.join( QLatin1String(
", " ) );
243 QDomElement licenseElement = docElem.firstChildElement( QStringLiteral(
"license" ) );
244 if ( licenseElement.isNull() )
246 QgsDebugMsg( QStringLiteral(
"license tag missing" ) );
250 QDomElement e = licenseElement.firstChildElement( QStringLiteral(
"informal" ) );
252 copyingMap[ QStringLiteral(
"license/informal" )] = e.text().simplified();
253 e = licenseElement.firstChildElement( QStringLiteral(
"year" ) );
255 copyingMap[ QStringLiteral(
"license/year" )] = e.text().simplified();
256 e = licenseElement.firstChildElement( QStringLiteral(
"text" ) );
257 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
258 copyingMap[ QStringLiteral(
"license/url" )] = e.attribute( QStringLiteral(
"href" ) );
262 QDomElement element = docElem.firstChildElement( QStringLiteral(
"src" ) );
263 if ( element.isNull() )
265 QgsDebugMsg( QStringLiteral(
"src tag missing" ) );
269 QDomElement e = element.firstChildElement( QStringLiteral(
"link" ) );
270 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
271 copyingMap[ QStringLiteral(
"src/link" )] = e.attribute( QStringLiteral(
"href" ) );
275 ( *sCopyingInfoMap() )[ fileName ] = copyingMap;
283 QgsDebugMsg(
"description fileName = " + fileName );
286 if ( ! f.open( QFile::ReadOnly ) )
288 QgsDebugMsg(
"description file " + fileName +
" ] does not exist" );
294 QDomDocument doc( QStringLiteral(
"description" ) );
295 if ( !doc.setContent( &f, &errMsg ) )
298 QgsDebugMsg(
"Couldn't parse file " + fileName +
" : " + errMsg );
304 QDomElement docElem = doc.documentElement();
305 if ( docElem.tagName() != QLatin1String(
"description" ) )
307 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
312 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
315 QgsDebugMsg( QStringLiteral(
"name tag missing" ) );
317 descMap[ QStringLiteral(
"name" )] = e.text().simplified();
318 e = docElem.firstChildElement( QStringLiteral(
"full" ) );
321 QgsDebugMsg( QStringLiteral(
"full tag missing" ) );
323 descMap[ QStringLiteral(
"full" )] = e.text().simplified();
330 QMap< double, QPair<QColor, QColor> > colorMap;
334 if ( !f.open( QFile::ReadOnly ) )
336 QgsDebugMsg(
"Couldn't open SVG file: " + fileName );
341 QDomDocument doc( QStringLiteral(
"gradient" ) );
342 if ( !doc.setContent( &f ) )
345 QgsDebugMsg(
"Couldn't parse SVG file: " + fileName );
350 QDomElement docElem = doc.documentElement();
352 if ( docElem.tagName() != QLatin1String(
"svg" ) )
354 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
359 QDomElement rampsElement = docElem.firstChildElement( QStringLiteral(
"linearGradient" ) );
360 if ( rampsElement.isNull() )
362 QDomNodeList nodeList = docElem.elementsByTagName( QStringLiteral(
"linearGradient" ) );
363 if ( ! nodeList.isEmpty() )
364 rampsElement = nodeList.at( 0 ).toElement();
366 if ( rampsElement.isNull() )
368 QgsDebugMsg( QStringLiteral(
"linearGradient tag missing" ) );
373 QDomElement e = rampsElement.firstChildElement();
375 while ( !e.isNull() )
377 if ( e.tagName() == QLatin1String(
"stop" ) )
381 QString offsetStr = e.attribute( QStringLiteral(
"offset" ) );
382 QString colorStr = e.attribute( QStringLiteral(
"stop-color" ), QString() );
383 QString opacityStr = e.attribute( QStringLiteral(
"stop-opacity" ), QStringLiteral(
"1.0" ) );
384 if ( offsetStr.endsWith(
'%' ) )
385 offset = offsetStr.remove( offsetStr.size() - 1, 1 ).toDouble() / 100.0;
387 offset = offsetStr.toDouble();
391 if ( color != QColor() )
393 int alpha = opacityStr.toDouble() * 255;
394 color.setAlpha( alpha );
395 if ( colorMap.contains( offset ) )
396 colorMap[offset].second = color;
398 colorMap[offset] = qMakePair( color, color );
402 QgsDebugMsg( QStringLiteral(
"at offset=%1 invalid color" ).arg( offset ) );
410 e = e.nextSiblingElement();
418 return ( mRootItems.isEmpty() );
424 QgsSettings settings;
425 *sDefaultArchiveName() = settings.value( QStringLiteral(
"CptCity/archiveName" ),
DEFAULT_CPTCITY_ARCHIVE ).toString();
426 if ( sArchiveRegistry()->contains( *sDefaultArchiveName() ) )
427 return sArchiveRegistry()->value( *sDefaultArchiveName() );
443 QgsSettings settings;
445 QString
baseDir = settings.value( QStringLiteral(
"CptCity/baseDir" ),
448 QString defArchiveName = settings.value( QStringLiteral(
"CptCity/archiveName" ),
DEFAULT_CPTCITY_ARCHIVE ).toString();
450 if ( ! sArchiveRegistry()->contains( defArchiveName ) )
457 QString
baseDir, defArchiveName;
458 QgsSettings settings;
461 baseDir = settings.value( QStringLiteral(
"CptCity/baseDir" ),
464 defArchiveName = settings.value( QStringLiteral(
"CptCity/archiveName" ),
DEFAULT_CPTCITY_ARCHIVE ).toString();
470 const QStringList fileList = dir.entryList( QStringList() << QStringLiteral(
"cpt-city*" ), QDir::Dirs );
471 for (
const QString &entry : fileList )
473 if ( QFile::exists(
baseDir +
'/' + entry +
"/VERSION.xml" ) )
474 archivesMap[ entry ] =
baseDir +
'/' + entry;
479 archivesMap[ defArchiveName ] =
baseDir +
'/' + defArchiveName;
482 for ( QgsStringMap::iterator it = archivesMap.begin();
483 it != archivesMap.end(); ++it )
485 if ( QDir( it.value() ).exists() )
489 QgsDebugMsg( QStringLiteral(
"not loading archive [%1] because dir %2 does not exist " ).arg( it.key(), it.value() ) );
492 *sDefaultArchiveName() = defArchiveName;
497 qDeleteAll( *sArchiveRegistry() );
498 sArchiveRegistry()->clear();
505 const QString &name,
const QString &path )
509 , mPopulated( false )
518 QVector<QgsCptCityDataItem *>
children;
529 QApplication::setOverrideCursor( Qt::WaitCursor );
532 const auto constChildren =
children;
540 QApplication::restoreOverrideCursor();
560 count += child->leafCount();
582 mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
590 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
637 for (
int i = 0; i < items.size(); i++ )
640 if ( items[i]->
equal( item ) )
650 QApplication::setOverrideCursor( Qt::WaitCursor );
655 QVector<QgsCptCityDataItem *> remove;
659 if (
findItem( items, child ) >= 0 )
661 remove.append( child );
663 const auto constRemove = remove;
670 const auto constItems = items;
682 QApplication::restoreOverrideCursor();
687 return ( metaObject()->className() == other->metaObject()->className() &&
694 const QString &name,
const QString &path,
const QString &variantName,
bool initialize )
696 , mInitialized( false )
697 , mRamp( path, variantName, false )
706 const QString &name,
const QString &path,
const QStringList &variantList,
bool initialize )
708 , mInitialized( false )
709 , mRamp( path, variantList, QString(), false )
742 if ( variantList.isEmpty() )
747 mInfo = QString::number( count ) +
' ' + tr(
"colors" ) +
" - ";
749 mInfo += tr(
"discrete" );
753 mInfo += tr(
"continuous" );
755 mInfo += tr(
"continuous (multi)" );
761 mInfo = QString::number( variantList.count() ) +
' ' + tr(
"variants" );
790 return icon( QSize( 100, 15 ) );
795 const auto constMIcons =
mIcons;
796 for (
const QIcon &
icon : constMIcons )
798 if (
icon.availableSizes().contains( size ) )
812 QPixmap blankPixmap( size );
813 blankPixmap.fill( Qt::white );
814 icon = QIcon( blankPixmap );
824 const QString &name,
const QString &path )
826 , mPopulatedRamps( false )
837 QVector< QgsCptCityDataItem * > rampItems;
838 QVector< QgsCptCityDataItem * > deleteItems;
843 const auto constChildren =
children();
848 QgsDebugMsgLevel( QStringLiteral(
"child path= %1 coll= %2 ramp = %3" ).arg( childItem->path() ).arg(
nullptr != collectionItem ).arg(
nullptr != rampItem ), 2 );
849 if ( collectionItem && recursive )
859 rampItems << rampItem;
861 deleteItems << rampItem;
865 QgsDebugMsg(
"invalid item " + childItem->path() );
870 const auto constDeleteItems = deleteItems;
873 QgsDebugMsg( QStringLiteral(
"item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
885 const QString &name,
const QString &path )
899 mPath +
'/' +
"DESC.xml";
901 if ( descMap.contains( QStringLiteral(
"name" ) ) )
902 mInfo = descMap.value( QStringLiteral(
"name" ) );
910 return QVector<QgsCptCityDataItem *>();
912 QVector<QgsCptCityDataItem *>
children;
915 QMapIterator< QString, QStringList> it(
rampsMap() );
916 while ( it.hasNext() )
930 for (
const QString &childPath : constDirEntries )
948 QString curName, prevName, curVariant, curSep, schemeName;
949 QStringList listVariant;
950 QStringList schemeNamesAll, schemeNames;
951 bool prevAdd, curAdd;
954 schemeNamesAll = dir.entryList( QStringList( QStringLiteral(
"*.svg" ) ), QDir::Files, QDir::Name );
957 for (
int i = 0; i < schemeNamesAll.count(); i++ )
960 schemeName = schemeNamesAll[i];
961 schemeName.chop( 4 );
964 curName = schemeName;
969 if ( schemeName.length() > 1 && schemeName.endsWith(
'a' ) && ! listVariant.isEmpty() &&
970 ( ( prevName + listVariant.last() +
'a' ) == curName ) )
973 curVariant = listVariant.last() +
'a';
977 QRegExp rxVariant(
"^(.*[^\\d])(\\d{1,3})$" );
978 int pos = rxVariant.indexIn( schemeName );
981 curName = rxVariant.cap( 1 );
982 curVariant = rxVariant.cap( 2 );
986 curSep = curName.right( 1 );
987 if ( curSep == QLatin1String(
"-" ) || curSep == QLatin1String(
"_" ) )
990 curVariant = curSep + curVariant;
993 if ( prevName.isEmpty() )
999 if ( curName.isEmpty() )
1000 curName = QStringLiteral(
"__empty__" );
1002 if ( curName == prevName )
1005 if ( i == schemeNamesAll.count() - 1 )
1007 listVariant << curVariant;
1011 if ( !prevName.isEmpty() )
1016 if ( i == schemeNamesAll.count() - 1 )
1025 if ( listVariant.isEmpty() )
1029 schemeNames << prevName;
1032 else if ( listVariant.count() <= 3 )
1035 for (
int j = 0; j < listVariant.count(); j++ )
1038 schemeNames << prevName + listVariant[j];
1039 mRampsMap[
mPath +
'/' + prevName + listVariant[j] ] = QStringList();
1046 schemeNames << prevName;
1048 listVariant.clear();
1052 if ( !curVariant.isEmpty() )
1053 curName += curVariant;
1054 schemeNames << curName;
1058 if ( prevAdd || curAdd )
1061 if ( !curVariant.isEmpty() )
1062 listVariant << curVariant;
1069 mSchemeMap[
path ] = schemeNames;
1070 schemeCount += schemeName.count();
1071 schemeNames.clear();
1072 listVariant.clear();
1081 '/' +
mPath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
1091 return (
path() == other->
path() );
1095 const QString &name,
const QString &path )
1101 if ( dirItem && ! dirItem->
isValid() )
1146 const QString &name,
const QString &path )
1158 return QVector<QgsCptCityDataItem *>();
1161 QVector<QgsCptCityDataItem *>
children;
1167 for ( QString childPath : constMSelectionsList )
1169 QgsDebugMsg(
"childPath = " + childPath +
" name= " + QFileInfo( childPath ).baseName() );
1170 if ( childPath.endsWith(
'/' ) )
1172 childPath.chop( 1 );
1205 QFile f( filename );
1206 if ( ! f.open( QFile::ReadOnly ) )
1214 QDomDocument doc( QStringLiteral(
"selection" ) );
1215 if ( !doc.setContent( &f, &errMsg ) )
1218 QgsDebugMsg(
"Couldn't parse file " + filename +
" : " + errMsg );
1224 QDomElement docElem = doc.documentElement();
1225 if ( docElem.tagName() != QLatin1String(
"selection" ) )
1227 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
1230 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
1231 if ( ! e.isNull() && ! e.text().isNull() )
1233 mInfo = docElem.firstChildElement( QStringLiteral(
"synopsis" ) ).text().simplified();
1236 QDomElement collectsElem = docElem.firstChildElement( QStringLiteral(
"seealsocollects" ) );
1237 e = collectsElem.firstChildElement( QStringLiteral(
"collect" ) );
1238 while ( ! e.isNull() )
1240 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1245 e = e.nextSiblingElement();
1248 QDomElement gradientsElem = docElem.firstChildElement( QStringLiteral(
"gradients" ) );
1249 e = gradientsElem.firstChildElement( QStringLiteral(
"gradient" ) );
1250 while ( ! e.isNull() )
1252 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1256 mSelectionsList << e.attribute( QStringLiteral(
"dir" ) ) +
'/' + e.attribute( QStringLiteral(
"file" ) );
1258 e = e.nextSiblingElement();
1269 return (
path() == other->
path() );
1274 const QString &name,
const QVector<QgsCptCityDataItem *> &items )
1286 return QVector<QgsCptCityDataItem *>();
1288 QVector<QgsCptCityDataItem *>
children;
1291 const auto constMItems =
mItems;
1306 : QAbstractItemModel( parent )
1307 , mArchive( archive )
1308 , mViewType( viewType )
1311 QgsDebugMsg( QLatin1String(
"archiveName = " ) + archive->
archiveName() +
" viewType=" + QString::number(
static_cast< int >( viewType ) ) );
1342 if ( !
index.isValid() )
1343 return Qt::ItemFlags();
1345 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
1352 if ( !
index.isValid() )
1361 else if ( role == Qt::DisplayRole )
1363 if (
index.column() == 0 )
1364 return item->
name();
1365 if (
index.column() == 1 )
1367 return item->
info();
1370 else if ( role == Qt::ToolTipRole )
1374 return QString( item->
path() +
'\n' + item->
info() );
1377 else if ( role == Qt::DecorationRole &&
index.column() == 1 &&
1383 else if ( role == Qt::FontRole &&
1384 qobject_cast< QgsCptCityCollectionItem * >( item ) )
1388 font.setPointSize( 11 );
1389 font.setBold(
true );
1403 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
1406 return QVariant( tr(
"Name" ) );
1407 else if ( section == 1 )
1408 return QVariant( tr(
"Info" ) );
1426 return item ? item->
rowCount() : 0;
1448 QModelIndex rootIndex;
1449 bool foundParent =
false, foundChild =
true;
1455 if ( path.isEmpty() )
1457 for (
int i = 0; i <
rowCount( rootIndex ); i++ )
1459 QModelIndex idx =
index( i, 0, rootIndex );
1462 return QModelIndex();
1464 itemPath = item->
path();
1466 if ( itemPath == path )
1474 while ( foundChild )
1480 if ( itemPath.isEmpty() )
1482 for ( ; i <
rowCount( rootIndex ); i++ )
1484 QModelIndex idx =
index( i, 0, rootIndex );
1487 return QModelIndex();
1489 itemPath = item->
path();
1491 if ( itemPath == path )
1497 if ( ! itemPath.endsWith(
'/' ) )
1500 foundParent =
false;
1511 for ( QString childPath : constSelectionsList )
1513 if ( childPath.endsWith(
'/' ) )
1514 childPath.chop( 1 );
1516 if ( path.startsWith( childPath ) )
1525 else if ( path.startsWith( itemPath ) )
1543 return QModelIndex();
1557 QModelIndex idx =
findPath( path );
1558 if ( idx.isValid() )
1571 return item ? createIndex( row, column, item ) : QModelIndex();
1578 return QModelIndex();
1587 for (
int i = 0; i < items.size(); i++ )
1589 if ( items[i] == item )
1590 return createIndex( i, 0, item );
1592 QModelIndex childIndex =
findItem( item, items[i] );
1593 if ( childIndex.isValid() )
1597 return QModelIndex();
1615 if ( !idx.isValid() )
1618 beginInsertRows( idx, first, last );
1629 if ( !idx.isValid() )
1631 beginRemoveRows( idx, first, last );
1675 QStringList QgsCptCityBrowserModel::mimeTypes()
const
1680 types <<
"application/x-vnd.qgis.qgis.uri";
1684 QMimeData *QgsCptCityBrowserModel::mimeData(
const QModelIndexList &indexes )
const
1687 const auto constIndexes = indexes;
1688 for (
const QModelIndex &
index : constIndexes )
1690 if (
index.isValid() )
1693 if ( ptr->
type() != QgsCptCityDataItem::Layer )
continue;
1701 bool QgsCptCityBrowserModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
1719 void *v = idx.internalPointer();
1721 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
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
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)
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 a list of mime that can describe model indexes.
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.
bool equal(const QgsCptCityDataItem *other) override
QgsCptCityColorRampItem(QgsCptCityDataItem *parent, const QString &name, const QString &path, const QString &variantName=QString(), bool initialize=false)
QgsCptCityColorRamp mRamp
const QgsCptCityColorRamp & ramp() const
QStringList variantList() const
void setVariantName(const QString &variantName)
bool hasMultiStops() const
QString variantName() const
Base class for all items in the model.
virtual void addChildItem(QgsCptCityDataItem *child, bool refresh=false)
void beginRemoveItems(QgsCptCityDataItem *parent, int first, int last)
virtual QVector< QgsCptCityDataItem * > createChildren()
virtual QgsCptCityDataItem * removeChildItem(QgsCptCityDataItem *child)
QVector< QgsCptCityDataItem * > children() const
static int findItem(QVector< QgsCptCityDataItem * > items, QgsCptCityDataItem *item)
QVector< QgsCptCityDataItem * > mChildren
void setParent(QgsCptCityDataItem *parent)
virtual void deleteChildItem(QgsCptCityDataItem *child)
virtual bool equal(const QgsCptCityDataItem *other)
QgsCptCityDataItem(QgsCptCityDataItem::Type type, QgsCptCityDataItem *parent, const QString &name, const QString &path)
void beginInsertItems(QgsCptCityDataItem *parent, int first, int last)
QgsCptCityDataItem * parent() const
virtual int leafCount() const
virtual bool handleDrop(const QMimeData *, Qt::DropAction)
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
QgsCptCityDirectoryItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
QMap< QString, QStringList > mRampsMap
bool equal(const QgsCptCityDataItem *other) override
QMap< QString, QStringList > rampsMap()
A selection: contains subdirectories and color ramps.
QVector< QgsCptCityDataItem * > createChildren() override
QgsCptCitySelectionItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
bool equal(const QgsCptCityDataItem *other) override
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.
Item that represents a layer that can be opened with one of the providers.
QList< QgsMimeDataUtils::Uri > UriList
static QMimeData * encodeUriList(const UriList &layers)
Encodes a URI list to a new QMimeData object.
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)