Changeset dd87350 in subsurface


Ignore:
Timestamp:
Dec 14, 2017, 8:53:06 AM (6 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
c2e76aa
Parents:
62ef78b
git-author:
Jan Mulder <jlmulder@…> (12/14/17 06:41:47)
git-committer:
Dirk Hohndel <dirk@…> (12/14/17 08:53:06)
Message:

mobile: stay on same dive after edit

See issue #875. In hindsight the reason for this bug is easy to
understand. When updating a dive, the dive was first removed
from the model, and added in its new state again. This does seems
resonable, but the delete in the model causes the internal (QML)
state to be changed, and the previous state (like the currentIndex
that was pointing to the just deleted row, so that one is changed to
something valid internally) is not restored at recreation of
the edited dive. The QML engine has no way to understand that
the remove and subsequent add are in fact one atomic operation.

This can be solved by simply updating the underlying data in
place, and notifying the change using a dataChanged emitted
signal. The dataChanged signal takes care of the repaint of
the screen, and there is no need for removeRow/insertRow pairs.

Fixes: #875

Signed-off-by: Jan Mulder <jlmulder@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qt-models/divelistmodel.cpp

    r3f0d210 rdd87350  
    9494{
    9595        DiveObjectHelper *newDive = new DiveObjectHelper(d);
    96         removeDive(i);
    97         insertDive(i, newDive);
     96        m_dives.replace(i, newDive);
     97        emit dataChanged(createIndex(i, 0), createIndex(i, 0));
    9898}
    9999
Note: See TracChangeset for help on using the changeset viewer.