[gnote] Replace std::list with std::vector in tableofcontentes
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Replace std::list with std::vector in tableofcontentes
- Date: Mon, 22 Apr 2019 08:42:29 +0000 (UTC)
commit df13f67ed9410a841d62d8745691946da656556c
Author: Aurimas Černius <aurisc4 gmail com>
Date: Mon Apr 22 11:17:30 2019 +0300
Replace std::list with std::vector in tableofcontentes
src/addins/tableofcontents/tableofcontentsnoteaddin.cpp | 12 ++++++------
src/addins/tableofcontents/tableofcontentsnoteaddin.hpp | 4 +---
2 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
b/src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
index 75b38811..7ca9abc0 100644
--- a/src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
+++ b/src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
@@ -179,12 +179,9 @@ void TableofcontentsNoteAddin::populate_toc_menu (Gtk::Menu *toc_menu, bool has_
}
// Build a new list
- std::list<TableofcontentsMenuItem*> items;
- get_tableofcontents_menu_items(items);
+ auto items = get_tableofcontents_menu_items();
- for(std::list<TableofcontentsMenuItem*>::iterator iter = items.begin();
- iter != items.end(); ++iter) {
- TableofcontentsMenuItem *item(*iter);
+ for(auto item : items) {
item->show_all();
toc_menu->append(*item);
}
@@ -306,10 +303,11 @@ void TableofcontentsNoteAddin::get_toc_items(std::vector<TocItem> & items) const
}
-void TableofcontentsNoteAddin::get_tableofcontents_menu_items(std::list<TableofcontentsMenuItem*> & items)
+std::vector<TableofcontentsMenuItem*> TableofcontentsNoteAddin::get_tableofcontents_menu_items()
//go through the note text, and list all lines tagged as heading,
//and for each heading, create a new TableofcontentsMenuItem.
{
+ std::vector<TableofcontentsMenuItem*> items;
TableofcontentsMenuItem *item = NULL;
std::vector<TocItem> toc_items;
@@ -325,6 +323,8 @@ void TableofcontentsNoteAddin::get_tableofcontents_menu_items(std::list<Tableofc
item = manage(new TableofcontentsMenuItem(get_note(), toc_item.heading, toc_item.heading_level,
toc_item.heading_position));
items.push_back(item);
}
+
+ return items;
}
diff --git a/src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
b/src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
index faf3f18c..f3a0beac 100644
--- a/src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
+++ b/src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
@@ -24,8 +24,6 @@
#ifndef __TABLEOFCONTENT_NOTEADDIN_HPP_
#define __TABLEOFCONTENT_NOTEADDIN_HPP_
-#include <list>
-
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/menu.h>
@@ -90,7 +88,7 @@ private:
int heading_position;
};
void get_toc_items(std::vector<TocItem> & items) const;
- void get_tableofcontents_menu_items (std::list<TableofcontentsMenuItem*> & items);
+ std::vector<TableofcontentsMenuItem*> get_tableofcontents_menu_items();
void get_toc_popover_items(std::vector<Gtk::Widget*> & items) const;
void headification_switch (Heading::Type heading_request);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]