diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 22:43:28 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 21:55:13 +0000 |
commit | bd3cb530795a6233024166a81518c5cde1e62273 (patch) | |
tree | 3e8341f2b887a65101310b33bad9cc7146e30f63 | |
parent | efc119e2d5c85e2bc98f9d0904ddad223cf7f74e (diff) |
Contact List: simplify the ContactModel getters
QList::value() does the boundary checking for us.
Change-Id: I6965e6be861da86d35e6f30f74c94ba39e4ad2ea
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
-rw-r--r-- | examples/quickcontrols2/contactlist/contactmodel.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/examples/quickcontrols2/contactlist/contactmodel.cpp b/examples/quickcontrols2/contactlist/contactmodel.cpp index 3ffaed8c..3252c80a 100644 --- a/examples/quickcontrols2/contactlist/contactmodel.cpp +++ b/examples/quickcontrols2/contactlist/contactmodel.cpp @@ -122,28 +122,20 @@ void ContactModel::removeContact(int row) QString ContactModel::getFullName(int row) const { - if (row >= 0 && row < rowCount()) - return m_contacts.at(row).fullName; - return QString(); + return m_contacts.value(row).fullName; } QString ContactModel::getAddress(int row) const { - if (row >= 0 && row < rowCount()) - return m_contacts.at(row).address; - return QString(); + return m_contacts.value(row).address; } QString ContactModel::getCity(int row) const { - if (row >= 0 && row < rowCount()) - return m_contacts.at(row).city; - return QString(); + return m_contacts.value(row).city; } QString ContactModel::getNumber(int row) const { - if (row >= 0 && row < rowCount()) - return m_contacts.at(row).number; - return QString(); + return m_contacts.value(row).number; } |