21 #include <QVBoxLayout>
47 if ( role == Qt::DisplayRole )
54 if ( role == Qt::UserRole + 1 )
61 if ( role == Qt::CheckStateRole )
73 if ( role == Qt::CheckStateRole )
89 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
90 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable;
95 return Qt::MoveAction;
101 types <<
"application/qgis.layerorderdata";
112 mimeData->
setData(
"application/qgis.layerorderdata", lst.
join(
"\n" ).
toUtf8() );
121 if ( action == Qt::IgnoreAction )
124 if ( !data->
hasFormat(
"application/qgis.layerorderdata" ) )
127 QByteArray encodedData = data->
data(
"application/qgis.layerorderdata" );
134 for (
int i = 0; i < lst.
count(); ++i )
148 while ( --count >= 0 )
193 connect(
mChkOverride, SIGNAL( toggled(
bool ) ), bridge, SLOT( setHasCustomLayerOrder(
bool ) ) );
205 l->addWidget(
mView );
QMimeData * mimeData(const QModelIndexList &indexes) const override
Base class for all map layer types.
void setCustomLayerOrder(const QStringList &order)
QByteArray data(const QString &mimeType) const
bool setData(const QModelIndex &index, const QVariant &value, int role) override
void setSelectionMode(QAbstractItemView::SelectionMode mode)
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
virtual void setModel(QAbstractItemModel *model)
const T & at(int i) const
void setDragDropMode(DragDropMode behavior)
QString join(const QString &separator) const
CustomLayerOrderModel(QgsLayerTreeMapCanvasBridge *bridge, QObject *parent=0)
bool removeRows(int row, int count, const QModelIndex &parent) override
QVariant data(const QModelIndex &index, int role) const override
QStringList defaultLayerOrder() const
QString tr(const char *sourceText, const char *disambiguation, int n)
const QString & name() const
Get the display name of the layer.
QgsLayerTreeGroup * rootGroup() const
Qt::CheckState isVisible() const
int count(const T &value) const
QString fromUtf8(const char *str, int size)
int toInt(bool *ok) const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Qt::DropActions supportedDropActions() const override
This class is a base class for nodes in a layer tree.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void setVisible(Qt::CheckState visible)
bool isLayer(QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
void setMargin(int margin)
Qt::ItemFlags flags(const QModelIndex &index) const override
QStringList customLayerOrder() const
void beginInsertRows(const QModelIndex &parent, int first, int last)
int rowCount(const QModelIndex &) const override
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QStringList order() const
QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer. No type checking is done - use isLayer() to find out whether this operation is ...
void insert(int i, const T &value)
QgsLayerTreeLayer * findLayer(const QString &layerId) const
Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tr...
QgsLayerTreeMapCanvasBridge * mBridge
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
int indexOf(const QRegExp &rx, int from) const
void setData(const QString &mimeType, const QByteArray &data)
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
bool hasCustomLayerOrder() const
QStringList mimeTypes() const override
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void updateLayerVisibility(const QString &layerId)
void refreshModel(const QStringList &order)
void setDropIndicatorShown(bool enable)
void setDragEnabled(bool enable)
Layer tree node points to a map layer.
QByteArray toUtf8() const