~vcs-imports/gnote/master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 * gnote
 *
 * Copyright (C) 2010-2014,2017,2019-2020,2022 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 _NOTEMANAGER_HPP__
#define _NOTEMANAGER_HPP__

#include "notemanagerbase.hpp"
#include "note.hpp"
#include "preferences.hpp"
#include "tagmanager.hpp"
#include "notebooks/notebookmanager.hpp"

namespace gnote {

  class AddinManager;

  class NoteManager 
    : public NoteManagerBase
  {
  public:
    typedef sigc::slot<void(const Note::Ptr &)> NoteChangedSlot;
    
    NoteManager(IGnote & g);
    virtual ~NoteManager();

    void init(const Glib::ustring &);

    virtual notebooks::NotebookManager & notebook_manager() override
      {
        return m_notebook_manager;
      }
    virtual NoteArchiver & note_archiver() override
      {
        return m_note_archiver;
      }
    virtual const ITagManager & tag_manager() const override
      {
        return m_tag_manager;
      }
    virtual ITagManager & tag_manager() override
      {
        return m_tag_manager;
      }

    AddinManager & get_addin_manager()
      {
        return *m_addin_mgr;
      }

    virtual NoteBase::Ptr get_or_create_template_note() override;

    ChangedHandler signal_note_buffer_changed;

    using NoteManagerBase::create_note_from_template;
  protected:
    virtual void post_load() override;
    virtual void migrate_notes(const Glib::ustring & old_note_dir) override;
    NoteBase::Ptr create_note_from_template(Glib::ustring && title, const NoteBase::Ptr & template_note, Glib::ustring && guid) override;
    NoteBase::Ptr create_note(Glib::ustring && title, Glib::ustring && body, Glib::ustring && guid = Glib::ustring()) override;
    NoteBase::Ptr create_new_note(Glib::ustring && title, Glib::ustring && xml_content, Glib::ustring && guid) override;
    virtual NoteBase::Ptr note_create_new(Glib::ustring && title, Glib::ustring && file_name) override;
    NoteBase::Ptr note_load(Glib::ustring && file_name) override;
  private:
    AddinManager *create_addin_manager();
    void create_start_notes();
    void load_notes();
    void on_exiting_event();

    Preferences & m_preferences;
    notebooks::NotebookManager m_notebook_manager;
    AddinManager   *m_addin_mgr;
    NoteArchiver m_note_archiver;
    TagManager m_tag_manager;
  };


}

#endif