Please find attached a quick brainstorm of a facet class.
The idea is that one restriction is one facet and those can be put in
groups. A group can be exclusive (for dates or types) or not (tags for
example). The a group can also have a range type which can be used by
the gui to create a range selection based on that type.

These groups could then be added to a model (the only reason for using a
model is that it can easily be displayed in a treeview - might be
overkill) which in turn could be filtered by a custom
QSortProxyFilterModel which hides all facets that do not change the
result (i.e. could of 0 or the same as the result set).

Can you find any use cases that cannot be expressed using it?

Cheers,
Sebastian

On 06/18/2010 03:15 PM, Alessandro Sivieri wrote:
> 2010/6/18 Sebastian Trüg <[email protected] <mailto:[email protected]>>
> 
>     The problem remaining is date ranges: it is simple to have fixed dates
>     for stuff like "this week" or "today" but a custom range is harder. One
>     possibility would be to have a generic facet which can handle literal
>     values like so:
> 
> 
> There is also a UI problem with custom date ranges: I dropped it (for
> now), because it has a fixed minimum width too large, and it blocked the
> whole layout (at least, having it in a QStack); some kind of popup might
> be applied here...
> 
> Now I understand your model idea, but I don't know if it is the best way
> to have just a single model with "everything" in it; I will think about it.
> Meanwhile, I have separated model and view in Sembrowser (I am still
> testing it, so it may not make sense or work :) )...
> 
> -- 
> Sivieri Alessandro
> [email protected] <mailto:[email protected]>
> http://www.chimera-bellerofonte.eu/
> http://www.poul.org/
namespace Nepomuk {
namespace Query {
class FacetPrivate;

class Facet
{
public:
    Facet();
    Facet( const Facet& other );
    Facet( const QString& title, const Query::Term& term );
    ~Facet();

    QString title() const;
    Query::Term queryTerm() const;

    void setTitle( const QString& title );
    void setQueryTerm( const Query::Term& term );

    bool operator==( const Facet& other ) const;
    bool operator!=( const Facet& other ) const;

private:
    QSharedDataPointer<FactePrivate> d;
};


class FacetGroup
{
public:
    FacetGroup();
    ~FacetGroup();

    QString title() const;
    bool exclusive() const;
    QString rangeTitle() const;
    QVariant::Types rangeType() const;

    void setTitle( const QString& title );
    void setExclusive( bool exclusive );

    /**
     * Especially dates are better expressed in ranges.
     * While a group normally only contains fixed Facets
     * the range type allows to provide a user selection
     * of the range in which the facet should result.
     *
     * By default the type is invalid which means that
     * no range is available.
     */
    void setRangeType( QVariant::Type );

    /**
     * Set the title displayed to the user when offering GUI
     * for the range selection.
     */
    void setRangeTitle( const QString& title );

    /**
     * Used by the GUI to set the user selected range. The corresponding
     * term can be created via createRangeTerm(). This avoids caching the
     * values in the GUI classes.
     */
    void setRange( const QVariant& start, const QVariant& end );

    /**
     * Used by the GUI to create the term for a range selected by the user.
     */
    Term createRangeTerm() const;

    void addFacet( const Facet& facet );
    void removeFacet( const Facet& facet );

    QList<Facet> toList() const;

private:
    QSharedDataPointer<FacetGroupPrivate> d;
};
}
}
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk

Reply via email to