27 #include "../../../common/Exception.h" 
   28 #include "../../../dataaccess/dataset/DataSet.h" 
   29 #include "../../../dataaccess/dataset/ObjectIdSet.h" 
   30 #include "../../../dataaccess/utils/Utils.h" 
   31 #include "../../../datatype/Enums.h" 
   32 #include "../../../datatype/SimpleData.h" 
   33 #include "../../../memory/DataSet.h" 
   34 #include "../../../memory/DataSetItem.h" 
   41 #include <QMessageBox> 
   43 bool IsPkey(
const int& column, 
const std::vector<size_t>& pkeys)
 
   45   std::vector<size_t>::const_iterator it;
 
   47   for(it=pkeys.begin(); it!=pkeys.end(); ++it)
 
   60       return QObject::tr(
"Void");
 
   64       return QObject::tr(
"Bit");
 
   68       return QObject::tr(
"Char");
 
   72       return QObject::tr(
"Unsigned char");
 
   78       return QObject::tr(
"Integer");
 
   84       return QObject::tr(
"Unsigned integer");
 
   88       return QObject::tr(
"Boolean");
 
   92       return QObject::tr(
"Float");
 
   96       return QObject::tr(
"Double");
 
  100       return QObject::tr(
"Numeric");
 
  104       return QObject::tr(
"String");
 
  108       return QObject::tr(
"Byte array");
 
  112       return QObject::tr(
"Geometry");
 
  116       return QObject::tr(
"Date time");
 
  120       return QObject::tr(
"Unknown");
 
  138     void setValue(
const int& row, 
const int& column, 
const std::string& value)
 
  140       std::pair<int, int> key(row, column);
 
  144     bool isEdited(
const int& row, 
const int& column)
 const 
  149     std::string 
getValue(
const int& row, 
const int& column)
 
  151       return m_editions[std::pair<int, int>(row, column)];
 
  161       std::vector<int> rows;
 
  166       for(
int i = 0; i < (int)rows.size(); ++i)
 
  169         std::set<int> ef = fields[i];
 
  176           bool edited = ef.find(j) != ef.end();
 
  182             std::string data = 
getValue(rows[i], j);
 
  226       for(
int i = init; i <= 
final; i++)
 
  232       std::map< std::pair<int, int>, std::string > aux;
 
  233       std::map< std::pair<int, int>, std::string >::iterator it;
 
  237         int cE = it->first.second;
 
  242         std::pair<int, int> rC = it->first;
 
  244         if(rC.second > column)
 
  247         aux[rC] = it->second;
 
  257       std::vector< std::set<int> > res;
 
  261         std::set<int> subRes;
 
  262         int current = 
m_editions.begin()->first.first;
 
  263         rows.push_back(current);
 
  264         std::map< std::pair<int, int>, std::string >::iterator it;
 
  268           int cR = it->first.first;
 
  273             res.push_back(subRes);
 
  278           subRes.insert(it->first.second);
 
  281         if(rows.size() != res.size())
 
  282           res.push_back(subRes);
 
  292   : QAbstractTableModel(parent),
 
  320   m_rowCount = (m_dataset == 0 || !m_enabled) ? 0 : (
int)m_dataset->
size();
 
  327   m_pkeysColumns = pkeys;
 
  334   m_promoter->promote(oids);
 
  346   m_OIdsVisible = visible;
 
  354   std::vector<size_t>::iterator it;
 
  356   for(it=m_pkeysColumns.begin(); it!=m_pkeysColumns.end(); ++it)
 
  357     oids->
addProperty(m_dataset->getPropertyName(*it), *it, m_dataset->getPropertyDataType(*it));
 
  362   for(
int i=initRow; i<=finalRow; i++)
 
  364     row = (int)m_promoter->getLogicalRow(i);
 
  365     m_dataset->move(row);
 
  379   m_rowCount = (m_enabled && m_dataset != 0) ? (
int)m_dataset->size() : 0;
 
  386   m_isEditable = editable;
 
  391   std::auto_ptr<te::da::DataSet> dset;
 
  394   m_editor->getEditedDataSet(m_dataset, md, ps);
 
  403   return m_editor->hasEditions();
 
  418   return (m_dataset == 0) ? 0 : (int) m_dataset->getNumProperties();
 
  428     case Qt::TextAlignmentRole:
 
  429       return (
int)(Qt::AlignCenter);
 
  432     case Qt::DisplayRole:
 
  434       if(m_currentRow != index.row())
 
  436         m_currentRow = index.row();
 
  438         int row = (int)m_promoter->getLogicalRow(m_currentRow);
 
  439         m_dataset->move(row);
 
  442       if(m_editor->isEdited(m_promoter->getLogicalRow(index.row()), index.column()))
 
  443         return m_editor->getValue(m_promoter->getLogicalRow(index.row()), index.column()).c_str();
 
  445       if(m_dataset->isNull(index.column()))
 
  450         std::string value = m_dataset->getString(index.column());
 
  453           return value.c_str();
 
  458         return m_dataset->getAsString(index.column(), 6).c_str();
 
  463       if(m_editor->isEdited(m_promoter->getLogicalRow(index.row()), index.column()))
 
  473       return data(index, Qt::DisplayRole);
 
  485   if(orientation == Qt::Horizontal)
 
  489       case Qt::DisplayRole:
 
  490         return m_dataset->getPropertyName(section).c_str();
 
  493       case Qt::DecorationRole:
 
  494         return (m_OIdsVisible && 
IsPkey(section, m_pkeysColumns)) ?
 
  495           QIcon::fromTheme(
"key") :
 
  499       case Qt::ToolTipRole:
 
  500        return m_dataset->getPropertyName(section).c_str() + QString(
" : ") + 
ColumnType(m_dataset->getPropertyDataType(section));
 
  504         return QAbstractTableModel::headerData(section, orientation, role);
 
  512       case Qt::DisplayRole:
 
  517         return QAbstractTableModel::headerData(section, orientation, role);
 
  527   if (index.isValid() == 
false)
 
  530   Qt::ItemFlags flags = QAbstractItemModel::flags(index);
 
  532   flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
 
  534   if(m_isEditable && !
IsPkey(index.column(), m_pkeysColumns))
 
  535     flags |= Qt::ItemIsEditable;
 
  542   if(role == Qt::EditRole)
 
  546       switch(m_dataset->getPropertyDataType(index.column()))
 
  576       QString curV = data(index, Qt::DisplayRole).toString();
 
  577       QString newV = value.toString();
 
  580         m_editor->setValue(m_promoter->getLogicalRow(index.row()), index.column(), value.toString().toStdString());
 
  586       QMessageBox::warning(0, tr(
"Edition Failure"), e.
what());
 
  596   beginInsertColumns(parent, column, column+count);
 
  605   beginRemoveColumns(parent, column, column+count);
 
  607   m_editor->columnsRemoved(column, column+count);
 
std::string getValue(const int &row, const int &column)
 
A model based on te::da::DataSet. 
 
CharEncoding
Supported charsets (character encoding). 
 
std::map< std::pair< int, int >, std::string > m_editions
 
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
 
A class that models the description of a dataset. 
 
virtual const char * what() const 
It outputs the exception message. 
 
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property. 
 
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. 
 
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership. 
 
virtual bool move(std::size_t i)=0
It moves the dataset internal pointer to a given position. 
 
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
 
void getEditedDataSet(te::da::DataSet *in, te::mem::DataSet *out, std::vector< std::set< int > > &fields)
 
This class represents a set of unique ids created in the same context. i.e. from the same data set...
 
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL. 
 
std::vector< std::set< int > > getEditedLists(std::vector< int > &rows)
 
bool IsPkey(const int &column, const std::vector< size_t > &pkeys)
 
virtual std::size_t size() const =0
It returns the collection size, if it is known. 
 
void columnRemoved(const int &column)
 
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset. 
 
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
 
void columnsRemoved(const int &init, const int &final)
 
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
 
A dataset is the unit of information manipulated by the data access module of TerraLib. 
 
bool isEdited(const int &row, const int &column) const 
 
const std::vector< std::string > & getPropertyNames() const 
It returns the property names used to generated the oids. 
 
void add(ObjectId *oid)
It adds an object id to this object id set. 
 
A template for atomic data types (integers, floats, strings and others). 
 
void setValue(const int &row, const int &column, const std::string &value)
 
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos. 
 
virtual std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const 
Method for retrieving any other type of data value stored in the data source. 
 
QString ColumnType(const int &type)