[gnote] Replace std::string by Glib::ustring in SearchNotesWidget



commit c1d14454b27d640b125f7ee0dafff5380585225f
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Feb 4 15:11:08 2017 +0200

    Replace std::string by Glib::ustring in SearchNotesWidget

 src/searchnoteswidget.cpp |   23 +++++++++++------------
 src/searchnoteswidget.hpp |   10 +++++-----
 2 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 171423b..a70015a 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -518,7 +518,7 @@ void SearchNotesWidget::update_results()
 
   FOREACH(const NoteBase::Ptr & note_iter, m_manager.get_notes()) {
     Note::Ptr note(static_pointer_cast<Note>(note_iter));
-    std::string nice_date = utils::get_pretty_print_date(note->change_date(), true);
+    Glib::ustring nice_date = utils::get_pretty_print_date(note->change_date(), true);
 
     Gtk::TreeIter iter = m_store->append();
     iter->set_value(0, get_note_icon());  /* icon */
@@ -603,8 +603,8 @@ bool SearchNotesWidget::filter_notes(const Gtk::TreeIter & iter)
 
 int SearchNotesWidget::compare_titles(const Gtk::TreeIter & a, const Gtk::TreeIter & b)
 {
-  Glib::ustring title_a = std::string((*a)[m_column_types.title]);
-  Glib::ustring title_b = std::string((*b)[m_column_types.title]);
+  Glib::ustring title_a = (*a)[m_column_types.title];
+  Glib::ustring title_b = (*b)[m_column_types.title];
 
   if(title_a.empty() || title_b.empty()) {
     return -1;
@@ -1082,13 +1082,12 @@ void SearchNotesWidget::matches_column_data_func(Gtk::CellRenderer * cell,
     return;
   }
 
-  std::string match_str = "";
+  Glib::ustring match_str = "";
 
   Note::Ptr note = (*iter)[m_column_types.note];
   if(note) {
     int match_count;
-    std::map<std::string, int>::const_iterator miter
-      = m_current_matches.find(note->uri());
+    auto miter = m_current_matches.find(note->uri());
     if(miter != m_current_matches.end()) {
       match_count = miter->second;
       if(match_count == INT_MAX) {
@@ -1117,8 +1116,8 @@ int SearchNotesWidget::compare_search_hits(const Gtk::TreeIter & a, const Gtk::T
 
   int matches_a;
   int matches_b;
-  std::map<std::string, int>::iterator iter_a = m_current_matches.find(note_a->uri());
-  std::map<std::string, int>::iterator iter_b = m_current_matches.find(note_b->uri());
+  auto iter_a = m_current_matches.find(note_a->uri());
+  auto iter_b = m_current_matches.find(note_b->uri());
   bool has_matches_a = (iter_a != m_current_matches.end());
   bool has_matches_b = (iter_b != m_current_matches.end());
 
@@ -1167,7 +1166,7 @@ void SearchNotesWidget::on_note_added(const NoteBase::Ptr & note)
 }
 
 void SearchNotesWidget::on_note_renamed(const NoteBase::Ptr & note,
-                                        const std::string &)
+                                        const Glib::ustring &)
 {
   restore_matches_window();
   rename_note(static_pointer_cast<Note>(note));
@@ -1194,11 +1193,11 @@ void SearchNotesWidget::delete_note(const Note::Ptr & note)
 
 void SearchNotesWidget::add_note(const Note::Ptr & note)
 {
-  std::string nice_date =
+  Glib::ustring nice_date =
     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, std::string(note->get_title()));
+  iter->set_value(m_column_types.title, note->get_title());
   iter->set_value(m_column_types.change_date, nice_date);
   iter->set_value(m_column_types.note, note);
 }
@@ -1210,7 +1209,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, std::string(note->get_title()));
+      iter->set_value(m_column_types.title, note->get_title());
       break;
     }
   }
diff --git a/src/searchnoteswidget.hpp b/src/searchnoteswidget.hpp
index 4996afe..ddda138 100644
--- a/src/searchnoteswidget.hpp
+++ b/src/searchnoteswidget.hpp
@@ -109,7 +109,7 @@ private:
   int compare_search_hits(const Gtk::TreeIter & , const Gtk::TreeIter &);
   void on_note_deleted(const NoteBase::Ptr & note);
   void on_note_added(const NoteBase::Ptr & note);
-  void on_note_renamed(const NoteBase::Ptr&, const std::string&);
+  void on_note_renamed(const NoteBase::Ptr&, const Glib::ustring&);
   void on_note_saved(const NoteBase::Ptr&);
   void delete_note(const Note::Ptr & note);
   void add_note(const Note::Ptr & note);
@@ -153,8 +153,8 @@ private:
       }
 
     Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
-    Gtk::TreeModelColumn<std::string> title;
-    Gtk::TreeModelColumn<std::string> change_date;
+    Gtk::TreeModelColumn<Glib::ustring> title;
+    Gtk::TreeModelColumn<Glib::ustring> change_date;
     Gtk::TreeModelColumn<Note::Ptr> note;
   };
 
@@ -177,13 +177,13 @@ private:
   NoteManager & m_manager;
   Gtk::TreeView *m_tree;
   std::vector<Gtk::TargetEntry> m_targets;
-  std::map<std::string, int> m_current_matches;
+  std::map<Glib::ustring, int> m_current_matches;
   int m_clickX, m_clickY;
   Gtk::TreeViewColumn *m_matches_column;
   Gtk::Menu *m_note_list_context_menu;
   Gtk::Menu *m_notebook_list_context_menu;
   bool m_initial_position_restored;
-  std::string m_search_text;
+  Glib::ustring m_search_text;
   int m_sort_column_id;
   Gtk::SortType m_sort_column_order;
   std::vector<sigc::connection> m_action_cids;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]