From 21e8478e02d0d56e8ea225d504f980717a58d203 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 20 Oct 2009 16:52:52 +0200 Subject: Fixing WebHistory moves and removing a strange SIGNAL/SLOT connection. Lionel, did you write a wrong function there? --- src/mainwindow.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b41b630f..f68a3880 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1054,22 +1054,22 @@ void MainWindow::slotAboutToShowBackMenu() return; QWebHistory *history = currentTab()->history(); int historyCount = history->count(); + // Limit history views in the menu to 8 - int limit = 0; + if(historyCount > 8) + historyCount = 8; + + kDebug() << "History Count: " << historyCount; for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { - qDebug() << history->currentItemIndex(); QWebHistoryItem item = history->backItems(history->count()).at(i); KAction *action = new KAction(this); - action->setData(history->currentItemIndex() - (i + 1)); - QIcon icon = Application::icon(item.url()); + action->setData( i - history->currentItemIndex() ); + kDebug() << "Current Item Index: " << history->currentItemIndex(); + QIcon icon = Application::icon(item.url()); action->setIcon(icon); action->setText(item.title()); m_historyBackMenu->addAction(action); - ++limit; - if (limit >= 8) { - break; - } } } @@ -1077,20 +1077,26 @@ void MainWindow::slotAboutToShowBackMenu() void MainWindow::slotOpenActionUrl(QAction *action) { int offset = action->data().toInt(); + kDebug() << "Offset: " << offset; QWebHistory *history = currentTab()->history(); - qDebug() << offset; - qDebug() << history->itemAt(offset).isValid(); + + if(!history->itemAt(offset).isValid()) + { + kDebug() << "Invalid Offset!"; + return; + } + if (offset < 0) { history->goToItem(history->itemAt(offset)); // back + return; } - else + + if (offset > 0) { - if (offset > 0) - { - history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward - } + history->goToItem(history->forwardItems(history->count() - offset).back()); // forward FIXME CRASH } + } -- cgit v1.2.1