Beyond 2.6
John Ralls
jralls at ceridwen.us
Sat Feb 16 15:59:37 EST 2013
On Feb 16, 2013, at 12:30 PM, Herbert Thoma <herbert.thoma at iis.fraunhofer.de> wrote:
>
>
> Am 16.02.2013 17:06, schrieb John Ralls:
>>
>> On Feb 16, 2013, at 5:06 AM, Herbert Thoma <herbert.thoma at iis.fraunhofer.de> wrote:
>>
>>> forgot CC list ...
>>>
>>> Am 15.02.2013 21:06, schrieb John Ralls:
>>>>>> Why hard to say? MVC isn't exactly cutting-edge design. It's been
>>>>>> around since 1988 and 7 years later GoF thought it so well-understood
>>>>>> that it's the "how to use patterns" example in the introduction.
>>>>>
>>>>> Well, the point is that every time the user leaves a field you need to
>>>>> parse all the input fields and process them in the controller/model as
>>>>> part of the validation, even if the user hasn't asked to 'save' yet.
>>>>>
>>>>> I guess it all depends on your controller APIs. (In the RoR world this
>>>>> is harder to do, because the view is in the browser, but the model and
>>>>> controllers are on the server -- and there is no "verify this model" API
>>>>> in the controller. At least not directly. The client-side-validations
>>>>> gem adds some support for this).
>>>>
>>>>
>>>> We already do that for the account type listbox: We connect to a signal
>>>> (don't know offhand which one) in the parent accounts GtkTreeView that tells
>>>> us that the user has selected a parent account, retrieve that account, run
>>>> xaccAccountGetCompatibleTypes() on it, and populate the account type listbox
>>>> with the result.
>>>>
>>>> That's a pretty standard way for UI View objects to communicate with their
>>>> controller objects, though there are others. Wx has a specific "Validator"
>>>> class that lets you register a callback to test control input as it happens.
>>>> It also has a signals mechanism (which they rather confusingly call Events)
>>>> to support other interactivity needs. Qt is well-known for its "signals and slots"
>>>> feature, which I imagine is used for this purpose much like Gtk's signals are, but
>>>> I've never written anything for Qt so I don't actually know.
>>>
>>> Yes, you can use signals and slots this way. I personally like Qt very much. For me
>>> it is the best GUI toolkit I have ever worked with (I worked with Motif, MFC,
>>> GTK and Qt, but always only small projects or patches to GnuCash).
>>>
>>> However, I would still be hesitant to use signals and slots in the engine. Earlier
>>> in this thread it was stated that the engine depends heavily on Glib and that this
>>> is bad for portability. Do we want to replace the Glib dependency with a Qt
>>> dependency?
>>>
>>
>> See Geert's and my responses about where the "slots" go.
>
> OK, thanks. I think I got it. I only just know enough C++ to be dangerous ...
>
>> Does Qt have another mechanism for validating user input as he types? How does it handle spell checking? ("Magic" is a reasonable answer here: I know in detail how Gtk handles spell checking because it's an add-on that I've contributed to, but Apple handles it inside the toolkit so that application devs needn't do anything about it.)
>
> Qt has a QValidator class. http://qt-project.org/doc/qt-4.8/qvalidator.html
> I don't think that this is used for spell checking, though.
Looks similar to Wx's.
It also links to http://qt-project.org/doc/qt-4.8/widgets-lineedits.html which shows signals and slots being used to perform the interactive features we've been discussing. They're even used to fire off the validator.
Regards,
John Ralls
More information about the gnucash-devel
mailing list