| 26 | } |
| 27 | |
| 28 | bool ProjectFilter::isValid( const Path &path, const bool isFolder ) const |
| 29 | { |
| 30 | if (!isFolder && path == m_projectFile) { |
| 31 | // do not show the project file |
| 32 | ///TODO: enable again once the project page is ready for consumption |
| 33 | return false; |
| 34 | } else if (isFolder && path == m_project) { |
| 35 | // always show the project root |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | if (isFolder && path.isLocalFile() && QFile::exists(path.toLocalFile() + QLatin1String("/.kdev_ignore"))) { |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | // from here on the user can configure what he wants to see or not. |
| 44 | |
| 45 | // we operate on the path relative to the project base |
| 46 | // by prepending a slash we can filter hidden files with the pattern "*/.*" |
| 47 | |
| 48 | const QString relativePath = makeRelative(path); |
| 49 | |
| 50 | if (isFolder && relativePath.endsWith(QLatin1String("/.kdev4"))) { |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | bool isValid = true; |
| 55 | for (const Filter& filter : m_filters) { |
| 56 | if (isFolder && !(filter.targets & Filter::Folders)) { |
| 57 | continue; |
| 58 | } else if (!isFolder && !(filter.targets & Filter::Files)) { |
| 59 | continue; |
| 60 | } |
| 61 | if ((!isValid && filter.type == Filter::Inclusive) || (isValid && filter.type == Filter::Exclusive)) { |
| 62 | const bool match = filter.pattern.exactMatch( relativePath ); |
| 63 | if (filter.type == Filter::Inclusive) { |
| 64 | isValid = match; |
| 65 | } else { |
| 66 | isValid = !match; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | return isValid; |
| 71 | } |
| 72 | |
| 73 | QString ProjectFilter::makeRelative(const Path& path) const |
| 74 | { |