D18249: [datamodel] Rework items insert/remove

David Edmundson noreply at phabricator.kde.org
Mon Jan 14 19:54:01 GMT 2019


davidedmundson added inline comments.

INLINE COMMENTS

> datamodel.cpp:55-61
> +    const QHash<int, QByteArray> roles = sourceModel()->roleNames();
> +    m_roleIds.reserve(roles.count());
> +    for (auto i = roles.constBegin(); i != roles.constEnd(); ++i) {
>          m_roleIds[QString::fromUtf8(i.value())] = i.key();
>      }
>  
> +    setRoleNames(roles);

This part, ship it! but I don't think it'll make a huge difference to anything

> datamodel.cpp:77
>  
> +    beginResetModel();
> +

This shouldn't be needed

setSourceModel will will do a reset internally

> datamodel.cpp:379
> +
> +    if (oldLength > 0) {
> +        beginRemoveRows(QModelIndex(), sourceIndex, sourceIndex + oldLength - 1);

I don't understand what you're changing here, can you provide a bit more detail on the exact problem.

> datamodel.cpp:444
>                  beginRemoveRows(QModelIndex(), sourceIndex, sourceIndex + count - 1);
> -            }
> -            m_items.remove(sourceName);
> -            if (count > 0) {
> +                m_items.remove(sourceName);
>                  endRemoveRows();

this isn't equivalent.

I could have an entry with an empty count

Now this gets left behind

REPOSITORY
  R242 Plasma Framework (Library)

REVISION DETAIL
  https://phabricator.kde.org/D18249

To: anthonyfieroni, davidedmundson, broulik, ngraham, mart, #plasma
Cc: kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190114/80069a92/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list