Fix some errors found by ModelTest

icc-effect-5.14.5
Martin Gräßlin 2013-02-20 12:37:47 +01:00
parent 54b263e7b6
commit 2547192d95
1 changed files with 8 additions and 4 deletions

View File

@ -118,7 +118,9 @@ int ClientModel::columnCount(const QModelIndex& parent) const
int ClientModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent)
if (parent.isValid()) {
return 0;
}
return m_clientList.count();
}
@ -130,11 +132,13 @@ QModelIndex ClientModel::parent(const QModelIndex& child) const
QModelIndex ClientModel::index(int row, int column, const QModelIndex& parent) const
{
Q_UNUSED(parent)
int index = row * columnCount() + column;
if (row < 0 || column != 0 || parent.isValid()) {
return QModelIndex();
}
int index = row * columnCount();
if (index >= m_clientList.count() && !m_clientList.isEmpty())
return QModelIndex();
return createIndex(row, column);
return createIndex(row, 0);
}
QModelIndex ClientModel::index(QWeakPointer<TabBoxClient> client) const