From e1d67586140fe18d48acf6fb4fef1556b15b091c Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 21 Mar 2021 15:52:23 +0000 Subject: library: added feature to recreate database git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9769 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/library/library.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/plugins/General/library/library.cpp') diff --git a/src/plugins/General/library/library.cpp b/src/plugins/General/library/library.cpp index b174f4fa8..9c9582e9f 100644 --- a/src/plugins/General/library/library.cpp +++ b/src/plugins/General/library/library.cpp @@ -55,7 +55,7 @@ Library::Library(QPointer *libraryWidget, QObject *parent) : if(createTables()) qDebug("Library: database initialization finished"); else - qWarning("Library: plugin is disabled"); + qWarning("Library: unable to create table"); } } QSqlDatabase::removeDatabase(CONNECTION_NAME); @@ -80,6 +80,20 @@ Library::Library(QPointer *libraryWidget, QObject *parent) : m_libraryWidget->data()->refresh(); } }); + + if(settings.value("Library/recreate_db", false).toBool()) + { + settings.setValue("Library/recreate_db", false); + + { + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", CONNECTION_NAME); + db.open(); + db.exec("DELETE FROM track_library"); + db.close(); + } + QSqlDatabase::removeDatabase(CONNECTION_NAME); + startDirectoryScanning(); + } } Library::~Library() @@ -114,6 +128,9 @@ void Library::showLibraryWindow() if(m_libraryWidget->data()->isWindow()) m_libraryWidget->data()->show(); + + if(m_future.isRunning()) + m_libraryWidget->data()->setBusyMode(true); } void Library::startDirectoryScanning() -- cgit v1.2.3-13-gbd6f