summaryrefslogtreecommitdiffstats
path: root/TreeView
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-01-31 15:51:57 +0100
committertv <tv@shackspace.de>2015-01-31 15:51:57 +0100
commitef48d081dfd0e817c4959dbbd49929ae760a310e (patch)
tree54867be238b6f8707a43fa7af6d16d3f59144f73 /TreeView
parent39e76d0c83515a98f84f06b1c3b430d1e67cd1cd (diff)
Notmuch: replace {un,}setTag by notmuchTag
Diffstat (limited to 'TreeView')
-rw-r--r--TreeView/Types.hs63
1 files changed, 63 insertions, 0 deletions
diff --git a/TreeView/Types.hs b/TreeView/Types.hs
new file mode 100644
index 0000000..0dd1290
--- /dev/null
+++ b/TreeView/Types.hs
@@ -0,0 +1,63 @@
+{-# LANGUAGE LambdaCase #-}
+
+module TreeView.Types where
+
+import qualified Data.CaseInsensitive as CI
+import qualified Data.Text as T
+import Notmuch.Message
+import Notmuch.SearchResult
+
+
+type LineNr = Int
+
+
+data TreeView
+ = TVMessage Message
+ | TVMessageHeaderField Message (CI.CI T.Text)
+ | TVMessagePart Message MessagePart
+ | TVMessageQuoteLine Message MessagePart LineNr String
+ | TVMessageLine Message MessagePart LineNr String
+ | TVSearch String
+ | TVSearchResult SearchResult
+ deriving (Show)
+
+
+instance Eq TreeView where
+ x1 == x2 = treeViewId x1 == treeViewId x2
+
+
+data TreeViewId
+ = TVIDMessage T.Text
+ | TVIDMessageHeaderField T.Text T.Text
+ | TVIDMessagePart T.Text Int
+ | TVIDMessageLine T.Text Int Int
+ | TVIDSearch T.Text
+ | TVIDSearchResult T.Text
+ deriving (Eq,Show)
+
+
+treeViewId :: TreeView -> TreeViewId
+treeViewId = \case
+ TVMessage m ->
+ TVIDMessage (fromMessage m)
+
+ TVMessageHeaderField m mhf ->
+ TVIDMessageHeaderField (fromMessage m) (CI.foldedCase mhf)
+
+ TVMessagePart m mp ->
+ TVIDMessagePart (fromMessage m) (partID mp)
+
+ TVMessageLine m mp lineNr _ ->
+ TVIDMessageLine (fromMessage m) (partID mp) lineNr
+
+ TVMessageQuoteLine m mp lineNr _ ->
+ TVIDMessageLine (fromMessage m) (partID mp) lineNr
+
+ TVSearch s ->
+ TVIDSearch (T.pack s)
+
+ TVSearchResult sr ->
+ TVIDSearchResult (T.pack $ unThreadID $ searchThread sr)
+
+ where
+ fromMessage = T.pack . unMessageID . messageId