Bug 110694

Summary: adding #include directive gui
Product: [Applications] kdevelop Reporter: Vinay Khaitan <vkhaitan>
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: wishlist CC: david.nolden.kde
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Vinay Khaitan 2005-08-13 12:20:15 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    SuSE RPMs

When we are editing a very long source file, and a new Qt/KDE class is now going to be used, we would need to add a header file for that class.
It is annoying to go at the top, add the include file and then come back, where you were working(which we will have to search).

As this thing keeps on happening, it becomes more and more annoying.
What should happend is that, there should be a GUI to add any include file(for which we can assigne shortcut). When the shortcut is pressed, the gui will popup with included files. we should be able to view,add,delete,edit included files.

thanks!
Comment 1 Amilcar do Carmo Lucas 2005-08-15 17:49:19 UTC
There are already bookmarks you can use to go back to your work position.
So you can:
-bookmark
-go to the top of the file
-add the includes
-go back to the bookmarked position

There is a nice technote on the kdevelop.org website about "efficient code navigation". If gives you other tricks you can use.

Comment 2 Vinay Khaitan 2005-08-16 09:30:58 UTC
This is a partial solution to extremely annoying trouble.
When we go to top, we find the normal copyright notice.
so navigate through cursor to the position, where we want to include the file?
then go back to bookmark, and dont forget to delete bookmark after that.

Okay, we can bookmark the include position too, but still this is minimum 4 step process. If extremely useful feature like this requires this much step, then why do we have "Quick OPen" dialogs? that is also possible in maximum 4 steps too?

What is needed actually is that, A dialog, which scans all the #includes, then presents a dialog which lists all the includes and present possibility of adding, deleting etc.
Please, this is very easy thing.
And as one kdevelop developer also suggested, including can be automatic based on persistent code completion database.
This is very useful feature.
Thanks
Comment 3 Amilcar do Carmo Lucas 2005-08-16 10:52:27 UTC
> Please, this is very easy thing. 
I do not think so. What happeds with the #if def ... else directives ?
How do you propuse to treat those ?

 
Comment 4 Vinay Khaitan 2005-08-16 11:20:59 UTC
I suppose that you are asking for following condition..
#ifdef _X11
#include <something.h>
#else
#include <something_else.h>
#endif

To make implementation easy, you can omit all the #ifdef includes and only present with possibilites about those, which are directly included.
Those with #ifdef will have to edited manually.

But if you want to implement that too, scan for ifdefs too, and present in the dialog like this...
#ifdef _X11(QLabel)
|---------------------|
|         ListBox     |
|---------------------|
#endif
(all ifdefs like this)

Then in the last, direct includes.
Comment 5 Amilcar do Carmo Lucas 2005-08-16 11:26:34 UTC
Can you help us implement it ?
Comment 6 Vinay Khaitan 2005-08-16 18:47:50 UTC
I sincerely hope that this comment was not to show me that this is not easy to implement. I thought myself once about crreating a plugin for kdevelop to do this. But because I have never developed for kdevelop and I am doing something else, I didn't want to get involved into it.
Thanks, if you implement it...
Comment 7 Andreas Pakulat 2008-06-30 01:10:24 UTC
valid wish and could be really helpful. Not sure when this is going to happen though.
Comment 8 David Nolden 2009-01-20 21:42:50 UTC
I consider having a special GUI not very useful, the editor is a GUI after all, why have the same once again?

And for the basic problem, automatic adding of include-directives is implemented in KDevelop4.

So if you have
QString|<invoke code-completion>
You will get an entry in the completion-list that says "Add #include <qstring.h> for class QString".