diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8ad53315..9352ec36 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1110,20 +1110,23 @@ void MainWindow::aboutToShowBackMenu() if (!currentTab()) return; QWebHistory *history = currentTab()->view()->history(); - int historyCount = history->count(); + int pivot = history->currentItemIndex(); + int offset = 0; + QList<QWebHistoryItem> historyList = history->backItems(8); //no more than 8 elements! + int listCount = historyList.count(); + if(pivot >= 8) + offset = pivot - 8; + - // Limit history views in the menu to 8 - if(historyCount > 8) - historyCount = 8; - for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) + for(int i = listCount - 1; i>=0; --i) { - QWebHistoryItem item = history->backItems(history->count()).at(i); + QWebHistoryItem item = historyList.at(i); KAction *action = new KAction(this); - action->setData( i - history->currentItemIndex() ); - QIcon icon = Application::icon(item.url()); - action->setIcon(icon); - action->setText(item.title()); + action->setData(i + offset); + QIcon icon = Application::icon( item.url() ); + action->setIcon( icon ); + action->setText( item.title() ); m_historyBackMenu->addAction(action); } } @@ -1131,24 +1134,14 @@ void MainWindow::aboutToShowBackMenu() void MainWindow::openActionUrl(QAction *action) { - int offset = action->data().toInt(); - QWebHistory *history = currentTab()->view()->history(); - - if(!history->itemAt(offset).isValid()) - { - kDebug() << "Invalid Offset!"; - return; - } - - if (offset < 0) + int index = action->data().toInt(); + + QWebHistory *history = currentTab()->view()->history(); + if(!history->itemAt(index).isValid()) { - history->goToItem(history->itemAt(offset)); // back + kDebug() << "Invalid Index!: "<< index; return; } - if (offset > 0) - { - history->goToItem(history->forwardItems(history->count() - offset).back()); // forward FIXME CRASH - } - + history->goToItem( history->itemAt(index) ); } |