mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Core: simplify ConnectionListModel
The complicated setup with the AddressRole is unnecessary. All we want to be able to do is get the index of a specific text in the list. In hindsight I am puzzled why I implemented this in such a complex fashion. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
643f4a5726
commit
c69ca4df80
3 changed files with 4 additions and 27 deletions
|
@ -7,29 +7,15 @@ ConnectionListModel::ConnectionListModel(QObject *parent) :
|
|||
{
|
||||
}
|
||||
|
||||
QHash <int, QByteArray> ConnectionListModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[AddressRole] = "address";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant ConnectionListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() < 0 || index.row() >= m_addresses.count())
|
||||
return QVariant();
|
||||
if (role != AddressRole)
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
return m_addresses[index.row()];
|
||||
}
|
||||
|
||||
QString ConnectionListModel::address(int idx) const
|
||||
{
|
||||
if (idx < 0 || idx >> m_addresses.count())
|
||||
return QString();
|
||||
return m_addresses[idx];
|
||||
}
|
||||
|
||||
int ConnectionListModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
return m_addresses.count();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue