17#ifndef QGSCPTCITYARCHIVE_H
18#define QGSCPTCITYARCHIVE_H
25#include <QAbstractItemModel>
33#define DEFAULT_CPTCITY_ARCHIVE "cpt-city-qgis-min"
44 const QString &baseDir = QString() );
51 QString baseDir()
const;
52 static QString baseDir( QString archiveName );
53 static QString defaultBaseDir();
54 void setBaseDir(
const QString &dirName ) { mBaseDir = dirName; }
57 QString copyingFileName(
const QString &dirName )
const;
58 QString descFileName(
const QString &dirName )
const;
59 static QString findFileName(
const QString &target,
const QString &startDir,
const QString &baseDir );
60 static QMap< QString, QString > copyingInfo(
const QString &fileName );
61 static QMap< QString, QString > description(
const QString &fileName );
63 static QMap< double, QPair<QColor, QColor> > gradientColorMap(
const QString &fileName )
SIP_SKIP;
68 static void initArchives(
bool loadAll =
false );
69 static void initArchive(
const QString &archiveName,
const QString &archiveBaseDir );
70 static void initDefaultArchive();
71 static void clearArchives();
73 static QMap< QString, QgsCptCityArchive * > archiveRegistry();
76 QVector< QgsCptCityDataItem * >
rootItems()
const {
return mRootItems; }
77 QVector< QgsCptCityDataItem * >
selectionItems()
const {
return mSelectionItems; }
84 QVector< QgsCptCityDataItem * > mRootItems;
85 QVector<QgsCptCityDataItem *> mSelectionItems;
112 const QString &name,
const QString &path );
121 virtual int leafCount()
const;
125 virtual void refresh();
130 virtual QVector<QgsCptCityDataItem *> createChildren();
135 virtual void populate();
183 Q_DECL_DEPRECATED
virtual bool handleDrop(
const QMimeData *data, Qt::DropAction action )
SIP_DEPRECATED { Q_UNUSED( data ); Q_UNUSED( action );
return false; }
197 QVector<QgsCptCityDataItem *>
children()
const {
return mChildren; }
198 virtual QIcon
icon() {
return mIcon; }
199 virtual QIcon
icon( QSize size ) { Q_UNUSED( size )
return icon(); }
200 QString
name()
const {
return mName; }
201 QString
path()
const {
return mPath; }
202 QString
info()
const {
return mInfo; }
205 void setIcon(
const QIcon &icon ) { mIcon = icon; }
282 const QString &name,
const QString &path,
283 const QString &variantName = QString(),
284 bool initialize =
false );
286 const QString &name,
const QString &path,
287 const QStringList &variantList,
288 bool initialize =
false );
297 QIcon icon()
override;
298 QIcon icon( QSize size )
override;
318 const QString &name,
const QString &path );
323 QVector<QgsCptCityDataItem *> childrenRamps(
bool recursive );
338 const QString &name,
const QString &path );
340 QVector<QgsCptCityDataItem *> createChildren()
override;
345 const QString &name,
const QString &path );
348 QMap< QString, QStringList > rampsMap();
349 QStringList dirEntries()
const;
364 QVector<QgsCptCityDataItem *> createChildren()
override;
384 const QVector<QgsCptCityDataItem *> &items );
386 QVector<QgsCptCityDataItem *> createChildren()
override;
412 ViewType Type = Authors );
416 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
417 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
418 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
419 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
420 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
421 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
425 QModelIndex parent(
const QModelIndex &index )
const override;
432 bool hasChildren(
const QModelIndex &parent = QModelIndex() )
const override;
438 void refresh(
const QString &path );
441 void refresh(
const QModelIndex &index = QModelIndex() );
444 QModelIndex findPath(
const QString &path );
448 bool canFetchMore(
const QModelIndex &parent )
const override;
449 void fetchMore(
const QModelIndex &parent )
override;
454 void endInsertItems();
456 void endRemoveItems();
462 void removeRootItems();
An "All ramps item", which contains all items in a flat hierarchy.
QVector< QgsCptCityDataItem * > mItems
Represents a CPT City color scheme.
QVector< QgsCptCityDataItem * > rootItems() const
QString archiveName() const
static QgsCptCityArchive * defaultArchive()
QgsCptCityArchive & operator=(const QgsCptCityArchive &rh)=delete
void setBaseDir(const QString &dirName)
QVector< QgsCptCityDataItem * > selectionItems() const
QgsCptCityArchive(const QgsCptCityArchive &rh)=delete
A custom item model for display of CPT City color palettes.
QVector< QgsCptCityDataItem * > mRootItems
A Collection: logical collection of subcollections and color ramps.
void addChild(QgsCptCityDataItem *item)
Item that represents a layer that can be opened with one of the providers.
const QgsCptCityColorRamp & ramp() const
int leafCount() const override
Returns the total count of "leaf" items (all children which are end nodes).
QgsCptCityColorRamp mRamp
A color ramp from the CPT City collection.
Base class for all items in the model.
QgsCptCityDataItem * parent() const
void setToolTip(const QString &msg)
void beginRemoveItems(QgsCptCityDataItem *parent, int first, int last)
Emitted before child items are removed from this data item.
QString shortInfo() const
virtual Q_DECL_DEPRECATED bool acceptDrop()
Returns true if the item accepts drag & dropped layers - e.g.
virtual Q_DECL_DEPRECATED bool handleDrop(const QMimeData *data, Qt::DropAction action)
Tries to process the data dropped on this item.
void endRemoveItems()
Emitted after child items have been removed from this data item.
bool isPopulated()
Returns true if the item is already populated.
QVector< QgsCptCityDataItem * > mChildren
void endInsertItems()
Emitted after child items have been added to this data item.
void setParent(QgsCptCityDataItem *parent)
virtual Q_DECL_DEPRECATED QWidget * paramWidget()
virtual QIcon icon(QSize size)
void setIcon(const QIcon &icon)
QVector< QgsCptCityDataItem * > children() const
void beginInsertItems(QgsCptCityDataItem *parent, int first, int last)
Emitted before child items are added to this item.
A directory: contains subdirectories and color ramps.
QMap< QString, QStringList > mRampsMap
A selection: contains subdirectories and color ramps.
QStringList mSelectionsList
QStringList selectionsList() const
#define DEFAULT_CPTCITY_ARCHIVE