ui: Fix missing selection in duplicated tabs

This commit is contained in:
Oleg Shparber 2017-11-20 22:35:55 +02:00
parent 465a8b92a8
commit 4ba5512411
2 changed files with 15 additions and 5 deletions

View File

@ -566,8 +566,11 @@ void MainWindow::duplicateTab(int index)
if (index < 0 || index >= m_tabStates.size())
return;
TabState *tabState = m_tabStates.at(index);
syncTabState(tabState);
using Registry::SearchModel;
TabState *newTab = new TabState(*m_tabStates.at(index));
TabState *newTab = new TabState(*tabState);
connect(newTab->searchModel, &SearchModel::updated, this, &MainWindow::queryCompleted);
connect(newTab->tocModel, &SearchModel::updated, this, &MainWindow::syncToc);
@ -649,10 +652,7 @@ void MainWindow::setupTabBar()
TabState *previousTabState
= static_cast<TabState *>(m_tabBar->property(PreviousTabState).value<void *>());
if (m_tabStates.contains(previousTabState)) {
previousTabState->selections = ui->treeView->selectionModel()->selectedIndexes();
previousTabState->searchScrollPosition = ui->treeView->verticalScrollBar()->value();
previousTabState->tocScrollPosition = ui->tocListView->verticalScrollBar()->value();
previousTabState->zoomLevel = ui->webView->zoomLevel();
syncTabState(previousTabState);
}
// Load current tab state
@ -752,6 +752,14 @@ void MainWindow::removeTrayIcon()
delete trayIconMenu;
}
void MainWindow::syncTabState(TabState *tabState)
{
tabState->selections = ui->treeView->selectionModel()->selectedIndexes();
tabState->searchScrollPosition = ui->treeView->verticalScrollBar()->value();
tabState->tocScrollPosition = ui->tocListView->verticalScrollBar()->value();
tabState->zoomLevel = ui->webView->zoomLevel();
}
void MainWindow::bringToFront()
{
show();

View File

@ -96,6 +96,8 @@ private:
void createTrayIcon();
void removeTrayIcon();
void syncTabState(TabState *tabState);
QList<TabState *> m_tabStates;
Ui::MainWindow *ui = nullptr;