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)
48 if(*it == static_cast<size_t>(column))
60 return QObject::tr(
"Void");
63 return QObject::tr(
"Bit");
66 return QObject::tr(
"Char");
69 return QObject::tr(
"Unsigned char");
74 return QObject::tr(
"Integer");
79 return QObject::tr(
"Unsigned integer");
82 return QObject::tr(
"Boolean");
85 return QObject::tr(
"Float");
88 return QObject::tr(
"Double");
91 return QObject::tr(
"Numeric");
94 return QObject::tr(
"String");
97 return QObject::tr(
"Byte array");
100 return QObject::tr(
"Geometry");
103 return QObject::tr(
"Date time");
106 return QObject::tr(
"Unknown");
120 void setValue(
const int& row,
const int& column,
const std::string& value)
122 std::pair<int, int> key(row, column);
126 bool isEdited(
const int& row,
const int& column)
const 131 std::string
getValue(
const int& row,
const int& column)
133 return m_editions[std::pair<int, int>(row, column)];
143 std::vector<int> rows;
148 for(
size_t i = 0; i < rows.size(); ++i)
151 std::set<int> ef = fields[i];
153 in->
move(static_cast<size_t>(rows[i]));
158 bool edited = ef.find(static_cast<int>(j)) != ef.end();
164 std::string data =
getValue(rows[i], static_cast<int>(j));
208 for(
int i = init; i <=
final; i++)
214 std::map< std::pair<int, int>, std::string > aux;
215 std::map< std::pair<int, int>, std::string >::iterator it;
219 int cE = it->first.second;
224 std::pair<int, int> rC = it->first;
226 if(rC.second > column)
229 aux[rC] = it->second;
239 std::vector< std::set<int> > res;
243 std::set<int> subRes;
244 int current =
m_editions.begin()->first.first;
245 rows.push_back(current);
246 std::map< std::pair<int, int>, std::string >::iterator it;
250 int cR = it->first.first;
255 res.push_back(subRes);
260 subRes.insert(it->first.second);
263 if(rows.size() != res.size())
264 res.push_back(subRes);
339 std::vector<size_t>::iterator it;
347 for(
size_t i=static_cast<size_t>(initRow); i<=static_cast<size_t>(finalRow); i++)
378 std::unique_ptr<te::da::DataSet> dset;
415 case Qt::TextAlignmentRole:
416 return (
int)(Qt::AlignCenter);
419 case Qt::DisplayRole:
431 std::string value =
m_editor->getValue(
435 return QString::fromUtf8(value.c_str());
445 return QString::fromUtf8(value.c_str());
463 return data(index, Qt::DisplayRole);
475 if(orientation == Qt::Horizontal)
479 case Qt::DisplayRole:
483 case Qt::DecorationRole:
485 QIcon::fromTheme(
"key") :
489 case Qt::ToolTipRole:
494 return QAbstractTableModel::headerData(section, orientation, role);
502 case Qt::DisplayRole:
507 return QAbstractTableModel::headerData(section, orientation, role);
517 if (index.isValid() ==
false)
520 Qt::ItemFlags
flags = QAbstractItemModel::flags(index);
522 flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
525 flags |= Qt::ItemIsEditable;
532 if(role == Qt::EditRole)
566 QString curV =
data(index, Qt::DisplayRole).toString();
567 QString newV = value.toString();
571 std::string out = newV.toUtf8().data();
579 QMessageBox::warning(
nullptr, tr(
"Edition Failure"), e.
what());
589 beginInsertColumns(parent, column, column+count);
598 beginRemoveColumns(parent, column, column+count);
600 m_editor->columnsRemoved(column, column+count);
std::string getValue(const int &row, const int &column)
A model based on te::da::DataSet.
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.
virtual std::size_t size() const =0
It returns the collection size, if it is known.
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)
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
void setExpressionByInClause(const std::string source="")
std::vector< std::set< int > > getEditedLists(std::vector< int > &rows)
bool IsPkey(const int &column, const std::vector< size_t > &pkeys)
virtual std::string getAsString(std::size_t i, int precision=0) const
Method for retrieving a data value as a string plain representation.
void columnRemoved(const int &column)
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.
virtual std::unique_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
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.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
A template for atomic data types (integers, floats, strings and others).
void setValue(const int &row, const int &column, const std::string &value)
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
virtual bool moveFirst()=0
It moves the internal pointer to the first item in the collection.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
QString ColumnType(const int &type)