23 #include "qgsconfig.h"
28 #include <QApplication>
34 #include <QDomDocument>
35 #include <QDomElement>
36 #include <QRegularExpression>
47 return *sArchiveRegistry();
51 : mArchiveName( archiveName )
58 const auto constEntryList = QDir( mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
59 for (
const QString &path : constEntryList )
61 if ( path == QLatin1String(
"selections" ) )
66 mRootItems << dirItem;
73 const QDir seldir( mBaseDir +
'/' +
"selections" );
74 QgsDebugMsg(
"populating selection from " + seldir.path() );
75 const QStringList fileList = seldir.entryList( QStringList() << QStringLiteral(
"*.xml" ), QDir::Files );
76 for (
const QString &selfile : fileList )
78 QgsDebugMsg(
"file= " + seldir.path() +
'/' + selfile );
80 seldir.dirName() +
'/' + selfile );
83 mSelectionItems << selItem;
92 mRootItems.prepend( allRampsItem );
95 mSelectionItems.prepend( allRampsItem );
100 const auto constMRootItems = mRootItems;
103 const auto constMSelectionItems = mSelectionItems;
107 mSelectionItems.clear();
114 if ( ! mBaseDir.isNull() )
126 return archive->baseDir();
137 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
150 if ( startDir.isEmpty() || ! startDir.startsWith(
baseDir ) )
153 QDir dir = QDir( startDir );
155 while ( ! dir.exists( target ) && dir.path() !=
baseDir )
160 if ( ! dir.exists( target ) )
163 return dir.path() +
'/' + target;
183 if ( fileName.isNull() )
186 if ( sCopyingInfoMap()->contains( fileName ) )
188 QgsDebugMsg(
"found copying info in copyingInfoMap, file = " + fileName );
189 return sCopyingInfoMap()->value( fileName );
196 if ( !f.open( QFile::ReadOnly ) )
198 QgsDebugMsg(
"Couldn't open xml file: " + fileName );
203 QDomDocument doc( QStringLiteral(
"license" ) );
204 if ( !doc.setContent( &f ) )
207 QgsDebugMsg(
"Couldn't parse xml file: " + fileName );
213 const QDomElement docElem = doc.documentElement();
214 if ( docElem.tagName() != QLatin1String(
"copying" ) )
216 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
221 const QDomElement authorsElement = docElem.firstChildElement( QStringLiteral(
"authors" ) );
222 if ( authorsElement.isNull() )
224 QgsDebugMsg( QStringLiteral(
"authors tag missing" ) );
228 QDomElement e = authorsElement.firstChildElement();
230 while ( ! e.isNull() )
232 if ( e.tagName() == QLatin1String(
"author" ) )
234 if ( ! e.firstChildElement( QStringLiteral(
"name" ) ).isNull() )
235 authors << e.firstChildElement( QStringLiteral(
"name" ) ).text().simplified();
238 e = e.nextSiblingElement();
240 copyingMap[ QStringLiteral(
"authors" )] = authors.join( QLatin1String(
", " ) );
244 const QDomElement licenseElement = docElem.firstChildElement( QStringLiteral(
"license" ) );
245 if ( licenseElement.isNull() )
247 QgsDebugMsg( QStringLiteral(
"license tag missing" ) );
251 QDomElement e = licenseElement.firstChildElement( QStringLiteral(
"informal" ) );
253 copyingMap[ QStringLiteral(
"license/informal" )] = e.text().simplified();
254 e = licenseElement.firstChildElement( QStringLiteral(
"year" ) );
256 copyingMap[ QStringLiteral(
"license/year" )] = e.text().simplified();
257 e = licenseElement.firstChildElement( QStringLiteral(
"text" ) );
258 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
259 copyingMap[ QStringLiteral(
"license/url" )] = e.attribute( QStringLiteral(
"href" ) );
263 const QDomElement element = docElem.firstChildElement( QStringLiteral(
"src" ) );
264 if ( element.isNull() )
266 QgsDebugMsg( QStringLiteral(
"src tag missing" ) );
270 const QDomElement e = element.firstChildElement( QStringLiteral(
"link" ) );
271 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
272 copyingMap[ QStringLiteral(
"src/link" )] = e.attribute( QStringLiteral(
"href" ) );
276 ( *sCopyingInfoMap() )[ fileName ] = copyingMap;
284 QgsDebugMsg(
"description fileName = " + fileName );
287 if ( ! f.open( QFile::ReadOnly ) )
289 QgsDebugMsg(
"description file " + fileName +
" ] does not exist" );
295 QDomDocument doc( QStringLiteral(
"description" ) );
296 if ( !doc.setContent( &f, &errMsg ) )
299 QgsDebugMsg(
"Couldn't parse file " + fileName +
" : " + errMsg );
305 const QDomElement docElem = doc.documentElement();
306 if ( docElem.tagName() != QLatin1String(
"description" ) )
308 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
313 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
316 QgsDebugMsg( QStringLiteral(
"name tag missing" ) );
318 descMap[ QStringLiteral(
"name" )] = e.text().simplified();
319 e = docElem.firstChildElement( QStringLiteral(
"full" ) );
322 QgsDebugMsg( QStringLiteral(
"full tag missing" ) );
324 descMap[ QStringLiteral(
"full" )] = e.text().simplified();
331 QMap< double, QPair<QColor, QColor> > colorMap;
335 if ( !f.open( QFile::ReadOnly ) )
337 QgsDebugMsg(
"Couldn't open SVG file: " + fileName );
342 QDomDocument doc( QStringLiteral(
"gradient" ) );
343 if ( !doc.setContent( &f ) )
346 QgsDebugMsg(
"Couldn't parse SVG file: " + fileName );
351 const QDomElement docElem = doc.documentElement();
353 if ( docElem.tagName() != QLatin1String(
"svg" ) )
355 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
360 QDomElement rampsElement = docElem.firstChildElement( QStringLiteral(
"linearGradient" ) );
361 if ( rampsElement.isNull() )
363 const QDomNodeList nodeList = docElem.elementsByTagName( QStringLiteral(
"linearGradient" ) );
364 if ( ! nodeList.isEmpty() )
365 rampsElement = nodeList.at( 0 ).toElement();
367 if ( rampsElement.isNull() )
369 QgsDebugMsg( QStringLiteral(
"linearGradient tag missing" ) );
374 QDomElement e = rampsElement.firstChildElement();
376 while ( !e.isNull() )
378 if ( e.tagName() == QLatin1String(
"stop" ) )
382 QString offsetStr = e.attribute( QStringLiteral(
"offset" ) );
383 const QString colorStr = e.attribute( QStringLiteral(
"stop-color" ), QString() );
384 const QString opacityStr = e.attribute( QStringLiteral(
"stop-opacity" ), QStringLiteral(
"1.0" ) );
385 if ( offsetStr.endsWith(
'%' ) )
386 offset = offsetStr.remove( offsetStr.size() - 1, 1 ).toDouble() / 100.0;
388 offset = offsetStr.toDouble();
392 if ( color != QColor() )
394 const int alpha = opacityStr.toDouble() * 255;
395 color.setAlpha( alpha );
396 if ( colorMap.contains( offset ) )
397 colorMap[offset].second = color;
399 colorMap[offset] = qMakePair( color, color );
403 QgsDebugMsg( QStringLiteral(
"at offset=%1 invalid color" ).arg( offset ) );
411 e = e.nextSiblingElement();
419 return ( mRootItems.isEmpty() );
427 if ( sArchiveRegistry()->contains( *sDefaultArchiveName() ) )
428 return sArchiveRegistry()->value( *sDefaultArchiveName() );
446 const QString
baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
451 if ( ! sArchiveRegistry()->contains( defArchiveName ) )
458 QString
baseDir, defArchiveName;
462 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
471 const QStringList fileList = dir.entryList( QStringList() << QStringLiteral(
"cpt-city*" ), QDir::Dirs );
472 for (
const QString &entry : fileList )
474 if ( QFile::exists(
baseDir +
'/' + entry +
"/VERSION.xml" ) )
475 archivesMap[ entry ] =
baseDir +
'/' + entry;
480 archivesMap[ defArchiveName ] =
baseDir +
'/' + defArchiveName;
483 for ( QgsStringMap::iterator it = archivesMap.begin();
484 it != archivesMap.end(); ++it )
486 if ( QDir( it.value() ).exists() )
490 QgsDebugMsg( QStringLiteral(
"not loading archive [%1] because dir %2 does not exist " ).arg( it.key(), it.value() ) );
493 *sDefaultArchiveName() = defArchiveName;
498 qDeleteAll( *sArchiveRegistry() );
499 sArchiveRegistry()->clear();
506 const QString &name,
const QString &path )
510 , mPopulated( false )
519 QVector<QgsCptCityDataItem *>
children;
530 QApplication::setOverrideCursor( Qt::WaitCursor );
533 const auto constChildren =
children;
541 QApplication::restoreOverrideCursor();
561 count += child->leafCount();
583 mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
591 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
612 const int i =
mChildren.indexOf( child );
623 const int i =
mChildren.indexOf( child );
638 for (
int i = 0; i < items.size(); i++ )
641 if ( items[i]->
equal( item ) )
651 QApplication::setOverrideCursor( Qt::WaitCursor );
656 QVector<QgsCptCityDataItem *> remove;
660 if (
findItem( items, child ) >= 0 )
662 remove.append( child );
664 const auto constRemove = remove;
671 const auto constItems = items;
683 QApplication::restoreOverrideCursor();
688 return ( metaObject()->className() == other->metaObject()->className() &&
695 const QString &name,
const QString &path,
const QString &variantName,
bool initialize )
697 , mInitialized( false )
698 , mRamp( path, variantName, false )
707 const QString &name,
const QString &path,
const QStringList &variantList,
bool initialize )
709 , mInitialized( false )
710 , mRamp( path, variantList, QString(), false )
743 if ( variantList.isEmpty() )
748 mInfo = QString::number( count ) +
' ' + tr(
"colors" ) +
" - ";
750 mInfo += tr(
"discrete" );
754 mInfo += tr(
"continuous" );
756 mInfo += tr(
"continuous (multi)" );
762 mInfo = QString::number( variantList.count() ) +
' ' + tr(
"variants" );
791 return icon( QSize( 100, 15 ) );
796 const auto constMIcons =
mIcons;
797 for (
const QIcon &
icon : constMIcons )
799 if (
icon.availableSizes().contains( size ) )
813 QPixmap blankPixmap( size );
814 blankPixmap.fill( Qt::white );
815 icon = QIcon( blankPixmap );
825 const QString &name,
const QString &path )
827 , mPopulatedRamps( false )
838 QVector< QgsCptCityDataItem * > rampItems;
839 QVector< QgsCptCityDataItem * > deleteItems;
844 const auto constChildren =
children();
849 QgsDebugMsgLevel( QStringLiteral(
"child path= %1 coll= %2 ramp = %3" ).arg( childItem->path() ).arg(
nullptr != collectionItem ).arg(
nullptr != rampItem ), 2 );
850 if ( collectionItem && recursive )
860 rampItems << rampItem;
862 deleteItems << rampItem;
866 QgsDebugMsg(
"invalid item " + childItem->path() );
871 const auto constDeleteItems = deleteItems;
874 QgsDebugMsg( QStringLiteral(
"item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
875 const int i =
mChildren.indexOf( deleteItem );
886 const QString &name,
const QString &path )
900 mPath +
'/' +
"DESC.xml";
902 if ( descMap.contains( QStringLiteral(
"name" ) ) )
903 mInfo = descMap.value( QStringLiteral(
"name" ) );
911 return QVector<QgsCptCityDataItem *>();
913 QVector<QgsCptCityDataItem *>
children;
916 QMapIterator< QString, QStringList> it(
rampsMap() );
917 while ( it.hasNext() )
931 for (
const QString &childPath : constDirEntries )
949 QString curName, prevName, curVariant, curSep, schemeName;
950 QStringList listVariant;
951 QStringList schemeNamesAll, schemeNames;
952 bool prevAdd, curAdd;
955 schemeNamesAll = dir.entryList( QStringList( QStringLiteral(
"*.svg" ) ), QDir::Files, QDir::Name );
958 for (
int i = 0; i < schemeNamesAll.count(); i++ )
961 schemeName = schemeNamesAll[i];
962 schemeName.chop( 4 );
965 curName = schemeName;
970 if ( schemeName.length() > 1 && schemeName.endsWith(
'a' ) && ! listVariant.isEmpty() &&
971 ( ( prevName + listVariant.last() +
'a' ) == curName ) )
974 curVariant = listVariant.last() +
'a';
978 const thread_local QRegularExpression rxVariant(
"^(.*[^\\d])(\\d{1,3})$" );
979 const QRegularExpressionMatch match = rxVariant.match( schemeName );
980 if ( match.hasMatch() )
982 curName = match.captured( 1 );
983 curVariant = match.captured( 2 );
987 curSep = curName.right( 1 );
988 if ( curSep == QLatin1String(
"-" ) || curSep == QLatin1String(
"_" ) )
991 curVariant = curSep + curVariant;
994 if ( prevName.isEmpty() )
1000 if ( curName.isEmpty() )
1001 curName = QStringLiteral(
"__empty__" );
1003 if ( curName == prevName )
1006 if ( i == schemeNamesAll.count() - 1 )
1008 listVariant << curVariant;
1012 if ( !prevName.isEmpty() )
1017 if ( i == schemeNamesAll.count() - 1 )
1026 if ( listVariant.isEmpty() )
1030 schemeNames << prevName;
1033 else if ( listVariant.count() <= 3 )
1036 for (
int j = 0; j < listVariant.count(); j++ )
1039 schemeNames << prevName + listVariant[j];
1040 mRampsMap[
mPath +
'/' + prevName + listVariant[j] ] = QStringList();
1047 schemeNames << prevName;
1049 listVariant.clear();
1053 if ( !curVariant.isEmpty() )
1054 curName += curVariant;
1055 schemeNames << curName;
1059 if ( prevAdd || curAdd )
1062 if ( !curVariant.isEmpty() )
1063 listVariant << curVariant;
1070 mSchemeMap[
path ] = schemeNames;
1071 schemeCount += schemeName.count();
1072 schemeNames.clear();
1073 listVariant.clear();
1082 '/' +
mPath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
1092 return (
path() == other->
path() );
1096 const QString &name,
const QString &path )
1102 if ( dirItem && ! dirItem->
isValid() )
1147 const QString &name,
const QString &path )
1159 return QVector<QgsCptCityDataItem *>();
1162 QVector<QgsCptCityDataItem *>
children;
1168 for ( QString childPath : constMSelectionsList )
1170 QgsDebugMsg(
"childPath = " + childPath +
" name= " + QFileInfo( childPath ).baseName() );
1171 if ( childPath.endsWith(
'/' ) )
1173 childPath.chop( 1 );
1206 QFile f( filename );
1207 if ( ! f.open( QFile::ReadOnly ) )
1215 QDomDocument doc( QStringLiteral(
"selection" ) );
1216 if ( !doc.setContent( &f, &errMsg ) )
1219 QgsDebugMsg(
"Couldn't parse file " + filename +
" : " + errMsg );
1225 const QDomElement docElem = doc.documentElement();
1226 if ( docElem.tagName() != QLatin1String(
"selection" ) )
1228 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
1231 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
1232 if ( ! e.isNull() && ! e.text().isNull() )
1234 mInfo = docElem.firstChildElement( QStringLiteral(
"synopsis" ) ).text().simplified();
1237 const QDomElement collectsElem = docElem.firstChildElement( QStringLiteral(
"seealsocollects" ) );
1238 e = collectsElem.firstChildElement( QStringLiteral(
"collect" ) );
1239 while ( ! e.isNull() )
1241 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1246 e = e.nextSiblingElement();
1249 const QDomElement gradientsElem = docElem.firstChildElement( QStringLiteral(
"gradients" ) );
1250 e = gradientsElem.firstChildElement( QStringLiteral(
"gradient" ) );
1251 while ( ! e.isNull() )
1253 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1257 mSelectionsList << e.attribute( QStringLiteral(
"dir" ) ) +
'/' + e.attribute( QStringLiteral(
"file" ) );
1259 e = e.nextSiblingElement();
1270 return (
path() == other->
path() );
1275 const QString &name,
const QVector<QgsCptCityDataItem *> &items )
1287 return QVector<QgsCptCityDataItem *>();
1289 QVector<QgsCptCityDataItem *>
children;
1292 const auto constMItems =
mItems;
1307 : QAbstractItemModel( parent )
1308 , mArchive( archive )
1309 , mViewType( viewType )
1312 QgsDebugMsg( QLatin1String(
"archiveName = " ) + archive->
archiveName() +
" viewType=" + QString::number(
static_cast< int >( viewType ) ) );
1343 if ( !
index.isValid() )
1344 return Qt::ItemFlags();
1346 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
1353 if ( !
index.isValid() )
1362 else if ( role == Qt::DisplayRole )
1364 if (
index.column() == 0 )
1365 return item->
name();
1366 if (
index.column() == 1 )
1368 return item->
info();
1371 else if ( role == Qt::ToolTipRole )
1375 return QString( item->
path() +
'\n' + item->
info() );
1378 else if ( role == Qt::DecorationRole &&
index.column() == 1 &&
1384 else if ( role == Qt::FontRole &&
1385 qobject_cast< QgsCptCityCollectionItem * >( item ) )
1389 font.setPointSize( 11 );
1390 font.setBold(
true );
1404 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
1407 return QVariant( tr(
"Name" ) );
1408 else if ( section == 1 )
1409 return QVariant( tr(
"Info" ) );
1427 return item ? item->
rowCount() : 0;
1449 QModelIndex rootIndex;
1450 bool foundParent =
false, foundChild =
true;
1456 if ( path.isEmpty() )
1458 for (
int i = 0; i <
rowCount( rootIndex ); i++ )
1460 QModelIndex idx =
index( i, 0, rootIndex );
1463 return QModelIndex();
1465 itemPath = item->
path();
1467 if ( itemPath == path )
1475 while ( foundChild )
1481 if ( itemPath.isEmpty() )
1483 for ( ; i <
rowCount( rootIndex ); i++ )
1485 QModelIndex idx =
index( i, 0, rootIndex );
1488 return QModelIndex();
1490 itemPath = item->
path();
1492 if ( itemPath == path )
1498 if ( ! itemPath.endsWith(
'/' ) )
1501 foundParent =
false;
1512 for ( QString childPath : constSelectionsList )
1514 if ( childPath.endsWith(
'/' ) )
1515 childPath.chop( 1 );
1517 if ( path.startsWith( childPath ) )
1526 else if ( path.startsWith( itemPath ) )
1544 return QModelIndex();
1558 const QModelIndex idx =
findPath( path );
1559 if ( idx.isValid() )
1572 return item ? createIndex( row, column, item ) : QModelIndex();
1579 return QModelIndex();
1588 for (
int i = 0; i < items.size(); i++ )
1590 if ( items[i] == item )
1591 return createIndex( i, 0, item );
1593 QModelIndex childIndex =
findItem( item, items[i] );
1594 if ( childIndex.isValid() )
1598 return QModelIndex();
1616 if ( !idx.isValid() )
1619 beginInsertRows( idx, first, last );
1630 if ( !idx.isValid() )
1632 beginRemoveRows( idx, first, last );
1676 QStringList QgsCptCityBrowserModel::mimeTypes()
const
1681 types <<
"application/x-vnd.qgis.qgis.uri";
1685 QMimeData *QgsCptCityBrowserModel::mimeData(
const QModelIndexList &indexes )
const
1688 const auto constIndexes = indexes;
1689 for (
const QModelIndex &
index : constIndexes )
1691 if (
index.isValid() )
1694 if ( ptr->
type() != QgsCptCityDataItem::Layer )
continue;
1702 bool QgsCptCityBrowserModel::dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
1720 void *v = idx.internalPointer();
1722 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.
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)