Databasewindow: formatting

This commit is contained in:
zvon 2020-01-18 21:16:43 +01:00
parent b8906467fc
commit a93cff77d9
2 changed files with 5 additions and 17 deletions

View File

@ -1,10 +1,9 @@
#include <algorithm>
#include <gtkmm/box.h> #include <gtkmm/box.h>
#include <gtkmm/button.h> #include <gtkmm/button.h>
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
#include <gtkmm/messagedialog.h> #include <gtkmm/messagedialog.h>
#include <gtkmm/scrolledwindow.h> #include <gtkmm/scrolledwindow.h>
#include <iostream> #include <thread>
#include "databasewindow.hpp" #include "databasewindow.hpp"
#include "filesystem.hpp" #include "filesystem.hpp"
@ -47,9 +46,6 @@ DatabaseWindow::DatabaseWindow( bool _linux,
auto *button_remove = new Gtk::Button(); auto *button_remove = new Gtk::Button();
auto *button_quit = new Gtk::Button(); auto *button_quit = new Gtk::Button();
scrolled_window->set_size_request( 550, 300 );
scrolled_window->add( *m_tree_database );
// pack boxes // pack boxes
box->pack_start( *scrolled_window, Gtk::PACK_EXPAND_WIDGET ); box->pack_start( *scrolled_window, Gtk::PACK_EXPAND_WIDGET );
box->pack_start( *buttons, Gtk::PACK_SHRINK ); box->pack_start( *buttons, Gtk::PACK_SHRINK );
@ -62,11 +58,13 @@ DatabaseWindow::DatabaseWindow( bool _linux,
buttons->set_margin_top( 5 ); buttons->set_margin_top( 5 );
buttons->set_margin_bottom( 5 ); buttons->set_margin_bottom( 5 );
scrolled_window->add( *m_tree_database );
buttons->pack_start( *button_save, Gtk::PACK_SHRINK ); buttons->pack_start( *button_save, Gtk::PACK_SHRINK );
buttons->pack_start( *button_remove, Gtk::PACK_SHRINK ); buttons->pack_start( *button_remove, Gtk::PACK_SHRINK );
buttons->pack_end( *button_quit, Gtk::PACK_SHRINK ); buttons->pack_end( *button_quit, Gtk::PACK_SHRINK );
button_save->set_margin_right(5); button_save->set_margin_right( 5 );
// set button texts // set button texts
button_save->set_label( "Save" ); button_save->set_label( "Save" );
@ -120,7 +118,6 @@ DatabaseWindow::DatabaseWindow( bool _linux,
void DatabaseWindow::save() { void DatabaseWindow::save() {
if ( changed_rows.size() == 0 ) if ( changed_rows.size() == 0 )
return; return;
std::cout << "Starting for" << std::endl;
for ( auto &x : m_model->children() ) { for ( auto &x : m_model->children() ) {
auto index = static_cast< size_t >( x[m_columns_database.m_col_id] ); auto index = static_cast< size_t >( x[m_columns_database.m_col_id] );
if ( changed_rows.find( index ) != changed_rows.end() ) { if ( changed_rows.find( index ) != changed_rows.end() ) {
@ -132,8 +129,6 @@ void DatabaseWindow::save() {
std::transform( dvd_string.begin(), dvd_string.end(), std::transform( dvd_string.begin(), dvd_string.end(),
dvd_string.begin(), ::tolower ); dvd_string.begin(), ::tolower );
bool dvd = dvd_string == "yes"; bool dvd = dvd_string == "yes";
std::cout << index << " " << path << " " << lang << " " << show_id
<< " " << dvd_string << std::endl;
changeDB( index, path, lang, show_id, dvd ); changeDB( index, path, lang, show_id, dvd );
} }
} }
@ -141,7 +136,7 @@ void DatabaseWindow::save() {
auto *pw = new ProgressWindow; auto *pw = new ProgressWindow;
app->add_window( *pw ); app->add_window( *pw );
t = std::thread( refreshSelectDB, changed_rows, linux, pw ); std::thread t = std::thread( refreshSelectDB, changed_rows, linux, pw );
t.detach(); t.detach();
// lambda capture // lambda capture
@ -159,9 +154,6 @@ void DatabaseWindow::save() {
void DatabaseWindow::remove() { void DatabaseWindow::remove() {
auto selected = m_tree_database->get_selection()->get_selected(); auto selected = m_tree_database->get_selection()->get_selected();
std::cout << static_cast< size_t >(
( *selected )[m_columns_database.m_col_id] )
<< std::endl;
removeFromDB( static_cast< std::string >( removeFromDB( static_cast< std::string >(
( *selected )[m_columns_database.m_col_path] ) ); ( *selected )[m_columns_database.m_col_path] ) );
m_model->erase( selected ); m_model->erase( selected );

View File

@ -4,11 +4,8 @@
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
#include <gtkmm/treeview.h> #include <gtkmm/treeview.h>
#include <gtkmm/window.h> #include <gtkmm/window.h>
#include <thread>
#include <unordered_set> #include <unordered_set>
#include "network.hpp"
class DatabaseWindow : public Gtk::Window { class DatabaseWindow : public Gtk::Window {
public: public:
DatabaseWindow() = delete; DatabaseWindow() = delete;
@ -54,7 +51,6 @@ protected:
bool linux; bool linux;
Glib::RefPtr< Gtk::Application > app; Glib::RefPtr< Gtk::Application > app;
std::thread t;
}; };
#endif // GTKMM_MAIN_WINDOW #endif // GTKMM_MAIN_WINDOW