TemplatePreview - cleanup needed!
Miha Čančula
miha at noughmad.eu
Wed Oct 31 13:14:17 UTC 2012
2012/10/30 Milian Wolff <mail at milianw.de>
> Hey Miha!
>
> I just had to fix https://bugs.kde.org/show_bug.cgi?id=309271 and stumbled
> upon that file the first time. This needs some serious cleanup imo:
>
> a) figure out whether the file is a template or not, before trying to read
> its
> contents and rendering it. couldn#t you look for a .desktop file?
> b) analogous to b, automatically deduce whether we look at a project or
> file
> template
>
Hello, I've just started fixing this. I agree the plugin is in a sad state.
However, I'm not sure if searching for a .desktop file is easier than
rendering a document. Then we have to read the desktop file to determine if
it's a template or not.
Having only a manual context menu action "preview as template" doesn't
sound good either, because you will often edit more than one file
simultaneously (.h and .cpp file, for example).
c) only use one temporary file (create it on the stack in the class) and
> don't
> recreate new ones all the time
>
The problem here is syntax highlighting in the preview. You generally want
this, and the easiest way is to keep the suffix of the original file. This
means changing the name of the temp file. I know KTextEditor has methods to
set the syntax highlighting mode, I will try to work with this instead.
d) only operate on text documents, i.e. make m_currentDocument a KTextEditor
> Document
> e) rename m_document to m_preview or similar to make clearer what it does
> f) use a stacked widget or similar to show a static error message and also
> include a link to the template/project documentation instead of using the
> text
> preview for that
> g) use TrimEmptyLines as default which is afaik also used for the
> templates,
> no?
h) add a context menu action for template files "preview template" that
> shows
> this toolview, otherwise its just not findable
> i) add the preview to the config dialog somehow
>
This I can do.
In any case, the biggest problem is detecting whether a file is a template
or not, both for rendering and for a context menu action. I really don't
have a good answer.
>
> and probably more
> --
> Milian Wolff
> mail at milianw.de
> http://milianw.de
> --
> KDevelop-devel mailing list
> KDevelop-devel at kdevelop.org
> https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20121031/86b4aa53/attachment.html>
More information about the KDevelop-devel
mailing list