[gnote] Do not show empty Active notes notebook



commit 187650a2ec0dd3382e4fb6177e823e219bafc337
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Jul 14 17:12:20 2013 +0300

    Do not show empty Active notes notebook
    
    When template note is opened, it is added to Active notebook.
    Since template notes are filterred out, this causes Active notebook to
    apear empty.

 src/notebooks/notebook.cpp |   17 +++++++++++++++++
 src/notebooks/notebook.hpp |    5 +----
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index a91215d..76cc065 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.cpp
@@ -339,5 +339,22 @@ namespace notebooks {
     }
   }
 
+  bool ActiveNotesNotebook::empty()
+  {
+    if(m_notes.size() == 0) {
+      return true;
+    }
+
+    // ignore template notes
+    Tag::Ptr template_tag = 
ITagManager::obj().get_or_create_system_tag(ITagManager::TEMPLATE_NOTE_SYSTEM_TAG);
+    for(std::set<Note::Ptr>::iterator iter = m_notes.begin(); iter != m_notes.end(); ++iter) {
+      if(!(*iter)->contains_tag(template_tag)) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
 }
 }
diff --git a/src/notebooks/notebook.hpp b/src/notebooks/notebook.hpp
index aa6832d..9760500 100644
--- a/src/notebooks/notebook.hpp
+++ b/src/notebooks/notebook.hpp
@@ -153,10 +153,7 @@ public:
   virtual bool        contains_note(const Note::Ptr &);
   virtual bool        add_note(const Note::Ptr &);
   virtual Glib::RefPtr<Gdk::Pixbuf> get_icon();
-  bool empty()
-    {
-      return m_notes.size() == 0;
-    }
+  bool empty();
   sigc::signal<void> signal_size_changed;
 private:
   void on_note_deleted(const Note::Ptr & note);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]