Пример #1
0
void FindBar::findNext()
{
    // parent webwindow
    WebWindow *w = qobject_cast<WebWindow *>(parent());

    if (w->page()->isOnRekonqPage())
    {
        // trigger part find action
        KParts::ReadOnlyPart *p = w->tabView()->part();
        if (p)
        {
            connect(this, SIGNAL(triggerPartFind()), p, SLOT(slotFind()));
            emit triggerPartFind();
            return;
        }
    }

    if (isHidden())
    {
        QPoint previous_position = w->page()->currentFrame()->scrollPosition();
        w->page()->focusNextPrevChild(true);
        w->page()->currentFrame()->setScrollPosition(previous_position);
        return;
    }

    QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
    if (matchCase())
        options |= QWebPage::FindCaseSensitively;

    bool found = w->page()->findText(_lastStringSearched, options);
    notifyMatch(found);

    if (!found)
    {
        QPoint previous_position = w->page()->currentFrame()->scrollPosition();
        w->page()->focusNextPrevChild(true);
        w->page()->currentFrame()->setScrollPosition(previous_position);
    }
}
Пример #2
0
void MainWindow::findNext()
{
    if (!currentTab())
        return;

    if(currentTab()->page()->isOnRekonqPage())
    {
        // trigger part find action
        KParts::ReadOnlyPart *p = currentTab()->part();
        if(p)
        {
            connect(this, SIGNAL(triggerPartFind()), p, SLOT(slotFind()));
            emit triggerPartFind();
            return;
        }
    }

    if (m_findBar->isHidden())
    {
        QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition();
        currentTab()->view()->page()->focusNextPrevChild(true);
        currentTab()->view()->page()->currentFrame()->setScrollPosition(previous_position);
        return;
    }

    QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
    if (m_findBar->matchCase())
        options |= QWebPage::FindCaseSensitively;

    bool found = currentTab()->view()->findText(m_lastSearch, options);
    m_findBar->notifyMatch(found);

    if (!found)
    {
        QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition();
        currentTab()->view()->page()->focusNextPrevChild(true);
        currentTab()->view()->page()->currentFrame()->setScrollPosition(previous_position);
    }
}