Review Request: A Facet and search GUI API for Nepomuk

John Layt johnlayt at googlemail.com
Sat Oct 23 13:31:24 BST 2010



> On 2010-10-22 19:05:38, John Layt wrote:
> > trunk/KDE/kdelibs/nepomuk/utils/daterange.h, line 31
> > <http://svn.reviewboard.kde.org/r/5671/diff/2/?file=39912#file39912line31>
> >
> >     Now, where else in KDE have a seen a DateRange class?  Somewhere in kdepim?  Perhaps we need one in kdelibs?
> 
> Sebastian Trueg wrote:
>     I agree. I will write a unit test and then propose DateRange for kdecore

I'll try find all the date range classes and work out a common set of requirements.  I'll definitely need to talk to the pim guys about their needs, and Dave Jarvie about how it would work with KDateTime as well.


> On 2010-10-22 19:05:38, John Layt wrote:
> > trunk/KDE/kdelibs/nepomuk/utils/datefacet.cpp, line 183
> > <http://svn.reviewboard.kde.org/r/5671/diff/2/?file=39911#file39911line183>
> >
> >     Already here :-)  Yes, the first / last days of the year will need localizing, but it's not pretty.  In fact, it's so ugly, I'll add some public convenience methods to KCalendarSystem for them instead as it's easy to get t wrong (I already have private ones).  I'll get that done this weekend, If not ready in time free free to commit and I'll clean up afterward :-)
> >     
> >     (The whole calendar api is just awkward anyway, I really need to do a KDate class to wrap it all).
> 
> Sebastian Trueg wrote:
>     In DateRange I use this now:
>     
>     DateRange DateRange::yearOf( const QDate& date )
>     {
>         return DateRange( QDate( date.year(), 1, 1 ),
>                           QDate( date.year(),
>                                 KGlobal::locale()->calendar()->monthsInYear( date ),
>                                 KGlobal::locale()->calendar()->daysInMonth( QDate( date.year(), KGlobal::locale()->calendar()->monthsInYear( date ), 1 ) ) ) );
>     }
>     
>     is that correct?

Actually, the year needs localizing too, so it would be:

DateRange DateRange::yearOf( const QDate& date )
{
    int year = KGlobal::locale()->calendar()->year( date );
    QDate startDate, endDate;
    KGlobal::locale()->calendar()->setDate( startDate, year, 1, 1 );
    int lastMonth = KGlobal::locale()->calendar()->monthsInYear( year );
    int lastDay = KGlobal::locale()->calendar()->daysInMonth( year, lastMonth );
    KGlobal::locale()->calendar()->setDate( endDate, year, lastMonth, lastDay );
    return DateRange( startDate, endDate );
}

Too ugly, too long, no? :-(  So it would be easier to use the new api I committed last night:

DateRange DateRange::yearOf( const QDate& date )
{
    return DateRange( KGlobal::locale()->calendar()->firstDayOfYear( date ),
                      KGlobal::locale()->calendar()->lastDayOfYear( date ) );
}

Same goes for the monthOf() method which can use the new firstDayOfMonth() and lastDayOfMoth() methods.

I'm halfway through writing a new KDate class which would reduce the above to:

    KDate localizedDate( date );
    return DateRange( localizedDate.firstDayOfYear(), localizedDate.lastDayOfYear() );

But that's for later.


> On 2010-10-22 19:05:38, John Layt wrote:
> > trunk/KDE/kdelibs/nepomuk/utils/daterangeselectionwidget.ui, line 100
> > <http://svn.reviewboard.kde.org/r/5671/diff/2/?file=39916#file39916line100>
> >
> >     Why not KDatePicker or KDateTable?  It localizes the calendar to the KDE calendar, the Qt one will only ever give you Gregorian.  If you need extra features added let me know.
> 
> Sebastian Trueg wrote:
>     Actually it would be nice to be able to hide the extra day selection gui at the bottom of KDatePicker since that is where the range selection should be.

I'll have a look at that, should be easy and safe to do. I know there are others who want a more flexible KDatePicker/KDateTable.  The pim guys have also talked about merging their date widgets into kdelibs so it's something that really needs working on.


- John


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://svn.reviewboard.kde.org/r/5671/#review8315
-----------------------------------------------------------


On 2010-10-22 18:53:14, Sebastian Trueg wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://svn.reviewboard.kde.org/r/5671/
> -----------------------------------------------------------
> 
> (Updated 2010-10-22 18:53:14)
> 
> 
> Review request for kdelibs and Vishesh Handa.
> 
> 
> Summary
> -------
> 
> I have been struggling with creating a good facet API for a long time now. I finally reached a point where I am happy with the result. IMHO this is essential enough to get into kdelibs/nepomuk. The first usage will obviously be Dolphin, closely followed by the file dialog. All in all this will make it so much simpler to provide Nepomuk powered search capabilities in applications.
> Anyway, this review request is intended for an API review before I commit.
> 
> 
> Diffs
> -----
> 
>   trunk/KDE/kdelibs/includes/CMakeLists.txt 1187872 
>   trunk/KDE/kdelibs/includes/Nepomuk/Utils/DynamicResourceFacet PRE-CREATION 
>   trunk/KDE/kdelibs/includes/Nepomuk/Utils/Facet PRE-CREATION 
>   trunk/KDE/kdelibs/includes/Nepomuk/Utils/FacetWidget PRE-CREATION 
>   trunk/KDE/kdelibs/includes/Nepomuk/Utils/ResourceModel PRE-CREATION 
>   trunk/KDE/kdelibs/includes/Nepomuk/Utils/SearchWidget PRE-CREATION 
>   trunk/KDE/kdelibs/includes/Nepomuk/Utils/SimpleFacet PRE-CREATION 
>   trunk/KDE/kdelibs/includes/Nepomuk/Utils/SimpleResourceModel PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/Mainpage.dox 1187872 
>   trunk/KDE/kdelibs/nepomuk/utils/CMakeLists.txt 1187872 
>   trunk/KDE/kdelibs/nepomuk/utils/datefacet.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/datefacet.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/daterange.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/daterange.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/daterangeselectionwidget.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/daterangeselectionwidget.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/daterangeselectionwidget.ui PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/dynamicresourcefacet.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/dynamicresourcefacet.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facet.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facet.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetdelegate.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetdelegate.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetfiltermodel.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetfiltermodel.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetmodel.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetmodel.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetwidget.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/facetwidget.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/resourcemodel.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/resourcemodel.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/searchlineedit.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/searchlineedit.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/searchwidget.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/searchwidget.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/searchwidget_p.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/simplefacet.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/simplefacet.cpp PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/simpleresourcemodel.h PRE-CREATION 
>   trunk/KDE/kdelibs/nepomuk/utils/simpleresourcemodel.cpp PRE-CREATION 
> 
> Diff: http://svn.reviewboard.kde.org/r/5671/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Sebastian
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20101023/075b7e82/attachment.htm>


More information about the kde-core-devel mailing list