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 _______________________________________________ Qt-creator mailing list Qt-creator@trolltech.com http://lists.trolltech.com/mailman/listinfo/qt-creator