[Qt-creator] Way to make some custome operations before file save in subclasses of TextEditor::BaseTextEditor
Denis Kormalev
kormalev.denis at gmail.com
Thu Nov 4 11:48:33 CET 2010
Thanks, I'll try.
Regards,
Denis Kormalev.
On Thursday 04 November 2010 at 11:31:38, eike.ziller at nokia.com wrote:
> On Nov 3, 2010, at 10:41 PM, ext Denis Kormalev wrote:
> > Hello all,
> > I'm developing plugin to show xml as tree (you can look at it here:
> > http://gitorious.org/qt-creator-xml-tree-plugin). For now I've stopped
> > at design where I have two tabs: one for tree and another for xml
> > source. I'm showing xml source in PlainTextEditor subclass and so I use
> > BaseTextEditable subclass too instead of custom Core::IEditor
> > subclassing. I need to perform some work before saving. For example, I
> > need to update PlainTextEditor contents before saving if I'm in tree tab
> > (I'm updating contents of tabs only at tab switching for better
> > performance), but I can't find way to put my code after ctrl-s was
> > clicked and before data was pushed to file. I think that someone who
> > will need to write some editor based on PlainTextEditor will want such
> > functionality too. For example if he wants to add some data to file or
> > maybe clean it from unneeded spaces or somewhat else. What are you
> > thinking about adding virtual method named like beforeSave() to
> > BaseTextEditor?
>
> Subclass BaseTextDocument and reimplement the "save" method (do your stuff,
> then call BaseTextDocument::save). Set an instance of your
> BaseTextDocument subclass as the text document via
> BaseTextEditor::setBaseTextDocument. Have a look how that is used in other
> BaseTextEditor subclasses in Qt Creator.
>
> Br, Eike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20101104/901b2f63/attachment.html
More information about the Qt-creator-old
mailing list