From 564c7b09e25736027e8731dd027af0b862ebee2a Mon Sep 17 00:00:00 2001 From: zvon Date: Sun, 9 Feb 2020 16:57:37 +0100 Subject: [PATCH] Use treestore instead of liststore for database --- databasewindow.cpp | 10 +++------- databasewindow.hpp | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/databasewindow.cpp b/databasewindow.cpp index 45136e1..6c72892 100644 --- a/databasewindow.cpp +++ b/databasewindow.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -77,7 +76,7 @@ DatabaseWindow::DatabaseWindow( bool _linux, button_quit->set_size_request( 80, 30 ); // set database model - m_model = Gtk::ListStore::create( m_columns_database ); + m_model = Gtk::TreeStore::create( m_columns_database ); m_tree_database->set_model( m_model ); for ( auto &x : dbGetShows() ) { @@ -89,7 +88,7 @@ DatabaseWindow::DatabaseWindow( bool _linux, row[m_columns_database.m_col_path] = x["PATH"]; row[m_columns_database.m_col_lang] = x["LANGUAGE"]; row[m_columns_database.m_col_show_id] = x["TVID"]; - row[m_columns_database.m_col_dvd] = ( x["DVD"] == "1" ? "Yes" : "No" ); + row[m_columns_database.m_col_dvd] = x["DVD"] == "1"; } m_tree_database->append_column( "Show", m_columns_database.m_col_show ); @@ -125,10 +124,7 @@ void DatabaseWindow::save() { std::string path = x[m_columns_database.m_col_path]; std::string lang = x[m_columns_database.m_col_lang]; std::string show_id = x[m_columns_database.m_col_show_id]; - std::string dvd_string = x[m_columns_database.m_col_dvd]; - std::transform( dvd_string.begin(), dvd_string.end(), - dvd_string.begin(), ::tolower ); - bool dvd = dvd_string == "yes"; + bool dvd = x[m_columns_database.m_col_dvd]; changeDB( index, path, lang, show_id, dvd ); } } diff --git a/databasewindow.hpp b/databasewindow.hpp index 30802d6..b66cb56 100644 --- a/databasewindow.hpp +++ b/databasewindow.hpp @@ -1,7 +1,7 @@ #ifndef GTKMM_DATABASE_WINDOW #define GTKMM_DATABASE_WINDOW -#include +#include #include #include #include @@ -43,11 +43,11 @@ protected: Gtk::TreeModelColumn< std::string > m_col_path; Gtk::TreeModelColumn< std::string > m_col_lang; Gtk::TreeModelColumn< std::string > m_col_show_id; - Gtk::TreeModelColumn< std::string > m_col_dvd; + Gtk::TreeModelColumn< bool > m_col_dvd; }; DatabaseColumns m_columns_database; - Glib::RefPtr< Gtk::ListStore > m_model; + Glib::RefPtr< Gtk::TreeStore > m_model; bool linux; Glib::RefPtr< Gtk::Application > app;