PropertyBasedTableModel.cpp   PropertyBasedTableModel.cpp 
#include "PropertyBasedTableModel.hpp" #include "PropertyBasedTableModel.hpp"
#include <QDebug> #include <QDebug>
/* ********************************************************************* */
#if 0
#pragma mark -
#pragma mark instance Methods
#endif
/* ********************************************************************* */
PropertyBasedTableModel::PropertyBasedTableModel(QObject *parent) PropertyBasedTableModel::PropertyBasedTableModel(QObject *parent)
: QAbstractTableModel(parent) : QAbstractTableModel(parent)
{ {
} }
PropertyBasedTableModel::~PropertyBasedTableModel() PropertyBasedTableModel::~PropertyBasedTableModel()
{ {
delete modelObject; delete modelObject;
modelObject = NULL; modelObject = NULL;
} }
skipping to change at line 46 skipping to change at line 52
int PropertyBasedTableModel::columnCount(const QModelIndex &parent) const int PropertyBasedTableModel::columnCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
return mappings.size(); return mappings.size();
} }
QVariant PropertyBasedTableModel::data(const QModelIndex &index, int role) const QVariant PropertyBasedTableModel::data(const QModelIndex &index, int role) const
{ {
QVariant data; QVariant data;
if ((role == Qt::DisplayRole || role ==Qt::EditRole) if ((role == Qt::DisplayRole || role == Qt::EditRole)
&& index.isValid() && index.isValid()
&& index.row() < content->size() && index.row() < content->size()
&& index.row() >= 0 && index.row() >= 0
&& index.column() < mappings.size() && index.column() < mappings.size()
&& index.column() >= 0){ && index.column() >= 0){
QObject *object = content->at(index.row()); QObject *object = content->at(index.row());
data = object->property(mappings[index.column()].toS tdString().c_str()); data = object->property(mappings[index.column()].toS tdString().c_str());
} }
return data; return data;
} }
bool PropertyBasedTableModel::insertRows(int position, int rows, const QMod elIndex &index) bool PropertyBasedTableModel::insertRows(int position, int rows, const QMod elIndex &index)
{ {
Q_UNUSED(index); Q_UNUSED(index);
beginInsertRows(QModelIndex(), position, position+rows-1); beginInsertRows(QModelIndex(), position, position + rows - 1);
for (int row=0; row < rows; row++) { for (int row=0; row < rows; row++) {
QObject* newInstance = modelObject->metaObject()->newInstanc e(Q_ARG(QObject, *modelObject)); QObject* newInstance = modelObject->metaObject()->newInstanc e(Q_ARG(QObject, *modelObject));
Q_ASSERT(newInstance != 0); Q_ASSERT(newInstance != 0);
content->insert(position, newInstance); content->insert(position, newInstance);
} }
endInsertRows(); endInsertRows();
return true; return true;
} }
bool PropertyBasedTableModel::removeRows(int position, int rows, const QMod elIndex &index) bool PropertyBasedTableModel::removeRows(int position, int rows, const QMod elIndex &index)
{ {
Q_UNUSED(index); Q_UNUSED(index);
beginRemoveRows(QModelIndex(), position, position+rows-1); beginRemoveRows(QModelIndex(), position, position + rows - 1);
for (int row=0; row < rows; ++row) { for (int row=0; row < rows; ++row) {
content->removeAt(position); content->removeAt(position);
} }
endRemoveRows(); endRemoveRows();
return true; return true;
} }
bool PropertyBasedTableModel::setData(const QModelIndex &index, const QVari ant &value, int role) bool PropertyBasedTableModel::setData(const QModelIndex &index, const QVari ant &value, int role)
 End of changes. 4 change blocks. 
3 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/