mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
VerticalTabs: Expand subtree when new tab is inserted
This commit is contained in:
parent
072d3c28ee
commit
805c23ddb9
@ -23,6 +23,7 @@
|
|||||||
#include "webtab.h"
|
#include "webtab.h"
|
||||||
#include "tabcontextmenu.h"
|
#include "tabcontextmenu.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
#include <QHoverEvent>
|
#include <QHoverEvent>
|
||||||
|
|
||||||
@ -77,6 +78,28 @@ void TabTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
|
||||||
|
{
|
||||||
|
QTreeView::rowsInserted(parent, start, end);
|
||||||
|
|
||||||
|
// Parent for WebTab is set after insertTab is emitted
|
||||||
|
const QPersistentModelIndex index = model()->index(start, 0, parent);
|
||||||
|
QTimer::singleShot(0, this, [=]() {
|
||||||
|
if (!index.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QModelIndex idx = index;
|
||||||
|
QVector<QModelIndex> stack;
|
||||||
|
do {
|
||||||
|
stack.append(idx);
|
||||||
|
idx = idx.parent();
|
||||||
|
} while (idx.isValid());
|
||||||
|
for (const QModelIndex &index : qAsConst(stack)) {
|
||||||
|
expand(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool TabTreeView::viewportEvent(QEvent *event)
|
bool TabTreeView::viewportEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
|
@ -36,7 +36,7 @@ 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;
|
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
|
||||||
|
void rowsInserted(const QModelIndex &parent, int start, int end) override;
|
||||||
bool viewportEvent(QEvent *event) override;
|
bool viewportEvent(QEvent *event) override;
|
||||||
|
|
||||||
enum DelegateButton {
|
enum DelegateButton {
|
||||||
|
Loading…
Reference in New Issue
Block a user