Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 07-18-2014, 08:15 PM   #31
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi varlog,

Quote:
Originally Posted by varlog View Post
Just curious: why subversion?
Because it is supported at GitHub (says so on there Code page) and most Mac machines had svn already installed (at least they did in the past).

And I have learned too many other concurrent versioning systems in the past to learn yet another: rcs, cvs, hg (mercurial), svn, bitkeeper, so I haven't bothered to learn git.

Kevin

Last edited by KevinH; 07-18-2014 at 08:23 PM.
KevinH is online now   Reply With Quote
Old 07-19-2014, 11:19 AM   #32
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by KevinH View Post
The project is orphaned, it has no maintainer and is therefore not actually being developed so I don't think anyone is going to actually make the pull.
Orphaned and not actively developed are two different things. I'm still merging changes that make sense. I'm just not developing it myself anymore.

Quote:
Originally Posted by KevinH View Post
The issue/bug list is closed, so no posting of patches either.
The issue tracker was closed for two reasons. First, you can't attach any patches because it reached the attachment limit. Multiple requests to Google to increase it were ignored. Second, The vast majority of issues opened were closed as not an issue or were abusive. The level of noise made the issue tracker useless.

I've merged this change into the main code repo on github.
user_none is offline   Reply With Quote
Advert
Old 07-19-2014, 12:09 PM   #33
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi user_none,

Understood. If I have patches in the future, what should I do with them? Could we create a forum thread just for patches?

The reason I ask, is that there is one minor thing I would like to change: tidy (I think) converts svg single image tags to an empty pair.

Code:
<image />  to  an empty <image></image>
which freaks out kindlegen 2.9 which believes that tag is always single just like the html img tag.

Along, those same lines, I would like to prevent replacement of html entities into unicode in code view if they were originally present as entities, in an attempt to keep things as the designer intended or as close as.

Thanks,

KevinH


Quote:
Originally Posted by user_none View Post
Orphaned and not actively developed are two different things. I'm still merging changes that make sense. I'm just not developing it myself anymore.



The issue tracker was closed for two reasons. First, you can't attach any patches because it reached the attachment limit. Multiple requests to Google to increase it were ignored. Second, The vast majority of issues opened were closed as not an issue or were abusive. The level of noise made the issue tracker useless.

I've merged this change into the main code repo on github.
KevinH is online now   Reply With Quote
Old 07-19-2014, 12:13 PM   #34
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,660
Karma: 127838196
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Is it possible to get these changes compiled for a Windows version?
JSWolf is offline   Reply With Quote
Old 07-19-2014, 12:39 PM   #35
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi,
Sorry, I dislike trying to develop on Windows and gave up trying to build anything on it long long ago. I can gladly make Linux and Mac OS X builds, but not Windows.

That said, building from source (especially well written build processes like this one) is a useful skill to have. You don't have to be a programmer just to build your own. You just have to take the time to set up and install the build tools properly. Many Linux users who are not developers learn how to do this almost immediately. Given the number of trojans and malware out there, building your own from public source is just safer inherently.

That is why I posted the detailed step by step process for doing a build under Mac OS X. Perhaps some kind soul will do the same for Windows ... ie starting from stock Windows install, grabbing the tools you need, and doing the build.

Quote:
Originally Posted by JSWolf View Post
Is it possible to get these changes compiled for a Windows version?
KevinH is online now   Reply With Quote
Advert
Old 07-19-2014, 02:50 PM   #36
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by KevinH View Post
Understood. If I have patches in the future, what should I do with them? Could we create a forum thread just for patches?
You can either use github and issue a pull request or email them to me directly.

Quote:
Originally Posted by KevinH View Post
Along, those same lines, I would like to prevent replacement of html entities into unicode in code view if they were originally present as entities, in an attempt to keep things as the designer intended or as close as.
This isn't really possible. Some of the XML libraries Sigil runs the code though (not Tidy) converts the entities. This happens even if you only use Code View.

Quote:
Originally Posted by KevinH
That is why I posted the detailed step by step process for doing a build under Mac OS X. Perhaps some kind soul will do the same for Windows ... ie starting from stock Windows install, grabbing the tools you need, and doing the build.
The build instructions in INSTALL.txt in the source has instruction for building on all platforms. If this needs to be enhanced, as they say, patches welcome.

Quote:
Originally Posted by JSWolf
Is it possible to get these changes compiled for a Windows version?
I'm not included to do a release and build any packages at this point. The changes have been pretty minor. Also, Since moving to OS X 10.9 I don't have VM's for Windows packages ready at the moment.
user_none is offline   Reply With Quote
Old 07-19-2014, 02:56 PM   #37
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,465
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
Along, those same lines, I would like to prevent replacement of html entities into unicode in code view if they were originally present as entities, in an attempt to keep things as the designer intended or as close as.

Thanks,

KevinH
Hey Kevin,

If you do look into preventing entity replacement, take a peek at this thread that documents the steps to reproduce 0.7.4 eating markup (regarding the &#160; entity). Post #13 has the steps to duplicate.

I've just not been able to get my head around the codebase (C++ and Qt double-whammy). The problem originated in the changes from 0.7.3 to 0.7.4--where it was decided that &nbsp; would be replaced with &#160; to fix the problem of 0.7.3 barking about missing DOCTYPES (because Sigil would replace the unicode non-breaking space character with &nbsp; in documents it was opening/importing when Tidy was turned off).

That bug is one of the main reasons I've held off on using 0.7.4. It's easy to make sure my epubs have a doctype before editing ... not so easy figuring out whether markup got silently eaten.

Maybe your work will make it go away.
DiapDealer is offline   Reply With Quote
Old 07-19-2014, 04:30 PM   #38
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi DiapDealer

The problem is the QWebView auto converts all internal named and numeric entries on the fly as soon as it is loaded. So in wysiwyg mode you will never see a nbsp as it will appear as just a space.

After pulling the html back out of qwebview you will have lost all entities (ie they were converted to their full unicode counterpart.

To partially deal with that, Sigil uses the CleanSource class which can invoke tidy, pretty print, etc. zone method of that class is given below:

Code:
QString CleanSource::NbspToEntity(const QString &source)
{
    QString new_source = source;
    new_source.replace(QChar(160), "*");  that * should be ampersand # 160;
    return new_source;
}
I think you can easily change that to the named entity if you want but I will have to look closer to be sure.

My idea would be to create a Prefs dialog with the 10 or so most common named entities which the user can enable or disable and expand this routine to replace the selected QChar values with those desired named entities (ie it would only preserve those entities as named entities).

A similar approach could be used for numeric entities as well.

The key is that this routine is invoked a lot and so must run quickly so supporting all possible entities would be hard.

I am thinking of a hashtable (dictionary) with char lookup value and replacement value or a simple range check and then subtraction of base value to get an offset to its replacement value.

That should make things fast even for 10 to 20 named entities.


What do you think? Again, I have just eyeballed this briefly, so I could be all wet here.

Kevin



Quote:
Originally Posted by DiapDealer View Post
Hey Kevin,

If you do look into preventing entity replacement, take a peek at this thread that documents the steps to reproduce 0.7.4 eating markup (regarding the &#160; entity). Post #13 has the steps to duplicate.

I've just not been able to get my head around the codebase (C++ and Qt double-whammy). The problem originated in the changes from 0.7.3 to 0.7.4--where it was decided that &nbsp; would be replaced with &#160; to fix the problem of 0.7.3 barking about missing DOCTYPES (because Sigil would replace the unicode non-breaking space character with &nbsp; in documents it was opening/importing when Tidy was turned off).

That bug is one of the main reasons I've held off on using 0.7.4. It's easy to make sure my epubs have a doctype before editing ... not so easy figuring out whether markup got silently eaten.

Maybe your work will make it go away.

Last edited by KevinH; 07-19-2014 at 04:39 PM.
KevinH is online now   Reply With Quote
Old 07-19-2014, 04:44 PM   #39
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by KevinH View Post
I think you can easily change that to the named entity if you want but I will have to look closer to be sure.
You can.

Quote:
Originally Posted by KevinH View Post
My idea would be to create a Prefs dialog with the 10 or so most common named entities which the user can enable or disable and expand this routine to replace the selected QChar values with those desired named entities (ie it would only preserve those entities as named entities).

A similar approach could be used for numeric entities as well.

The key is that this routine is invoked a lot and so must run quickly so supporting all possible entities would be hard.

I am thinking of a hashtable (dictionary) with char lookup value and replacement value or a simple range check and then subtraction of base value to get an offset to its replacement value.

That should make things fast even for 10 to 20 named entities.


What do you think? Again, I have just eyeballed this briefly, so I could be all wet here.
Having a preference dialog doesn't sound bad. The user can specify which characters they want converted and they can specify if they want named or numeric. There are a few ways this dialog could look. I'm not going to weigh in on that part.

You'd probably want to keep the list charters to entities in a hastable and also keep a list of the entities to match. Something like:

Code:
QString CleanSource::CharToEntity(const QString &source)
{
    QString new_source = source;
    Q_FOREACH (QChar c, m_chars) {
        new_source.replace(c, m_charToEntity->value(c, c));
    }
    return new_source;
}
user_none is offline   Reply With Quote
Old 07-19-2014, 05:12 PM   #40
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi user_none,

Thanks for the tips. I have used QHash and QList previously so my biggest problem would be the preferences pane/dialog and where is the best place to store the info from it in an accessible place.

Would the best example I could learn from and follow along in the current code be the use of Tidy/Pretty Print in Preferences? Those preferences are accessed in the CleanSource code now I think so would using that as an example to follow be best? Or do you recommend I use something else as a template/example to follow.

Sorry to partially drag you back into this, but it has been a few years since I've seen this code and lots and lots of changes and improvements have been made since then. So a few hints would certainly help!!!

Thanks,

KevinH

Last edited by KevinH; 07-19-2014 at 05:21 PM.
KevinH is online now   Reply With Quote
Old 07-19-2014, 05:32 PM   #41
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by KevinH View Post
Would the best example I could learn from and follow along in the current code be the use of Tidy/Pretty Print in Preferences? Those preferences are accessed in the CleanUp code now I think so would using that as an example to follow be best? Or do you recommend I use something else as a template/example to follow.
Sigil has a settings store which is a subclass of QSettings. First you'll want to add a getter and setter for any settings you're adding. Default values as well if it was never set explicitly via preferences.

A QList of std:air of QChar and QString might be a better way to go since this will always be iterated. This way you don't have to to worry about tracking two variables.
Code:
QList<std::pair <QChar, QString> >
Once you have the SettingsStore entity addition in place you'll need a preference widget. The implementation is in src/Sigil/Dialogs/PreferenceWidgets and the .ui files are in src/Sigil/Form_Files. The convention for the .ui is "PName.ui"

The CleanSourceWidget.cpp is a good example to start with. You need to implement the readSettings and saveSettings functions. As you can see read gets the data from the SettingsStore and set that data into the widget. Save takes the data from the widget and save it in the SettingsStore.

One way you could do the UI is have a user modifiable list where they can add and remove entries. See the SpellCheckWidget for an example of this. I'm not saying do this but you could have two columns. First column is the numeric value of the caracter Since some characters are printable) and the second column is the text the user wants to use. Then you can convert the numeric value into a character for saving into the settings. Reading it back out you'd convert from the char into the number and put that into the list.

Quote:
Originally Posted by KevinH View Post
Sorry to partially drag you back into this, but it has been a few years since I've seen this code and lots and lots of changes and improvements have been made since then. So a few hints would certainly help!!!
No worries. I have no problem helping someone who want to enhance Sigil. I'm just not interested in doing it myself.
user_none is offline   Reply With Quote
Old 07-19-2014, 09:07 PM   #42
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi user_none,
In the preferences, if I allow a two column list for users to put in numeric values in one column and a numeric entity or named entity in the other column, how can I validate what they input?

I can use QIntValidator to only except a string with digits for the unicode codepoint value. For numeric entities, I can split out the nondigit parts and validate the unicode code point digit string. But how can I validate named entities that people type in.

My fear is they enter in a non-valid or incomplete named entity string that ends up horribly messing up their code, requiring lots of search and replace to fix it.

Is there some way to easily pass potential named entity into some simple Qt class (instead of a full blown QWebView) that I can use to verify I get back a single unicode character?

I could try validating it against a long list of known math ml and other named entities, but that would be overkill.


Edit: Found my answer using this trick:

QTextDocument text;
text.setHtml("&lt;&gt;&quot;");
QString plain = text.toPlainText();

So I can validate both numeric value and entity string in one easy step. Simply use text.setHtml(entity_string) similar to above and verify that using toPlainText() the resulting QString has length 1 and that QChar.unicode() has the exact same value as the numeric value.

If not, don't save it to preferences and reload the Preferences widget with only known good pairs and let the user try again.

Hope that does the trick. If you have a better idea, please just let me know ...

Thanks,

KevinH

Last edited by KevinH; 07-19-2014 at 10:06 PM.
KevinH is online now   Reply With Quote
Old 07-19-2014, 11:26 PM   #43
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by KevinH View Post
In the preferences, if I allow a two column list for users to put in numeric values in one column and a numeric entity or named entity in the other column, how can I validate what they input?

QTextDocument text;
text.setHtml("&lt;&gt;&quot;");
QString plain = text.toPlainText();
This will work in most but not all cases. QTextDocument only uses a subset of HTML 4. I doubt it supports all entities.

My recommendation is to validate that the entity starts and ends with &;. If it's wrong it's wrong. You could provide an optional validation button that does the QTextDocument check and any that it can't validate it sets the background color of the line in error in yell letting the user know there is an issue with that one. If the basic (& validation fails, don't allow saving and mark the line that failed in red.
user_none is offline   Reply With Quote
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,506
Karma: 5433350
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, 155 views)
KevinH is online now   Reply With Quote
Old 07-21-2014, 11:13 AM   #45
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi,

After thinking about it, I am going to make the following changes to my Preserve Entities patch:

1. remove the edit button in the new preferences widget since the only way to add a entity will validate that the strings are proper to begin with, and the entities are short strings that should not need editing once set. So the add and remove buttons should be enough.

2. shrink the entity list widget down to some more reasonable width (given I can figure out how to do that) by hand editing the ui file

3. change just the SettingsStore to use the list of std:pairs of code and string so that constant hash-lookups are not needed. The Preferences widget will still just ask for a list of entities not codes, and XMLEntities will be used to add the codes when going to SettingsStore (and remove the codes when loading back into the Preferences widget).

I will work on a new patch that makes these changes.

I would still like feedback from anyone trying the version already posted if possible, in case there are other things that need changing.

Edit:

Well QSettings uses QVariant and no matter how hard I try QVariant can not seem to grok a QList of anything other than the types QVariant understands which unfortunately is not std::pairs. I could not even get it to work using typedefs. I would have to cast it to a void * blob and back which loses all type safety and causes problems. I guess QVariant is a union type of some sort that requires to at least grok the basic underlying types or structures it is working with.

I will simply have to store them as int lists and QStringList as two separate keys to get it to work.

Edit 2:

That did not work ... Even storing an QList <int> is an issue since what it is really storing is a QList <QVariant> (since QVariant needed by QSettings) and so it requires a lot of casts (which is a nightmare!) when trying to use a custom Type. I am sure there is a way to do it but all of the templates and things may confuse the preprocessors/compilers and be hard to read.

Then it hit me ... all of our codes are valid unicode code points so a List of ushorts can simply become a single QString and saved in SettingsStored in that way. And QSettings handles those just fine. So now I am using two keys in SettingsStore, one to hold the QStringList of entitiy names, and one to hold the QString of codepoints. I convert them to the QList < std::pair < ushort, QString > > for passing around and using them in the Clean routines.

So now the only time the XMLEnities is used is when they are added the first time, and only valid named/numbered Entities are ever added. With edit removed, I don't have to worry about people editing the values into something non-valid.

This approach also prevents this Preference being used as an attack vector using nested entities or any random user generated strings. That should be a good thing.

Last edited by KevinH; 07-21-2014 at 03:01 PM.
KevinH is online now   Reply With Quote
Reply

Tags
crashes, mavericks, osx 10.9.4, sigil 7.4

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
0.7.4 on Maverick crashing Geoff_C8 Sigil 6 01-17-2014 01:40 AM
Sigil keeps crashing kksdragons Sigil 18 11-14-2013 06:20 AM
Sigil is crashing in Windows lindaw2396 Sigil 4 04-22-2013 05:42 PM
crashing and crashing bookjunky Calibre 2 01-16-2011 05:59 PM
0.7.9 crashing on OS X? riverteeth Calibre 7 07-21-2010 11:02 AM


All times are GMT -4. The time now is 09:50 PM.


MobileRead.com is a privately owned, operated and funded community.