[gnote] Move special notebooks to separate files
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Move special notebooks to separate files
- Date: Fri, 28 Feb 2014 21:43:12 +0000 (UTC)
commit 5b0f2a200b94f9d0cb8ff602239d6f9175ef5782
Author: Aurimas Černius <aurisc4 gmail com>
Date: Fri Feb 28 23:40:21 2014 +0200
Move special notebooks to separate files
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
.../specialnotes/specialnotesapplicationaddin.cpp | 4 +-
src/notebooks/notebook.cpp | 166 -----------------
src/notebooks/notebook.hpp | 94 ----------
src/notebooks/notebookmanager.cpp | 1 +
src/notebooks/notebookstreeview.cpp | 1 +
src/notebooks/specialnotebooks.cpp | 196 ++++++++++++++++++++
src/notebooks/specialnotebooks.hpp | 117 ++++++++++++
src/searchnoteswidget.cpp | 1 +
10 files changed, 320 insertions(+), 262 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6678587..7af7bed 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -61,6 +61,7 @@ src/notebooks/notebookmanager.cpp
src/notebooks/notebookmenuitem.cpp
src/notebooks/notebooknewnotemenuitem.cpp
src/notebooks/notebooknoteaddin.cpp
+src/notebooks/specialnotebooks.cpp
src/notebuffer.cpp
src/note.cpp
src/notebase.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index a9c3084..dad281c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -146,6 +146,7 @@ libgnote_la_SOURCES = \
notebooks/notebookmenuitem.hpp notebooks/notebookmenuitem.cpp \
notebooks/notebooknewnotemenuitem.hpp notebooks/notebooknewnotemenuitem.cpp \
notebooks/notebooknoteaddin.hpp notebooks/notebooknoteaddin.cpp \
+ notebooks/specialnotebooks.hpp notebooks/specialnotebooks.cpp \
synchronization/filesystemsyncserver.hpp synchronization/filesystemsyncserver.cpp \
synchronization/fusesyncserviceaddin.hpp synchronization/fusesyncserviceaddin.cpp \
synchronization/isyncmanager.hpp synchronization/isyncmanager.cpp \
diff --git a/src/addins/specialnotes/specialnotesapplicationaddin.cpp
b/src/addins/specialnotes/specialnotesapplicationaddin.cpp
index 6244ea6..c9e9589 100644
--- a/src/addins/specialnotes/specialnotesapplicationaddin.cpp
+++ b/src/addins/specialnotes/specialnotesapplicationaddin.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2013 Aurimas Cernius
+ * Copyright (C) 2013-2014 Aurimas Cernius
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
#include <glibmm/i18n.h>
-#include "notebooks/notebook.hpp"
+#include "notebooks/specialnotebooks.hpp"
#include "notebooks/notebookmanager.hpp"
#include "iconmanager.hpp"
#include "specialnotesapplicationaddin.hpp"
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index 547aa8f..897c765 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.cpp
@@ -24,7 +24,6 @@
#include <glibmm/i18n.h>
#include "sharp/string.hpp"
-#include "iconmanager.hpp"
#include "notemanager.hpp"
#include "notebooks/notebook.hpp"
#include "notebooks/notebookmanager.hpp"
@@ -221,170 +220,5 @@ namespace notebooks {
return Glib::ustring(sharp::string_trim(s)).lowercase();
}
- Tag::Ptr SpecialNotebook::get_tag() const
- {
- return Tag::Ptr();
- }
-
- Note::Ptr SpecialNotebook::get_template_note() const
- {
- return static_pointer_cast<Note>(m_note_manager.get_or_create_template_note());
- }
-
-
- AllNotesNotebook::AllNotesNotebook(NoteManager & manager)
- : SpecialNotebook(manager, _("All"))
- {
- }
-
-
- std::string AllNotesNotebook::get_normalized_name() const
- {
- return "___NotebookManager___AllNotes__Notebook___";
- }
-
-
- bool AllNotesNotebook::contains_note(const Note::Ptr & note, bool include_system)
- {
- if(include_system) {
- return true;
- }
- return !is_template_note(note);
- }
-
-
- bool AllNotesNotebook::add_note(const Note::Ptr &)
- {
- return false;
- }
-
- Glib::RefPtr<Gdk::Pixbuf> AllNotesNotebook::get_icon()
- {
- return IconManager::obj().get_icon(IconManager::FILTER_NOTE_ALL, 22);
- }
-
-
- UnfiledNotesNotebook::UnfiledNotesNotebook(NoteManager & manager)
- : SpecialNotebook(manager, _("Unfiled"))
- {
- }
-
- std::string UnfiledNotesNotebook::get_normalized_name() const
- {
- return "___NotebookManager___UnfiledNotes__Notebook___";
- }
-
-
- bool UnfiledNotesNotebook::contains_note(const Note::Ptr & note, bool include_system)
- {
- bool contains = !notebooks::NotebookManager::obj().get_notebook_from_note(note);
- if(!contains || include_system) {
- return contains;
- }
- return !is_template_note(note);
- }
-
-
- bool UnfiledNotesNotebook::add_note(const Note::Ptr & note)
- {
- NotebookManager::obj().move_note_to_notebook(note, Notebook::Ptr());
- return true;
- }
-
- Glib::RefPtr<Gdk::Pixbuf> UnfiledNotesNotebook::get_icon()
- {
- return IconManager::obj().get_icon(IconManager::FILTER_NOTE_UNFILED, 22);
- }
-
-
- PinnedNotesNotebook::PinnedNotesNotebook(NoteManager & manager)
- : SpecialNotebook(manager, _("Important"))
- {
- }
-
- std::string PinnedNotesNotebook::get_normalized_name() const
- {
- return "___NotebookManager___PinnedNotes__Notebook___";
- }
-
-
- bool PinnedNotesNotebook::contains_note(const Note::Ptr & note, bool)
- {
- return note->is_pinned();
- }
-
- bool PinnedNotesNotebook::add_note(const Note::Ptr & note)
- {
- note->set_pinned(true);
- return true;
- }
-
- Glib::RefPtr<Gdk::Pixbuf> PinnedNotesNotebook::get_icon()
- {
- return IconManager::obj().get_icon(IconManager::PIN_DOWN, 22);
- }
-
-
- ActiveNotesNotebook::ActiveNotesNotebook(NoteManager & manager)
- : SpecialNotebook(manager, _("Active"))
- {
- manager.signal_note_deleted
- .connect(sigc::mem_fun(*this, &ActiveNotesNotebook::on_note_deleted));
- }
-
- std::string ActiveNotesNotebook::get_normalized_name() const
- {
- return "___NotebookManager___ActiveNotes__Notebook___";
- }
-
- bool ActiveNotesNotebook::contains_note(const Note::Ptr & note, bool include_system)
- {
- bool contains = m_notes.find(note) != m_notes.end();
- if(!contains || include_system) {
- return contains;
- }
- return !is_template_note(note);
- }
-
- bool ActiveNotesNotebook::add_note(const Note::Ptr & note)
- {
- if(m_notes.insert(note).second) {
- signal_size_changed();
- }
-
- return true;
- }
-
- Glib::RefPtr<Gdk::Pixbuf> ActiveNotesNotebook::get_icon()
- {
- return IconManager::obj().get_icon(IconManager::ACTIVE_NOTES, 22);
- }
-
- void ActiveNotesNotebook::on_note_deleted(const NoteBase::Ptr & note)
- {
- std::set<Note::Ptr>::iterator iter = m_notes.find(static_pointer_cast<Note>(note));
- if(iter != m_notes.end()) {
- m_notes.erase(iter);
- signal_size_changed();
- }
- }
-
- bool ActiveNotesNotebook::empty()
- {
- if(m_notes.size() == 0) {
- return true;
- }
-
- // ignore template notes
- Tag::Ptr templ_tag = template_tag();
- FOREACH(const Note::Ptr & note, m_notes) {
- if(!note->contains_tag(templ_tag)) {
- return false;
- }
- }
-
- return true;
- }
-
}
}
diff --git a/src/notebooks/notebook.hpp b/src/notebooks/notebook.hpp
index ed57e70..eb2b181 100644
--- a/src/notebooks/notebook.hpp
+++ b/src/notebooks/notebook.hpp
@@ -23,7 +23,6 @@
#ifndef __NOTEBOOKS_NOTEBOOK_HPP_
#define __NOTEBOOKS_NOTEBOOK_HPP_
-#include <set>
#include <string>
#include "base/macros.hpp"
@@ -75,99 +74,6 @@ private:
Tag::Ptr m_tag;
};
-
-/// <summary>
-/// A notebook of this type is special in the sense that it
-/// will not normally be displayed to the user as a notebook
-/// but it's used in the Search All Notes Window for special
-/// filtering of the notes.
-/// </summary>
-class SpecialNotebook
- : public Notebook
-{
-public:
- typedef shared_ptr<SpecialNotebook> Ptr;
-
- virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() = 0;
-protected:
- SpecialNotebook(NoteManager & m, const std::string &s)
- : Notebook(m, s, true)
- {
- }
- virtual Tag::Ptr get_tag() const override;
- virtual Note::Ptr get_template_note() const override;
-};
-
-
-/// <summary>
-/// A special notebook that represents really "no notebook" as
-/// being selected. This notebook is used in the Search All
-/// Notes Window to allow users to select it at the top of the
-/// list so that all notes are shown.
-/// </summary>
-class AllNotesNotebook
- : public SpecialNotebook
-{
-public:
- typedef shared_ptr<AllNotesNotebook> Ptr;
- AllNotesNotebook(NoteManager &);
- virtual std::string get_normalized_name() const override;
- virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
- virtual bool add_note(const Note::Ptr &) override;
- virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
-};
-
-
-/// <summary>
-/// A special notebook that represents a notebook with notes
-/// that are not filed. This is used in the Search All Notes
-/// Window to filter notes that are not placed in any notebook.
-/// </summary>
-class UnfiledNotesNotebook
- : public SpecialNotebook
-{
-public:
- typedef shared_ptr<UnfiledNotesNotebook> Ptr;
- UnfiledNotesNotebook(NoteManager &);
- virtual std::string get_normalized_name() const override;
- virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
- virtual bool add_note(const Note::Ptr &) override;
- virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
-};
-
-
-class PinnedNotesNotebook
- : public SpecialNotebook
-{
-public:
- typedef shared_ptr<PinnedNotesNotebook> Ptr;
- PinnedNotesNotebook(NoteManager &);
- virtual std::string get_normalized_name() const override;
- virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
- virtual bool add_note(const Note::Ptr &) override;
- virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
-};
-
-
-class ActiveNotesNotebook
- : public SpecialNotebook
-{
-public:
- typedef shared_ptr<ActiveNotesNotebook> Ptr;
- ActiveNotesNotebook(NoteManager &);
- virtual std::string get_normalized_name() const override;
- virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
- virtual bool add_note(const Note::Ptr &) override;
- virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
- bool empty();
- sigc::signal<void> signal_size_changed;
-private:
- void on_note_deleted(const NoteBase::Ptr & note);
-
- std::set<Note::Ptr> m_notes;
-};
-
-
}
}
diff --git a/src/notebooks/notebookmanager.cpp b/src/notebooks/notebookmanager.cpp
index 76fcc26..95326c7 100644
--- a/src/notebooks/notebookmanager.cpp
+++ b/src/notebooks/notebookmanager.cpp
@@ -28,6 +28,7 @@
#include "sharp/exception.hpp"
#include "notebooks/createnotebookdialog.hpp"
#include "notebooks/notebookmanager.hpp"
+#include "notebooks/specialnotebooks.hpp"
#include "debug.hpp"
#include "ignote.hpp"
#include "notemanager.hpp"
diff --git a/src/notebooks/notebookstreeview.cpp b/src/notebooks/notebookstreeview.cpp
index d475630..6a43857 100644
--- a/src/notebooks/notebookstreeview.cpp
+++ b/src/notebooks/notebookstreeview.cpp
@@ -28,6 +28,7 @@
#include "notebooks/notebook.hpp"
#include "notebooks/notebookmanager.hpp"
#include "notebooks/notebookstreeview.hpp"
+#include "notebooks/specialnotebooks.hpp"
#include "notemanager.hpp"
namespace gnote {
diff --git a/src/notebooks/specialnotebooks.cpp b/src/notebooks/specialnotebooks.cpp
new file mode 100644
index 0000000..36e74d0
--- /dev/null
+++ b/src/notebooks/specialnotebooks.cpp
@@ -0,0 +1,196 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2010-2014 Aurimas Cernius
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <glibmm/i18n.h>
+
+#include "iconmanager.hpp"
+#include "notemanager.hpp"
+#include "notebookmanager.hpp"
+#include "specialnotebooks.hpp"
+
+
+namespace gnote {
+namespace notebooks {
+
+
+Tag::Ptr SpecialNotebook::get_tag() const
+{
+ return Tag::Ptr();
+}
+
+Note::Ptr SpecialNotebook::get_template_note() const
+{
+ return static_pointer_cast<Note>(m_note_manager.get_or_create_template_note());
+}
+
+
+AllNotesNotebook::AllNotesNotebook(NoteManager & manager)
+ : SpecialNotebook(manager, _("All"))
+{
+}
+
+std::string AllNotesNotebook::get_normalized_name() const
+{
+ return "___NotebookManager___AllNotes__Notebook___";
+}
+
+bool AllNotesNotebook::contains_note(const Note::Ptr & note, bool include_system)
+{
+ if(include_system) {
+ return true;
+ }
+ return !is_template_note(note);
+}
+
+bool AllNotesNotebook::add_note(const Note::Ptr &)
+{
+ return false;
+}
+
+Glib::RefPtr<Gdk::Pixbuf> AllNotesNotebook::get_icon()
+{
+ return IconManager::obj().get_icon(IconManager::FILTER_NOTE_ALL, 22);
+}
+
+
+UnfiledNotesNotebook::UnfiledNotesNotebook(NoteManager & manager)
+ : SpecialNotebook(manager, _("Unfiled"))
+{
+}
+
+std::string UnfiledNotesNotebook::get_normalized_name() const
+{
+ return "___NotebookManager___UnfiledNotes__Notebook___";
+}
+
+bool UnfiledNotesNotebook::contains_note(const Note::Ptr & note, bool include_system)
+{
+ bool contains = !notebooks::NotebookManager::obj().get_notebook_from_note(note);
+ if(!contains || include_system) {
+ return contains;
+ }
+ return !is_template_note(note);
+}
+
+bool UnfiledNotesNotebook::add_note(const Note::Ptr & note)
+{
+ NotebookManager::obj().move_note_to_notebook(note, Notebook::Ptr());
+ return true;
+}
+
+Glib::RefPtr<Gdk::Pixbuf> UnfiledNotesNotebook::get_icon()
+{
+ return IconManager::obj().get_icon(IconManager::FILTER_NOTE_UNFILED, 22);
+}
+
+
+PinnedNotesNotebook::PinnedNotesNotebook(NoteManager & manager)
+ : SpecialNotebook(manager, _("Important"))
+{
+}
+
+std::string PinnedNotesNotebook::get_normalized_name() const
+{
+ return "___NotebookManager___PinnedNotes__Notebook___";
+}
+
+bool PinnedNotesNotebook::contains_note(const Note::Ptr & note, bool)
+{
+ return note->is_pinned();
+}
+
+bool PinnedNotesNotebook::add_note(const Note::Ptr & note)
+{
+ note->set_pinned(true);
+ return true;
+}
+
+Glib::RefPtr<Gdk::Pixbuf> PinnedNotesNotebook::get_icon()
+{
+ return IconManager::obj().get_icon(IconManager::PIN_DOWN, 22);
+}
+
+
+ActiveNotesNotebook::ActiveNotesNotebook(NoteManager & manager)
+ : SpecialNotebook(manager, _("Active"))
+{
+ manager.signal_note_deleted
+ .connect(sigc::mem_fun(*this, &ActiveNotesNotebook::on_note_deleted));
+}
+
+std::string ActiveNotesNotebook::get_normalized_name() const
+{
+ return "___NotebookManager___ActiveNotes__Notebook___";
+}
+
+bool ActiveNotesNotebook::contains_note(const Note::Ptr & note, bool include_system)
+{
+ bool contains = m_notes.find(note) != m_notes.end();
+ if(!contains || include_system) {
+ return contains;
+ }
+ return !is_template_note(note);
+}
+
+bool ActiveNotesNotebook::add_note(const Note::Ptr & note)
+{
+ if(m_notes.insert(note).second) {
+ signal_size_changed();
+ }
+
+ return true;
+}
+
+Glib::RefPtr<Gdk::Pixbuf> ActiveNotesNotebook::get_icon()
+{
+ return IconManager::obj().get_icon(IconManager::ACTIVE_NOTES, 22);
+}
+
+void ActiveNotesNotebook::on_note_deleted(const NoteBase::Ptr & note)
+{
+ std::set<Note::Ptr>::iterator iter = m_notes.find(static_pointer_cast<Note>(note));
+ if(iter != m_notes.end()) {
+ m_notes.erase(iter);
+ signal_size_changed();
+ }
+}
+
+bool ActiveNotesNotebook::empty()
+{
+ if(m_notes.size() == 0) {
+ return true;
+ }
+
+ // ignore template notes
+ Tag::Ptr templ_tag = template_tag();
+ FOREACH(const Note::Ptr & note, m_notes) {
+ if(!note->contains_tag(templ_tag)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+}
+}
+
diff --git a/src/notebooks/specialnotebooks.hpp b/src/notebooks/specialnotebooks.hpp
new file mode 100644
index 0000000..32a6408
--- /dev/null
+++ b/src/notebooks/specialnotebooks.hpp
@@ -0,0 +1,117 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2010-2014 Aurimas Cernius
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+#ifndef __NOTEBOOKS_SPECIALNOTEBOOKS_HPP_
+#define __NOTEBOOKS_SPECIALNOTEBOOKS_HPP_
+
+
+#include <set>
+
+#include "base/macros.hpp"
+#include "notebook.hpp"
+#include "tag.hpp"
+
+
+namespace gnote {
+namespace notebooks {
+
+
+class SpecialNotebook
+ : public Notebook
+{
+public:
+ typedef shared_ptr<SpecialNotebook> Ptr;
+
+ virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() = 0;
+protected:
+ SpecialNotebook(NoteManager & m, const std::string &s)
+ : Notebook(m, s, true)
+ {
+ }
+ virtual Tag::Ptr get_tag() const override;
+ virtual Note::Ptr get_template_note() const override;
+};
+
+
+class AllNotesNotebook
+ : public SpecialNotebook
+{
+public:
+ typedef shared_ptr<AllNotesNotebook> Ptr;
+ AllNotesNotebook(NoteManager &);
+ virtual std::string get_normalized_name() const override;
+ virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
+ virtual bool add_note(const Note::Ptr &) override;
+ virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
+};
+
+
+class UnfiledNotesNotebook
+ : public SpecialNotebook
+{
+public:
+ typedef shared_ptr<UnfiledNotesNotebook> Ptr;
+ UnfiledNotesNotebook(NoteManager &);
+ virtual std::string get_normalized_name() const override;
+ virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
+ virtual bool add_note(const Note::Ptr &) override;
+ virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
+};
+
+
+class PinnedNotesNotebook
+ : public SpecialNotebook
+{
+public:
+ typedef shared_ptr<PinnedNotesNotebook> Ptr;
+ PinnedNotesNotebook(NoteManager &);
+ virtual std::string get_normalized_name() const override;
+ virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
+ virtual bool add_note(const Note::Ptr &) override;
+ virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
+};
+
+
+class ActiveNotesNotebook
+ : public SpecialNotebook
+{
+public:
+ typedef shared_ptr<ActiveNotesNotebook> Ptr;
+ ActiveNotesNotebook(NoteManager &);
+ virtual std::string get_normalized_name() const override;
+ virtual bool contains_note(const Note::Ptr & note, bool include_system = false) override;
+ virtual bool add_note(const Note::Ptr &) override;
+ virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override;
+ bool empty();
+ sigc::signal<void> signal_size_changed;
+private:
+ void on_note_deleted(const NoteBase::Ptr & note);
+
+ std::set<Note::Ptr> m_notes;
+};
+
+
+}
+}
+
+#endif
+
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 77be130..8c17252 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -38,6 +38,7 @@
#include "searchnoteswidget.hpp"
#include "itagmanager.hpp"
#include "notebooks/notebookmanager.hpp"
+#include "notebooks/specialnotebooks.hpp"
#include "sharp/string.hpp"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]