Example #1
0
void TextShow::startSearch(int parag, int index)
{
    QString to_find_string = srchdialog->getText();
    if (doSearch(to_find_string, srchdialog->case_sensitive(), (!srchdialog->get_direction()), &parag, &index)){
        setSelection(parag, index, parag, index + to_find_string.length());
        setCursorPosition(parag, index + to_find_string.length());
        ensureCursorVisible();
        return;
    }
    if (!srchdialog->isVisible()){
        QApplication::beep();
        return;
    }
    QStringList btns;
    btns.append(i18n("&Yes"));
    btns.append(i18n("&No"));

    QObjectList *l = srchdialog->queryList("QPushButton");
    QObjectListIt it( *l );
    if (it.current() == 0){
        delete l;
        QApplication::beep();
        return;
    }
    QPushButton *btnOK = static_cast<QPushButton*>(it.current());
    delete l;
    QRect rc = btnOK->rect();
    rc.moveTopLeft(btnOK->mapToGlobal(rc.topLeft()));
    BalloonMsg *msg = new BalloonMsg(!srchdialog->get_direction() ?
                                     i18n("End of document reached.\nContinue from the beginning?") :
                                     i18n("Beginning of document reached.\nContinue from the end?"),
                                     rc, btns, this);
    connect(msg, SIGNAL(action(int)), this, SLOT(searchAgain(int)));
    msg->show();
}