skydrive: Add rescan option
Add menu option to drop all items from the database and rescan the cloud drive.
This commit is contained in:
parent
c87409c896
commit
05f513ab6f
|
@ -30,6 +30,7 @@
|
||||||
#include "core/waitforsignal.h"
|
#include "core/waitforsignal.h"
|
||||||
#include "internet/core/oauthenticator.h"
|
#include "internet/core/oauthenticator.h"
|
||||||
#include "internet/skydrive/skydriveurlhandler.h"
|
#include "internet/skydrive/skydriveurlhandler.h"
|
||||||
|
#include "library/librarybackend.h"
|
||||||
#include "ui/iconloader.h"
|
#include "ui/iconloader.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -137,9 +138,11 @@ void SkydriveService::FetchUserInfoFinished(QNetworkReply* reply) {
|
||||||
|
|
||||||
emit Connected();
|
emit Connected();
|
||||||
|
|
||||||
ListFiles("root");
|
ListFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkydriveService::ListFiles() { ListFiles("root"); }
|
||||||
|
|
||||||
void SkydriveService::ListFiles(const QString& folder) {
|
void SkydriveService::ListFiles(const QString& folder) {
|
||||||
QUrl url(QString(kDriveBase) + folder + "/children");
|
QUrl url(QString(kDriveBase) + folder + "/children");
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
|
@ -206,6 +209,24 @@ QUrl SkydriveService::GetStreamingUrlFromSongId(const QString& file_id) {
|
||||||
return ItemUrl(file_id, "content");
|
return ItemUrl(file_id, "content");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkydriveService::PopulateContextMenu() {
|
||||||
|
context_menu_->addActions(GetPlaylistActions());
|
||||||
|
full_rescan_action_ = context_menu_->addAction(
|
||||||
|
IconLoader::Load("view-refresh", IconLoader::Base),
|
||||||
|
tr("Do a full rescan..."), this, SLOT(FullRescanRequested()));
|
||||||
|
context_menu_->addSeparator();
|
||||||
|
context_menu_->addAction(IconLoader::Load("download", IconLoader::Base),
|
||||||
|
tr("Cover Manager"), this, SLOT(ShowCoverManager()));
|
||||||
|
context_menu_->addSeparator();
|
||||||
|
context_menu_->addAction(IconLoader::Load("configure", IconLoader::Base),
|
||||||
|
tr("Configure..."), this,
|
||||||
|
SLOT(ShowSettingsDialog()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkydriveService::UpdateContextMenu() {
|
||||||
|
full_rescan_action_->setEnabled(!is_indexing());
|
||||||
|
}
|
||||||
|
|
||||||
void SkydriveService::EnsureConnected() {
|
void SkydriveService::EnsureConnected() {
|
||||||
if (!access_token_.isEmpty()) {
|
if (!access_token_.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -222,3 +243,8 @@ void SkydriveService::ForgetCredentials() {
|
||||||
s.remove("refresh_token");
|
s.remove("refresh_token");
|
||||||
s.remove("name");
|
s.remove("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkydriveService::DoFullRescan() {
|
||||||
|
library_backend_->DeleteAll();
|
||||||
|
ListFiles();
|
||||||
|
}
|
||||||
|
|
|
@ -62,12 +62,19 @@ class SkydriveService : public CloudFileService {
|
||||||
QString refresh_token() const;
|
QString refresh_token() const;
|
||||||
void AddAuthorizationHeader(QNetworkRequest* request);
|
void AddAuthorizationHeader(QNetworkRequest* request);
|
||||||
void FetchUserInfo();
|
void FetchUserInfo();
|
||||||
|
void ListFiles();
|
||||||
void ListFiles(const QString& folder);
|
void ListFiles(const QString& folder);
|
||||||
void EnsureConnected();
|
void EnsureConnected();
|
||||||
QUrl ItemUrl(const QString& id, const QString& path);
|
QUrl ItemUrl(const QString& id, const QString& path);
|
||||||
|
void DoFullRescan() override;
|
||||||
|
|
||||||
|
void PopulateContextMenu() override;
|
||||||
|
void UpdateContextMenu() override;
|
||||||
|
|
||||||
QString access_token_;
|
QString access_token_;
|
||||||
QDateTime expiry_time_;
|
QDateTime expiry_time_;
|
||||||
|
|
||||||
|
QAction* full_rescan_action_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTERNET_SKYDRIVE_SKYDRIVESERVICE_H_
|
#endif // INTERNET_SKYDRIVE_SKYDRIVESERVICE_H_
|
||||||
|
|
Loading…
Reference in New Issue