2013-07-08 11:12:50 +00:00
|
|
|
#ifndef CSM_WOLRD_REGIONMAP_H
|
|
|
|
#define CSM_WOLRD_REGIONMAP_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
2013-07-08 14:53:08 +00:00
|
|
|
class Data;
|
|
|
|
|
2013-07-08 11:12:50 +00:00
|
|
|
/// \brief Model for the region map
|
|
|
|
///
|
|
|
|
/// This class does not holds any record data (other than for the purpose of buffering).
|
|
|
|
class RegionMap : public QAbstractTableModel
|
|
|
|
{
|
2013-07-08 14:53:08 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-07-09 12:20:28 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
typedef std::pair<int, int> CellIndex;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
struct CellDescription
|
|
|
|
{
|
|
|
|
bool mDeleted;
|
|
|
|
std::string mRegion;
|
|
|
|
|
|
|
|
CellDescription();
|
|
|
|
};
|
|
|
|
|
|
|
|
std::map<CellIndex, CellDescription> mMap;
|
|
|
|
CellIndex mMin; ///< inclusive
|
|
|
|
CellIndex mMax; ///< exclusive
|
2013-07-08 11:12:50 +00:00
|
|
|
std::map<std::string, unsigned int> mColours; ///< region ID, colour (RGBA)
|
|
|
|
|
2013-07-09 12:20:28 +00:00
|
|
|
CellIndex getIndex (const QModelIndex& index) const;
|
2013-07-08 11:12:50 +00:00
|
|
|
///< Translates a Qt model index into a cell index (which can contain negative components)
|
|
|
|
|
2013-07-08 14:53:08 +00:00
|
|
|
void buildRegions (Data& data);
|
|
|
|
|
|
|
|
void buildMap (Data& data);
|
|
|
|
|
2013-07-08 11:12:50 +00:00
|
|
|
public:
|
|
|
|
|
2013-07-08 14:53:08 +00:00
|
|
|
RegionMap (Data& data);
|
2013-07-08 11:12:50 +00:00
|
|
|
|
|
|
|
virtual int rowCount (const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
virtual int columnCount (const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
|
|
|
|
|
|
|
|
virtual Qt::ItemFlags flags (const QModelIndex& index) const;
|
2013-07-08 14:53:08 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void regionsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
|
|
|
|
|
|
|
void regionsInserted (const QModelIndex& parent, int start, int end);
|
|
|
|
|
|
|
|
void regionsChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
|
|
|
|
|
|
|
void cellsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
|
|
|
|
|
|
|
void cellsInserted (const QModelIndex& parent, int start, int end);
|
|
|
|
|
|
|
|
void cellsChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
2013-07-08 11:12:50 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|