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 Q_FOREACH (
const QString &path, QDir(
mBaseDir ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name ) )
56 if ( path == QLatin1String(
"selections" ) )
68 QDir seldir(
mBaseDir +
'/' +
"selections" );
69 QgsDebugMsg(
"populating selection from " + seldir.path() );
70 const QStringList fileList = seldir.entryList( QStringList() << QStringLiteral(
"*.xml" ), QDir::Files );
71 for (
const QString &selfile : fileList )
73 QgsDebugMsg(
"file= " + seldir.path() +
'/' + selfile );
75 seldir.dirName() +
'/' + selfile );
77 if ( selItem->isValid() )
116 if ( archiveName.isNull() )
119 return archive->baseDir();
130 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
143 if ( startDir.isEmpty() || ! startDir.startsWith( baseDir ) )
146 QDir dir = QDir( startDir );
148 while ( ! dir.exists( target ) && dir.path() !=
baseDir )
153 if ( ! dir.exists( target ) )
156 return dir.path() +
'/' + target;
176 if ( fileName.isNull() )
181 QgsDebugMsg(
"found copying info in copyingInfoMap, file = " + fileName );
189 if ( !f.open( QFile::ReadOnly ) )
191 QgsDebugMsg(
"Couldn't open xml file: " + fileName );
196 QDomDocument doc( QStringLiteral(
"license" ) );
197 if ( !doc.setContent( &f ) )
200 QgsDebugMsg(
"Couldn't parse xml file: " + fileName );
206 QDomElement docElem = doc.documentElement();
207 if ( docElem.tagName() != QLatin1String(
"copying" ) )
209 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
214 QDomElement authorsElement = docElem.firstChildElement( QStringLiteral(
"authors" ) );
215 if ( authorsElement.isNull() )
221 QDomElement e = authorsElement.firstChildElement();
223 while ( ! e.isNull() )
225 if ( e.tagName() == QLatin1String(
"author" ) )
227 if ( ! e.firstChildElement( QStringLiteral(
"name" ) ).isNull() )
228 authors << e.firstChildElement( QStringLiteral(
"name" ) ).text().simplified();
231 e = e.nextSiblingElement();
233 copyingMap[ QStringLiteral(
"authors" )] = authors.join( QStringLiteral(
", " ) );
237 QDomElement licenseElement = docElem.firstChildElement( QStringLiteral(
"license" ) );
238 if ( licenseElement.isNull() )
244 QDomElement e = licenseElement.firstChildElement( QStringLiteral(
"informal" ) );
246 copyingMap[ QStringLiteral(
"license/informal" )] = e.text().simplified();
247 e = licenseElement.firstChildElement( QStringLiteral(
"year" ) );
249 copyingMap[ QStringLiteral(
"license/year" )] = e.text().simplified();
250 e = licenseElement.firstChildElement( QStringLiteral(
"text" ) );
251 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
252 copyingMap[ QStringLiteral(
"license/url" )] = e.attribute( QStringLiteral(
"href" ) );
256 QDomElement element = docElem.firstChildElement( QStringLiteral(
"src" ) );
257 if ( element.isNull() )
263 QDomElement e = element.firstChildElement( QStringLiteral(
"link" ) );
264 if ( ! e.isNull() && e.attribute( QStringLiteral(
"href" ) ) != QString() )
265 copyingMap[ QStringLiteral(
"src/link" )] = e.attribute( QStringLiteral(
"href" ) );
277 QgsDebugMsg(
"description fileName = " + fileName );
280 if ( ! f.open( QFile::ReadOnly ) )
282 QgsDebugMsg(
"description file " + fileName +
" ] does not exist" );
288 QDomDocument doc( QStringLiteral(
"description" ) );
289 if ( !doc.setContent( &f, &errMsg ) )
292 QgsDebugMsg(
"Couldn't parse file " + fileName +
" : " + errMsg );
298 QDomElement docElem = doc.documentElement();
299 if ( docElem.tagName() != QLatin1String(
"description" ) )
301 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
306 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
311 descMap[ QStringLiteral(
"name" )] = e.text().simplified();
312 e = docElem.firstChildElement( QStringLiteral(
"full" ) );
317 descMap[ QStringLiteral(
"full" )] = e.text().simplified();
324 QMap< double, QPair<QColor, QColor> > colorMap;
328 if ( !f.open( QFile::ReadOnly ) )
330 QgsDebugMsg(
"Couldn't open SVG file: " + fileName );
335 QDomDocument doc( QStringLiteral(
"gradient" ) );
336 if ( !doc.setContent( &f ) )
339 QgsDebugMsg(
"Couldn't parse SVG file: " + fileName );
344 QDomElement docElem = doc.documentElement();
346 if ( docElem.tagName() != QLatin1String(
"svg" ) )
348 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
353 QDomElement rampsElement = docElem.firstChildElement( QStringLiteral(
"linearGradient" ) );
354 if ( rampsElement.isNull() )
356 QDomNodeList nodeList = docElem.elementsByTagName( QStringLiteral(
"linearGradient" ) );
357 if ( ! nodeList.isEmpty() )
358 rampsElement = nodeList.at( 0 ).toElement();
360 if ( rampsElement.isNull() )
367 QDomElement e = rampsElement.firstChildElement();
369 while ( !e.isNull() )
371 if ( e.tagName() == QLatin1String(
"stop" ) )
375 QString offsetStr = e.attribute( QStringLiteral(
"offset" ) );
376 QString colorStr = e.attribute( QStringLiteral(
"stop-color" ), QLatin1String(
"" ) );
377 QString opacityStr = e.attribute( QStringLiteral(
"stop-opacity" ), QStringLiteral(
"1.0" ) );
378 if ( offsetStr.endsWith(
'%' ) )
379 offset = offsetStr.remove( offsetStr.size() - 1, 1 ).toDouble() / 100.0;
381 offset = offsetStr.toDouble();
385 if ( color != QColor() )
387 int alpha = opacityStr.toDouble() * 255;
388 color.setAlpha( alpha );
389 if ( colorMap.contains( offset ) )
390 colorMap[offset].second = color;
392 colorMap[offset] = qMakePair( color, color );
396 QgsDebugMsg( QString(
"at offset=%1 invalid color" ).arg( offset ) );
404 e = e.nextSiblingElement();
428 QgsDebugMsg(
"archiveName = " + archiveName +
" archiveBaseDir = " + archiveBaseDir );
439 QString
baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
445 initArchive( defArchiveName, baseDir +
'/' + defArchiveName );
451 QString
baseDir, defArchiveName;
455 baseDir = settings.
value( QStringLiteral(
"CptCity/baseDir" ),
460 QgsDebugMsg(
"baseDir= " + baseDir +
" defArchiveName= " + defArchiveName );
464 const QStringList fileList = dir.entryList( QStringList() << QStringLiteral(
"cpt-city*" ), QDir::Dirs );
465 for (
const QString &entry : fileList )
467 if ( QFile::exists( baseDir +
'/' + entry +
"/VERSION.xml" ) )
468 archivesMap[ entry ] = baseDir +
'/' + entry;
473 archivesMap[ defArchiveName ] = baseDir +
'/' + defArchiveName;
476 for ( QgsStringMap::iterator it = archivesMap.begin();
477 it != archivesMap.end(); ++it )
479 if ( QDir( it.value() ).exists() )
483 QgsDebugMsg( QString(
"not loading archive [%1] because dir %2 does not exist " ).arg( it.key(), it.value() ) );
499 const QString &name,
const QString &path )
503 , mPopulated( false )
512 QVector<QgsCptCityDataItem *>
children;
523 QApplication::setOverrideCursor( Qt::WaitCursor );
533 QApplication::restoreOverrideCursor();
574 mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
582 if (
mChildren.at( i )->mName.localeAwareCompare( child->
mName ) >= 0 )
629 for (
int i = 0; i < items.size(); i++ )
632 if ( items[i]->
equal( item ) )
642 QApplication::setOverrideCursor( Qt::WaitCursor );
647 QVector<QgsCptCityDataItem *>
remove;
650 if (
findItem( items, child ) >= 0 )
652 remove.append( child );
671 QApplication::restoreOverrideCursor();
676 return ( metaObject()->className() == other->metaObject()->className() &&
683 const QString &
name,
const QString &
path,
const QString &variantName,
bool initialize )
685 , mInitialized( false )
686 , mRamp( path, variantName, false )
695 const QString &
name,
const QString &
path,
const QStringList &variantList,
bool initialize )
698 ,
mRamp( path, variantList, QString(), false )
731 if ( variantList.isEmpty() )
736 mInfo = QString::number( count ) +
' ' + tr(
"colors" ) +
" - ";
738 mInfo += tr(
"discrete" );
742 mInfo += tr(
"continuous" );
744 mInfo += tr(
"continuous (multi)" );
750 mInfo = QString::number( variantList.count() ) +
' ' + tr(
"variants" );
779 return icon( QSize( 100, 15 ) );
786 if ( icon.availableSizes().contains( size ) )
800 QPixmap blankPixmap( size );
801 blankPixmap.fill( Qt::white );
802 icon = QIcon( blankPixmap );
812 const QString &
name,
const QString &
path )
814 , mPopulatedRamps( false )
825 QVector< QgsCptCityDataItem * > rampItems;
826 QVector< QgsCptCityDataItem * > deleteItems;
835 QgsDebugMsgLevel( QString(
"child path= %1 coll= %2 ramp = %3" ).arg( childItem->
path() ).arg(
nullptr != collectionItem ).arg(
nullptr != rampItem ), 2 );
836 if ( collectionItem && recursive )
846 rampItems << rampItem;
848 deleteItems << rampItem;
859 QgsDebugMsg( QString(
"item %1 is invalid, will be deleted" ).arg( deleteItem->
path() ) );
871 const QString &
name,
const QString &
path )
885 mPath +
'/' +
"DESC.xml";
887 if ( descMap.contains( QStringLiteral(
"name" ) ) )
888 mInfo = descMap.value( QStringLiteral(
"name" ) );
896 return QVector<QgsCptCityDataItem *>();
898 QVector<QgsCptCityDataItem *>
children;
901 QMapIterator< QString, QStringList> it(
rampsMap() );
902 while ( it.hasNext() )
915 Q_FOREACH (
const QString &childPath,
dirEntries() )
920 children << childItem;
923 QgsDebugMsg( QString(
"name= %1 path= %2 found %3 children" ).arg(
mName,
mPath ).arg( children.count() ) );
933 QString curName, prevName, curVariant, curSep, schemeName;
934 QStringList listVariant;
935 QStringList schemeNamesAll, schemeNames;
936 bool prevAdd, curAdd;
939 schemeNamesAll = dir.entryList( QStringList( QStringLiteral(
"*.svg" ) ), QDir::Files, QDir::Name );
942 for (
int i = 0; i < schemeNamesAll.count(); i++ )
945 schemeName = schemeNamesAll[i];
946 schemeName.chop( 4 );
949 curName = schemeName;
954 if ( schemeName.length() > 1 && schemeName.endsWith(
'a' ) && ! listVariant.isEmpty() &&
955 ( ( prevName + listVariant.last() +
'a' ) == curName ) )
958 curVariant = listVariant.last() +
'a';
962 QRegExp rxVariant(
"^(.*[^\\d])(\\d{1,3})$" );
963 int pos = rxVariant.indexIn( schemeName );
966 curName = rxVariant.cap( 1 );
967 curVariant = rxVariant.cap( 2 );
971 curSep = curName.right( 1 );
972 if ( curSep == QLatin1String(
"-" ) || curSep == QLatin1String(
"_" ) )
975 curVariant = curSep + curVariant;
978 if ( prevName.isEmpty() )
984 if ( curName.isEmpty() )
985 curName = QStringLiteral(
"__empty__" );
987 if ( curName == prevName )
990 if ( i == schemeNamesAll.count() - 1 )
992 listVariant << curVariant;
996 if ( !prevName.isEmpty() )
1001 if ( i == schemeNamesAll.count() - 1 )
1010 if ( listVariant.isEmpty() )
1014 schemeNames << prevName;
1017 else if ( listVariant.count() <= 3 )
1020 for (
int j = 0; j < listVariant.count(); j++ )
1023 schemeNames << prevName + listVariant[j];
1024 mRampsMap[
mPath +
'/' + prevName + listVariant[j] ] = QStringList();
1031 schemeNames << prevName;
1033 listVariant.clear();
1037 if ( !curVariant.isEmpty() )
1038 curName += curVariant;
1039 schemeNames << curName;
1043 if ( prevAdd || curAdd )
1046 if ( !curVariant.isEmpty() )
1047 listVariant << curVariant;
1054 mSchemeMap[
path ] = schemeNames;
1055 schemeCount += schemeName.count();
1056 schemeNames.clear();
1057 listVariant.clear();
1066 '/' +
mPath ).entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name );
1076 return (
path() == other->
path() );
1080 const QString &
name,
const QString &
path )
1082 QgsDebugMsg(
"name= " + name +
" path= " + path );
1086 if ( dirItem && ! dirItem->
isValid() )
1098 QgsDebugMsg( QString(
"item has %1 dirs and %2 ramps" ).arg( dirEntries.count() ).arg( rampsMap.count() ) );
1101 if ( !dirEntries.isEmpty() )
1105 if ( rampsMap.isEmpty() )
1112 else if ( rampsMap.count() == 1 )
1117 rampsMap.begin().key(), rampsMap.begin().value() );
1131 const QString &
name,
const QString &
path )
1135 mValid = ! path.isNull();
1143 return QVector<QgsCptCityDataItem *>();
1146 QVector<QgsCptCityDataItem *>
children;
1153 QgsDebugMsg(
"childPath = " + childPath +
" name= " + QFileInfo( childPath ).baseName() );
1154 if ( childPath.endsWith(
'/' ) )
1156 childPath.chop( 1 );
1162 children << childItem;
1171 if ( item->isValid() )
1178 QgsDebugMsg( QString(
"path= %1 inserted %2 children" ).arg(
mPath ).arg( children.count() ) );
1189 QFile f( filename );
1190 if ( ! f.open( QFile::ReadOnly ) )
1198 QDomDocument doc( QStringLiteral(
"selection" ) );
1199 if ( !doc.setContent( &f, &errMsg ) )
1202 QgsDebugMsg(
"Couldn't parse file " + filename +
" : " + errMsg );
1208 QDomElement docElem = doc.documentElement();
1209 if ( docElem.tagName() != QLatin1String(
"selection" ) )
1211 QgsDebugMsg(
"Incorrect root tag: " + docElem.tagName() );
1214 QDomElement e = docElem.firstChildElement( QStringLiteral(
"name" ) );
1215 if ( ! e.isNull() && ! e.text().isNull() )
1217 mInfo = docElem.firstChildElement( QStringLiteral(
"synopsis" ) ).text().simplified();
1220 QDomElement collectsElem = docElem.firstChildElement( QStringLiteral(
"seealsocollects" ) );
1221 e = collectsElem.firstChildElement( QStringLiteral(
"collect" ) );
1222 while ( ! e.isNull() )
1224 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1229 e = e.nextSiblingElement();
1232 QDomElement gradientsElem = docElem.firstChildElement( QStringLiteral(
"gradients" ) );
1233 e = gradientsElem.firstChildElement( QStringLiteral(
"gradient" ) );
1234 while ( ! e.isNull() )
1236 if ( ! e.attribute( QStringLiteral(
"dir" ) ).isNull() )
1240 mSelectionsList << e.attribute( QStringLiteral(
"dir" ) ) +
'/' + e.attribute( QStringLiteral(
"file" ) );
1242 e = e.nextSiblingElement();
1253 return (
path() == other->
path() );
1258 const QString &
name,
const QVector<QgsCptCityDataItem *> &items )
1270 return QVector<QgsCptCityDataItem *>();
1272 QVector<QgsCptCityDataItem *>
children;
1289 : QAbstractItemModel( parent )
1290 , mArchive( archive )
1291 , mViewType( viewType )
1294 QgsDebugMsg(
"archiveName = " + archive->
archiveName() +
" viewType=" +
static_cast< int >( viewType ) );
1331 if ( !index.isValid() )
1332 return Qt::ItemFlags();
1334 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
1341 if ( !index.isValid() )
1350 else if ( role == Qt::DisplayRole )
1352 if ( index.column() == 0 )
1353 return item->
name();
1354 if ( index.column() == 1 )
1356 return item->
info();
1359 else if ( role == Qt::ToolTipRole )
1363 return item->
path() +
'\n' + item->
info();
1366 else if ( role == Qt::DecorationRole && index.column() == 1 &&
1372 else if ( role == Qt::FontRole &&
1373 dynamic_cast< QgsCptCityCollectionItem * >( item ) )
1377 font.setPointSize( 11 );
1378 font.setBold(
true );
1391 Q_UNUSED( section );
1392 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
1395 return QVariant( tr(
"Name" ) );
1396 else if ( section == 1 )
1397 return QVariant( tr(
"Info" ) );
1406 if ( !parent.isValid() )
1415 return item ? item->
rowCount() : 0;
1421 if ( !parent.isValid() )
1437 QModelIndex rootIndex;
1438 bool foundParent =
false, foundChild =
true;
1444 if ( path.isEmpty() )
1446 for (
int i = 0; i <
rowCount( rootIndex ); i++ )
1448 QModelIndex idx =
index( i, 0, rootIndex );
1451 return QModelIndex();
1453 itemPath = item->
path();
1455 if ( itemPath == path )
1463 while ( foundChild )
1469 if ( itemPath.isEmpty() )
1471 for ( ; i <
rowCount( rootIndex ); i++ )
1473 QModelIndex idx =
index( i, 0, rootIndex );
1476 return QModelIndex();
1478 itemPath = item->
path();
1480 if ( itemPath == path )
1486 if ( ! itemPath.endsWith(
'/' ) )
1489 foundParent =
false;
1501 if ( childPath.endsWith(
'/' ) )
1502 childPath.chop( 1 );
1504 if ( path.startsWith( childPath ) )
1513 else if ( path.startsWith( itemPath ) )
1531 return QModelIndex();
1545 QModelIndex idx =
findPath( path );
1546 if ( idx.isValid() )
1559 return item ? createIndex( row, column, item ) : QModelIndex();
1566 return QModelIndex();
1573 const QVector<QgsCptCityDataItem *> &items = parent ? parent->
children() :
mRootItems;
1575 for (
int i = 0; i < items.size(); i++ )
1577 if ( items[i] == item )
1578 return createIndex( i, 0, item );
1580 QModelIndex childIndex =
findItem( item, items[i] );
1581 if ( childIndex.isValid() )
1585 return QModelIndex();
1602 QModelIndex idx =
findItem( parent );
1603 if ( !idx.isValid() )
1606 beginInsertRows( idx, first, last );
1616 QModelIndex idx =
findItem( parent );
1617 if ( !idx.isValid() )
1619 beginRemoveRows( idx, first, last );
1663 QStringList QgsCptCityBrowserModel::mimeTypes()
const 1668 types <<
"application/x-vnd.qgis.qgis.uri";
1672 QMimeData *QgsCptCityBrowserModel::mimeData(
const QModelIndexList &indexes )
const 1675 Q_FOREACH (
const QModelIndex &
index, indexes )
1677 if ( index.isValid() )
1680 if ( ptr->
type() != QgsCptCityDataItem::Layer )
continue;
1688 bool QgsCptCityBrowserModel::dropMimeData(
const QMimeData *
data, Qt::DropAction action,
int row,
int column,
const QModelIndex &
parent )
1706 void *v = idx.internalPointer();
1708 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)
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