[Qt-creator] Document sync
Michael Klank
michael.klank at amk-antriebe.de
Tue May 3 10:33:38 CEST 2011
Hello Christian,
with your recommendation, it works perfectly now.
Thank you very much.
Michael
-----Ursprüngliche Nachricht-----
Von: qt-creator-bounces+michael.klank=amk-antriebe.de at qt.nokia.com
[mailto:qt-creator-bounces+michael.klank=amk-antriebe.de at qt.nokia.com] Im
Auftrag von Michael Klank
Gesendet: Dienstag, 3. Mai 2011 09:15
An: qt-creator at qt.nokia.com
Betreff: Re: [Qt-creator] Document sync
Thank you very much for the hint. I will try.
-----Ursprüngliche Nachricht-----
Von: Christian Kamm [mailto:christian.d.kamm at nokia.com]
Gesendet: Dienstag, 3. Mai 2011 09:09
An: qt-creator at qt.nokia.com
Cc: ext Michael Klank
Betreff: Re: [Qt-creator] Document sync
On Tuesday 03 May 2011 07:11:04 ext Michael Klank wrote:
> I'm developing a QtCreator plug-in, which should generates/removes (a lot)
> source code. I have problems with add/remove source code and the document
> sync, probably.
>
> In details, I have to remove a method from a class (*.h, *.cpp) as next I
> have to add new methods. The problem is that some code is not removed from
> class, probably the document is out of sync?!?! I tried
> CPlusPlus::CppModelManagerInterface::instance()->updateModifiedSourceFiles(
> ); to get sync but it doesn't work.
>
> How can I handle add/remove source code to a "Document::Ptr" in a save way,
> without losing sync?
I strongly recommend you use CppTools::CppRefactoringChanges for applying
changes to source files. Not only does it take care of triggering the right
update signals, it also does the right thing if the document you want to
modify is currently opened in Creator.
Short (untested) example:
{
CppRefactoringChanges changes(modelManager->snapshot());
CppRefactoringFile file = changes.file("/path/to/myfile.cpp");
ChangeSet changeSet;
// use file.document() (QTextDocument)
// and file.cppDocument() (Document::Ptr) and fill changeSet
file.change(changeSet);
} // changes are applied as the Refactoring classes are destroyed
Also look at cppquickfixes.cpp for some more examples.
Regards,
Christian
_______________________________________________
Qt-creator mailing list
Qt-creator at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-creator
More information about the Qt-creator-old
mailing list