[Qt-creator] Multiple IEditors for one IDocument

Ziller Eike Eike.Ziller at theqtcompany.com
Mon Sep 14 09:42:12 CEST 2015


> On Sep 13, 2015, at 9:28 AM, Jochen Becher <jochen_becher at gmx.de> wrote:
> 
> Hello,
> 
> for my ModelEditor plugin I would like to use many IEditor (one for each
> diagram) associated to one IDocument (representing the XML model file).
> Currently I must create a new document for each diagram editor because
> of limitations in the design. For example displayName is only defined in
> IDocument, not in IEditor, and different editors should show different
> names (in my case the diagram's name).
> 
> Having many documents related to one physical file has some annoying
> consequences. If you modified the model you will be asked if you want to
> save the file for each closing diagram even if you do not close the last
> diagram (and thus the document). If you close all editors you will be
> asked to save all diagrams instead of only the single file. And more...
> 
> Before I start implementing the changes I would like to discuss it:
> * add getter IEditor::displayName() (default implementation falls back
> to IDocument), IEditor::uniqueName() and some setters.
> * change combobox in toolbar showing all open editors (instead of open
> documents)
> * introduce new side bar window "Open Editors"
> * extend Core::EditorManager to allow opening another Editor for an
> existing editor (with a parameter that tells the editor to show which
> view on the document).
> 
> There are a view more changes I have not yet though about: the draggable
> icon in the toolbar (which stores a file path but no identifier for the
> editor) and the state of open documents (instead of open editors) which
> is saved on closing QtCreator.

The case “multiple IEditors on the same IDocument” is used for splitting. Trying to use it for anything else would require a major refactoring of the whole editor/document machinery, and that would definitely be a challenging task. We just arrived at a barely acceptable state of the editor manager, with actually still quite a few annoying issues open.

> If you modified the model you will be asked if you want to
> save the file for each closing diagram even if you do not close the last
> diagram (and thus the document). If you close all editors you will be
> asked to save all diagrams instead of only the single file.

Yes, but from the user point of view if I edit multiple diagrams, and these open as a separate editors, I expect to be able to save them individually. The implementation detail that all the diagrams are saved in the same file is hidden from me, by the fact that I have different editors with different titles etc open for the diagrams.

But you control the UI of your editor. If you have multiple diagrams in the same file, you can add whatever control (lists, combo boxes) suits you to switch between the different “views” on your file. It’s even possible to nest QMainWindows / FancyMainWindows.

Br, Eike

-- 
Eike Ziller, Senior Software Engineer - The Qt Company GmbH
 
The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list