WindowHistoryInformation QtWebKitWebWidget::getHistory() const { QVariantHash data; data[QLatin1String("position")] = m_webView->page()->mainFrame()->scrollPosition(); data[QLatin1String("zoom")] = getZoom(); m_webView->history()->currentItem().setUserData(data); QWebHistory *history = m_webView->history(); WindowHistoryInformation information; information.index = history->currentItemIndex(); for (int i = 0; i < history->count(); ++i) { const QWebHistoryItem item = history->itemAt(i); WindowHistoryEntry entry; entry.url = item.url().toString(); entry.title = item.title(); entry.position = item.userData().toHash().value(QLatin1String("position"), QPoint(0, 0)).toPoint(); entry.zoom = item.userData().toHash().value(QLatin1String("zoom")).toInt(); information.entries.append(entry); } return information; }
void MainWindow::displayViewActions() { ui->actionBack->setEnabled(ui->webView->canGoBack()); ui->backButton->setEnabled(ui->webView->canGoBack()); ui->actionForward->setEnabled(ui->webView->canGoForward()); ui->forwardButton->setEnabled(ui->webView->canGoForward()); ui->menuView->clear(); ui->menuView->addAction(ui->actionBack); ui->menuView->addAction(ui->actionForward); ui->menuView->addSeparator(); m_backMenu->clear(); m_forwardMenu->clear(); QWebHistory *history = ui->webView->page()->history(); for (const QWebHistoryItem &item: history->backItems(10)) m_backMenu->addAction(addHistoryAction(history, item)); if (history->count() > 0) addHistoryAction(history, history->currentItem())->setEnabled(false); for (const QWebHistoryItem &item: history->forwardItems(10)) m_forwardMenu->addAction(addHistoryAction(history, item)); displayTabs(); }
void NavigationBar::aboutToShowHistoryNextMenu() { if (!m_menuForward || !m_window->weView()) { return; } m_menuForward->clear(); QWebHistory* history = m_window->weView()->history(); int curindex = history->currentItemIndex(); int count = 0; for (int i = curindex + 1; i < history->count(); i++) { QWebHistoryItem item = history->itemAt(i); if (item.isValid()) { QString title = titleForUrl(item.title(), item.url()); const QIcon icon = iconForPage(item.url(), IconProvider::standardIcon(QStyle::SP_ArrowForward)); Action* act = new Action(icon, title); act->setData(i); connect(act, SIGNAL(triggered()), this, SLOT(loadHistoryIndex())); connect(act, SIGNAL(ctrlTriggered()), this, SLOT(loadHistoryIndexInNewTab())); m_menuForward->addAction(act); } count++; if (count == 20) { break; } } m_menuForward->addSeparator(); m_menuForward->addAction(tr("Clear history"), this, SLOT(clearHistory())); }
QString DumpRenderTree::dumpBackForwardList(QWebPage* page) { QWebHistory* history = page->history(); QString result; result.append(QLatin1String("\n============== Back Forward List ==============\n")); // FORMAT: // " (file test):fast/loader/resources/click-fragment-link.html **nav target**" // "curr-> (file test):fast/loader/resources/click-fragment-link.html#testfragment **nav target**" int maxItems = history->maximumItemCount(); foreach (const QWebHistoryItem item, history->backItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); } QWebHistoryItem item = history->currentItem(); if (item.isValid()) result.append(dumpHistoryItem(item, 8, true)); foreach (const QWebHistoryItem item, history->forwardItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); } result.append(QLatin1String("===============================================\n")); return result; }
void NavigationBar::aboutToShowHistoryBackMenu() { if (!m_menuBack || !p_QupZilla->weView()) { return; } m_menuBack->clear(); QWebHistory* history = p_QupZilla->weView()->history(); int curindex = history->currentItemIndex(); int count = 0; for (int i = curindex - 1; i >= 0; i--) { QWebHistoryItem item = history->itemAt(i); if (item.isValid()) { QString title = titleForUrl(item.title(), item.url()); const QIcon &icon = iconForPage(item.url(), qIconProvider->standardIcon(QStyle::SP_ArrowBack)); Action* act = new Action(icon, title); act->setData(i); connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex())); connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab())); m_menuBack->addAction(act); } count++; if (count == 20) { break; } } m_menuBack->addSeparator(); m_menuBack->addAction(tr("Clear history"), this, SLOT(clearHistory())); }
void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers) { QWebHistory *history = currentTab()->view()->history(); QWebHistoryItem *item = 0; if (currentTab()->page()->isOnRekonqPage()) { item = new QWebHistoryItem(history->currentItem()); } else { if (history->canGoBack()) { item = new QWebHistoryItem(history->backItem()); } } if(!item) return; if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) { Application::instance()->loadUrl(item->url(), Rekonq::NewTab); } else { history->goToItem(*item); } updateActions(); }
void BackButton::goBack() { QAction * action = qobject_cast<QAction *>(sender()); int index = action->data().toInt(); QWebHistory * history = m_webView->history(); history->goToItem(history->backItems(-index).first()); }
void NavigationBar::loadHistoryIndex() { QWebHistory* history = m_window->weView()->page()->history(); if (QAction* action = qobject_cast<QAction*>(sender())) { loadHistoryItem(history->itemAt(action->data().toInt())); } }
void NavigationBar::refreshHistory() { if (mApp->isClosing() || p_QupZilla->isClosing()) { return; } QWebHistory* history = p_QupZilla->weView()->page()->history(); m_buttonBack->setEnabled(history->canGoBack()); m_buttonNext->setEnabled(history->canGoForward()); }
void NavigationBar::goAtHistoryIndex() { QWebHistory* history = p_QupZilla->weView()->page()->history(); if (QAction* action = qobject_cast<QAction*>(sender())) { history->goToItem(history->itemAt(action->data().toInt())); } refreshHistory(); }
void MainWindow::clearWebHistory() { QWebHistory *history = view->history(); history->clear(); for (const auto &item : pageHistoryItems) { pageHistoryMenu->removeAction(item); } pageHistoryItems.clear(); visitedUrls.clear(); }
void NavigationBar::refreshHistory() { if (mApp->isClosing() || !m_window->weView()) { return; } QWebHistory* history = m_window->weView()->page()->history(); m_buttonBack->setEnabled(history->canGoBack()); m_buttonForward->setEnabled(history->canGoForward()); }
void NavigationBar::goForwardInNewTab() { QWebHistory* history = m_window->weView()->page()->history(); if (!history->canGoForward()) { return; } loadHistoryItemInNewTab(history->forwardItem()); }
void WebView::back() { QWebHistory* history = page()->history(); if (history->canGoBack()) { history->back(); emit urlChanged(url()); emit iconChanged(); } }
void WebView::forward() { QWebHistory* history = page()->history(); if (history->canGoForward()) { history->forward(); emit urlChanged(url()); emit iconChanged(); } }
static void clearHistory(QWebPage* page) { // QWebHistory::clear() leaves current page, so remove it as well by setting // max item count to 0, and then setting it back to it's original value. QWebHistory* history = page->history(); int itemCount = history->maximumItemCount(); history->clear(); history->setMaximumItemCount(0); history->setMaximumItemCount(itemCount); }
void WebKitBrowserExtension::saveState(QDataStream &stream) { // TODO: Save information such as form data from the current page. QWebHistory* history = (view() ? view()->history() : 0); const int historyIndex = (history ? history->currentItemIndex() : -1); const KUrl historyUrl = (history ? KUrl(history->currentItem().url()) : m_part->url()); stream << historyUrl << static_cast<qint32>(xOffset()) << static_cast<qint32>(yOffset()) << historyIndex << m_historyData; }
void NavigationBar::loadHistoryItemInNewTab(const QWebHistoryItem &item) { TabWidget* tabWidget = m_window->tabWidget(); int tabIndex = tabWidget->duplicateTab(tabWidget->currentIndex()); QWebHistory* history = m_window->weView(tabIndex)->page()->history(); history->goToItem(item); if (qzSettings->newTabPosition == Qz::NT_SelectedTab) { tabWidget->setCurrentIndex(tabIndex); } }
void NavigationBar::loadHistoryIndexInNewTab(int index) { if (QAction* action = qobject_cast<QAction*>(sender())) { index = action->data().toInt(); } if (index == -1) { return; } QWebHistory* history = m_window->weView()->page()->history(); loadHistoryItemInNewTab(history->itemAt(index)); }
void NavigationBar::goForwardInNewTab() { QWebHistory* history = p_QupZilla->weView()->page()->history(); if (!history->canGoForward()) { return; } int itemIndex = WebHistoryWrapper::indexOfItem(history->items(), history->forwardItem()); if (itemIndex == -1) { return; } goAtHistoryIndexInNewTab(itemIndex); }
void NavigationBar::goAtHistoryIndexInNewTab(int index) { if (QAction* action = qobject_cast<QAction*>(sender())) { index = action->data().toInt(); } if (index == -1) { return; } TabWidget* tabWidget = p_QupZilla->tabWidget(); int tabIndex = tabWidget->duplicateTab(tabWidget->currentIndex()); QWebHistory* history = p_QupZilla->weView(tabIndex)->page()->history(); history->goToItem(history->itemAt(index)); if (qzSettings->newTabPosition == Qz::NT_SelectedTab) { tabWidget->setCurrentIndex(tabIndex); } }
void KWebKitPart::slotRestoreFrameState(QWebFrame *frame) { QWebPage* page = (frame ? frame->page() : 0); QWebHistory* history = (page ? page->history() : 0); // No history item... if (!history || history->count() < 1) return; QWebHistoryItem currentHistoryItem (history->currentItem()); // Update the scroll position if needed. See comment in slotSaveFrameState above. if (frame->baseUrl().resolved(frame->url()) == currentHistoryItem.url()) { const QPoint currentPos (frame->scrollPosition()); const QPoint desiredPos (currentHistoryItem.userData().toPoint()); if (currentPos.isNull() && !desiredPos.isNull()) { frame->setScrollPosition(desiredPos); } } }
static PyObject *meth_QWebHistory_clear(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QWebHistory *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QWebHistory, &sipCpp)) { sipCpp->clear(); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QWebHistory, sipName_clear, doc_QWebHistory_clear); return NULL; }
static PyObject *meth_QWebHistory_setMaximumItemCount(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { int a0; QWebHistory *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "Bi", &sipSelf, sipType_QWebHistory, &sipCpp, &a0)) { sipCpp->setMaximumItemCount(a0); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QWebHistory, sipName_setMaximumItemCount, doc_QWebHistory_setMaximumItemCount); return NULL; }
static SIP_SSIZE_T slot_QWebHistory___len__(PyObject *sipSelf) { QWebHistory *sipCpp = reinterpret_cast<QWebHistory *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_QWebHistory)); if (!sipCpp) return 0; { { SIP_SSIZE_T sipRes = 0; #line 1 "Auto-generated" sipRes = (SIP_SSIZE_T)sipCpp->count(); #line 513 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtWebKit/sipQtWebKitQWebHistory.cpp" return sipRes; } } return 0; }
static PyObject *meth_QWebHistory_goToItem(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { const QWebHistoryItem* a0; QWebHistory *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QWebHistory, &sipCpp, sipType_QWebHistoryItem, &a0)) { sipCpp->goToItem(*a0); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QWebHistory, sipName_goToItem, doc_QWebHistory_goToItem); return NULL; }
void QtWebKitHelpViewer::goToHistoryItem(bool forward) { QAction *action = qobject_cast<QAction *>(sender()); QTC_ASSERT(action, return); QWebHistory *history = m_webView->history(); QTC_ASSERT(history, return); bool ok = false; int index = action->data().toInt(&ok); QTC_ASSERT(ok, return); if (forward) history->goToItem(history->forwardItems(history->count()).at(index)); else history->goToItem(history->backItems(history->count()).at(index)); }
void BrowserWidget::loadUrlBackend(QUrl url, bool tryFromHistory) { if (url == homePageUrl) { emit loadingHomePage(); } else if (tryFromHistory) { QWebHistory *history = webView->page()->history(); for (int i = 0; i < history->count(); i++) { if (history->itemAt(i).url() == url) { history->goToItem(history->itemAt(i)); urlChanging(history->itemAt(i).url()); // workaround return; } } } webView->load(url); }
void WebKitBrowserExtension::restoreState(QDataStream &stream) { KUrl u; QByteArray historyData; qint32 xOfs = -1, yOfs = -1, historyItemIndex = -1; stream >> u >> xOfs >> yOfs >> historyItemIndex >> historyData; QWebHistory* history = (view() ? view()->page()->history() : 0); if (history) { bool success = false; if (history->count() == 0) { // Handle restoration: crash recovery, tab close undo, session restore if (!historyData.isEmpty()) { historyData = qUncompress(historyData); // uncompress the history data... QBuffer buffer (&historyData); if (buffer.open(QIODevice::ReadOnly)) { QDataStream stream (&buffer); view()->page()->setProperty("HistoryNavigationLocked", true); stream >> *history; QWebHistoryItem currentItem (history->currentItem()); if (currentItem.isValid()) { if (currentItem.userData().isNull() && (xOfs != -1 || yOfs != -1)) { const QPoint scrollPos (xOfs, yOfs); currentItem.setUserData(scrollPos); } // NOTE 1: The following Konqueror specific workaround is necessary // because Konqueror only preserves information for the last visited // page. However, we save the entire history content in saveState and // and hence need to elimiate all but the current item here. // NOTE 2: This condition only applies when Konqueror is restored from // abnormal termination ; a crash and/or a session restoration. if (QCoreApplication::applicationName() == QLatin1String("konqueror")) { history->clear(); } //kDebug() << "Restoring URL:" << currentItem.url(); m_part->setProperty("NoEmitOpenUrlNotification", true); history->goToItem(currentItem); } } } success = (history->count() > 0); } else { // Handle navigation: back and forward button navigation.
void TestRunner::removeAllVisitedLinks() { QWebHistory* history = m_drt->webPage()->history(); history->clear(); DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks(true); }