27 #include "../../../common/Exception.h" 
   28 #include "../../../dataaccess/dataset/DataSet.h" 
   29 #include "../../../dataaccess/dataset/ObjectIdSet.h" 
   30 #include "../../../dataaccess/utils/Utils.h" 
   36 #include <QtGui/QIcon> 
   38 bool IsPkey(
const int& column, 
const std::vector<size_t>& pkeys)
 
   40   std::vector<size_t>::const_iterator it;
 
   42   for(it=pkeys.begin(); it!=pkeys.end(); ++it)
 
   55       return QObject::tr(
"Void");
 
   59       return QObject::tr(
"Bit");
 
   63       return QObject::tr(
"Char");
 
   67       return QObject::tr(
"Unsigned char");
 
   73       return QObject::tr(
"Integer");
 
   79       return QObject::tr(
"Unsigned integer");
 
   83       return QObject::tr(
"Boolean");
 
   87       return QObject::tr(
"Float");
 
   91       return QObject::tr(
"Double");
 
   95       return QObject::tr(
"Numeric");
 
   99       return QObject::tr(
"String");
 
  103       return QObject::tr(
"Byte array");
 
  107       return QObject::tr(
"Geometry");
 
  111       return QObject::tr(
"Date time");
 
  115       return QObject::tr(
"Unknown");
 
  121   : QAbstractTableModel(parent),
 
  149   m_pkeysColumns = pkeys;
 
  156   m_promoter->promote(oids);
 
  168   m_OIdsVisible = visible;
 
  176   std::vector<size_t>::iterator it;
 
  178   for(it=m_pkeysColumns.begin(); it!=m_pkeysColumns.end(); ++it)
 
  179     oids->
addProperty(m_dataset->getPropertyName(*it), *it, m_dataset->getPropertyDataType(*it));
 
  184   for(
int i=initRow; i<=finalRow; i++)
 
  186     row = (m_promoter == 0) ? i : (
int)m_promoter->getLogicalRow(i);
 
  187     m_dataset->move(row);
 
  206   return (m_dataset == 0 || !m_enabled) ? 0 : (int)m_dataset->size();
 
  211   return (m_dataset == 0) ? 0 : (int) m_dataset->getNumProperties();
 
  221     case Qt::TextAlignmentRole:
 
  222       return (
int)(Qt::AlignCenter);
 
  225     case Qt::DisplayRole:
 
  226       if(m_currentRow != index.row())
 
  228         m_currentRow = index.row();
 
  230         int row = (m_promoter == 0) ? m_currentRow : (
int)m_promoter->getLogicalRow(m_currentRow);
 
  231         m_dataset->move(row);
 
  234       if(!m_dataset->isNull(index.column())) 
 
  235         return m_dataset->getAsString(index.column(), 6).c_str();
 
  248   if(orientation == Qt::Horizontal)
 
  252       case Qt::DisplayRole:
 
  253         return m_dataset->getPropertyName(section).c_str();
 
  256       case Qt::DecorationRole:
 
  257         return (m_OIdsVisible && 
IsPkey(section, m_pkeysColumns)) ?
 
  258           QIcon::fromTheme(
"key") :
 
  262       case Qt::ToolTipRole:
 
  263        return m_dataset->getPropertyName(section).c_str() + QString(
" : ") + 
columnType(m_dataset->getPropertyDataType(section));
 
  267         return QAbstractTableModel::headerData(section, orientation, role);
 
  275       case Qt::DisplayRole:
 
  280         return QAbstractTableModel::headerData(section, orientation, role);
 
  290   if (index.isValid() == 
false)
 
  293   Qt::ItemFlags flags = QAbstractItemModel::flags(index);
 
  295   flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable ;
 
  307   beginInsertColumns(parent, column, column+count);
 
  316   beginRemoveColumns(parent, column, column+count);
 
Defines an mechanism for logical ordering of rows. 
 
This class represents a set of unique ids created in the same context. i.e. from the same data set...
 
void showOIdsVisible(const bool &visible)
Shows an icon for indentify the columns that are used for identify objects. 
 
int columnCount(const QModelIndex &parent) const 
 
te::da::ObjectIdSet * getObjectIdSet(const int &initRow, const int &finalRow)
Returns the ObjectIdSet begining with row initRow and ending in finalRow. 
 
Promoter * m_promoter
Promoter to be used. 
 
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
 
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 
void setDataSet(te::da::DataSet *dset)
Updates the data being used. 
 
const std::vector< std::string > & getPropertyNames() const 
It returns the property names used to generated the oids. 
 
Promoter * getPromoter()
Returns the pointer to the promoter being used. 
 
void setEnabled(const bool &enabled)
Enable or disable the dataset presentation. 
 
int rowCount(const QModelIndex &parent) const 
 
void setPkeysColumns(const std::vector< size_t > &pkeys)
Sets the columns used as pkeys, for presentation purposes. 
 
QString columnType(const int &type)
 
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
 
void promote(const te::da::ObjectIdSet *oids)
Promotes the rows identified by oids. 
 
QVariant data(const QModelIndex &index, int role) const 
 
DataSetTableModel(QObject *parent=0)
Constructor. 
 
bool IsPkey(const int &column, const std::vector< size_t > &pkeys)
 
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
 
Qt::ItemFlags flags(const QModelIndex &index) const 
 
void addProperty(const std::string &name, std::size_t pos, int type)
It adds a property that will be used to generate the unique ids. 
 
virtual ~DataSetTableModel()
Virtual destructor. 
 
void add(ObjectId *oid)
It adds an object id to this object id set. 
 
A dataset is the unit of information manipulated by the data access module of TerraLib. 
 
A model based on te::da::DataSet. 
 
A class used for logical ordering of rows. 
 
QVariant headerData(int section, Qt::Orientation orientation, int role) const