View Single Post
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("<>"");
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