Changeset View
Changeset View
Standalone View
Standalone View
addons/search/plugin_search.cpp
Show First 20 Lines • Show All 543 Lines • ▼ Show 20 Line(s) | 543 | { | |||
---|---|---|---|---|---|
544 | QString types = m_ui.filterCombo->currentText(); | 544 | QString types = m_ui.filterCombo->currentText(); | ||
545 | QString excludes = m_ui.excludeCombo->currentText(); | 545 | QString excludes = m_ui.excludeCombo->currentText(); | ||
546 | if (((types.isEmpty() || types == QStringLiteral("*"))) && (excludes.isEmpty())) { | 546 | if (((types.isEmpty() || types == QStringLiteral("*"))) && (excludes.isEmpty())) { | ||
547 | // shortcut for use all files | 547 | // shortcut for use all files | ||
548 | return files; | 548 | return files; | ||
549 | } | 549 | } | ||
550 | 550 | | |||
551 | QStringList tmpTypes = types.split(QLatin1Char(',')); | 551 | QStringList tmpTypes = types.split(QLatin1Char(',')); | ||
552 | QVector<QRegExp> typeList; | 552 | QVector<QRegExp> typeList(tmpTypes.size()); | ||
553 | for (int i=0; i<tmpTypes.size(); i++) { | 553 | for (int i=0; i<tmpTypes.size(); i++) { | ||
554 | QRegExp rx(tmpTypes[i].trimmed()); | 554 | QRegExp rx(tmpTypes[i].trimmed()); | ||
555 | rx.setPatternSyntax(QRegExp::Wildcard); | 555 | rx.setPatternSyntax(QRegExp::Wildcard); | ||
556 | typeList << rx; | 556 | typeList << rx; | ||
557 | } | 557 | } | ||
558 | 558 | | |||
559 | QStringList tmpExcludes = excludes.split(QLatin1Char(',')); | 559 | QStringList tmpExcludes = excludes.split(QLatin1Char(',')); | ||
560 | QVector<QRegExp> excludeList; | 560 | QVector<QRegExp> excludeList(tmpExcludes.size()); | ||
561 | for (int i=0; i<tmpExcludes.size(); i++) { | 561 | for (int i=0; i<tmpExcludes.size(); i++) { | ||
562 | QRegExp rx(tmpExcludes[i].trimmed()); | 562 | QRegExp rx(tmpExcludes[i].trimmed()); | ||
563 | rx.setPatternSyntax(QRegExp::Wildcard); | 563 | rx.setPatternSyntax(QRegExp::Wildcard); | ||
564 | excludeList << rx; | 564 | excludeList << rx; | ||
565 | } | 565 | } | ||
566 | 566 | | |||
567 | QStringList filteredFiles; | 567 | QStringList filteredFiles; | ||
568 | foreach (QString fileName, files) { | 568 | foreach (QString fileName, files) { | ||
569 | bool isInSubDir = fileName.startsWith(m_resultBaseDir); | 569 | bool isInSubDir = fileName.startsWith(m_resultBaseDir); | ||
570 | QString nameToCheck = fileName; | 570 | QString nameToCheck = fileName; | ||
571 | if (isInSubDir) { | 571 | if (isInSubDir) { | ||
572 | nameToCheck = fileName.mid(m_resultBaseDir.size()); | 572 | nameToCheck = fileName.mid(m_resultBaseDir.size()); | ||
573 | } | 573 | } | ||
574 | 574 | | |||
575 | bool skip = false; | 575 | bool skip = false; | ||
576 | for (int i=0; i<excludeList.size(); i++) { | 576 | for (const auto& regex : qAsConst(excludeList)) { | ||
577 | if (excludeList[i].exactMatch(nameToCheck)) { | 577 | if (regex.exactMatch(nameToCheck)) { | ||
578 | skip = true; | 578 | skip = true; | ||
579 | break; | 579 | break; | ||
580 | } | 580 | } | ||
581 | } | 581 | } | ||
582 | if (skip) { | 582 | if (skip) { | ||
583 | continue; | 583 | continue; | ||
584 | } | 584 | } | ||
585 | 585 | | |||
586 | 586 | | |||
587 | for (int i=0; i<typeList.size(); i++) { | 587 | for (const auto& regex : qAsConst(typeList)) { | ||
588 | if (typeList[i].exactMatch(nameToCheck)) { | 588 | if (regex.exactMatch(nameToCheck)) { | ||
589 | filteredFiles << fileName; | 589 | filteredFiles << fileName; | ||
590 | break; | 590 | break; | ||
591 | } | 591 | } | ||
592 | } | 592 | } | ||
593 | } | 593 | } | ||
594 | return filteredFiles; | 594 | return filteredFiles; | ||
595 | } | 595 | } | ||
596 | 596 | | |||
▲ Show 20 Lines • Show All 1708 Lines • Show Last 20 Lines |