mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
TabTreeModel: Only sync top-level tabs when closing window
Otherwise reordering tabs is too distracting when tabbar is visible.
This commit is contained in:
parent
ae4d971d1a
commit
4ad6d6cda1
|
@ -151,7 +151,7 @@ void TabModelTest::treeModelTest()
|
||||||
BrowserWindow *w = mApp->createWindow(Qz::BW_NewWindow);
|
BrowserWindow *w = mApp->createWindow(Qz::BW_NewWindow);
|
||||||
|
|
||||||
TabModel sourceModel(w);
|
TabModel sourceModel(w);
|
||||||
TabTreeModel model;
|
TabTreeModel model(w);
|
||||||
model.setSourceModel(&sourceModel);
|
model.setSourceModel(&sourceModel);
|
||||||
ModelTest modelTest(&model);
|
ModelTest modelTest(&model);
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ void TabModelTest::resetTreeModelTest()
|
||||||
BrowserWindow *w = mApp->createWindow(Qz::BW_NewWindow);
|
BrowserWindow *w = mApp->createWindow(Qz::BW_NewWindow);
|
||||||
|
|
||||||
TabModel sourceModel(w);
|
TabModel sourceModel(w);
|
||||||
TabTreeModel model;
|
TabTreeModel model(w);
|
||||||
model.setSourceModel(&sourceModel);
|
model.setSourceModel(&sourceModel);
|
||||||
ModelTest modelTest(&model);
|
ModelTest modelTest(&model);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "tabtreemodel.h"
|
#include "tabtreemodel.h"
|
||||||
#include "tabmodel.h"
|
#include "tabmodel.h"
|
||||||
#include "webtab.h"
|
#include "webtab.h"
|
||||||
|
#include "browserwindow.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
@ -81,13 +82,10 @@ void TabTreeModelItem::addChild(TabTreeModelItem *item, int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TabTreeModel::TabTreeModel(QObject *parent)
|
TabTreeModel::TabTreeModel(BrowserWindow *window, QObject *parent)
|
||||||
: QAbstractProxyModel(parent)
|
: QAbstractProxyModel(parent)
|
||||||
{
|
{
|
||||||
m_syncTimer = new QTimer(this);
|
connect(window, &BrowserWindow::aboutToClose, this, &TabTreeModel::syncTopLevelTabs);
|
||||||
m_syncTimer->setInterval(100);
|
|
||||||
m_syncTimer->setSingleShot(true);
|
|
||||||
connect(m_syncTimer, &QTimer::timeout, this, &TabTreeModel::syncTopLevelTabs);
|
|
||||||
|
|
||||||
connect(this, &QAbstractProxyModel::sourceModelChanged, this, &TabTreeModel::init);
|
connect(this, &QAbstractProxyModel::sourceModelChanged, this, &TabTreeModel::init);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +237,6 @@ bool TabTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, in
|
||||||
}
|
}
|
||||||
m_root->addChild(it, childPos);
|
m_root->addChild(it, childPos);
|
||||||
endMoveRows();
|
endMoveRows();
|
||||||
m_syncTimer->start();
|
|
||||||
} else {
|
} else {
|
||||||
parentItem->tab->addChildTab(tab, row);
|
parentItem->tab->addChildTab(tab, row);
|
||||||
}
|
}
|
||||||
|
@ -390,7 +387,6 @@ void TabTreeModel::connectTab(WebTab *tab)
|
||||||
}
|
}
|
||||||
m_root->addChild(item, pos);
|
m_root->addChild(item, pos);
|
||||||
endMoveRows();
|
endMoveRows();
|
||||||
m_syncTimer->start();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(tab, &WebTab::childTabAdded, this, [=](WebTab *child, int pos) {
|
connect(tab, &WebTab::childTabAdded, this, [=](WebTab *child, int pos) {
|
||||||
|
@ -407,9 +403,6 @@ void TabTreeModel::connectTab(WebTab *tab)
|
||||||
}
|
}
|
||||||
item->addChild(from, childPos);
|
item->addChild(from, childPos);
|
||||||
endMoveRows();
|
endMoveRows();
|
||||||
if (item->parent == m_root) {
|
|
||||||
m_syncTimer->start();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
class WebTab;
|
class WebTab;
|
||||||
|
class BrowserWindow;
|
||||||
class TabTreeModelItem;
|
class TabTreeModelItem;
|
||||||
|
|
||||||
class FALKON_EXPORT TabTreeModel : public QAbstractProxyModel
|
class FALKON_EXPORT TabTreeModel : public QAbstractProxyModel
|
||||||
|
@ -31,7 +32,7 @@ class FALKON_EXPORT TabTreeModel : public QAbstractProxyModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TabTreeModel(QObject *parent = nullptr);
|
explicit TabTreeModel(BrowserWindow *window, QObject *parent = nullptr);
|
||||||
~TabTreeModel();
|
~TabTreeModel();
|
||||||
|
|
||||||
QModelIndex tabIndex(WebTab *tab) const;
|
QModelIndex tabIndex(WebTab *tab) const;
|
||||||
|
@ -68,5 +69,4 @@ private:
|
||||||
|
|
||||||
TabTreeModelItem *m_root = nullptr;
|
TabTreeModelItem *m_root = nullptr;
|
||||||
QHash<WebTab*, TabTreeModelItem*> m_items;
|
QHash<WebTab*, TabTreeModelItem*> m_items;
|
||||||
QTimer *m_syncTimer = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,7 @@ void VerticalTabsWidget::setViewType(VerticalTabsPlugin::ViewType type)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VerticalTabsPlugin::TabTreeView:
|
case VerticalTabsPlugin::TabTreeView:
|
||||||
m_treeModel = new TabTreeModel(model);
|
m_treeModel = new TabTreeModel(m_window, model);
|
||||||
m_treeModel->setSourceModel(m_window->tabModel());
|
m_treeModel->setSourceModel(m_window->tabModel());
|
||||||
model->setSourceModel(m_treeModel);
|
model->setSourceModel(m_treeModel);
|
||||||
m_normalView->setModel(model);
|
m_normalView->setModel(model);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user