[gnote] Use Glib::ustring for note title and content
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Use Glib::ustring for note title and content
- Date: Wed, 15 Jan 2014 21:08:45 +0000 (UTC)
commit d8e25aee248a76b873a800fcbadfdec0103696d5
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Jan 12 23:34:46 2014 +0200
Use Glib::ustring for note title and content
src/note.cpp | 40 +++++++++++++++++++---------------------
src/note.hpp | 40 ++++++++++++++++++++--------------------
src/searchnoteswidget.cpp | 6 +++---
3 files changed, 42 insertions(+), 44 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index 868c7d0..c98a982 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2013 Aurimas Cernius
+ * Copyright (C) 2010-2014 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -200,13 +200,13 @@ namespace gnote {
invalidate_text();
}
- const std::string & NoteDataBufferSynchronizer::text()
+ const Glib::ustring & NoteDataBufferSynchronizer::text()
{
synchronize_text();
return m_data->text();
}
- void NoteDataBufferSynchronizer::set_text(const std::string & t)
+ void NoteDataBufferSynchronizer::set_text(const Glib::ustring & t)
{
m_data->text() = t;
synchronize_buffer();
@@ -635,19 +635,19 @@ namespace gnote {
}
- const std::string & Note::get_title() const
+ const Glib::ustring & Note::get_title() const
{
return m_data.data().title();
}
- void Note::set_title(const std::string & new_title)
+ void Note::set_title(const Glib::ustring & new_title)
{
set_title(new_title, false);
}
- void Note::set_title(const std::string & new_title,
+ void Note::set_title(const Glib::ustring & new_title,
bool from_user_action)
{
if (m_data.data().title() != new_title) {
@@ -655,7 +655,7 @@ namespace gnote {
m_window->set_name(new_title);
}
- std::string old_title = m_data.data().title();
+ Glib::ustring old_title = m_data.data().title();
m_data.data().title() = new_title;
if (from_user_action) {
@@ -737,30 +737,29 @@ namespace gnote {
}
- bool Note::contains_text(const std::string & text)
+ bool Note::contains_text(const Glib::ustring & text)
{
- const std::string text_lower = sharp::string_to_lower(text);
- const std::string text_content_lower
- = sharp::string_to_lower(text_content());
- return sharp::string_index_of(text_content_lower, text_lower) > -1;
+ const std::string text_lower = text.lowercase();
+ const std::string text_content_lower = text_content().lowercase();
+ return text_content_lower.find(text_lower) != Glib::ustring::npos;
}
- void Note::rename_links(const std::string & old_title,
+ void Note::rename_links(const Glib::ustring & old_title,
const Ptr & renamed)
{
handle_link_rename(old_title, renamed, true);
}
- void Note::remove_links(const std::string & old_title,
+ void Note::remove_links(const Glib::ustring & old_title,
const Ptr & renamed)
{
handle_link_rename(old_title, renamed, false);
}
- void Note::handle_link_rename(const std::string & old_title,
+ void Note::handle_link_rename(const Glib::ustring & old_title,
const Ptr & renamed,
bool rename)
{
@@ -768,8 +767,7 @@ namespace gnote {
if (!contains_text(old_title))
return;
- const std::string old_title_lower
- = sharp::string_to_lower(old_title);
+ const std::string old_title_lower = old_title.lowercase();
const NoteTag::Ptr link_tag = m_tag_table->get_link_tag();
@@ -777,7 +775,7 @@ namespace gnote {
utils::TextTagEnumerator enumerator(m_buffer, link_tag);
while (enumerator.move_next()) {
const utils::TextRange & range(enumerator.current());
- if (sharp::string_to_lower(range.text()) != old_title_lower)
+ if (range.text().lowercase() != old_title_lower)
continue;
if (!rename) {
@@ -800,7 +798,7 @@ namespace gnote {
}
- void Note::rename_without_link_update(const std::string & newTitle)
+ void Note::rename_without_link_update(const Glib::ustring & newTitle)
{
if (m_data.data().title() != newTitle) {
if (m_window) {
@@ -816,7 +814,7 @@ namespace gnote {
}
}
- void Note::set_xml_content(const std::string & xml)
+ void Note::set_xml_content(const Glib::ustring & xml)
{
if (m_buffer) {
m_buffer->set_text("");
@@ -943,7 +941,7 @@ namespace gnote {
}
}
- std::string Note::text_content()
+ Glib::ustring Note::text_content()
{
if(!m_buffer) {
get_buffer();
diff --git a/src/note.hpp b/src/note.hpp
index ca683ba..e6a5e9b 100644
--- a/src/note.hpp
+++ b/src/note.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2013 Aurimas Cernius
+ * Copyright (C) 2011-2014 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -64,19 +64,19 @@ public:
{
return m_uri;
}
- const std::string & title() const
+ const Glib::ustring & title() const
{
return m_title;
}
- std::string & title()
+ Glib::ustring & title()
{
return m_title;
}
- const std::string & text() const
+ const Glib::ustring & text() const
{
return m_text;
}
- std::string & text()
+ Glib::ustring & text()
{
return m_text;
}
@@ -151,8 +151,8 @@ public:
private:
const std::string m_uri;
- std::string m_title;
- std::string m_text;
+ Glib::ustring m_title;
+ Glib::ustring m_text;
sharp::DateTime m_create_date;
sharp::DateTime m_change_date;
sharp::DateTime m_metadata_change_date;
@@ -197,8 +197,8 @@ public:
return m_buffer;
}
void set_buffer(const Glib::RefPtr<NoteBuffer> & b);
- const std::string & text();
- void set_text(const std::string & t);
+ const Glib::ustring & text();
+ void set_text(const Glib::ustring & t);
private:
void invalidate_text();
@@ -262,19 +262,19 @@ public:
{
return m_filepath;
}
- const std::string & get_title() const;
- void set_title(const std::string & new_tile);
- void set_title(const std::string & new_title, bool from_user_action);
- void rename_without_link_update(const std::string & newTitle);
- const std::string & xml_content()
+ const Glib::ustring & get_title() const;
+ void set_title(const Glib::ustring & new_tile);
+ void set_title(const Glib::ustring & new_title, bool from_user_action);
+ void rename_without_link_update(const Glib::ustring & newTitle);
+ const Glib::ustring & xml_content()
{
return m_data.text();
}
- void set_xml_content(const std::string & xml);
+ void set_xml_content(const Glib::ustring & xml);
std::string get_complete_note_xml();
void load_foreign_note_xml(const std::string & foreignNoteXml, ChangeType changeType);
static void parse_tags(const xmlNodePtr tagnodes, std::list<std::string> & tags);
- std::string text_content();
+ Glib::ustring text_content();
void set_text_content(const std::string & text);
const NoteData & data() const;
NoteData & data();
@@ -334,8 +334,8 @@ public:
{ return m_signal_tag_removed; }
private:
- bool contains_text(const std::string & text);
- void handle_link_rename(const std::string & old_title,
+ bool contains_text(const Glib::ustring & text);
+ void handle_link_rename(const Glib::ustring & old_title,
const Ptr & renamed,
bool rename);
void on_buffer_changed();
@@ -354,9 +354,9 @@ private:
void process_rename_link_update(const std::string & old_title);
void process_rename_link_update_end(int response, Gtk::Dialog *dialog,
const std::string & old_title, const Note::Ptr & self);
- void rename_links(const std::string & old_title,
+ void rename_links(const Glib::ustring & old_title,
const Ptr & renamed);
- void remove_links(const std::string & old_title,
+ void remove_links(const Glib::ustring & old_title,
const Ptr & renamed);
void on_note_window_embedded();
void on_note_window_foregrounded();
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index ae7c8ca..3eecba2 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2013 Aurimas Cernius
+ * Copyright (C) 2010-2014 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -1192,7 +1192,7 @@ void SearchNotesWidget::add_note(const Note::Ptr & note)
utils::get_pretty_print_date(note->change_date(), true);
Gtk::TreeIter iter = m_store->append();
iter->set_value(m_column_types.icon, get_note_icon());
- iter->set_value(m_column_types.title, note->get_title());
+ iter->set_value(m_column_types.title, std::string(note->get_title()));
iter->set_value(m_column_types.change_date, nice_date);
iter->set_value(m_column_types.note, note);
}
@@ -1204,7 +1204,7 @@ void SearchNotesWidget::rename_note(const Note::Ptr & note)
for(Gtk::TreeModel::iterator iter = rows.begin();
rows.end() != iter; iter++) {
if(note == iter->get_value(m_column_types.note)) {
- iter->set_value(m_column_types.title, note->get_title());
+ iter->set_value(m_column_types.title, std::string(note->get_title()));
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]