Esempio n. 1
0
void FindBar::setVisible(bool visible)
{
    // parent webwindow
    WebWindow *w = qobject_cast<WebWindow *>(parent());

    if (visible
            && w->page()->isOnRekonqPage()
            && w->tabView()->part() != 0)
    {
        // findNext is the slot containing part integration code
        findNext();
        return;
    }

    QWidget::setVisible(visible);

    if (visible)
    {
        const QString selectedText = w->page()->selectedText();
        if (!hasFocus() && !selectedText.isEmpty())
        {
            const QString previousText = m_lineEdit->text();
            m_lineEdit->setText(selectedText);

            if (m_lineEdit->text() != previousText)
                findPrevious();
            else
                updateHighlight();
        }
        else if (selectedText.isEmpty())
        {
            emit searchString(m_lineEdit->text());
        }

        m_lineEdit->setFocus();
        m_lineEdit->selectAll();
    }
    else
    {
        updateHighlight();
    }
}
Esempio n. 2
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);
    }
}