CLI+GTK: show progress when cleaning database
This commit is contained in:
parent
d6899a505e
commit
2206f28124
@ -760,7 +760,11 @@ void changeDBPattern( const string &pattern ) {
|
|||||||
TEXT( "' WHERE TVID == 'pattern';" ) );
|
TEXT( "' WHERE TVID == 'pattern';" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef GUI
|
||||||
void cleanDB() {
|
void cleanDB() {
|
||||||
|
#else
|
||||||
|
void cleanDB( void *progress_ptr ) {
|
||||||
|
#endif
|
||||||
if ( !FSLib::exists( getDBName() ) )
|
if ( !FSLib::exists( getDBName() ) )
|
||||||
return;
|
return;
|
||||||
std::vector< std::unordered_map< string, string > > shows;
|
std::vector< std::unordered_map< string, string > > shows;
|
||||||
@ -775,7 +779,19 @@ void cleanDB() {
|
|||||||
" != 'pattern';" ),
|
" != 'pattern';" ),
|
||||||
shows );
|
shows );
|
||||||
|
|
||||||
|
#ifndef GUI
|
||||||
|
ProgressBar p;
|
||||||
|
#else // GUI
|
||||||
|
ProgressBar p( progress_ptr );
|
||||||
|
#endif // GUI
|
||||||
|
p.print( _( CLEANING_DB ) );
|
||||||
|
p.print( 0 );
|
||||||
|
int percent = 0;
|
||||||
|
int increment = 100 / shows.size();
|
||||||
|
|
||||||
for ( auto &show : shows ) {
|
for ( auto &show : shows ) {
|
||||||
|
p.print( percent );
|
||||||
|
percent += increment;
|
||||||
bool dir_exists = FSLib::exists( show[TEXT( "PATH" )] );
|
bool dir_exists = FSLib::exists( show[TEXT( "PATH" )] );
|
||||||
std::unordered_set< string > episodes;
|
std::unordered_set< string > episodes;
|
||||||
db.exec( TEXT( "SELECT PATH FROM EPISODES WHERE SHOWID == " ) +
|
db.exec( TEXT( "SELECT PATH FROM EPISODES WHERE SHOWID == " ) +
|
||||||
@ -796,6 +812,8 @@ void cleanDB() {
|
|||||||
show[TEXT( "ID" )] + TEXT( ";" ) );
|
show[TEXT( "ID" )] + TEXT( ";" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.print( 100 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeFromDB( const string &path ) {
|
void removeFromDB( const string &path ) {
|
||||||
|
@ -63,15 +63,13 @@ void removeFromDB( const string &path );
|
|||||||
void changeDBPattern( const string &pattern );
|
void changeDBPattern( const string &pattern );
|
||||||
#ifndef GUI
|
#ifndef GUI
|
||||||
void refreshDB( bool linux );
|
void refreshDB( bool linux );
|
||||||
|
void updateDB( bool linux );
|
||||||
|
void cleanDB();
|
||||||
#else
|
#else
|
||||||
void refreshDB( bool linux, void *progress_ptr );
|
void refreshDB( bool linux, void *progress_ptr );
|
||||||
#endif
|
|
||||||
#ifndef GUI
|
|
||||||
void updateDB( bool linux );
|
|
||||||
#else
|
|
||||||
void updateDB( bool linux, void *progress_ptr );
|
void updateDB( bool linux, void *progress_ptr );
|
||||||
|
void cleanDB( void *progress_ptr );
|
||||||
#endif
|
#endif
|
||||||
void cleanDB();
|
|
||||||
|
|
||||||
#ifdef GUI
|
#ifdef GUI
|
||||||
std::vector< std::unordered_map< string, string > > dbGetShows();
|
std::vector< std::unordered_map< string, string > > dbGetShows();
|
||||||
|
@ -216,7 +216,6 @@ void DatabaseWindow::save() {
|
|||||||
auto *app_ptr = app.get();
|
auto *app_ptr = app.get();
|
||||||
|
|
||||||
pw->signal_hide().connect( [pw, app_ptr]() {
|
pw->signal_hide().connect( [pw, app_ptr]() {
|
||||||
cleanDB();
|
|
||||||
app_ptr->remove_window( *pw );
|
app_ptr->remove_window( *pw );
|
||||||
delete pw;
|
delete pw;
|
||||||
} );
|
} );
|
||||||
|
@ -463,7 +463,17 @@ void MainWindow::dbUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dbClean() {
|
void MainWindow::dbClean() {
|
||||||
cleanDB();
|
auto *pw = new ProgressWindow;
|
||||||
|
app->add_window( *pw );
|
||||||
|
auto app_ptr = app;
|
||||||
|
|
||||||
|
pw->signal_hide().connect( [pw, app_ptr]() {
|
||||||
|
app_ptr->remove_window( *pw );
|
||||||
|
delete pw;
|
||||||
|
} );
|
||||||
|
pw->show();
|
||||||
|
std::thread t( cleanDB, pw );
|
||||||
|
t.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dbRefresh() {
|
void MainWindow::dbRefresh() {
|
||||||
|
@ -82,6 +82,7 @@
|
|||||||
#define RENAMING "Renaming"
|
#define RENAMING "Renaming"
|
||||||
#define ADDING_TO_DB "Adding to database"
|
#define ADDING_TO_DB "Adding to database"
|
||||||
#define REFRESHING_DB "Refreshing database"
|
#define REFRESHING_DB "Refreshing database"
|
||||||
|
#define CLEANING_DB "Cleaning database"
|
||||||
#define REFRESHING "Refreshing"
|
#define REFRESHING "Refreshing"
|
||||||
#define UPDATING_IN_DB "Updating %s in database"
|
#define UPDATING_IN_DB "Updating %s in database"
|
||||||
#define UPDATING_DB "Updating database"
|
#define UPDATING_DB "Updating database"
|
||||||
|
@ -126,3 +126,4 @@
|
|||||||
#define INVALID_LOCALE 0x9080
|
#define INVALID_LOCALE 0x9080
|
||||||
#define MEM_ALLOC_FAILED 0x9081
|
#define MEM_ALLOC_FAILED 0x9081
|
||||||
#define DATABASE_MENU 0x9082
|
#define DATABASE_MENU 0x9082
|
||||||
|
#define CLEANING_DB 0x9083
|
||||||
|
@ -370,3 +370,6 @@ msgstr "neplatné locale"
|
|||||||
|
|
||||||
msgid "memory allocation failed"
|
msgid "memory allocation failed"
|
||||||
msgstr "alokace paměti selhala"
|
msgstr "alokace paměti selhala"
|
||||||
|
|
||||||
|
msgid "Cleaning database"
|
||||||
|
msgstr "Čistím databázi"
|
||||||
|
@ -370,3 +370,6 @@ msgstr "invalid locale"
|
|||||||
|
|
||||||
msgid "memory allocation failed"
|
msgid "memory allocation failed"
|
||||||
msgstr "memory allocation failed"
|
msgstr "memory allocation failed"
|
||||||
|
|
||||||
|
msgid "Cleaning database"
|
||||||
|
msgstr "Cleaning database"
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user