[gnote] Introduce get_note_content
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Introduce get_note_content
- Date: Mon, 13 Apr 2020 14:32:14 +0000 (UTC)
commit 01727a85a1d626ba56ef5b985e8d60632f7b92e2
Author: Aurimas Černius <aurisc4 gmail com>
Date: Mon Apr 13 16:08:07 2020 +0300
Introduce get_note_content
src/notemanagerbase.cpp | 7 ++++++-
src/notemanagerbase.hpp | 1 +
src/test/unit/notemanagerutests.cpp | 7 +++++++
3 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/notemanagerbase.cpp b/src/notemanagerbase.cpp
index 18211798..25ae5e66 100644
--- a/src/notemanagerbase.cpp
+++ b/src/notemanagerbase.cpp
@@ -374,13 +374,18 @@ NoteBase::Ptr NoteManagerBase::create_new_note(const Glib::ustring & title, cons
}
Glib::ustring NoteManagerBase::get_note_template_content(const Glib::ustring & title)
+{
+ return get_note_content(title, _("Describe your new note here."));
+}
+
+Glib::ustring NoteManagerBase::get_note_content(const Glib::ustring & title, const Glib::ustring & body)
{
return Glib::ustring::compose("<note-content>"
"<note-title>%1</note-title>\n\n"
"%2"
"</note-content>",
utils::XmlEncoder::encode(title),
- _("Describe your new note here."));
+ utils::XmlEncoder::encode(body));
}
NoteBase::Ptr NoteManagerBase::get_or_create_template_note()
diff --git a/src/notemanagerbase.hpp b/src/notemanagerbase.hpp
index 7feb2cfe..f0a258a0 100644
--- a/src/notemanagerbase.hpp
+++ b/src/notemanagerbase.hpp
@@ -45,6 +45,7 @@ public:
static Glib::ustring sanitize_xml_content(const Glib::ustring & xml_content);
static Glib::ustring get_note_template_content(const Glib::ustring & title);
+ static Glib::ustring get_note_content(const Glib::ustring & title, const Glib::ustring & body);
static Glib::ustring split_title_from_content(Glib::ustring title, Glib::ustring & body);
NoteManagerBase(IGnote & g);
diff --git a/src/test/unit/notemanagerutests.cpp b/src/test/unit/notemanagerutests.cpp
index 59a1bec0..cb391217 100644
--- a/src/test/unit/notemanagerutests.cpp
+++ b/src/test/unit/notemanagerutests.cpp
@@ -46,6 +46,13 @@ SUITE(NoteManager)
};
+ TEST(get_note_content)
+ {
+ auto content = gnote::NoteManagerBase::get_note_content("test_title", "test_content");
+ CHECK(content.find("<note-title>test_title</note-title>") != Glib::ustring::npos);
+ CHECK(content.find("test_content") != Glib::ustring::npos);
+ }
+
TEST(split_title_from_content)
{
Glib::ustring body;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]