Permalink
Browse files

Initial SearchView::toggleUnreadSelectedThread()

  • Loading branch information...
pioto committed May 22, 2012
1 parent 1b0a2bc commit 3e0bf0febfe899220056a0040ff22e18e5caaffe
Showing with 31 additions and 0 deletions.
  1. +30 −0 src/search_view.cc
  2. +1 −0 src/search_view.hh
View
@@ -52,6 +52,7 @@ SearchView::SearchView(const std::string & search, const View::Geometry & geomet
addHandledSequence("\n", std::bind(&SearchView::openSelectedThread, this));
addHandledSequence("a", std::bind(&SearchView::archiveSelectedThread, this));
+ addHandledSequence("N", std::bind(&SearchView::toggleUnreadSelectedThread, this));
addHandledSequence("+", std::bind(&SearchView::addTags, this));
addHandledSequence("-", std::bind(&SearchView::removeTags, this));
@@ -220,6 +221,35 @@ void SearchView::archiveSelectedThread()
}
}
+void SearchView::toggleUnreadSelectedThread()
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+
+ if (_selectedIndex < _threads.size())
+ {
+ try
+ {
+ auto thread = _threads.at(_selectedIndex);
+ bool unread = thread.tags.find("unread") != thread.tags.end();
+ if (unread)
+ thread.removeTag("unread");
+ else
+ thread.addTag("unread");
+
+ next();
+ update();
+ }
+ catch (const InvalidThreadException & e)
+ {
+ StatusBar::instance().displayMessage(e.what());
+ }
+ catch (const InvalidMessageException & e)
+ {
+ StatusBar::instance().displayMessage(e.what());
+ }
+ }
+}
+
void SearchView::refreshThreads()
{
/* If the thread is still going, stop it, and wait for it to return */
View
@@ -42,6 +42,7 @@ class SearchView : public LineBrowserView
void openSelectedThread();
void archiveSelectedThread();
+ void toggleUnreadSelectedThread();
void addTags();
void removeTags();

0 comments on commit 3e0bf0f

Please sign in to comment.