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;
69 static void initArchives(
bool loadAll =
false );
70 static void initArchive(
const QString &archiveName,
const QString &archiveBaseDir );
71 static void initDefaultArchive();
72 static void clearArchives();
74 static QMap< QString, QgsCptCityArchive * > archiveRegistry();
77 QVector< QgsCptCityDataItem * >
rootItems()
const {
return mRootItems; }
78 QVector< QgsCptCityDataItem * >
selectionItems()
const {
return mSelectionItems; }
85 QVector< QgsCptCityDataItem * > mRootItems;
86 QVector<QgsCptCityDataItem *> mSelectionItems;
113 const QString &name,
const QString &path );
122 virtual int leafCount()
const;
126 virtual void refresh();
131 virtual QVector<QgsCptCityDataItem *> createChildren();
136 virtual void populate();
184 Q_DECL_DEPRECATED
virtual bool handleDrop(
const QMimeData *data, Qt::DropAction action )
SIP_DEPRECATED { Q_UNUSED( data ); Q_UNUSED( action );
return false; }
198 QVector<QgsCptCityDataItem *>
children()
const {
return mChildren; }
199 virtual QIcon
icon() {
return mIcon; }
200 virtual QIcon
icon( QSize size ) { Q_UNUSED( size )
return icon(); }
201 QString
name()
const {
return mName; }
202 QString
path()
const {
return mPath; }
203 QString
info()
const {
return mInfo; }
206 void setIcon(
const QIcon &icon ) { mIcon = icon; }
283 const QString &name,
const QString &path,
284 const QString &variantName = QString(),
285 bool initialize =
false );
287 const QString &name,
const QString &path,
288 const QStringList &variantList,
289 bool initialize =
false );
298 QIcon icon()
override;
299 QIcon icon( QSize size )
override;
319 const QString &name,
const QString &path );
324 QVector<QgsCptCityDataItem *> childrenRamps(
bool recursive );
339 const QString &name,
const QString &path );
341 QVector<QgsCptCityDataItem *> createChildren()
override;
346 const QString &name,
const QString &path );
349 QMap< QString, QStringList > rampsMap();
350 QStringList dirEntries()
const;
365 QVector<QgsCptCityDataItem *> createChildren()
override;
385 const QVector<QgsCptCityDataItem *> &items );
387 QVector<QgsCptCityDataItem *> createChildren()
override;
413 ViewType Type = Authors );
417 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
418 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
419 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
420 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
421 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
422 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
426 QModelIndex parent(
const QModelIndex &index )
const override;
433 bool hasChildren(
const QModelIndex &parent = QModelIndex() )
const override;
439 void refresh(
const QString &path );
442 void refresh(
const QModelIndex &index = QModelIndex() );
445 QModelIndex findPath(
const QString &path );
449 bool canFetchMore(
const QModelIndex &parent )
const override;
450 void fetchMore(
const QModelIndex &parent )
override;
455 void endInsertItems();
457 void endRemoveItems();
463 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