diff options
author | Joey Hess <joey@kitenet.net> | 2014-03-02 14:53:19 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-03-02 14:53:19 -0400 |
commit | d6744f85d3ad9b924eeee47148d34bec6992b5eb (patch) | |
tree | e2e6bd867580e8850a7fbab6df2df18eb12ccf7d /Types | |
parent | be4e7d409c851eb1f0e65da98f93331c5ba8c1b7 (diff) |
view, vfilter: Add support for filtering tags and values out of a view, using !tag and field!=value.
Note that negated globs are not supported. Would have complicated the code
to add them, without changing the data type serialization in a
non-backwards-compatable way.
This commit was sponsored by Denver Gingerich.
Diffstat (limited to 'Types')
-rw-r--r-- | Types/View.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Types/View.hs b/Types/View.hs index 618193cf9..fd73d92e4 100644 --- a/Types/View.hs +++ b/Types/View.hs @@ -38,14 +38,20 @@ instance Arbitrary ViewComponent where data ViewFilter = FilterValues (S.Set MetaValue) | FilterGlob String + | ExcludeValues (S.Set MetaValue) deriving (Eq, Read, Show) instance Arbitrary ViewFilter where arbitrary = do size <- arbitrarySizedBoundedIntegral `suchThat` (< 100) - FilterValues . S.fromList <$> vector size + s <- S.fromList <$> vector size + ifM arbitrary + ( return (FilterValues s) + , return (ExcludeValues s) + ) {- Can a ViewFilter match multiple different MetaValues? -} multiValue :: ViewFilter -> Bool multiValue (FilterValues s) = S.size s > 1 multiValue (FilterGlob _) = True +multiValue (ExcludeValues _) = False |