1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

TabMruModel: Ignore moving already first index

This commit is contained in:
David Rosca 2018-02-06 14:56:18 +01:00
parent 71f5d72a65
commit beeb68f7a6
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8

View File

@ -151,16 +151,20 @@ TabMruModelItem *TabMruModel::item(const QModelIndex &index) const
void TabMruModel::currentTabChanged(int index) void TabMruModel::currentTabChanged(int index)
{ {
TabMruModelItem *it = item(mapFromSource(sourceModel()->index(index, 0))); TabMruModelItem *it = item(mapFromSource(sourceModel()->index(index, 0)));
if (it) { if (!it) {
const int from = m_root->children.indexOf(it); 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();
} }
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) void TabMruModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)