OSDN Git Service

Inform to ThreadWindow that ResNum increases.
[fukui-no-namari/dialektos.git] / src / board_window.cxx
index 5e02c53..70bc837 100644 (file)
@@ -52,6 +52,7 @@
 #include "misc.hxx"
 #include "board_window_state.hxx"
 #include "thread_idx.hxx"
+#include "thread_window.hxx"
 
 
 namespace dialektos {
@@ -379,6 +380,8 @@ void BoardWindow::on_http_get_end(bool success) {
   unmerge_subject_txt(buffer);
   merge_subject_txt(subjects, buffer);
   tree_model_->set_buffer(buffer);
+
+  inform_to_threads(buffer);
 }
 
 void BoardWindow::on_refresh_end(const http::StatusLine& status,
@@ -422,5 +425,29 @@ void BoardWindow::save_state() const{
   state.to_xml(boost::filesystem::path(bbs_->get_board_state_path()));
 }
 
+void BoardWindow::inform_to_threads(
+    boost::unordered_map<std::string, ModelColumns>& buffer) const {
+  typedef boost::unordered_map<std::string, ModelColumns> MapType;
+  typedef MapType::const_iterator Iter;
+
+  BOOST_FOREACH(ApplicationWindow& window, windows) {
+    if (ThreadWindow* thread_window = dynamic_cast<ThreadWindow*>(&window)) {
+      const bbs_detail::Base& bbs = thread_window->get_bbs_detail();
+      if (!bbs.belongs_to(*bbs_)) continue;
+
+      const std::string thread = bbs.get_thread_id();
+      Iter it = buffer.find(thread);
+      int res = 0;
+      if (it != buffer.end())
+        res = model_column::field<model_column::ResNum>(it->second);
+      inform_to_thread(*thread_window, res);
+    }
+  }
+}
+
+void BoardWindow::inform_to_thread(ThreadWindow& window, int res_num) const {
+  window.on_informed_from_board(res_num);
+}
+
 
 } // namespace dialektos