[gnote] Count from 1 when creating unique note name
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Count from 1 when creating unique note name
- Date: Sun, 2 Jun 2013 20:34:49 +0000 (UTC)
commit 5df67272c67b2e2dd2bfaebaf6109a5d5b1e8697
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Jun 2 23:33:09 2013 +0300
Count from 1 when creating unique note name
Fixes Bug 700448.
src/notebooks/notebook.cpp | 4 ++--
src/notemanager.cpp | 12 ++++++------
src/notemanager.hpp | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index f536195..38306bc 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.cpp
@@ -134,7 +134,7 @@ namespace notebooks {
if(m_note_manager.find(title)) {
std::list<Note*> tag_notes;
m_tag->get_notes(tag_notes);
- title = m_note_manager.get_unique_name (title, tag_notes.size());
+ title = m_note_manager.get_unique_name(title);
}
note = m_note_manager.create(title, NoteManager::get_note_template_content (title));
@@ -163,7 +163,7 @@ namespace notebooks {
std::string temp_title;
Note::Ptr note_template = get_template_note();
- temp_title = m_note_manager.get_unique_name(_("New Note"), m_note_manager.get_notes().size());
+ temp_title = m_note_manager.get_unique_name(_("New Note"));
Note::Ptr note = m_note_manager.create_note_from_template(temp_title, note_template);
// Add the notebook tag
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index e2b579d..280b074 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -521,7 +521,7 @@ namespace gnote {
title = split_title_from_content (title, body);
if (title.empty()) {
- title = get_unique_name(_("New Note"), 1);
+ title = get_unique_name(_("New Note"));
}
Note::Ptr template_note = get_or_create_template_note();
@@ -605,7 +605,7 @@ namespace gnote {
if (!template_note) {
std::string title = m_default_note_template_title;
if (find(title)) {
- title = get_unique_name(title, m_notes.size());
+ title = get_unique_name(title);
}
template_note =
create (title,
@@ -715,7 +715,7 @@ namespace gnote {
std::string new_title(title);
Tag::Ptr template_save_title =
ITagManager::obj().get_or_create_system_tag(ITagManager::TEMPLATE_NOTE_SAVE_TITLE_SYSTEM_TAG);
if(template_note->contains_tag(template_save_title)) {
- new_title = get_unique_name(template_note->get_title(), 1);
+ new_title = get_unique_name(template_note->get_title());
}
// Use the body from the template note
@@ -755,10 +755,10 @@ namespace gnote {
return new_note;
}
- // Find a title that does not exist using basename and id as
- // a starting point
- std::string NoteManager::get_unique_name(const std::string & basename, int id) const
+ // Find a title that does not exist using basename
+ std::string NoteManager::get_unique_name(const std::string & basename) const
{
+ int id = 1; // starting point
std::string title;
while (true) {
title = str(boost::format("%1% %2%") % basename % id++);
diff --git a/src/notemanager.hpp b/src/notemanager.hpp
index 16e61af..9bf12e5 100644
--- a/src/notemanager.hpp
+++ b/src/notemanager.hpp
@@ -82,7 +82,7 @@ namespace gnote {
Note::Ptr find_by_uri(const std::string &) const;
static std::string sanitize_xml_content(const std::string & xml_content);
Note::Ptr create_note_from_template(const std::string & title, const Note::Ptr & template_note);
- std::string get_unique_name (const std::string & basename, int id) const;
+ std::string get_unique_name (const std::string & basename) const;
void delete_note(const Note::Ptr & note);
Note::Ptr create();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]