diff --git a/src/plugins/VerticalTabs/tabfiltermodel.cpp b/src/plugins/VerticalTabs/tabfiltermodel.cpp index f2af6e24f..b411747d6 100644 --- a/src/plugins/VerticalTabs/tabfiltermodel.cpp +++ b/src/plugins/VerticalTabs/tabfiltermodel.cpp @@ -37,6 +37,11 @@ void TabFilterModel::setFilterPinnedTabs(bool filter) invalidateFilter(); } +void TabFilterModel::setRejectDropOnLastIndex(bool reject) +{ + m_rejectDropOnLastIndex = reject; +} + bool TabFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { if (m_mode == NoFilter) { @@ -47,3 +52,10 @@ bool TabFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePa return index.data(TabModel::PinnedRole).toBool() != m_filterPinnedTabs; } +bool TabFilterModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const +{ + if (m_rejectDropOnLastIndex && row == rowCount()) { + return false; + } + return QSortFilterProxyModel::canDropMimeData(data, action, row, column, parent); +} diff --git a/src/plugins/VerticalTabs/tabfiltermodel.h b/src/plugins/VerticalTabs/tabfiltermodel.h index aa44cf20c..cb6676cbc 100644 --- a/src/plugins/VerticalTabs/tabfiltermodel.h +++ b/src/plugins/VerticalTabs/tabfiltermodel.h @@ -30,8 +30,11 @@ public: void setFilterPinnedTabs(bool pinned); + void setRejectDropOnLastIndex(bool reject); + private: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override; enum Mode { NoFilter, @@ -40,4 +43,5 @@ private: Mode m_mode = NoFilter; bool m_filterPinnedTabs = false; + bool m_rejectDropOnLastIndex = false; }; diff --git a/src/plugins/VerticalTabs/verticaltabswidget.cpp b/src/plugins/VerticalTabs/verticaltabswidget.cpp index 0938d45e1..2caed14b1 100644 --- a/src/plugins/VerticalTabs/verticaltabswidget.cpp +++ b/src/plugins/VerticalTabs/verticaltabswidget.cpp @@ -43,6 +43,7 @@ VerticalTabsWidget::VerticalTabsWidget(BrowserWindow *window) m_pinnedView = new TabListView(this); TabFilterModel *model = new TabFilterModel(m_pinnedView); model->setFilterPinnedTabs(false); + model->setRejectDropOnLastIndex(true); model->setSourceModel(m_window->tabModel()); m_pinnedView->setModel(model); m_pinnedView->setHideWhenEmpty(true);