mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
VerticalTabs: Automatically scroll to current tab
This commit is contained in:
parent
66023d2dba
commit
ebd2b6da51
@ -58,10 +58,22 @@ void TabTreeView::drawBranches(QPainter *, const QRect &, const QModelIndex &) c
|
|||||||
// Disable drawing branches
|
// Disable drawing branches
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabTreeView::currentChanged(const QModelIndex &, const QModelIndex &)
|
void TabTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||||
{
|
{
|
||||||
// Disable current index
|
if (current.data(TabModel::CurrentTabRole).toBool()) {
|
||||||
setCurrentIndex(QModelIndex());
|
QTreeView::currentChanged(current, previous);
|
||||||
|
} else if (previous.data(TabModel::CurrentTabRole).toBool()) {
|
||||||
|
setCurrentIndex(previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||||
|
{
|
||||||
|
QTreeView::dataChanged(topLeft, bottomRight, roles);
|
||||||
|
|
||||||
|
if (roles.size() == 1 && roles.at(0) == TabModel::CurrentTabRole && topLeft.data(TabModel::CurrentTabRole).toBool()) {
|
||||||
|
setCurrentIndex(topLeft);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabTreeView::viewportEvent(QEvent *event)
|
bool TabTreeView::viewportEvent(QEvent *event)
|
||||||
|
@ -35,6 +35,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override;
|
void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override;
|
||||||
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override;
|
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override;
|
||||||
|
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
|
||||||
|
|
||||||
bool viewportEvent(QEvent *event) override;
|
bool viewportEvent(QEvent *event) override;
|
||||||
|
|
||||||
enum DelegateButton {
|
enum DelegateButton {
|
||||||
|
Loading…
Reference in New Issue
Block a user