Hi Daniel,
long time no see ;-)
I cannot rule out bugs in that code, but I am quite confident that the
behavior is as designed. If that design can be improved is likely
another question ;-)
We need to carefully distinguish file writers and mime types here. The
"Save..." dialog will show in its "filter list" all suitable mime-types
for the base data which is to be saved. The default selected item in
that list is based on the mime-type comparison operator only (which
considers the mime-type ranking). "Suitable" in that context means
mime-types related to file writers which claim to be able to write the
specific base data type. However, the FileWriterSelector class is not
responsible for "selecting a writer" just yet because the user still
needs to select the mime-type (i.e. the extension) in the "Save..." dialog.
Depending on the selected mime-type, the FileWriterSelector class is
finally asked to provide the "default" writer for the given base-data
and mime-type combination. In case of multiple suitable writers,
QmitkIOUtil will display another dialog box to the user for selecting
among the writers. mitk::IOUtil will just use the best match from
FileWriterSelector for writing.
So in summary, for writing, the procedure is roughly:
1. Get file writers for the base data type (using FileWriterSelector)
2. Get the associated mime-types to construct the "Save..." filter string
3. Get the best writer for the base data - mime type combination (using
FileWriterSelector)
4. In case of a tie, let the user select (QmitkIOUtil only)
Last, in order to influence the default in the "Save..." filter list,
you need to modify the ranking of the mime type, not of one of its
associated writers.
Hope that helps,
Sascha
On 08/18/2015 01:23 PM, Daniel Maleike wrote:
Hi,
I worked a bit with a custom file writer and would like to make it the
default choice in Data Manager's "Save..." dialog.
I understood that the Qt file type list is constructed by QmitkIOUtil
which makes use of mitk::FileWriterSelector.
When setting a high-enough "ranking" and an appropriate "base data
type" for my writer, it gets correctly selected as default and current
selection by the FileWriterSelector class. QmitkIOUtil will however
always select the first item in its file type list, completely
ignoring what the FileWriterSelector determined as default. To
reproduce this easily, you could manipulate mitk::ImageVtkXmlIO, for
example.
Question: is the behavior of the Qt dialog wanted? Or could we adapt
it to match the "decision" of the FileWriterSelector? Attached patch
(applies to 3fc812cc) is what I would have in mind.
Kind regards,
Daniel
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users