1
/***************************************************************************
5
copyright : (C) 2006 by Radim Blazek
6
email : radim.blazek@gmail.com
7
***************************************************************************/
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
16
#ifndef QGSGRASSMODEL_H
17
#define QGSGRASSMODEL_H
26
#include <QTreeWidget>
27
#include <QAbstractItemModel>
30
class QgsGrassModelItem;
33
/*! \class QgsGrassModel
34
* \brief Model representing GRASS location structure.
36
class QgsGrassModel: public QAbstractItemModel
42
QgsGrassModel ( QObject * parent = 0 );
47
enum ItemType { None, Gisbase, Location, Mapset, Rasters, Vectors, Raster,
48
Vector, VectorLayer, Regions, Region };
50
//! Set GISBASE and LOCATION_NAME
51
void setLocation ( const QString &gisbase, const QString &location );
53
// Refresh populated node
57
void refreshItem(QgsGrassModelItem *item) ;
59
// Remove items missing in the list
60
void removeItems ( QgsGrassModelItem *item, QStringList list ) ;
62
// Add items missing in children
63
void addItems ( QgsGrassModelItem *item, QStringList list, int type ) ;
66
int itemType(const QModelIndex &index) const;
68
//! Item URI if it is a map
69
QString uri(const QModelIndex &index) const;
72
QModelIndex index ( QgsGrassModelItem *item ) ;
75
QString itemName(const QModelIndex &index);
77
// Item mapset (raster and vector)
78
QString itemMapset(const QModelIndex &index);
80
// Item map (raster and vector)
81
QString itemMap(const QModelIndex &index);
83
// Get info in HTML format
84
QString itemInfo(const QModelIndex &index);
86
// Reimplemented QAbstractItemModel methods
87
QModelIndex index ( int row, int column,
88
const QModelIndex & parent = QModelIndex() ) const;
90
QModelIndex parent ( const QModelIndex & index ) const;
92
int rowCount ( const QModelIndex & parent ) const;
94
int columnCount ( const QModelIndex & parent ) const;
96
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
98
QVariant headerData(int section, Qt::Orientation orientation,
99
int role = Qt::DisplayRole) const;
100
Qt::ItemFlags flags(const QModelIndex &index) const;
106
//! Current LOCATION_NAME
109
//! Root node for current location
110
QgsGrassModelItem *mRoot;
113
QIcon mIconDirectory;
115
QIcon mIconRasterLayer;
116
QIcon mIconVectorLayer;
117
QIcon mIconPointLayer;
118
QIcon mIconLineLayer;
119
QIcon mIconPolygonLayer;
122
#endif // QGSGRASSMODEL_H