On Sunday 18 July 2010 20:59:23 Zoltan Padrah wrote:
> Replying to myself:
> if an "untitled", empty document is created, then it has the mimetype
> "application/octet-stream"; if it doesn't have extension, it will be
> "text/plain", and only if it has the .circuit extension, then it will be
> recognized as a circuit.
That's expected behaviour. Have a look into src/ktechlab.xml, there you can
find, what makes a file one with this mimetype. (That's why you have to run
update-mime-database after the first installation of this xml-file)
> So, as a workaround, in the test case a new, empty temporary file is
> created, with the .circuit extension, and that file is opened. This way a
> new document is obtained. Looks like a little hacking, but now it works :D
I don't think, it's hackish at all. As long as you are using a platform-
independent way to create that file. There is KTemporaryFile which you should
use in this case. You can use KTemporaryFile::setSuffix(".circuit") to create
a file with the suffix .circuit, which should then be recognised as
> Creating new circuits in ktechlab could be implemented this way: when a new
> circuit should be created, open a new file in a temporary directory, and
> set a flag indicating that the current document isn't really saved. When
> the document is saved, write the file to its final location.
Yes, that's the way to go.