Permalink
Browse files

Merge pull request #945 from cptspiff/autoscans

Get rid of the 'run automatic scan' buttons in the content dialogs
  • Loading branch information...
2 parents 65a8141 + ce49643 commit a3630022ae7a71f02597bd00e2606185f9153b5c Arne Morten Kvarving committed May 9, 2012
View
@@ -5532,7 +5532,8 @@ void CApplication::StartMusicScan(const CStdString &strDirectory)
m_musicInfoScanner->Start(strDirectory);
}
-void CApplication::StartMusicAlbumScan(const CStdString& strDirectory)
+void CApplication::StartMusicAlbumScan(const CStdString& strDirectory,
+ bool refresh)
{
if (m_musicInfoScanner->IsScanning())
return;
@@ -5547,10 +5548,11 @@ void CApplication::StartMusicAlbumScan(const CStdString& strDirectory)
}
}
SaveMusicScanSettings();
- m_musicInfoScanner->FetchAlbumInfo(strDirectory);
+ m_musicInfoScanner->FetchAlbumInfo(strDirectory,refresh);
}
-void CApplication::StartMusicArtistScan(const CStdString& strDirectory)
+void CApplication::StartMusicArtistScan(const CStdString& strDirectory,
+ bool refresh)
{
if (m_musicInfoScanner->IsScanning())
return;
@@ -5565,7 +5567,7 @@ void CApplication::StartMusicArtistScan(const CStdString& strDirectory)
}
}
SaveMusicScanSettings();
- m_musicInfoScanner->FetchArtistInfo(strDirectory);
+ m_musicInfoScanner->FetchArtistInfo(strDirectory,refresh);
}
View
@@ -225,8 +225,8 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
void StartVideoScan(const CStdString &path, bool scanAll = false);
void StartMusicScan(const CStdString &path);
- void StartMusicAlbumScan(const CStdString& strDirectory);
- void StartMusicArtistScan(const CStdString& strDirectory);
+ void StartMusicAlbumScan(const CStdString& strDirectory, bool refresh=false);
+ void StartMusicArtistScan(const CStdString& strDirectory, bool refresh=false);
void UpdateLibraries();
void CheckMusicPlaylist();
@@ -233,7 +233,8 @@ void CMusicInfoScanner::Start(const CStdString& strDirectory)
m_bRunning = true;
}
-void CMusicInfoScanner::FetchAlbumInfo(const CStdString& strDirectory)
+void CMusicInfoScanner::FetchAlbumInfo(const CStdString& strDirectory,
+ bool refresh)
{
m_albumsToScan.clear();
m_albumsScanned.clear();
@@ -256,6 +257,7 @@ void CMusicInfoScanner::FetchAlbumInfo(const CStdString& strDirectory)
}
}
+ m_musicDatabase.Open();
for (int i=0;i<items.Size();++i)
{
if (CMusicDatabaseDirectory::IsAllItem(items[i]->GetPath()) || items[i]->IsParentFolder())
@@ -266,15 +268,23 @@ void CMusicInfoScanner::FetchAlbumInfo(const CStdString& strDirectory)
album.artist = items[i]->GetMusicInfoTag()->GetArtist();
album.genre.push_back(items[i]->GetPath()); // a bit hacky use of field
m_albumsToScan.insert(album);
+ if (refresh)
+ {
+ int id = m_musicDatabase.GetAlbumByName(album.strAlbum, album.artist);
+ if (id > -1)
+ m_musicDatabase.DeleteAlbumInfo(id);
+ }
}
+ m_musicDatabase.Close();
m_scanType = 1;
StopThread();
Create();
m_bRunning = true;
}
-void CMusicInfoScanner::FetchArtistInfo(const CStdString& strDirectory)
+void CMusicInfoScanner::FetchArtistInfo(const CStdString& strDirectory,
+ bool refresh)
{
m_artistsToScan.clear();
m_artistsScanned.clear();
@@ -297,6 +307,7 @@ void CMusicInfoScanner::FetchArtistInfo(const CStdString& strDirectory)
}
}
+ m_musicDatabase.Open();
for (int i=0;i<items.Size();++i)
{
if (CMusicDatabaseDirectory::IsAllItem(items[i]->GetPath()) || items[i]->IsParentFolder())
@@ -306,7 +317,14 @@ void CMusicInfoScanner::FetchArtistInfo(const CStdString& strDirectory)
artist.strArtist = StringUtils::Join(items[i]->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
artist.genre.push_back(items[i]->GetPath()); // a bit hacky use of field
m_artistsToScan.insert(artist);
+ if (refresh)
+ {
+ int id = m_musicDatabase.GetArtistByName(artist.strArtist);
+ if (id > -1)
+ m_musicDatabase.DeleteArtistInfo(id);
+ }
}
+ m_musicDatabase.Close();
m_scanType = 2;
StopThread();
@@ -48,8 +48,8 @@ class CMusicInfoScanner : CThread, public IRunnable
virtual ~CMusicInfoScanner();
void Start(const CStdString& strDirectory);
- void FetchAlbumInfo(const CStdString& strDirectory);
- void FetchArtistInfo(const CStdString& strDirectory);
+ void FetchAlbumInfo(const CStdString& strDirectory, bool refresh=false);
+ void FetchArtistInfo(const CStdString& strDirectory, bool refresh=false);
bool IsScanning();
void Stop();
void SetObserver(IMusicInfoScannerObserver* pObserver);
@@ -237,17 +237,19 @@ bool CGUIWindowMusicBase::OnMessage(CGUIMessage& message)
return CGUIMediaWindow::OnMessage(message);
}
-void CGUIWindowMusicBase::OnInfoAll(int iItem, bool bCurrent)
+void CGUIWindowMusicBase::OnInfoAll(int iItem, bool bCurrent, bool refresh)
{
CMusicDatabaseDirectory dir;
CStdString strPath = m_vecItems->GetPath();
if (bCurrent)
strPath = m_vecItems->Get(iItem)->GetPath();
- if (dir.HasAlbumInfo(m_vecItems->Get(iItem)->GetPath()))
- g_application.StartMusicAlbumScan(strPath);
+ if (dir.HasAlbumInfo(strPath) ||
+ CMusicDatabaseDirectory::GetDirectoryChildType(strPath) ==
+ MUSICDATABASEDIRECTORY::NODE_TYPE_ALBUM)
+ g_application.StartMusicAlbumScan(strPath,refresh);
else
- g_application.StartMusicArtistScan(strPath);
+ g_application.StartMusicArtistScan(strPath,refresh);
}
/// \brief Retrieves music info for albums from allmusic.com and displays them in CGUIDialogMusicInfo
@@ -78,7 +78,7 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
void RetrieveMusicInfo();
void OnInfo(int iItem, bool bShowInfo = true);
- void OnInfoAll(int iItem, bool bCurrent=false);
+ void OnInfoAll(int iItem, bool bCurrent=false, bool refresh=false);
virtual void OnQueueItem(int iItem);
enum ALLOW_SELECTION { SELECTION_ALLOWED = 0, SELECTION_AUTO, SELECTION_FORCED };
bool FindAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist, MUSIC_GRABBER::CMusicAlbumInfo& album, ALLOW_SELECTION allowSelection);
@@ -37,6 +37,7 @@
#include "guilib/GUIWindowManager.h"
#include "dialogs/GUIDialogOK.h"
#include "dialogs/GUIDialogKeyboard.h"
+#include "dialogs/GUIDialogYesNo.h"
#include "guilib/GUIEditControl.h"
#include "GUIUserMessages.h"
#include "filesystem/File.h"
@@ -672,7 +673,6 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
case CONTEXT_BUTTON_SET_CONTENT:
{
- bool bScan=false;
ADDON::ScraperPtr scraper;
CStdString path(item->GetPath());
CQueryParams params;
@@ -700,11 +700,14 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
}
}
- if (CGUIDialogContentSettings::Show(scraper, bScan, content))
+ if (CGUIDialogContentSettings::Show(scraper, content))
{
m_musicdatabase.SetScraperForPath(path,scraper);
- if (bScan)
- OnInfoAll(itemNumber,true);
+ if (CGUIDialogYesNo::ShowAndGetInput(20442,20443,20444,20022))
+ {
+ OnInfoAll(itemNumber,true,true);
+ }
+
}
return true;
}
@@ -162,31 +162,26 @@ void CGUIDialogContentSettings::CreateSettings()
{
case CONTENT_TVSHOWS:
{
- AddBool(1,20345,&m_bRunScan, m_bShowScanSettings);
- AddBool(2,20379,&m_bSingleItem, m_bShowScanSettings);
- AddBool(3,20432,&m_bNoUpdate, m_bShowScanSettings);
+ AddBool(1,20379,&m_bSingleItem, m_bShowScanSettings);
+ AddBool(2,20432,&m_bNoUpdate, m_bShowScanSettings);
}
break;
case CONTENT_MOVIES:
{
- AddBool(1,20345,&m_bRunScan, m_bShowScanSettings);
- AddBool(2,20329,&m_bUseDirNames, m_bShowScanSettings);
- AddBool(3,20346,&m_bScanRecursive, m_bShowScanSettings && ((m_bUseDirNames && !m_bSingleItem) || !m_bUseDirNames));
- AddBool(4,20383,&m_bSingleItem, m_bShowScanSettings && (m_bUseDirNames && !m_bScanRecursive));
- AddBool(5,20432,&m_bNoUpdate, m_bShowScanSettings);
+ AddBool(1,20329,&m_bUseDirNames, m_bShowScanSettings);
+ AddBool(2,20346,&m_bScanRecursive, m_bShowScanSettings && ((m_bUseDirNames && !m_bSingleItem) || !m_bUseDirNames));
+ AddBool(3,20383,&m_bSingleItem, m_bShowScanSettings && (m_bUseDirNames && !m_bScanRecursive));
+ AddBool(4,20432,&m_bNoUpdate, m_bShowScanSettings);
}
break;
case CONTENT_MUSICVIDEOS:
{
- AddBool(1,20345,&m_bRunScan, m_bShowScanSettings);
- AddBool(2,20346,&m_bScanRecursive, m_bShowScanSettings);
- AddBool(3,20432,&m_bNoUpdate, m_bShowScanSettings);
+ AddBool(1,20346,&m_bScanRecursive, m_bShowScanSettings);
+ AddBool(2,20432,&m_bNoUpdate, m_bShowScanSettings);
}
break;
case CONTENT_ALBUMS:
- {
- AddBool(1,20345,&m_bRunScan, m_bShowScanSettings);
- }
+ case CONTENT_ARTISTS:
break;
case CONTENT_NONE:
default:
@@ -367,25 +362,25 @@ CFileItemPtr CGUIDialogContentSettings::GetCurrentListItem(int offset)
return m_vecItems->Get(item);
}
-bool CGUIDialogContentSettings::ShowForDirectory(const CStdString& strDirectory, ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, bool& bRunScan)
+bool CGUIDialogContentSettings::ShowForDirectory(const CStdString& strDirectory, ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings)
{
CVideoDatabase database;
database.Open();
scraper = database.GetScraperForPath(strDirectory, settings);
- bool bResult = Show(scraper,settings,bRunScan);
+ bool bResult = Show(scraper,settings);
if (bResult)
database.SetScraperForPath(strDirectory,scraper,settings);
return bResult;
}
-bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, bool& bRunScan, CONTENT_TYPE musicContext/*=CONTENT_NONE*/)
+bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, CONTENT_TYPE musicContext/*=CONTENT_NONE*/)
{
VIDEO::SScanSettings dummy;
- return Show(scraper,dummy,bRunScan,musicContext);
+ return Show(scraper,dummy,musicContext);
}
-bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, bool& bRunScan, CONTENT_TYPE musicContext/*=CONTENT_NONE*/)
+bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, CONTENT_TYPE musicContext/*=CONTENT_NONE*/)
{
CGUIDialogContentSettings *dialog = (CGUIDialogContentSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTENT_SETTINGS);
if (!dialog)
@@ -401,7 +396,6 @@ bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSet
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(24023), scraper->Name(), 2000, true);
}
- dialog->m_bRunScan = bRunScan;
dialog->m_bScanRecursive = (settings.recurse > 0 && !settings.parent_name) || (settings.recurse > 1 && settings.parent_name);
dialog->m_bUseDirNames = settings.parent_name;
dialog->m_bExclude = settings.exclude;
@@ -416,14 +410,12 @@ bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSet
if (!scraper || content == CONTENT_NONE)
{
scraper.reset();
- bRunScan = false;
settings.exclude = dialog->m_bExclude;
}
else
{
settings.exclude = false;
settings.noupdate = dialog->m_bNoUpdate;
- bRunScan = dialog->m_bRunScan;
scraper->SetPathSettings(content, "");
if (content == CONTENT_TVSHOWS)
@@ -39,9 +39,9 @@ class CGUIDialogContentSettings : public CGUIDialogSettings
virtual ~CGUIDialogContentSettings(void);
virtual bool OnMessage(CGUIMessage& message);
- static bool Show(ADDON::ScraperPtr& scraper, bool& bRunScan, CONTENT_TYPE musicContext = CONTENT_NONE);
- static bool Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, bool& bRunScan, CONTENT_TYPE musicContext = CONTENT_NONE);
- static bool ShowForDirectory(const CStdString& strDirectory, ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, bool& bRunScan);
+ static bool Show(ADDON::ScraperPtr& scraper, CONTENT_TYPE musicContext = CONTENT_NONE);
+ static bool Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, CONTENT_TYPE musicContext = CONTENT_NONE);
+ static bool ShowForDirectory(const CStdString& strDirectory, ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings);
virtual bool HasListItems() const { return true; };
virtual CFileItemPtr GetCurrentListItem(int offset = 0);
protected:
@@ -60,7 +60,6 @@ class CGUIDialogContentSettings : public CGUIDialogSettings
bool m_bNeedSave;
bool m_bShowScanSettings;
- bool m_bRunScan;
bool m_bScanRecursive;
bool m_bUseDirNames;
bool m_bSingleItem;
@@ -2028,7 +2028,7 @@ void CGUIWindowVideoBase::OnAssignContent(const CStdString &path)
ADDON::ScraperPtr info2(info);
- if (CGUIDialogContentSettings::Show(info, settings, bScan))
+ if (CGUIDialogContentSettings::Show(info, settings))
{
if(settings.exclude || (!info && info2))
{

0 comments on commit a363002

Please sign in to comment.