Index: sources/model/MListModel.cpp =================================================================== diff -u -reefb098d1e4b036c4b8dbaa1061b5765b93e1955 -r53f7433638ec721d4f687fe8a4ed5d98c03c2fe7 --- sources/model/MListModel.cpp (.../MListModel.cpp) (revision eefb098d1e4b036c4b8dbaa1061b5765b93e1955) +++ sources/model/MListModel.cpp (.../MListModel.cpp) (revision 53f7433638ec721d4f687fe8a4ed5d98c03c2fe7) @@ -4,8 +4,7 @@ * \brief Retrieve the role names set for this list model. * \return Role names used for this model. */ -QHash View::MListModel::roleNames() const -{ +QHash View::MListModel::roleNames() const { return _roleNames; } @@ -14,10 +13,8 @@ * \param[in] roleNames New role names for this list model. * \note This will clear the list model of any data. */ -void View::MListModel::setRoleNames(const QHash& vRoleNames) -{ - if (_roleNames != vRoleNames) - { +void View::MListModel::setRoleNames(const QHash& vRoleNames) { + if ( _roleNames != vRoleNames ) { clear(); _roleNames = vRoleNames; } @@ -27,8 +24,7 @@ * \brief Get the number of rows in this list model. * \return Number of rows in this list model. */ -int View::MListModel::rowCount(const QModelIndex &) const -{ +int View::MListModel::rowCount(const QModelIndex &) const { return _data.size(); } @@ -38,23 +34,22 @@ * \param[in] role Role of the data to fetch. * \return Data at index for role or Invalid if index or role are not valid. */ -QVariant View::MListModel::data(const QModelIndex &vIndex, int vRole) const -{ +QVariant View::MListModel::data(const QModelIndex &vIndex, int vRole) const { QVariant mData; // check for invalid or out of bounds index - if ( ! vIndex.isValid() || vIndex.row() >= rowCount()) { goto lOut; } + if ( ! vIndex.isValid() || vIndex.row() >= rowCount() ) { goto lOut; } // ensure the data is not empty if ( _data.isEmpty() ) { goto lOut; } // ensure the role is in the data - if ( _data[vIndex.row()].find(vRole) == _data[vIndex.row()].end()) { goto lOut; } + if ( _data[vIndex.row()].find(vRole) == _data[vIndex.row()].end() ) { goto lOut; } mData = _data[vIndex.row()][vRole]; // check if data is valid - if (! mData.isValid()) { goto lOut; } + if ( ! mData.isValid() ) { goto lOut; } lOut: return mData; @@ -64,18 +59,17 @@ * \brief Retrieve the data stored at the given index for the specified role and expose to QML * \param[in] vRow Index of the data in the list model. */ -QVariantMap View::MListModel::get(int vRow) const -{ +QVariantMap View::MListModel::get(int vRow) const { QVariantMap map; QHash roles = roleNames(); // Row bounds check - if (vRow < 0 || vRow >= rowCount()) { goto lOut; } + if ( vRow < 0 || vRow >= rowCount() ) { goto lOut; } // Check if roles are defined if ( roles.isEmpty() ) { goto lOut; } - for (auto it = roles.cbegin(); it != roles.cend(); ++it) { + for ( auto it = roles.cbegin(); it != roles.cend(); ++it ) { const int role = it.key(); const QByteArray roleName = it.value(); @@ -84,7 +78,7 @@ QVariant value = data(index(vRow, 0), role); if ( ! value.isValid() ) { goto lOut; } - map.insert(QString::fromUtf8(roleName), value); + map.insert( QString::fromUtf8(roleName), value ); } lOut: @@ -108,12 +102,11 @@ * \return Return true if data was set properly, otherwise false. */ bool View::MListModel::setData(const QModelIndex &vIndex, const QVariant& vValue, int vRole) { - if (! vIndex.isValid() || vIndex.row() >= _data.count()) { + if ( ! vIndex.isValid() || vIndex.row() >= _data.count() ) { return false; } - if (_data[vIndex.row()][vRole] != vValue) - { + if ( _data[vIndex.row()][vRole] != vValue ) { _data[vIndex.row()][vRole] = vValue; // explicitly emit a dataChanged signal to notify anybody bound to this property (vRole) emit dataChanged(vIndex, vIndex, QVector(1, vRole)); @@ -126,12 +119,10 @@ * \brief Assignment operator * \return A reference to this object. */ -View::MListModel& View::MListModel::operator = (const QList> &src) -{ +View::MListModel& View::MListModel::operator = (const QList> &src) { clear(); - if (_data != src) - { + if ( _data != src ) { beginInsertRows(QModelIndex(), 0, src.count() - 1); _data = src; endInsertRows();