From ec20e6dab63b51594363b2c85db193d8f6757aa0 Mon Sep 17 00:00:00 2001 From: APTX Date: Tue, 12 Jun 2012 22:09:11 +0200 Subject: [PATCH] Add options to clear various failed requests so they could be processed again. --- localmylist/database.cpp | 30 ++++++++++++++++++++++ localmylist/database.h | 5 ++++ management-gui/mainwindow.cpp | 41 ++++++++++++++++++++++++++---- management-gui/mainwindow.h | 9 +++++-- management-gui/mainwindow.ui | 47 ++++++++++++++++++++++++++++++++--- 5 files changed, 122 insertions(+), 10 deletions(-) diff --git a/localmylist/database.cpp b/localmylist/database.cpp index c393bae..7f13f9d 100644 --- a/localmylist/database.cpp +++ b/localmylist/database.cpp @@ -786,6 +786,36 @@ bool Database::clearPendingMyListUpdate(const PendingMyListUpdate &request) return exec(d->clearPendingMyListUpdateQuery); } +bool Database::clearStartedPendingRequests() +{ + return exec( + "UPDATE pending_request SET start = NULL " + " WHERE start IS NOT NULL"); +} + +bool Database::clearStartedMyListUpdateRequests() +{ + return exec( + "UPDATE pending_mylist_update SET started = NULL " + " WHERE start IS NOT NULL " + " AND finished IS NULL"); +} + +bool Database::clearFileRenames() +{ + return exec( + "UPDATE file_location SET " + " renamed = NULL, failed_rename = false"); +} + +bool Database::clearFailedFileRenames() +{ + return exec( + "UPDATE file_location SET " + " renamed = NULL, failed_rename = false " + "WHERE failed_rename = true"); +} + bool Database::truncateTitleData() { return exec("TRUNCATE TABLE anime_title"); diff --git a/localmylist/database.h b/localmylist/database.h index c2da1e9..bb6c22e 100644 --- a/localmylist/database.h +++ b/localmylist/database.h @@ -253,6 +253,11 @@ public: QList getPendingMyListUpdateBatch(int limit = 10); bool clearPendingMyListUpdate(const PendingMyListUpdate &request); + bool clearStartedPendingRequests(); + bool clearStartedMyListUpdateRequests(); + bool clearFileRenames(); + bool clearFailedFileRenames(); + bool truncateTitleData(); bool truncateMyListData(); bool truncateDatabase(); diff --git a/management-gui/mainwindow.cpp b/management-gui/mainwindow.cpp index 640acc9..7b8b146 100644 --- a/management-gui/mainwindow.cpp +++ b/management-gui/mainwindow.cpp @@ -113,11 +113,6 @@ void MainWindow::on_actionClearAnimeTitleData_triggered() MyList::instance()->database()->truncateTitleData(); } -void MainWindow::on_actionHandlePendingRequests_triggered() -{ - -} - void MainWindow::on_myListView_openFileRequested(const QModelIndex &index) { MyListModel::NodeType type = animeModel->type(index); @@ -191,3 +186,39 @@ void MainWindow::on_actionStartUDPCLient_triggered() MyList::instance()->setupUdpClient(); MyList::instance()->setupRequestHandler(); } + +void MainWindow::on_actionRenameFiles_triggered() +{ + MyList::instance()->database()->notifyRenameDataChanged(); +} + +void MainWindow::on_actionStartRenameHandler_triggered() +{ + MyList::instance()->setupRenameHandler(); +} + +void MainWindow::on_actionClearStartedPendingRequests_triggered() +{ + MyList::instance()->database()->clearStartedPendingRequests(); +} + +void MainWindow::on_actionHandleRequests_triggered() +{ + MyList::instance()->database()->notifyNewPendingRequest(); + MyList::instance()->database()->notifyNewPendingMyListUpdate(); +} + +void MainWindow::on_actionClearFailedFileRenames_triggered() +{ + MyList::instance()->database()->clearFailedFileRenames(); +} + +void MainWindow::on_actionClearFileRenames_triggered() +{ + MyList::instance()->database()->clearFileRenames(); +} + +void MainWindow::on_actionClearStartedMyListUpdates_triggered() +{ + MyList::instance()->database()->clearStartedMyListUpdateRequests(); +} diff --git a/management-gui/mainwindow.h b/management-gui/mainwindow.h index 9fb61d0..396b868 100644 --- a/management-gui/mainwindow.h +++ b/management-gui/mainwindow.h @@ -36,10 +36,15 @@ private slots: void on_actionClearDatabase_triggered(); void on_actionClearMyListData_triggered(); void on_actionClearAnimeTitleData_triggered(); - void on_actionHandlePendingRequests_triggered(); void on_myListView_openFileRequested(const QModelIndex &index); - void on_actionStartUDPCLient_triggered(); + void on_actionRenameFiles_triggered(); + void on_actionStartRenameHandler_triggered(); + void on_actionClearStartedPendingRequests_triggered(); + void on_actionHandleRequests_triggered(); + void on_actionClearFailedFileRenames_triggered(); + void on_actionClearFileRenames_triggered(); + void on_actionClearStartedMyListUpdates_triggered(); private: Ui::MainWindow *ui; diff --git a/management-gui/mainwindow.ui b/management-gui/mainwindow.ui index 2c9a408..d071aa1 100644 --- a/management-gui/mainwindow.ui +++ b/management-gui/mainwindow.ui @@ -36,6 +36,7 @@ + @@ -54,7 +55,14 @@ - + + + + + + + + @@ -124,9 +132,12 @@ Import MyList... - + - Reset Pending Requests + Clear Started Pending Requests + + + Clear Started Pending Requests @@ -134,6 +145,36 @@ Start UDP CLient + + + Rename Files + + + + + Handle Requests + + + + + Start Rename Handler + + + + + Clear Started MyList Updates + + + + + Clear File Renames + + + + + Clear Failed File Renames + + -- 2.52.0