Dive d/l selection UI: Add the setData method

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-01-08 10:55:38 -02:00 committed by Dirk Hohndel
parent 55cc16d77d
commit 797bf49129
2 changed files with 16 additions and 0 deletions

View file

@ -539,6 +539,21 @@ QVariant DiveImportedModel::data(const QModelIndex& index, int role) const
return QVariant();
}
bool DiveImportedModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid())
return false;
if (index.row() + firstIndex > lastIndex)
return false;
if (role != Qt::CheckStateRole)
return false;
checkStates[index.row() + firstIndex ] = value.toBool();
dataChanged(index, index, QVector<int>() << Qt::CheckStateRole);
}
void DiveImportedModel::setImportedDivesIndexes(int first, int last)
{
beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex);

View file

@ -33,6 +33,7 @@ public:
int columnCount(const QModelIndex& index = QModelIndex()) const;
int rowCount(const QModelIndex& index = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
void setImportedDivesIndexes(int first, int last);
private:
int firstIndex;