Slight code cleanup

This commit is contained in:
zvon 2020-04-16 13:39:20 +02:00
parent 0bc8c1d89a
commit c899157006
3 changed files with 17 additions and 18 deletions

View File

@ -31,10 +31,10 @@ string canonical( const string &path );
class Directory {
public:
Directory( const string &path_ );
Directory() = delete;
Directory( const Directory &d ) = default;
Directory( Directory &&d ) = default;
explicit Directory( const string &path_ );
explicit Directory( const Directory &d ) = default;
explicit Directory( Directory &&d ) = default;
class Iterator {
public:
@ -42,7 +42,7 @@ public:
~Iterator();
#ifdef _WIN32
Iterator( bool ended_ );
explicit Iterator( bool ended_ );
#else
Iterator( const Directory &d_, const struct dirent *current_entry_ );
#endif

View File

@ -431,7 +431,7 @@ void prepareDB( const string &_pattern ) {
db.open( getDBName(), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE );
} catch ( std::exception &e ) {
cerr << _( DB_NOT_CREATE ) << " " << getDBName() << std::endl;
throw e;
throw;
}
db.exec(
"CREATE TABLE IF NOT EXISTS SHOWS (ID INTEGER NOT NULL "
@ -474,7 +474,7 @@ void addToDB( const string &show, const string &path, const string &language,
db.open( getDBName(), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
#ifndef GUI
// gui gives id and correct show name
@ -588,7 +588,7 @@ void refreshDB( bool linux, void *progress_ptr ) {
db.open( getDBName(), SQLite::OPEN_READWRITE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
db.exec( "DELETE FROM EPISODES;" );
@ -643,10 +643,9 @@ void refreshDB( bool linux, void *progress_ptr ) {
p.print( _( UPDATING_IN_DB, show[TEXT( "SHOW" )].c_str() ) );
p.print( 0 );
i = 0;
size_t j{};
size_t addition = 100 / seasons_size;
for ( auto &season : seasons ) {
j = 0;
size_t j = 0;
size_t smalladdition = addition / season.second.size();
for ( auto &episode : season.second ) {
db.exec( TEXT( "INSERT INTO EPISODES ( SHOWID, PATH ) "
@ -680,7 +679,7 @@ void updateDB( bool linux, void *progress_ptr ) {
db.open( getDBName(), SQLite::OPEN_READWRITE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
db.exec(
TEXT( "SELECT ID, TVID, SHOW, PATH, LANGUAGE, DVD FROM SHOWS WHERE TVID"
@ -766,7 +765,7 @@ void changeDBPattern( const string &pattern ) {
db.open( getDBName(), SQLite::OPEN_READWRITE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
db.exec( TEXT( "UPDATE SHOWS SET PATH = '" ) + pattern +
TEXT( "' WHERE TVID == 'pattern';" ) );
@ -785,7 +784,7 @@ void cleanDB( void *progress_ptr ) {
db.open( getDBName(), SQLite::OPEN_READWRITE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
db.exec( TEXT( "SELECT ID, PATH FROM SHOWS WHERE TVID"
" != 'pattern';" ),
@ -840,7 +839,7 @@ void removeFromDB( const string &path ) {
db.open( getDBName(), SQLite::OPEN_READWRITE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
string show_id{};
db.exec( TEXT( "SELECT ID FROM SHOWS WHERE PATH == '" ) + sanitize( path ) +
@ -860,7 +859,7 @@ std::vector< std::unordered_map< string, string > > dbGetShows() {
db.open( getDBName(), SQLite::OPEN_READWRITE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
std::vector< std::unordered_map< string, string > > ret;
db.exec( TEXT( "SELECT * FROM SHOWS;" ), ret );
@ -877,7 +876,7 @@ void changeDB( size_t index, const string &path, const string &language,
db.open( getDBName(), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
#ifndef _WIN32
string show_id = std::to_string( index );
@ -913,7 +912,7 @@ void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux,
db.open( getDBName(), SQLite::OPEN_READWRITE );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
db.exec( TEXT( "DELETE FROM EPISODES WHERE SHOWID IN " ) + index_list +
TEXT( ";" ) );
@ -974,7 +973,7 @@ string getDBPattern() {
db.open( getDBName(), SQLite::OPEN_READONLY );
} catch ( std::exception &e ) {
cerr << _( DB_CANT_OPEN ) << std::endl;
throw e;
throw;
}
string pattern{};
db.exec( TEXT( "SELECT PATH FROM SHOWS WHERE TVID == 'pattern';" ),

View File

@ -19,7 +19,7 @@
class MainWindow : public Gtk::Window {
public:
MainWindow( const Glib::RefPtr< Gtk::Application > &ptr );
explicit MainWindow( const Glib::RefPtr< Gtk::Application > &ptr );
virtual ~MainWindow();
private: