Beispiel #1
0
void Filters::on_edit_inclusion_clicked()
{
    bool editedEntry=false;
    int index=0;
    while(index<ui->inclusion->count())
    {
        if(ui->inclusion->item(index)->isSelected())
        {
            FilterRules dialog(this);
            dialog.set_apply_on(exclude[index].apply_on);
            dialog.set_need_match_all(exclude[index].need_match_all);
            dialog.set_search_text(exclude[index].search_text);
            dialog.set_search_type(exclude[index].search_type);
            dialog.exec();
            if(dialog.getIsValid())
            {
                exclude[index].apply_on=dialog.get_apply_on();
                exclude[index].need_match_all=dialog.get_need_match_all();
                exclude[index].search_text=dialog.get_search_text();
                exclude[index].search_type=dialog.get_search_type();
                if(!convertToRegex(exclude[index]))
                    exclude.removeAt(index);
                editedEntry=true;
            }
        }
        index++;
    }
    if(editedEntry)
    {
        reShowAll();
        updateFilters();
    }
}
Beispiel #2
0
Strings expandShellWildcard( const std::string& filename )
{
    Strings expandedFilenames;

    namespace fs = boost::filesystem;

    const fs::path& filePath( filename );
    const fs::path& parent = filePath.parent_path();

    if( !fs::exists( parent ) || !fs::is_directory( parent ))
        LBTHROW( std::runtime_error( "Not a valid path" ));

    // Convert the filename with shell-like wildcard into a POSIX regex
    const boost::regex regex = convertToRegex( filename );

    for( fs::directory_iterator it( parent );
         it != fs::directory_iterator(); ++it )
    {
        const std::string& candidate = it->path().string();
        if( boost::regex_match( candidate, regex ))
            expandedFilenames.push_back( candidate );
    }

    return expandedFilenames;
}
Beispiel #3
0
void Filters::on_add_inclusion_clicked()
{
    FilterRules dialog(this);
    dialog.exec();
    if(dialog.getIsValid())
    {
        Filters_rules new_item;
        new_item.apply_on=dialog.get_apply_on();
        new_item.need_match_all=dialog.get_need_match_all();
        new_item.search_text=dialog.get_search_text();
        new_item.search_type=dialog.get_search_type();
        if(convertToRegex(new_item))
            include << new_item;
        reShowAll();
        updateFilters();
    }
}
static bool matchPart(const string & path, const string & search){
    string regex = convertToRegex(search);
    return Util::matchRegex(path, Util::Regex(regex));
}
Beispiel #5
0
void Filters::setFilters(QStringList includeStrings,QStringList includeOptions,QStringList excludeStrings,QStringList excludeOptions)
{
    if(includeStrings.size()!=includeOptions.size() || excludeStrings.size()!=excludeOptions.size())
        return;
    Filters_rules new_item;

    include.clear();
    int index=0;
    while(index<includeStrings.size())
    {
        new_item.search_text=includeStrings.at(index);
        QStringList options=includeOptions.at(index).split(";");
        new_item.need_match_all=false;
        new_item.search_type=SearchType_rawText;
        new_item.apply_on=ApplyOn_fileAndFolder;

        if(options.contains("SearchType_simpleRegex"))
            new_item.search_type=SearchType_simpleRegex;
        if(options.contains("SearchType_perlRegex"))
            new_item.search_type=SearchType_perlRegex;
        if(options.contains("ApplyOn_file"))
            new_item.apply_on=ApplyOn_file;
        if(options.contains("ApplyOn_folder"))
            new_item.apply_on=ApplyOn_folder;
        if(options.contains("need_match_all"))
            new_item.need_match_all=true;

        if(convertToRegex(new_item))
            include << new_item;

        index++;
    }

    exclude.clear();
    index=0;
    while(index<excludeStrings.size())
    {
        new_item.search_text=excludeStrings.at(index);
        QStringList options=excludeOptions.at(index).split(";");
        new_item.need_match_all=false;
        new_item.search_type=SearchType_rawText;
        new_item.apply_on=ApplyOn_fileAndFolder;

        if(options.contains("SearchType_simpleRegex"))
            new_item.search_type=SearchType_simpleRegex;
        if(options.contains("SearchType_perlRegex"))
            new_item.search_type=SearchType_perlRegex;
        if(options.contains("ApplyOn_file"))
            new_item.apply_on=ApplyOn_file;
        if(options.contains("ApplyOn_folder"))
            new_item.apply_on=ApplyOn_folder;
        if(options.contains("need_match_all"))
            new_item.need_match_all=true;

        if(convertToRegex(new_item))
            exclude << new_item;

        index++;
    }

    reShowAll();
}