void FindToolBar::setFindFlag(FindFlag flag, bool enabled)
{
    bool hasFlag = hasFindFlag(flag);
    if ((hasFlag && enabled) || (!hasFlag && !enabled))
        return;
    if (enabled)
        m_findFlags |= flag;
    else
        m_findFlags &= ~flag;
    if (flag != FindBackward)
        findFlagsChanged();
}
void FindFadLineEdit::invokeFindFlagsChanged()
{
    findFlags = 0;

    if ( actionCaseSensitive->isChecked() )
        findFlags |= Shared::CaseSensitive;

    if ( actionWholeWords->isChecked() )
        findFlags |= Shared::WholeWords;

    if ( actionRegExp->isChecked() )
        findFlags |= Shared::RegExp;

    updateIcons();
    emit findFlagsChanged();
}
FindAndReplace::FindAndReplace( QTextEdit * textedit, QWidget * parent )
    : QWidget( parent ),
      ui( new Ui::FindAndReplace ),
      d_editor ( textedit )
{
    ui->setupUi( this );
    highlighter = new Find_Highlighter( d_editor->document() );

    rehighlight();
    updateStates();

    timer.setSingleShot( true );
    connect( &timer, SIGNAL( timeout() ), SLOT( rehighlight() ) );
    setDelayInterval( 250 );

    connect( ui->findEdit, SIGNAL( cleansingText() ), SLOT( rehighlight() ) );
    connect( ui->findEdit, SIGNAL( findFlagsChanged() ), SLOT( rehighlight() ) );
}
void FindToolBar::readSettings()
{
    QSettings *settings = ICore::settings();
    settings->beginGroup(QLatin1String("Find"));
    settings->beginGroup(QLatin1String("FindToolBar"));
    FindFlags flags;
    if (settings->value(QLatin1String("Backward"), false).toBool())
        flags |= FindBackward;
    if (settings->value(QLatin1String("CaseSensitively"), false).toBool())
        flags |= FindCaseSensitively;
    if (settings->value(QLatin1String("WholeWords"), false).toBool())
        flags |= FindWholeWords;
    if (settings->value(QLatin1String("RegularExpression"), false).toBool())
        flags |= FindRegularExpression;
    if (settings->value(QLatin1String("PreserveCase"), false).toBool())
        flags |= FindPreserveCase;
    settings->endGroup();
    settings->endGroup();
    m_findFlags = flags;
    findFlagsChanged();
}