aboutsummaryrefslogtreecommitdiff
path: root/Types/View.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-02 14:53:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-02 14:53:19 -0400
commitd6744f85d3ad9b924eeee47148d34bec6992b5eb (patch)
treee2e6bd867580e8850a7fbab6df2df18eb12ccf7d /Types/View.hs
parentbe4e7d409c851eb1f0e65da98f93331c5ba8c1b7 (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/View.hs')
-rw-r--r--Types/View.hs8
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