D13358: Add new class that is a model of numbers between two values

David Edmundson noreply at phabricator.kde.org
Tue Jun 5 12:33:58 UTC 2018


davidedmundson added a comment.


  For any C++ project you're right that you'd use that or even a basic for loop instead of a model.
  
  But when writing declaratively means we shouldn't be doing programatic lopos.
  
  For a KDE project I wanted a QtQuickControls2 Tumbler to show year selection something like 1970 -> 2100 or whatever.
  
  You can do Tumbler {model: 130 delegate: Text{text:1970+model.value}}
  but then you have to do a whole fuss getting the value back, it's totally doable but not very clean.
  
  For a home project I had a repeater with a bunch of buttons 1->4 which again required the whole "text: index + 1" or a JS for loop creating items.

INLINE COMMENTS

> markg wrote in knumbermodel.cpp:121
> Won't this give compile warnings? It's double and int foo mixed.
> Also, the +1 should probably be "+ d->step"

right, the max should be 0.

The +1 is for the first entry

i.e 
min=5 max=5  = 1 starting point
min=5 max=7  = 1 starting poing + 2 complete steps  == 3 rows

REPOSITORY
  R275 KItemModels

REVISION DETAIL
  https://phabricator.kde.org/D13358

To: davidedmundson
Cc: markg, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180605/fe67f5a0/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list