From 2547192d95fd24c3df668a1f47df79d469723b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 20 Feb 2013 12:37:47 +0100 Subject: [PATCH] Fix some errors found by ModelTest --- tabbox/clientmodel.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tabbox/clientmodel.cpp b/tabbox/clientmodel.cpp index c27d3ffa2d..2230942947 100644 --- a/tabbox/clientmodel.cpp +++ b/tabbox/clientmodel.cpp @@ -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 client) const