Commit 2d7f0df0 authored by Simon Schmeißer's avatar Simon Schmeißer

Bugfix: don't move down last model entry

Qt model api does not allow move operations where sourceand destination overlapp.
parent 6346ca1e
......@@ -214,10 +214,18 @@ void UrlModel::add(const QJsonObject &data)
size_t i = 0;
for(const auto &urldata : m_data) {
if (urldata == data) {
beginMoveRows(QModelIndex(), i, i, QModelIndex(), m_data.size());
m_data.removeAt(i);
m_data.append(data);
endMoveRows();
if (i+1 < m_data.size()) {
beginMoveRows(QModelIndex(), i, i, QModelIndex(), m_data.size());
m_data.removeAt(i);
m_data.append(data);
endMoveRows();
} else {
//Qt Model Api does not allow overlapping moves, so we need to make sure
//not to move down the last entry
m_data[i] = data;
}
//notify about lastVisited changed
emit dataChanged(index(m_data.size()), index(m_data.size()));
return;
}
++i;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment