18 #include <QApplication> 23 #include <QMouseEvent> 24 #include <QTreeWidget> 25 #include <QTreeWidgetItem> 28 #include <QDomDocument> 29 #include <QDomElement> 36 #include "qgsconfig.h" 50 QgsDebugMsg(
"archiveName = " + archiveName +
" baseDir = " + baseDir );
54 const auto constEntryList = QDir(
mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
55 for (
const QString &path : constEntryList )
57 if ( path == QLatin1String(
"selections" ) )
69 QDir seldir(
mBaseDir +
'/' +
"selections" );
70 QgsDebugMsg(
"populating selection from " + seldir.path() );
71 const QStringList fileList = seldir.entryList( QStringList() << QStringLiteral(
"*.xml" ), QDir::Files );
72 for (
const QString &selfile : fileList )
74 QgsDebugMsg(
"file= " + seldir.path() +
'/' + selfile );
76 seldir.dirName() +
'/' + selfile );
78 if ( selItem->isValid() )
119 if ( archiveName.isNull() )
122 return archive->baseDir();
133 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
146 if ( startDir.isEmpty() || ! startDir.startsWith( baseDir ) )
149 QDir dir = QDir( startDir );
151 while ( ! dir.exists( target ) && dir.path() !=
baseDir )
156 if ( ! dir.exists( target ) )
159 return dir.path() +
'/' + target;
179 if ( fileName.isNull() )
184 QgsDebugMsg(
"found copying info in copyingInfoMap, file = " + fileName );
192 if ( !f.open( QFile::ReadOnly ) )
194 QgsDebugMsg(
"Couldn't open xml file: " + fileName );
199 QDomDocument doc( QStringLiteral(
"license" ) );
200 if ( !doc.setContent( &f ) )
203 QgsDebugMsg(
"Couldn't parse xml file: " + fileName );
209 QDomElement docElem = doc.documentElement();
210 if ( docElem.tagName() != QLatin1String(
"copying" ) )
212 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
217 QDomElement authorsElement = docElem.firstChildElement( QStringLiteral(
"authors" ) );
218 if ( authorsElement.isNull() )
220 QgsDebugMsg( QStringLiteral(
"authors tag missing" ) );
224 QDomElement e = authorsElement.firstChildElement();
226 while ( ! e.isNull() )
228 if ( e.tagName() == QLatin1String(
"author" ) )
230 if ( ! e.firstChildElement( QStringLiteral(
"name" ) ).isNull() )
231 authors << e.firstChildElement( QStringLiteral(
"name" ) ).text().simplified();
234 e = e.nextSiblingElement();
236 copyingMap[ QStringLiteral(
"authors" )] = authors.join( QStringLiteral(
", " ) );
240 QDomElement licenseElement = docElem.firstChildElement( QStringLiteral(
"license" ) );
241 if ( licenseElement.isNull() )
243 QgsDebugMsg( QStringLiteral(
"license tag missing" ) );
247 QDomElement e = licenseElement.firstChildElement( QStringLiteral(
"informal" ) );
249 copyingMap[ QStringLiteral(
"license/informal" )] = e.text().simplified();
250 e = licenseElement.firstChildElement( QStringLiteral(
"year" ) );
252 copyingMap[ QStringLiteral(
"license/year" )] = e.text().simplified();
253 e = licenseElement.firstChildElement( QStringLiteral(
"text" ) );
254 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
255 copyingMap[ QStringLiteral(
"license/url" )] = e.attribute( QStringLiteral(
"href" ) );
259 QDomElement element = docElem.firstChildElement( QStringLiteral(
"src" ) );
260 if ( element.isNull() )
262 QgsDebugMsg( QStringLiteral(
"src tag missing" ) );
266 QDomElement e = element.firstChildElement( QStringLiteral(
"link" ) );
267 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
268 copyingMap[ QStringLiteral(
"src/link" )] = e.attribute( QStringLiteral(
"href" ) );
280 QgsDebugMsg(
"description fileName = " + fileName );
283 if ( ! f.open( QFile::ReadOnly ) )
285 QgsDebugMsg(
"description file " + fileName +
" ] does not exist" );
291 QDomDocument doc( QStringLiteral(
"description" ) );
292 if ( !doc.setContent( &f, &errMsg ) )
295 QgsDebugMsg(
"Couldn't parse file " + fileName +
" : " + errMsg );
301 QDomElement docElem = doc.documentElement();
302 if ( docElem.tagName() != QLatin1String(
"description" ) )
304 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
309 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
312 QgsDebugMsg( QStringLiteral(
"name tag missing" ) );
314 descMap[ QStringLiteral(
"name" )] = e.text().simplified();
315 e = docElem.firstChildElement( QStringLiteral(
"full" ) );
318 QgsDebugMsg( QStringLiteral(
"full tag missing" ) );
320 descMap[ QStringLiteral(
"full" )] = e.text().simplified();
327 QMap< double, QPair<QColor, QColor> > colorMap;
331 if ( !f.open( QFile::ReadOnly ) )
333 QgsDebugMsg(
"Couldn't open SVG file: " + fileName );
338 QDomDocument doc( QStringLiteral(
"gradient" ) );
339 if ( !doc.setContent( &f ) )
342 QgsDebugMsg(
"Couldn't parse SVG file: " + fileName );
347 QDomElement docElem = doc.documentElement();
349 if ( docElem.tagName() != QLatin1String(
"svg" ) )
351 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
356 QDomElement rampsElement = docElem.firstChildElement( QStringLiteral(
"linearGradient" ) );
357 if ( rampsElement.isNull() )
359 QDomNodeList nodeList = docElem.elementsByTagName( QStringLiteral(
"linearGradient" ) );
360 if ( ! nodeList.isEmpty() )
361 rampsElement = nodeList.at( 0 ).toElement();
363 if ( rampsElement.isNull() )
365 QgsDebugMsg( QStringLiteral(
"linearGradient tag missing" ) );
370 QDomElement e = rampsElement.firstChildElement();
372 while ( !e.isNull() )
374 if ( e.tagName() == QLatin1String(
"stop" ) )
378 QString offsetStr = e.attribute( QStringLiteral(
"offset" ) );
379 QString colorStr = e.attribute( QStringLiteral(
"stop-color" ), QString() );
380 QString opacityStr = e.attribute( QStringLiteral(
"stop-opacity" ), QStringLiteral(
"1.0" ) );
381 if ( offsetStr.endsWith(
'%' ) )
382 offset = offsetStr.remove( offsetStr.size() - 1, 1 ).toDouble() / 100.0;
384 offset = offsetStr.toDouble();
388 if ( color != QColor() )
390 int alpha = opacityStr.toDouble() * 255;
391 color.setAlpha( alpha );
392 if ( colorMap.contains( offset ) )
393 colorMap[offset].second = color;
395 colorMap[offset] = qMakePair( color, color );
399 QgsDebugMsg( QStringLiteral(
"at offset=%1 invalid color" ).arg( offset ) );
407 e = e.nextSiblingElement();
431 QgsDebugMsg(
"archiveName = " + archiveName +
" archiveBaseDir = " + archiveBaseDir );
442 QString
baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
448 initArchive( defArchiveName, baseDir +
'/' + defArchiveName );
454 QString
baseDir, defArchiveName;
458 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
463 QgsDebugMsg(
"baseDir= " + baseDir +
" defArchiveName= " + defArchiveName );
467 const QStringList fileList = dir.entryList( QStringList() << QStringLiteral(
"cpt-city*" ), QDir::Dirs );
468 for (
const QString &entry : fileList )
470 if ( QFile::exists( baseDir +
'/' + entry +
"/VERSION.xml" ) )
471 archivesMap[ entry ] = baseDir +
'/' + entry;
476 archivesMap[ defArchiveName ] = baseDir +
'/' + defArchiveName;
479 for ( QgsStringMap::iterator it = archivesMap.begin();
480 it != archivesMap.end(); ++it )
482 if ( QDir( it.value() ).exists() )
486 QgsDebugMsg( QStringLiteral(
"not loading archive [%1] because dir %2 does not exist " ).arg( it.key(), it.value() ) );
502 const QString &name,
const QString &path )
506 , mPopulated( false )
515 QVector<QgsCptCityDataItem *>
children;
526 QApplication::setOverrideCursor( Qt::WaitCursor );
529 const auto constChildren =
children;
537 QApplication::restoreOverrideCursor();
557 count += child->leafCount();
579 mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
587 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
634 for (
int i = 0; i < items.size(); i++ )
637 if ( items[i]->
equal( item ) )
647 QApplication::setOverrideCursor( Qt::WaitCursor );
652 QVector<QgsCptCityDataItem *>
remove;
656 if (
findItem( items, child ) >= 0 )
658 remove.append( child );
660 const auto constRemove =
remove;
667 const auto constItems = items;
679 QApplication::restoreOverrideCursor();
684 return ( metaObject()->className() == other->metaObject()->className() &&
691 const QString &
name,
const QString &
path,
const QString &variantName,
bool initialize )
693 , mInitialized( false )
694 , mRamp( path, variantName, false )
703 const QString &
name,
const QString &
path,
const QStringList &variantList,
bool initialize )
706 ,
mRamp( path, variantList, QString(), false )
739 if ( variantList.isEmpty() )
744 mInfo = QString::number( count ) +
' ' + tr(
"colors" ) +
" - ";
746 mInfo += tr(
"discrete" );
750 mInfo += tr(
"continuous" );
752 mInfo += tr(
"continuous (multi)" );
758 mInfo = QString::number( variantList.count() ) +
' ' + tr(
"variants" );
787 return icon( QSize( 100, 15 ) );
792 const auto constMIcons =
mIcons;
793 for (
const QIcon &
icon : constMIcons )
795 if (
icon.availableSizes().contains( size ) )
809 QPixmap blankPixmap( size );
810 blankPixmap.fill( Qt::white );
811 icon = QIcon( blankPixmap );
821 const QString &
name,
const QString &
path )
823 , mPopulatedRamps( false )
834 QVector< QgsCptCityDataItem * > rampItems;
835 QVector< QgsCptCityDataItem * > deleteItems;
840 const auto constChildren =
children();
845 QgsDebugMsgLevel( QStringLiteral(
"child path= %1 coll= %2 ramp = %3" ).arg( childItem->path() ).arg(
nullptr != collectionItem ).arg(
nullptr != rampItem ), 2 );
846 if ( collectionItem && recursive )
855 if ( rampItem->isValid() )
856 rampItems << rampItem;
858 deleteItems << rampItem;
862 QgsDebugMsg(
"invalid item " + childItem->path() );
867 const auto constDeleteItems = deleteItems;
870 QgsDebugMsg( QStringLiteral(
"item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
882 const QString &
name,
const QString &
path )
896 mPath +
'/' +
"DESC.xml";
898 if ( descMap.contains( QStringLiteral(
"name" ) ) )
899 mInfo = descMap.value( QStringLiteral(
"name" ) );
907 return QVector<QgsCptCityDataItem *>();
909 QVector<QgsCptCityDataItem *>
children;
912 QMapIterator< QString, QStringList> it(
rampsMap() );
913 while ( it.hasNext() )
927 for (
const QString &childPath : constDirEntries )
932 children << childItem;
935 QgsDebugMsg( QStringLiteral(
"name= %1 path= %2 found %3 children" ).arg(
mName,
mPath ).arg( children.count() ) );
945 QString curName, prevName, curVariant, curSep, schemeName;
946 QStringList listVariant;
947 QStringList schemeNamesAll, schemeNames;
948 bool prevAdd, curAdd;
951 schemeNamesAll = dir.entryList( QStringList( QStringLiteral(
"*.svg" ) ), QDir::Files, QDir::Name );
954 for (
int i = 0; i < schemeNamesAll.count(); i++ )
957 schemeName = schemeNamesAll[i];
958 schemeName.chop( 4 );
961 curName = schemeName;
966 if ( schemeName.length() > 1 && schemeName.endsWith(
'a' ) && ! listVariant.isEmpty() &&
967 ( ( prevName + listVariant.last() +
'a' ) == curName ) )
970 curVariant = listVariant.last() +
'a';
974 QRegExp rxVariant(
"^(.*[^\\d])(\\d{1,3})$" );
975 int pos = rxVariant.indexIn( schemeName );
978 curName = rxVariant.cap( 1 );
979 curVariant = rxVariant.cap( 2 );
983 curSep = curName.right( 1 );
984 if ( curSep == QLatin1String(
"-" ) || curSep == QLatin1String(
"_" ) )
987 curVariant = curSep + curVariant;
990 if ( prevName.isEmpty() )
996 if ( curName.isEmpty() )
997 curName = QStringLiteral(
"__empty__" );
999 if ( curName == prevName )
1002 if ( i == schemeNamesAll.count() - 1 )
1004 listVariant << curVariant;
1008 if ( !prevName.isEmpty() )
1013 if ( i == schemeNamesAll.count() - 1 )
1022 if ( listVariant.isEmpty() )
1026 schemeNames << prevName;
1029 else if ( listVariant.count() <= 3 )
1032 for (
int j = 0; j < listVariant.count(); j++ )
1035 schemeNames << prevName + listVariant[j];
1036 mRampsMap[
mPath +
'/' + prevName + listVariant[j] ] = QStringList();
1043 schemeNames << prevName;
1045 listVariant.clear();
1049 if ( !curVariant.isEmpty() )
1050 curName += curVariant;
1051 schemeNames << curName;
1055 if ( prevAdd || curAdd )
1058 if ( !curVariant.isEmpty() )
1059 listVariant << curVariant;
1066 mSchemeMap[
path ] = schemeNames;
1067 schemeCount += schemeName.count();
1068 schemeNames.clear();
1069 listVariant.clear();
1078 '/' +
mPath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
1088 return (
path() == other->
path() );
1092 const QString &
name,
const QString &
path )
1094 QgsDebugMsg(
"name= " + name +
" path= " + path );
1098 if ( dirItem && ! dirItem->
isValid() )
1110 QgsDebugMsg( QStringLiteral(
"item has %1 dirs and %2 ramps" ).arg( dirEntries.count() ).arg( rampsMap.count() ) );
1113 if ( !dirEntries.isEmpty() )
1117 if ( rampsMap.isEmpty() )
1124 else if ( rampsMap.count() == 1 )
1129 rampsMap.begin().key(), rampsMap.begin().value() );
1143 const QString &
name,
const QString &
path )
1147 mValid = ! path.isNull();
1155 return QVector<QgsCptCityDataItem *>();
1158 QVector<QgsCptCityDataItem *>
children;
1164 for ( QString childPath : constMSelectionsList )
1166 QgsDebugMsg(
"childPath = " + childPath +
" name= " + QFileInfo( childPath ).baseName() );
1167 if ( childPath.endsWith(
'/' ) )
1169 childPath.chop( 1 );
1175 children << childItem;
1184 if ( item->isValid() )
1191 QgsDebugMsg( QStringLiteral(
"path= %1 inserted %2 children" ).arg(
mPath ).arg( children.count() ) );
1202 QFile f( filename );
1203 if ( ! f.open( QFile::ReadOnly ) )
1211 QDomDocument doc( QStringLiteral(
"selection" ) );
1212 if ( !doc.setContent( &f, &errMsg ) )
1215 QgsDebugMsg(
"Couldn't parse file " + filename +
" : " + errMsg );
1221 QDomElement docElem = doc.documentElement();
1222 if ( docElem.tagName() != QLatin1String(
"selection" ) )
1224 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
1227 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
1228 if ( ! e.isNull() && ! e.text().isNull() )
1230 mInfo = docElem.firstChildElement( QStringLiteral(
"synopsis" ) ).text().simplified();
1233 QDomElement collectsElem = docElem.firstChildElement( QStringLiteral(
"seealsocollects" ) );
1234 e = collectsElem.firstChildElement( QStringLiteral(
"collect" ) );
1235 while ( ! e.isNull() )
1237 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1242 e = e.nextSiblingElement();
1245 QDomElement gradientsElem = docElem.firstChildElement( QStringLiteral(
"gradients" ) );
1246 e = gradientsElem.firstChildElement( QStringLiteral(
"gradient" ) );
1247 while ( ! e.isNull() )
1249 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1253 mSelectionsList << e.attribute( QStringLiteral(
"dir" ) ) +
'/' + e.attribute( QStringLiteral(
"file" ) );
1255 e = e.nextSiblingElement();
1266 return (
path() == other->
path() );
1271 const QString &
name,
const QVector<QgsCptCityDataItem *> &items )
1283 return QVector<QgsCptCityDataItem *>();
1285 QVector<QgsCptCityDataItem *>
children;
1288 const auto constMItems =
mItems;
1303 : QAbstractItemModel( parent )
1304 , mArchive( archive )
1305 , mViewType( viewType )
1308 QgsDebugMsg(
"archiveName = " + archive->
archiveName() +
" viewType=" +
static_cast< int >( viewType ) );
1345 if ( !index.isValid() )
1346 return Qt::ItemFlags();
1348 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
1355 if ( !index.isValid() )
1364 else if ( role == Qt::DisplayRole )
1366 if ( index.column() == 0 )
1367 return item->
name();
1368 if ( index.column() == 1 )
1370 return item->
info();
1373 else if ( role == Qt::ToolTipRole )
1377 return item->
path() +
'\n' + item->
info();
1380 else if ( role == Qt::DecorationRole && index.column() == 1 &&
1386 else if ( role == Qt::FontRole &&
1387 qobject_cast< QgsCptCityCollectionItem * >( item ) )
1391 font.setPointSize( 11 );
1392 font.setBold(
true );
1406 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
1409 return QVariant( tr(
"Name" ) );
1410 else if ( section == 1 )
1411 return QVariant( tr(
"Info" ) );
1420 if ( !parent.isValid() )
1429 return item ? item->
rowCount() : 0;
1435 if ( !parent.isValid() )
1451 QModelIndex rootIndex;
1452 bool foundParent =
false, foundChild =
true;
1458 if ( path.isEmpty() )
1460 for (
int i = 0; i <
rowCount( rootIndex ); i++ )
1462 QModelIndex idx =
index( i, 0, rootIndex );
1465 return QModelIndex();
1467 itemPath = item->
path();
1469 if ( itemPath == path )
1477 while ( foundChild )
1483 if ( itemPath.isEmpty() )
1485 for ( ; i <
rowCount( rootIndex ); i++ )
1487 QModelIndex idx =
index( i, 0, rootIndex );
1490 return QModelIndex();
1492 itemPath = item->
path();
1494 if ( itemPath == path )
1500 if ( ! itemPath.endsWith(
'/' ) )
1503 foundParent =
false;
1514 for ( QString childPath : constSelectionsList )
1516 if ( childPath.endsWith(
'/' ) )
1517 childPath.chop( 1 );
1519 if ( path.startsWith( childPath ) )
1528 else if ( path.startsWith( itemPath ) )
1546 return QModelIndex();
1560 QModelIndex idx =
findPath( path );
1561 if ( idx.isValid() )
1574 return item ? createIndex( row, column, item ) : QModelIndex();
1581 return QModelIndex();
1588 const QVector<QgsCptCityDataItem *> &items = parent ? parent->
children() :
mRootItems;
1590 for (
int i = 0; i < items.size(); i++ )
1592 if ( items[i] == item )
1593 return createIndex( i, 0, item );
1595 QModelIndex childIndex =
findItem( item, items[i] );
1596 if ( childIndex.isValid() )
1600 return QModelIndex();
1617 QModelIndex idx =
findItem( parent );
1618 if ( !idx.isValid() )
1621 beginInsertRows( idx, first, last );
1631 QModelIndex idx =
findItem( parent );
1632 if ( !idx.isValid() )
1634 beginRemoveRows( idx, first, last );
1678 QStringList QgsCptCityBrowserModel::mimeTypes()
const 1683 types <<
"application/x-vnd.qgis.qgis.uri";
1687 QMimeData *QgsCptCityBrowserModel::mimeData(
const QModelIndexList &indexes )
const 1690 const auto constIndexes = indexes;
1691 for (
const QModelIndex &
index : constIndexes )
1693 if (
index.isValid() )
1696 if ( ptr->
type() != QgsCptCityDataItem::Layer )
continue;
1704 bool QgsCptCityBrowserModel::dropMimeData(
const QMimeData *
data, Qt::DropAction action,
int row,
int column,
const QModelIndex &
parent )
1722 void *v = idx.internalPointer();
1724 Q_ASSERT( !v || d );
void connectItem(QgsCptCityDataItem *item)
QStringList selectionsList() const
void beginInsertItems(QgsCptCityDataItem *parent, int first, int last)
QString descFileName(const QString &dirName) const
void fetchMore(const QModelIndex &parent) override
virtual QgsCptCityDataItem * removeChildItem(QgsCptCityDataItem *child)
An "All ramps item", which contains all items in a flat hierarchy.
Qt::ItemFlags flags(const QModelIndex &index) const override
QgsCptCityDataItem * dataItem(const QModelIndex &idx) const
Returns a list of mime that can describe model indexes.
QVector< QgsCptCityDataItem * > mItems
static QgsCptCityArchive * defaultArchive()
void beginRemoveItems(QgsCptCityDataItem *parent, int first, int last)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QgsCptCityDirectoryItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
This class is a composition of two QSettings instances:
QgsCptCityColorRamp mRamp
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static QString defaultBaseDir()
QgsCptCityAllRampsItem(QgsCptCityDataItem *parent, const QString &name, const QVector< QgsCptCityDataItem *> &items)
QMap< QString, QStringList > rampsMap()
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Item that represents a layer that can be opened with one of the providers.
QMap< QString, QStringList > mRampsMap
static QMimeData * encodeUriList(const UriList &layers)
Encodes a URI list to a new QMimeData object.
void setVariantName(const QString &variantName)
QgsCptCitySelectionItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
QModelIndex findPath(const QString &path)
Returns index of a path.
virtual void addChildItem(QgsCptCityDataItem *child, bool refresh=false)
QMap< QString, QString > QgsStringMap
QgsCptCityArchive(const QString &archiveName=DEFAULT_CPTCITY_ARCHIVE, const QString &baseDir=QString())
static QMap< QString, QMap< QString, QString > > sCopyingInfoMap
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...
virtual QVector< QgsCptCityDataItem * > createChildren()
QgsCptCityArchive * mArchive
QgsCptCityDataItem(QgsCptCityDataItem::Type type, QgsCptCityDataItem *parent, const QString &name, const QString &path)
QVector< QgsCptCityDataItem * > children() const
static void initArchives(bool loadAll=false)
QVector< QgsCptCityDataItem * > createChildren() override
bool equal(const QgsCptCityDataItem *other) override
const QgsCptCityColorRamp & ramp() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
virtual bool handleDrop(const QMimeData *, Qt::DropAction)
virtual bool equal(const QgsCptCityDataItem *other)
#define QgsDebugMsgLevel(str, level)
QModelIndex parent(const QModelIndex &index) const override
~QgsCptCityCollectionItem() override
QVector< QgsCptCityDataItem *> rootItems() const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
A directory: contains subdirectories and color ramps.
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
static QIcon colorRampPreviewIcon(QgsColorRamp *ramp, QSize size, int padding=0)
Returns an icon preview for a color ramp.
QgsCptCityCollectionItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
Base class for all items in the model.
void beginRemoveItems(QgsCptCityDataItem *parent, int first, int last)
static QMap< QString, QString > copyingInfo(const QString &fileName)
bool isDiscrete() const
Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating betw...
A Collection: logical collection of subcollections and color ramps.
static void initArchive(const QString &archiveName, const QString &archiveBaseDir)
static void initDefaultArchive()
QString archiveName() const
static QString pkgDataPath()
Returns the common root path of all application data directories.
#define DEFAULT_CPTCITY_ARCHIVE
QVector< QgsCptCityDataItem * > mSelectionItems
static void clearArchives()
virtual void deleteChildItem(QgsCptCityDataItem *child)
QStringList mSelectionsList
void refresh(const QString &path)
bool equal(const QgsCptCityDataItem *other) override
static QMap< QString, QString > description(const QString &fileName)
QVector< QgsCptCityDataItem * > createChildren() override
void setParent(QgsCptCityDataItem *parent)
QgsCptCityBrowserModel(QObject *parent=nullptr, QgsCptCityArchive *archive=QgsCptCityArchive::defaultArchive(), ViewType Type=Authors)
static QMap< QString, QgsCptCityArchive *> sArchiveRegistry
bool hasMultiStops() const
bool equal(const QgsCptCityDataItem *other) override
void beginInsertItems(QgsCptCityDataItem *parent, int first, int last)
static int findItem(QVector< QgsCptCityDataItem *> items, QgsCptCityDataItem *item)
bool canFetchMore(const QModelIndex &parent) const override
QList< QgsMimeDataUtils::Uri > UriList
~QgsCptCityBrowserModel() override
QVector< QgsCptCityDataItem * > createChildren() override
Item that represents a layer that can be opened with one of the providers.
QgsCptCityColorRampItem(QgsCptCityDataItem *parent, const QString &name, const QString &path, const QString &variantName=QString(), bool initialize=false)
static QMap< double, QPair< QColor, QColor > > gradientColorMap(const QString &fileName)
A selection: contains subdirectories and color ramps.
QgsCptCityDataItem * parent() const
QStringList variantList() const
QVector< QgsCptCityDataItem *> mRootItems
QVector< QgsCptCityDataItem * > mRootItems
QVector< QgsCptCityDataItem * > childrenRamps(bool recursive)
QModelIndex findItem(QgsCptCityDataItem *item, QgsCptCityDataItem *parent=nullptr) const
virtual int leafCount() const
QVector< QgsCptCityDataItem *> selectionItems() const
static QgsCptCityDataItem * dataItem(QgsCptCityDataItem *parent, const QString &name, const QString &path)
QString variantName() const
static QString findFileName(const QString &target, const QString &startDir, const QString &baseDir)
QString copyingFileName(const QString &dirName) const
QStringList dirEntries() const
QVector< QgsCptCityDataItem * > mChildren
static QMap< QString, QgsCptCityArchive *> archiveRegistry()
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int count() const override
Returns number of defined colors, or -1 if undefined.
static QString sDefaultArchiveName