View Single Post
Old 07-20-2014, 11:06 PM   #44
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,657
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi user_none,

I noticed that Misc/XMLEntities.cpp already had a list of the named entities and built hashes to map from codes to names. I extended that to add a hash to map from names to codes. And added a conversion routine that could take a name, numeric code point or hex codepoint and return the code (or 0 if not found).

That way instead of using a QList of a std:pair, I was able to simply use one QStringList of just the entity strings in SettingsStore and in PreserveEntitiesWidget.cpp. This in turn made the Form .ui file much easier as I had to build it by hand as I have never used QtCreator.app before and when I tried I got so frustrated I wanted to rip my head off as no right button clicks seemed to work on a Mac.

Anyway, I have something workable as proof of concept, but I have not tried to confuse it yet or make it break.

I could still move it to use std:pair if the lookup time in the hash is measurable but I don't think it will be.

I have attached preserve_entities.patch.zip

If you get a free moment, please take a look at it and let me know what if any changes and things you would prefer me to make before setting things up to do the pull.

I did test this by going back and forth from code view to test view. Even changing the preferences while running you could watch the entities that were preserved change when going from codeview to bookview and back.

One thing I was thinking was if you think it is a good idea I can expand the Misc/XMLEntities.cpp to include the full list provided by the Qt source in HTMLEntityNames.in.

Anyway, please let me know what you think. If anyone else out there builds their own, please test this patch and provide feedback on it. I guess at some point I will need translations for the gui and tooltips.

Thanks,

Kevin
Attached Files
File Type: zip preserve_entities.patch.zip (5.0 KB, 158 views)
KevinH is offline   Reply With Quote