BlogKDevelop Project Filters Syndicate content

Tue, 09/03/2013 - 00:24

Hey all!

Today, after a bit more than a month since I started working on it, I merged the projectfilter branches into KDevplatform/KDevelop. This is a generic configuration interface and library which allows users to customize which folders/files KDevelop includes in a project.

How to use it
Context Menu

The simplest way to use the new code to exclude items from a project, is to use the context menu. Simply right click on any folder/file (not the project root, or anything target related) and choose the “exclude item from project” action. This will then add a filter for the selected item(s). If you want to undo this, go to the project configuration (see below) and remove the filter.

Configuration

For more advanced management of project filters, or to remove filters and/or adapt the default filters, you need to go to the project configuration and select the new “Project Filter” config page. This allows you to add new filters, remove existing ones or edit them, including reordering them.

How it works

The pattern syntax uses QRegExp::WildcardUnix on relative project paths. This should be fairly easy to grasp and similar to what you know from e.g. .gitignore or svn:ignore. Generally, if you can write a .gitignore file then you should be able to configure your KDevelop project as well!

If you wonder what you can do with the include/exclude pattern type, see again the documentation of .gitignore and it’s !pattern syntax. It allows you to selectively unhide some paths which where previously hidden. E.g. you can only show *.cpp files in your project by first excluding all files * and then adding an inclusive pattern for *.cpp.

Note that the distinction between files/folders is probably not required most of the time. It does allow for some better performance though and may make some patterns more easy to write.

Note to Users-Who-Compile-Master-From-Source

Those of you who build KDevelop/KDevplatfrom from git master, please make sure to remove kcm_kdev_genericprojectmanagersettings.so and just to make sure also remove kcm_kdev_genericprojectmanagersettings.desktop. Otherwise you’ll get the old generic manager configuration alongside the new project filter, which may break things.

If you install KDevelop via the package manager of your distribution, you should have nothing to do but wait until we release a new KDevelop version (4.6) which will then include this new feature!

Anyhow, please test this and report bugs on bugs.kde.org. Feature requests also welcome, but I like that this new UI is rather simple and still powerful. I’m reluctant to add more here. Something which I do want to implement in the future though is support for reading e.g. .gitignore files and hiding files based on that from the project. The new API I added to KDevplatform should make this rather easy btw. You/I just have to write a new plugin implementing the IProjectFilterProvider interface and then we could e.g. query git directly for whether a given path is included or not.

Cheers!

AttachmentSize
kdev-projectfilter-config.png83.62 KB
kdev-projectfilter-ctxmenu.png24.93 KB

Comments

Is there a way to exclude Wed, 04/23/2014 - 11:43 — vasaka (not verified)

Is there a way to exclude files that are not in the project root, it works for dirs, but not for files.

is there a way to filter the Sat, 12/21/2013 - 21:04 — gary (not verified)

is there a way to filter the project ‘build info’ from project context? I think it is build info, has what looks like a build icon. for example: all clean config.o debug install . . . files.h|.cpp

at least to get rid of the build *.o . I have the rule for file types for *.o

thanks

This was added just a day Sun, 12/22/2013 - 20:01 — Milian Wolff

This was added just a day after the 4.6.0 release. Please stay tuned for 4.6.1.

Great, finally I’ll be able Wed, 09/04/2013 - 00:27 — lynxlynx (not verified)

Great, finally I’ll be able to exclude the build dir and its crashy extraneus entries in the quickopen completion!

Instead of “Type: Tue, 09/03/2013 - 17:54 — ben (not verified)

Instead of “Type: Inclusive/Exclusive”, I think a better terminology for the third column would be “Action: Include/Exclude”. It would make it easier to understand on first sight.

Cool, thanks for the Fri, 09/06/2013 - 01:19 — Milian Wolff

Cool, thanks for the suggestion. I’ll change this now.

What I’m really missing at Tue, 09/03/2013 - 13:34 — kbroulik (not verified)

What I’m really missing at work is a way for KDevelop to not show classes from a specific directory in the Classes browser (the entire library/ folder in my project) but that they are still recognized and presented for auto-completion. I can either completely exclude the directory from the project or have my Class list spammed with classes I don’t need to inspect but only use and see in auto-completion.

That you should be able to Fri, 09/06/2013 - 01:17 — Milian Wolff

That you should be able to achieve by excluding the folder, no? You’ll still get auto-completion then. Or what kind of project is that? not C++ but a script language? the situation is different there ;-)

Awesome! I’m playing with it Tue, 09/03/2013 - 10:04 — stativ (not verified)

Awesome! I’m playing with it right now and it looks like a very usefull feature. And what would make it even more awesome would be the support for hiding project targets. Especially with autotools-based projects there can be a ton of useless targets.

One more idea - it would be Tue, 09/03/2013 - 10:09 — stativ (not verified)

One more idea - it would be cool if it could read filters from .gitignore (or any other vcs ignore file). I guess this should be handled by the VCS integration, though.

Yeah, read my blog post Fri, 09/06/2013 - 01:18 — Milian Wolff

Yeah, read my blog post above. This is also something I had in mind.

Oh, I’m sorry. I missed that Fri, 09/06/2013 - 20:04 — stativ (not verified)

Oh, I’m sorry. I missed that because I thought the last section is only about compiling, which was something I have already done so I skipped it. Anyway, it’s great to hear that you already considered this option. I’m looking forward to the future development.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <pre>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options