[gnote] Remove sharp::string_to_lower
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Remove sharp::string_to_lower
- Date: Wed, 15 Jan 2014 21:08:50 +0000 (UTC)
commit e0f518cf4a99ee4923d71c46db2de17d1700b377
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Jan 12 23:45:18 2014 +0200
Remove sharp::string_to_lower
Use Glib::ustring::lowercase() instead
src/addins/backlinks/backlinksnoteaddin.cpp | 10 ++++------
src/notebooks/notebook.cpp | 8 ++++----
src/notemanager.cpp | 6 +++---
src/notemanager.hpp | 4 ++--
src/search.cpp | 16 ++++++++--------
src/search.hpp | 4 ++--
src/searchnoteswidget.cpp | 4 ++--
src/sharp/directory.cpp | 4 ++--
src/sharp/string.cpp | 8 +-------
src/sharp/string.hpp | 3 +--
src/tag.cpp | 5 +++--
src/tagmanager.cpp | 6 +++---
src/watchers.cpp | 18 +++++++++---------
src/watchers.hpp | 4 ++--
14 files changed, 46 insertions(+), 54 deletions(-)
---
diff --git a/src/addins/backlinks/backlinksnoteaddin.cpp b/src/addins/backlinks/backlinksnoteaddin.cpp
index 2bd1417..0796c37 100644
--- a/src/addins/backlinks/backlinksnoteaddin.cpp
+++ b/src/addins/backlinks/backlinksnoteaddin.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2011,2013 Aurimas Cernius
+ * Copyright (C) 2010-2011,2013-2014 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -109,11 +109,9 @@ void BacklinksNoteAddin::get_backlink_menu_items(std::list<BacklinkMenuItem*> &
bool BacklinksNoteAddin::check_note_has_match(const gnote::Note::Ptr & note,
const std::string & encoded_title)
{
- std::string note_text = sharp::string_to_lower(note->xml_content());
- if (sharp::string_index_of(note_text, encoded_title) < 0)
- return false;
-
- return true;
+ Glib::ustring note_text = note->xml_content();
+ note_text = note_text.lowercase();
+ return note_text.find(encoded_title) != Glib::ustring::npos;
}
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index 84cb338..36a6541 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.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
@@ -97,10 +97,10 @@ namespace notebooks {
void Notebook::set_name(const std::string & value)
{
- std::string trimmedName = value;
+ Glib::ustring trimmedName = sharp::string_trim(value);
if(!trimmedName.empty()) {
m_name = trimmedName;
- m_normalized_name = sharp::string_to_lower(trimmedName);
+ m_normalized_name = trimmedName.lowercase();
// The templateNoteTite should show the name of the
// notebook. For example, if the name of the notebooks
@@ -223,7 +223,7 @@ namespace notebooks {
std::string Notebook::normalize(const std::string & s)
{
- return sharp::string_to_lower(sharp::string_trim(s));
+ return Glib::ustring(sharp::string_trim(s)).lowercase();
}
Tag::Ptr SpecialNotebook::get_tag() const
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index 0e9a063..bd1b4be 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.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
*
@@ -646,12 +646,12 @@ namespace gnote {
return m_trie_controller->title_trie()->find_matches(match);
}
- Note::Ptr NoteManager::find(const std::string & linked_title) const
+ Note::Ptr NoteManager::find(const Glib::ustring & linked_title) const
{
for(Note::List::const_iterator iter = m_notes.begin();
iter != m_notes.end(); ++iter) {
const Note::Ptr & note(*iter);
- if (sharp::string_to_lower(note->get_title()) == sharp::string_to_lower(linked_title))
+ if (note->get_title().lowercase() == linked_title.lowercase())
return note;
}
return Note::Ptr();
diff --git a/src/notemanager.hpp b/src/notemanager.hpp
index ff2a15d..4d27299 100644
--- a/src/notemanager.hpp
+++ b/src/notemanager.hpp
@@ -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
@@ -78,7 +78,7 @@ namespace gnote {
{
return m_read_only;
}
- Note::Ptr find(const std::string &) const;
+ Note::Ptr find(const Glib::ustring &) const;
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);
diff --git a/src/search.cpp b/src/search.cpp
index 38d73dd..3c66c7b 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011,2013 Aurimas Cernius
+ * Copyright (C) 2011,2013-2014 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -39,13 +39,13 @@ namespace gnote {
Search::ResultsPtr Search::search_notes(const std::string & query, bool case_sensitive,
const notebooks::Notebook::Ptr & selected_notebook)
{
- std::string search_text = query;
+ Glib::ustring search_text = query;
if(!case_sensitive) {
- search_text = sharp::string_to_lower(search_text);
+ search_text = search_text.lowercase();
}
std::vector<std::string> words;
- Search::split_watching_quotes(words, search_text);
+ Search::split_watching_quotes(words, std::string(search_text));
// Used for matching in the raw note XML
std::vector<std::string> encoded_words;
@@ -96,9 +96,9 @@ namespace gnote {
const std::vector<std::string> & encoded_words,
bool match_case)
{
- std::string note_text = note->xml_content();
+ Glib::ustring note_text = note->xml_content();
if (!match_case) {
- note_text = sharp::string_to_lower(note_text);
+ note_text = note_text.lowercase();
}
for(std::vector<std::string>::const_iterator iter = encoded_words.begin();
@@ -114,14 +114,14 @@ namespace gnote {
return true;
}
- int Search::find_match_count_in_note(std::string note_text,
+ int Search::find_match_count_in_note(Glib::ustring note_text,
const std::vector<std::string> & words,
bool match_case)
{
int matches = 0;
if (!match_case) {
- note_text = sharp::string_to_lower(note_text);
+ note_text = note_text.lowercase();
}
for(std::vector<std::string>::const_iterator iter = words.begin();
diff --git a/src/search.hpp b/src/search.hpp
index 03b790f..518588f 100644
--- a/src/search.hpp
+++ b/src/search.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011,2013 Aurimas Cernius
+ * Copyright (C) 2011,2013-2014 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -76,7 +76,7 @@ public:
const notebooks::Notebook::Ptr & );
bool check_note_has_match(const Note::Ptr & note, const std::vector<std::string> & ,
bool match_case);
- int find_match_count_in_note(std::string note_text, const std::vector<std::string> &,
+ int find_match_count_in_note(Glib::ustring note_text, const std::vector<std::string> &,
bool match_case);
private:
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 3eecba2..153975e 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -164,7 +164,7 @@ void SearchNotesWidget::perform_search()
remove_matches_column();
Search search(m_manager);
- std::string text = m_search_text;
+ Glib::ustring text = m_search_text;
if(text.empty()) {
m_current_matches.clear();
m_store_filter->refilter();
@@ -173,7 +173,7 @@ void SearchNotesWidget::perform_search()
}
return;
}
- text = sharp::string_to_lower(text);
+ text = text.lowercase();
m_current_matches.clear();
diff --git a/src/sharp/directory.cpp b/src/sharp/directory.cpp
index 02d821a..fa88f75 100644
--- a/src/sharp/directory.cpp
+++ b/src/sharp/directory.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2012 Aurimas Cernius
+ * Copyright (C) 2011-2014 Aurimas Cernius
* Copyright (C) 2011 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -54,7 +54,7 @@ namespace sharp {
const std::string & extension = file_info.get_extension();
if (Glib::file_test(file, Glib::FILE_TEST_IS_REGULAR)
- && (ext.empty() || (sharp::string_to_lower(extension) == ext))) {
+ && (ext.empty() || (Glib::ustring(extension).lowercase() == ext))) {
list.push_back(file);
}
}
diff --git a/src/sharp/string.cpp b/src/sharp/string.cpp
index f2c9cf6..c79216f 100644
--- a/src/sharp/string.cpp
+++ b/src/sharp/string.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012 Aurimas Cernius
+ * Copyright (C) 2012,2014 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -156,10 +156,4 @@ namespace sharp {
return iter.begin() - source2.begin() + start_at;
}
-
- Glib::ustring string_to_lower(const Glib::ustring & source)
- {
- return source.lowercase();
- }
-
}
diff --git a/src/sharp/string.hpp b/src/sharp/string.hpp
index 628eaab..3e44f2d 100644
--- a/src/sharp/string.hpp
+++ b/src/sharp/string.hpp
@@ -1,6 +1,7 @@
/*
* gnote
*
+ * Copyright (C) 2014 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -69,8 +70,6 @@ namespace sharp {
int string_index_of(const std::string & source, const std::string & with);
int string_index_of(const std::string & source, const std::string & with, int);
int string_last_index_of(const std::string & source, const std::string & with);
-
- Glib::ustring string_to_lower(const Glib::ustring & source);
}
diff --git a/src/tag.cpp b/src/tag.cpp
index c4d4da8..014ec69 100644
--- a/src/tag.cpp
+++ b/src/tag.cpp
@@ -1,6 +1,7 @@
/*
* gnote
*
+ * Copyright (C) 2014 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -71,10 +72,10 @@ namespace gnote {
void Tag::set_name(const std::string & value)
{
if (!value.empty()) {
- std::string trimmed_name = sharp::string_trim(value);
+ Glib::ustring trimmed_name = sharp::string_trim(value);
if (!trimmed_name.empty()) {
m_name = trimmed_name;
- m_normalized_name = sharp::string_to_lower(trimmed_name);
+ m_normalized_name = trimmed_name.lowercase();
if(Glib::str_has_prefix(m_normalized_name, SYSTEM_TAG_PREFIX)) {
m_issystem = true;
}
diff --git a/src/tagmanager.cpp b/src/tagmanager.cpp
index c8b2c0f..0f8b6dd 100644
--- a/src/tagmanager.cpp
+++ b/src/tagmanager.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011,2013 Aurimas Cernius
+ * Copyright (C) 2011,2013-2014 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -69,7 +69,7 @@ namespace gnote {
if (tag_name.empty())
throw sharp::Exception("TagManager.GetTag () called with a null tag name.");
- std::string normalized_tag_name = sharp::string_to_lower(sharp::string_trim(tag_name));
+ std::string normalized_tag_name = Glib::ustring(sharp::string_trim(tag_name)).lowercase();
if (normalized_tag_name.empty())
throw sharp::Exception ("TagManager.GetTag () called with an empty tag name.");
@@ -100,7 +100,7 @@ namespace gnote {
if (tag_name.empty())
throw sharp::Exception ("TagManager.GetOrCreateTag () called with a null tag name.");
- std::string normalized_tag_name = sharp::string_to_lower(sharp::string_trim(tag_name));
+ std::string normalized_tag_name = Glib::ustring(sharp::string_trim(tag_name)).lowercase();
if (normalized_tag_name.empty())
throw sharp::Exception ("TagManager.GetOrCreateTag () called with an empty tag name.");
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 56afa4e..0da2d72 100644
--- a/src/watchers.cpp
+++ b/src/watchers.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
*
@@ -775,10 +775,10 @@ namespace gnote {
}
- bool NoteLinkWatcher::contains_text(const std::string & text)
+ bool NoteLinkWatcher::contains_text(const Glib::ustring & text)
{
- std::string body = sharp::string_to_lower(get_note()->text_content());
- std::string match = sharp::string_to_lower(text);
+ Glib::ustring body = get_note()->text_content().lowercase();
+ Glib::ustring match = text.lowercase();
return sharp::string_index_of(body, match) > -1;
}
@@ -808,13 +808,13 @@ namespace gnote {
return;
}
- std::string old_title_lower = sharp::string_to_lower(deleted->get_title());
+ std::string old_title_lower = deleted->get_title().lowercase();
// Turn all link:internal to link:broken for the deleted note.
utils::TextTagEnumerator enumerator(get_buffer(), m_link_tag);
while (enumerator.move_next()) {
const utils::TextRange & range(enumerator.current());
- if (sharp::string_to_lower(enumerator.current().text()) != old_title_lower)
+ if (enumerator.current().text().lowercase() != old_title_lower)
continue;
get_buffer()->remove_tag (m_link_tag, range.start(), range.end());
@@ -855,7 +855,7 @@ namespace gnote {
Note::Ptr hit_note(hit.value());
- if (sharp::string_to_lower(hit.key()) != sharp::string_to_lower(hit_note->get_title())) { // == 0 if
same string
+ if (hit.key().lowercase() != hit_note->get_title().lowercase()) { // == 0 if same string
DBG_OUT ("DoHighlight: '%s' links wrongly to note '%s'." ,
hit.key().c_str(),
hit_note->get_title().c_str());
@@ -904,8 +904,8 @@ namespace gnote {
const Gtk::TextIter & start,
const Gtk::TextIter & end)
{
- std::string buffer_text = sharp::string_to_lower(start.get_text (end));
- std::string find_title_lower = sharp::string_to_lower(find_note->get_title());
+ Glib::ustring buffer_text = start.get_text(end).lowercase();
+ Glib::ustring find_title_lower = find_note->get_title().lowercase();
int idx = 0;
while (true) {
diff --git a/src/watchers.hpp b/src/watchers.hpp
index e276680..487c644 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -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
@@ -182,7 +182,7 @@ namespace gnote {
virtual void on_note_opened() override;
private:
- bool contains_text(const std::string & text);
+ bool contains_text(const Glib::ustring & text);
void on_note_added(const Note::Ptr &);
void on_note_deleted(const Note::Ptr &);
void on_note_renamed(const Note::Ptr&, const std::string&);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]