TEST(FTSQueryNoop, Clone) {
    FTSQueryNoop q;
    q.setQuery("foo");
    q.setLanguage("bar");
    q.setCaseSensitive(true);
    q.setDiacriticSensitive(true);

    auto clone = q.clone();
    ASSERT_EQUALS(clone->getQuery(), q.getQuery());
    ASSERT_EQUALS(clone->getLanguage(), q.getLanguage());
    ASSERT_EQUALS(clone->getCaseSensitive(), q.getCaseSensitive());
    ASSERT_EQUALS(clone->getDiacriticSensitive(), q.getDiacriticSensitive());
}
Exemple #2
0
void ColorSettings::setRegexp() {
	if (bUsingRegexp)
		regexp.assign(strMatch.substr(4), getCaseSensitive() ? boost::match_default : boost::regex_constants::icase);
}
Exemple #3
0
int SearchDialog::find()
{
    QRegExp searchTextRegExp;
    QDltMsg msg;
    QByteArray buf;
    QString text;
    int searchLine;
    int searchBorder;


    if(file->sizeFilter()==0)
            return 0;

    //setSearchColour(QColor(0,0,0),QColor(255,255,255));

    if(getMatch() || getSearchFromBeginning()==false){
        QModelIndexList list = table->selectionModel()->selection().indexes();
        if(list.count()<=0)
        {
            QMessageBox::critical(0, QString("DLT Viewer"),QString("No message selected"));
            setMatch(false);
            //table->clearSelection();
            //setSearchColour(QColor(255,255,255),QColor(255,102,102));
            return 0;
        }

        QModelIndex index;
        for(int num=0; num < list.count();num++)
        {
            index = list[num];
            if(index.column()==0)
            {
                break;
            }
        }
        setStartLine(index.row());
    }

    searchLine = getStartLine();
    searchBorder = getStartLine();;
    if(searchBorder < 0){
        if(getNextClicked()){
            searchBorder = file->sizeFilter()==0?0:file->sizeFilter()-1;
        }else{
            searchBorder = 0;
        }

    }

    if(getRegExp())
    {
        searchTextRegExp.setPattern(getText());
        searchTextRegExp.setCaseSensitivity(getCaseSensitive()?Qt::CaseSensitive:Qt::CaseInsensitive);
        if (!searchTextRegExp.isValid())
        {
            QMessageBox::warning(0, QString("Search"),
                                    QString("Invalid regular expression!"));
            //setSearchColour(QColor(255,255,255),QColor(255,102,102));
            return 0;
        }
    }


    QProgressDialog fileprogress("Searching...", "Abort", 0, file->sizeFilter(), this);
    fileprogress.setWindowTitle("DLT Viewer");
    fileprogress.setWindowModality(Qt::WindowModal);
    fileprogress.show();
    do
    {

        if(getNextClicked()){
            searchLine++;
            if(searchLine >= file->sizeFilter()){
                searchLine = 0;
                //QMessageBox::information(0, QString("Search"),QString("End of file reached. Search start from top."));
            }
        }else{
            searchLine--;
            if(searchLine <= -1){
                searchLine = file->sizeFilter()-1;
                //QMessageBox::information(0, QString("Search"),QString("Top of file reached. Search start from bottom."));
            }
        }

        //qDebug()<<"startLine: "<<getStartLine();
        //qDebug()<<"searchBorder: "<<searchBorder;
        //qDebug()<<"searchLine: "<<searchLine;

        if(getNextClicked()){
            fileprogress.setValue(searchLine+1);
        }else{
            fileprogress.setValue(file->sizeFilter()-searchLine);
        }

        /* get the message with the selected item id */
        buf = file->getMsgFilter(searchLine);
        msg.setMsg(buf);
        for(int num2 = 0; num2 < plugin->topLevelItemCount (); num2++)
        {
            PluginItem *item = (PluginItem*)plugin->topLevelItem(num2);

            if(item->getMode() != item->ModeDisable && item->plugindecoderinterface && item->plugindecoderinterface->isMsg(msg,1))
            {
                item->plugindecoderinterface->decodeMsg(msg,1);
                break;
            }
        }

        bool pluginFound = false;

        /* search header */
        if(!pluginFound || text.isEmpty())
        {
            text += msg.toStringHeader();
        }

        if(getHeader())
        {
            if (getRegExp())
            {
                if(text.contains(searchTextRegExp))
                {
                    table->selectRow(searchLine);
                    setStartLine(searchLine);
                    setMatch(true);
                    break;
                }else {
                    setMatch(false);
                }
            }
            else
            {
                if(text.contains(getText(),getCaseSensitive()? Qt::CaseSensitive : Qt::CaseInsensitive ))
                {

                    table->selectRow(searchLine);
                    setStartLine(searchLine);
                    setMatch(true);
                    break;
                }else {
                    setMatch(false);
                }
            }
        }

        /* search payload */
        text.clear();
        if(!pluginFound || text.isEmpty())
        {
            text += msg.toStringPayload();
        }

        if(getPayload())
        {
            if (getRegExp())
            {
                if(text.contains(searchTextRegExp))
                {
                    table->selectRow(searchLine);
                    setMatch(true);
                    setStartLine(searchLine);
                    break;
                }else {
                    setMatch(false);
                }
            }
            else
            {
                if(text.contains(getText(),getCaseSensitive()?Qt::CaseSensitive:Qt::CaseInsensitive))
                {
                    table->selectRow(searchLine);
                    setMatch(true);
                    setStartLine(searchLine);
                    break;
                } else {
                    setMatch(false);
                }
            }
        }

    }while(searchBorder != searchLine);

    if(getMatch())
    {
        return 1;
    }

    //table->clearSelection();
    //setSearchColour(QColor(255,255,255),QColor(255,102,102));
    return 0;
}