HMG4: RFC: Implementing a VALID subsystem

Moderator: Rathinagiri

Post Reply
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

HMG4: RFC: Implementing a VALID subsystem

Post by mrduck » Sat Dec 11, 2010 5:03 pm

I'm currently implementing a VALID subsystem in HMG4. After some tests I had done in the past and others done recently with Luigi and a talk with Maurizio, I had the "vision" on haow it would work.

I want to tell you all so that you may suggest some other issues, especially telling me how you did in hmg3, which were the good things and the bad things.

My idea is to give each textbox a valid codeblock during object definition. At WINDOW ACTIVATE I will let create all the objects so that they exist. Just before the end of window:activate() I call a new doValidChildControls() window method. It will scan all the window object and if there is a "valid" assignment, it will evaluate it (so they will be evaluated in creation order).
Depending the return value of the "valid" codeblock, I will assign a "style" (note 1). Actually a return of .F. sets the background to red, .T. to white. So all the red backgrounds mean that that field is invalid.
doValidChildControls() returns an .AND. of all "valid" results, so .T. means that all editbox are correct, .F. means that at least one editbox is incorrect (note 2)

In my tests I'm using a onlostfocus method to call doValidChildControls(), but it recalculates ALL valids, and it may be bad in same cases (think at heavy value lookup). I will switch to a different method to only recalculate the single textbox valid we are exiting.

I'd also like to add a "realtimevalid" that uses ONCHANGE instead of onlostfocus. Imagine typing the text in the textbox and the background switches from red to white as soon the value is valid...

I hadn't checked compatibility with QValidator and other mask stuff. Unfortunately user-defined QValidator can't be used now in hbqt, they may be in the future...

If you have ideas of something to implement, have already developed something similar, have some sample code to contribute, or just want to browse/preview/test the changes please post...

note 1: I'm using the terrific Qt capability to use CSS syntax to style objects... I'm planning to make the 2 styles user-defined, so you can change color, style, font as you like...
note 2: we may use a window data variable to hold this data. I may also add a reference to a "save/ok" button, disabling it if it returns .F.

User avatar
Posts: 5071
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 87 times
Been thanked: 103 times

Post by Rathinagiri » Sat Dec 11, 2010 5:32 pm

On the fly 'Valid' is a nice implementation. It is very innovative. It is just like DynamicBackColor/DynamicForeColor in HMG3 Grids. Now, if it is implemented in all the controls, that would be fine. :)

Thanks a lot Francesco.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest