TabMruModel: Ignore moving already first index

remotes/origin/Falkon/3.0
David Rosca 8 years ago
parent 71f5d72a65
commit beeb68f7a6
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
  1. 22
      src/lib/tabwidget/tabmrumodel.cpp

@ -151,16 +151,20 @@ TabMruModelItem *TabMruModel::item(const QModelIndex &index) const
void TabMruModel::currentTabChanged(int index)
{
TabMruModelItem *it = item(mapFromSource(sourceModel()->index(index, 0)));
if (it) {
const int from = m_root->children.indexOf(it);
if (!beginMoveRows(QModelIndex(), from, from, QModelIndex(), 0)) {
qWarning() << "Invalid beginMoveRows" << from;
return;
}
m_root->children.removeAt(from);
m_root->children.insert(0, it);
endMoveRows();
if (!it) {
return;
}
const int from = m_root->children.indexOf(it);
if (from == 0) {
return;
}
if (!beginMoveRows(QModelIndex(), from, from, QModelIndex(), 0)) {
qWarning() << "Invalid beginMoveRows" << from;
return;
}
m_root->children.removeAt(from);
m_root->children.insert(0, it);
endMoveRows();
}
void TabMruModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)

Loading…
Cancel
Save