edit address dialog: basic data/widget binding

This commit is contained in:
Wladimir J. van der Laan
2011-06-02 17:48:45 +02:00
parent 5c94371f9a
commit 44384a4602
5 changed files with 84 additions and 4 deletions

View File

@@ -95,10 +95,8 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());
if(role == Qt::DisplayRole)
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
/* index.row(), index.column() */
/* Return QString */
switch(index.column())
{
case Label:
@@ -126,6 +124,30 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
return QVariant();
}
bool AddressTableModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
if(!index.isValid())
return false;
if(role == Qt::EditRole)
{
switch(index.column())
{
case Label:
/* TODO */
break;
case Address:
/* TODO */
/* Double-check that we're not overwriting receiving address */
/* Note that changing address changes index in map */
break;
}
/* emit dataChanged(index, index); */
return true;
}
return false;
}
QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation == Qt::Horizontal)