OSDN Git Service

Inform to ThreadWindow that ResNum increases.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Sun, 5 Jul 2009 11:33:55 +0000 (20:33 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Sun, 5 Jul 2009 11:33:55 +0000 (20:33 +0900)
src/board_window.cxx
src/board_window.hxx
src/thread_window.cxx
src/thread_window.hxx

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
index 5b29b4e..ac0f2cf 100644 (file)
@@ -43,6 +43,7 @@ namespace bbs_detail {
 
 struct ThreadIdx;
 
+class ThreadWindow;
 
 class BoardWindow: public dialektos::ApplicationFrameWork {
 public:
@@ -83,6 +84,10 @@ private:
   template <typename ColumnType>
   void add_column(const BoardWindowState&);
 
+  void inform_to_threads(
+      boost::unordered_map<std::string, ModelColumns>&) const;
+  void inform_to_thread(ThreadWindow&, int res_num) const;
+
   Gtk::TreeView tree_view_;
   boost::scoped_ptr<bbs_detail::Base> bbs_;
   Gtk::ScrolledWindow scrolled_;
index 13e6660..d7ea12d 100644 (file)
@@ -264,6 +264,17 @@ void ThreadWindow::save_state() const {
   state.to_xml(boost::filesystem::path(bbs_->get_thread_state_path()));
 }
 
+void ThreadWindow::on_informed_from_board(const int res_num) {
+  if (res_num == 0) {
+    statusbar_.push("Dropped.");
+  } else if (res_num > idx_.line_count_) {
+    std::stringstream ss;
+    ss << boost::format("Update. %1% -> %2%") % idx_.line_count_ % res_num;
+    statusbar_.push(ss.str());
+  }
+}
+
+
 void ThreadWindow::inform_to_board(const ThreadIdx& idx) const {
   BOOST_FOREACH(ApplicationWindow& window, windows) {
     if (BoardWindow* board_window = dynamic_cast<BoardWindow*>(&window)) {
index e503f2c..63e946f 100644 (file)
@@ -45,6 +45,8 @@ public:
   bool load();
   virtual ~ThreadWindow(){}
   virtual void save_state() const;
+  void on_informed_from_board(int res_num);
+  const bbs_detail::Base& get_bbs_detail() const { return *bbs_; }
 protected:
   ThreadWindow(std::auto_ptr<bbs_detail::Base> bbs);