Page 19 of 30

Re: hmg-4 Changelog

Posted: Sat Nov 12, 2011 2:16 pm
by l3whmg
Hi Friends.
first of all MOST IMPORTANT for everyone and Rathinagiri: UPDATE HARBOUR please.
HARBOUR COMPILER MINIMUM VERSION REQUIRED IS 3.1 rev. 17105
Some defined vars are added within HbQtGui.ch and I have removed them from hmg.ch

This, for me, it's a good day because I rewrite COMBOBOX object and the compatibility with HMG3 is 80%.
I hope can be a good work.
Only for DROPPEDWITH(), ONCLOSEUP(), ONDROPDOWN() I don't find solution.

Now, ITEMSOURCE, VALUESOURCE and IMAGESOURCE can be used to retrieve data from dbf (see samples/combobox/demo_2.prg). These method can not be used with ITEMS, ADDITEM, IMAGE (as previous Hmg3)

Attention: ITEMS() method must be only used at definition time. After, you must use ADDITEM(....)

Now image are supported (see samples/combobox/demo_1.prg).

I have add a plus: related values. In a combobox always we have a simple list and ITEM(n) give us the displayed text.
With RELATEDVALUES() we can give an alternative returned value using ITEMVAL(n). It can be a number, a string, a date,.... but to prevent errors and to simplify managing always string is returned. If is there someone who want find a good way....

I have done some test (see demo*) but everyone can do more test.

Code: Select all

2011-11-12 15:00 UTC+0100 Luigi Ferraris ( <luigi at l3w.it> )
   ; HARBOUR COMPILER MINIMUM VERSION REQUIRED IS 3.1 rev. 17105

   + samples/combobox/flags
   + samples/combobox/flags/argentina.png
   + samples/combobox/flags/australia.png
   + samples/combobox/flags/canada.png
   + samples/combobox/flags/denmark.png
   + samples/combobox/flags/finland.png
   + samples/combobox/flags/france.png
   + samples/combobox/flags/italy.png
   + samples/combobox/flags/russian.png
   + samples/combobox/flags/spain.png
   + samples/combobox/flags/sweden.png
   + samples/combobox/flags/switzerland.png
   + samples/combobox/flags/usa.png
   + samples/combobox/flags/usa.png
   + samples/combobox/cicades1.ntx
   + samples/combobox/cicades.dbf
   + samples/combobox/demo_1.hbp
   + samples/combobox/demo_1.prg
   + samples/combobox/demo_2.hbp
   + samples/combobox/demo_2.prg

   ! source/combobox.prg
     ! totally rewrited. Please refer to hmg3 documentation
     + RelatedValues() to handle values related with items
     + ItemVal( nIndex, xValue) to get or to set related value
     ! Item( nIndex, xArg1, xArg2) was extended. xArg2 is the related value.
     ; these methods are non implemented yet:
       DROPPEDWITH(), ONCLOSEUP(), ONDROPDOWN()

   ! samples/alldemo/demo_1.ch
     - removed QAbstractSpinBox_* defined vars because HbQtgui.ch update

   * include/hmg.ch
     + #xcommand IMAGESOURCE
     ! #xcommand ITEMSOURCE
     ! #xcommand VALUESOURCE
     + #xcommand RELATEDVALUES
     - removed QAbstractSpinBox_* defined vars because HbQtgui.ch update

Re: hmg-4 Changelog

Posted: Sat Nov 12, 2011 5:05 pm
by Roberto Lopez
l3whmg wrote: I have add a plus: related values. In a combobox always we have a simple list and ITEM(n) give us the displayed text.
With RELATEDVALUES() we can give an alternative returned value using ITEMVAL(n). It can be a number, a string, a date,.... but to prevent errors and to simplify managing always string is returned. If is there someone who want find a good way....
This is a wonderful addition.

But, IMHO, ITEMVAL(n) should return the data exactly as it was specified by the user (date, numeric, etc.).

The user should be responsible for the RELATEDVALUES content.

Just an opinion.

Re: hmg-4 Changelog

Posted: Sat Nov 12, 2011 6:19 pm
by l3whmg
Hi Roberto.
You are right, but there is a little problem: this value is stored as QVariant( xValue) and when I retrieve this I receive a Qt object (in other words QVariant). To know exactly, I must code like this

Code: Select all

oQtValue := .....ItemData(nx)
IF oQtValue:type() == QVariant_Int
   xReturn := oQtValue:toInt()
ELSEIF oQtValue:type() == QVariant_Date
   xReturn := oQtValue:toDate()
etc., etc.
It can be done......

Re: hmg-4 Changelog

Posted: Sun Nov 13, 2011 11:07 am
by l3whmg
Hi friends....As Roberto suggests, now ItemVal() returns stored value. To do this, I write a very, very simple "HmgQv2Clp( oQtVariant)" public function. Must be checked for all type of var stored: if is there someone who want do it....(can be used samples/combobox/demo_1.prg changing aRelatedValues array.....)

Code: Select all

2011-11-13 12:00 UTC+0100 Luigi Ferraris ( <luigi at l3w.it> )
   * samples/combobox/demo_1.prg
   * source/combobox.prg
     * ItemVal(...) now returns a converted value using HmgQv2Clp() function.
       Please read note about this new function.

   + include/qtqvariant.ch
   * source/misc.prg
     + HmgQv2Clp( oQtVariant ) public function. It converts from QVariant
       object to a CLIPPER var. It's a very simple interface: must be checked
       very well.
Cheers

Re: hmg-4 Changelog

Posted: Sun Nov 13, 2011 12:11 pm
by Rathinagiri
That's so nice of you Luigi.

I will update to the latest Harbour.

Re: hmg-4 Changelog

Posted: Sun Nov 13, 2011 3:40 pm
by l3whmg
Hi friends
I remove some icons, add comobox example....and revised all menu.

Code: Select all

2011-11-13 16:40 UTC+0100 Luigi Ferraris ( <luigi at l3w.it> )
   + samples/alldemo/data
   + samples/alldemo/data/cicades1.ntx
   + samples/alldemo/data/cicades.dbf
   + samples/alldemo/flags
   + samples/alldemo/flags/argentina.png
   + samples/alldemo/flags/australia.png
   + samples/alldemo/flags/canada.png
   + samples/alldemo/flags/denmark.png
   + samples/alldemo/flags/finland.png
   + samples/alldemo/flags/france.png
   + samples/alldemo/flags/italy.png
   + samples/alldemo/flags/russian.png
   + samples/alldemo/flags/spain.png
   + samples/alldemo/flags/sweden.png
   + samples/alldemo/flags/switzerland.png
   + samples/alldemo/flags/usa.png
   * samples/alldemo/demo_1.ch
   * samples/alldemo/demo_1.hbp
   * samples/alldemo/demo_1.prg
   * samples/alldemo/demo_1.qrc
   + samples/alldemo/demo_1p010.prg
   + samples/alldemo/demo_1p011.prg
     * p010 to show COMBOBOX usage with ARRAY
     * p011 to show COMBOBOX usage with DBF

   - samples/alldemo/icons/align_bottom.png
   - samples/alldemo/icons/align_horcenter.png
   - samples/alldemo/icons/align_left.png
   - samples/alldemo/icons/align_right.png
   - samples/alldemo/icons/align_top.png
   - samples/alldemo/icons/align_vercenter.png
   * samples/alldemo/demo_1p001.prg
   * samples/alldemo/demo_1p002.prg
   * samples/alldemo/demo_1p003.prg
   * samples/alldemo/demo_1p004.prg
   * samples/alldemo/demo_1p005.prg
   * samples/alldemo/demo_1p006.prg
   * samples/alldemo/demo_1p007.prg
   * samples/alldemo/demo_1p008.prg
   * samples/alldemo/demo_1p009.prg
     * minor fix about system menu to do actions and object setup. I want
       to reduce number of graphics files on SVN

Re: hmg-4 Changelog

Posted: Mon Nov 14, 2011 1:45 am
by Roberto Lopez
l3whmg wrote:Hi friends....As Roberto suggests, now ItemVal() returns stored value. To do this, I write a very, very simple "HmgQv2Clp( oQtVariant)" public function. Must be checked for all type of var stored: if is there someone who want do it....(can be used samples/combobox/demo_1.prg changing aRelatedValues array.....)
Thanks!

Re: hmg-4 Changelog

Posted: Mon Nov 14, 2011 2:14 pm
by l3whmg
Hi friends

Code: Select all

2011-11-14 15:10 UTC+0100 Luigi Ferraris ( <luigi at l3w.it> )
   * samples/alldemo/demo_1.hbp
   * samples/alldemo/demo_1.prg
   + samples/alldemo/demo_1p012.prg
     * p012 to show DIAL usage

   ! source/dial.prg
     ! all methods are out of Hmg4 standard style: aligned but always
       value is returned (I preserved this). It can be a good solution,
       but it doesn't respects Hmg4 standard.

   ! source/abstractslider.prg
     ! event handling alignment: usage of __Hmg* style
     ! all methods are out of Hmg4 standard style: aligned but always
       value is returned (I preserved this). It can be a good solution,
       but it doesn't respects Hmg4 standard.

Re: hmg-4 Changelog

Posted: Wed Nov 16, 2011 6:10 pm
by l3whmg
Hi a bug fixed about Ricci notification.

Code: Select all

2011-11-16 18:55 UTC+0100 Luigi Ferraris ( <luigi at l3w.it> )
   ! source/combobox.prg
     * wrong starting position when object created. Thanks to Ricci for notice.
This problem has showed me an old problem: when the events (OnChange and other) must be fired on. IMHO, when the object (and its childrens) is created and a little bit before showing. For this reason, a lot of code about some events (OnClick, OnChange, etc.) must be improved.

Little example

Code: Select all

/*..............................................................................
   OnChange
..............................................................................*/
METHOD OnChange( bArg1 ) CLASS COMBOBOX

   IF PCOUNT() == 0
      RETURN ::bOnChange
   ELSEIF PCOUNT() == 1
      IF hb_IsBlock( bArg1 ) == .T.
         ::bOnChange := bArg1
         IF ::IsCreated() == .T. <==== new
             ::oQTObject:Connect( "currentIndexChanged(int)" , { ||::__HmgOnChangeExec } )
         ENDIF   <==== new
      ELSEIF hb_IsNil( bArg1 ) == .T.
         ::bOnChange := NIL
        IF ::IsCreated() == .T. <==== new
            ::oQTObject:DisConnect( "currentIndexChanged(int)" )
         ENDIF   <==== new
      ENDIF
   ENDIF

RETURN Self
And within Create() method every On* must be checked

Code: Select all

/*..............................................................................
   Create
..............................................................................*/
METHOD Create() CLASS COMBOBOX

   LOCAL nX, oQtVariant
   
   IF ::lCreated == .T.
      RETURN NIL
   ENDIF

   ::lCreated := .T.

   // Create inner controls
   ::CreatePendingChildControls()

   IF hb_IsChar( ::cItemSource ) == .T.
      ::__HmgRefresh()
   ELSE
      ::__HmgLoadAllItems( ::__HmgSort( ::__HmgArray( ::aItems ) ) )
   ENDIF

   // positioning at startup
   IF hb_IsNumeric( ::nValue ) == .T.
      IF hb_IsChar( ::cItemSource ) == .T.
         FOR nX := 1 TO ::oQtObject:count()
            oQtVariant := ::oQtObject:itemData( nX-1 )
               IF oQtVariant:toInt() == ::nValue
                  ::oQtObject:setCurrentIndex( nX-1 )
               EXIT
            ENDIF
         NEXT nX
      ELSE
         ::oQtObject:setCurrentIndex( ::nValue-1 )
         ::nValue := ::oQtObject:currentIndex() + 1
      ENDIF
   ENDIF

   IF hb_IsBlock( ::bOnChange ) == .T. ; ::OnChange := ::bOnChange ; ENDIF  <=== new
   ::__HmgConnectEv()

   IF ::Visible() == .T.
      ::oQtObject:show()
   ENDIF

RETURN NIL
Why this? IMHO to prevent the On* events fired on before object was created.

If I remember well, HMG3 don't do as I described here. When "object" is created the On* event is fired on.
Every one can play changing the OnChange of the combobox as I write and see difference.

But this is a lot of work.

Re: hmg-4 Changelog

Posted: Sat Nov 19, 2011 8:05 am
by mrduck

Code: Select all

2011-11-19 08:54 UTC+0100 Francesco Perillo ( fperillo at gmail.com )
   * source/layout.prg
     * methods Release and Visible moved to Layouts class
     * methods Close, Show and Visible added to Layouts class. They are
       empty methods to comply with overloading
   * source/basic.prg
     * in method Create changed oQtObject:Show() to ::Show so that it
       may be overriden