Permalink
Browse files

Implements Trac Ticket #10796 - view state stored by skin

  • Loading branch information...
1 parent e5fe718 commit d6c609d976e4b3bf10f93e101c6c892ad4e6d71a @AaronDnz AaronDnz committed Apr 30, 2011
Showing with 18 additions and 11 deletions.
  1. +3 −2 xbmc/GUIViewState.cpp
  2. +12 −6 xbmc/ViewDatabase.cpp
  3. +3 −3 xbmc/ViewDatabase.h
View
@@ -411,7 +411,8 @@ void CGUIViewState::LoadViewState(const CStdString &path, int windowID)
if (db.Open())
{
CViewState state;
- if (db.GetViewState(path, windowID, state))
+ if (db.GetViewState(path, windowID, state, g_guiSettings.GetString("lookandfeel.skin")) ||
+ db.GetViewState(path, windowID, state, ""))
{
SetViewAsControl(state.m_viewMode);
SetSortMethod(state.m_sortMethod);
@@ -429,7 +430,7 @@ void CGUIViewState::SaveViewToDb(const CStdString &path, int windowID, CViewStat
CViewState state(m_currentViewAsControl, GetSortMethod(), m_sortOrder);
if (viewState)
*viewState = state;
- db.SetViewState(path, windowID, state);
+ db.SetViewState(path, windowID, state, g_guiSettings.GetString("lookandfeel.skin"));
db.Close();
if (viewState)
g_settings.Save();
View
@@ -54,7 +54,7 @@ bool CViewDatabase::CreateTables()
CDatabase::CreateTables();
CLog::Log(LOGINFO, "create view table");
- m_pDS->exec("CREATE TABLE view ( idView integer primary key, window integer, path text, viewMode integer, sortMethod integer, sortOrder integer)\n");
+ m_pDS->exec("CREATE TABLE view ( idView integer primary key, window integer, path text, viewMode integer, sortMethod integer, sortOrder integer, skin text)\n");
CLog::Log(LOGINFO, "create view index");
m_pDS->exec("CREATE INDEX idxViews ON view(path)");
CLog::Log(LOGINFO, "create view - window index");
@@ -72,10 +72,12 @@ bool CViewDatabase::CreateTables()
bool CViewDatabase::UpdateOldVersion(int version)
{
+ if (version < 4)
+ m_pDS->exec("alter table view add skin text");
return true;
}
-bool CViewDatabase::GetViewState(const CStdString &path, int window, CViewState &state)
+bool CViewDatabase::GetViewState(const CStdString &path, int window, CViewState &state, const CStdString &skin)
{
try
{
@@ -86,7 +88,11 @@ bool CViewDatabase::GetViewState(const CStdString &path, int window, CViewState
URIUtils::AddSlashAtEnd(path1);
if (path1.IsEmpty()) path1 = "root://";
- CStdString sql = PrepareSQL("select * from view where window = %i and path like '%s'", window, path1.c_str());
+ CStdString sql;
+ if (skin.IsEmpty())
+ sql = PrepareSQL("select * from view where window = %i and path like '%s'", window, path1.c_str());
+ else
+ sql = PrepareSQL("select * from view where window = %i and path like '%s' and skin='%s'", window, path1.c_str(), skin.c_str());
m_pDS->query(sql.c_str());
if (!m_pDS->eof())
@@ -106,7 +112,7 @@ bool CViewDatabase::GetViewState(const CStdString &path, int window, CViewState
return false;
}
-bool CViewDatabase::SetViewState(const CStdString &path, int window, const CViewState &state)
+bool CViewDatabase::SetViewState(const CStdString &path, int window, const CViewState &state, const CStdString &skin)
{
try
{
@@ -117,7 +123,7 @@ bool CViewDatabase::SetViewState(const CStdString &path, int window, const CView
URIUtils::AddSlashAtEnd(path1);
if (path1.IsEmpty()) path1 = "root://";
- CStdString sql = PrepareSQL("select idView from view where window = %i and path like '%s'", window, path1.c_str());
+ CStdString sql = PrepareSQL("select idView from view where window = %i and path like '%s' and skin='%s'", window, path1.c_str(), skin.c_str());
m_pDS->query(sql.c_str());
if (!m_pDS->eof())
{ // update the view
@@ -129,7 +135,7 @@ bool CViewDatabase::SetViewState(const CStdString &path, int window, const CView
else
{ // add the view
m_pDS->close();
- sql = PrepareSQL("insert into view (idView, path, window, viewMode, sortMethod, sortOrder) values(NULL, '%s', %i, %i, %i, %i)", path1.c_str(), window, state.m_viewMode, (int)state.m_sortMethod, (int)state.m_sortOrder);
+ sql = PrepareSQL("insert into view (idView, path, window, viewMode, sortMethod, sortOrder, skin) values(NULL, '%s', %i, %i, %i, %i, '%s')", path1.c_str(), window, state.m_viewMode, (int)state.m_sortMethod, (int)state.m_sortOrder, skin.c_str());
m_pDS->exec(sql.c_str());
}
}
View
@@ -30,13 +30,13 @@ class CViewDatabase : public CDatabase
virtual ~CViewDatabase(void);
virtual bool Open();
- bool GetViewState(const CStdString &path, int windowID, CViewState &state);
- bool SetViewState(const CStdString &path, int windowID, const CViewState &state);
+ bool GetViewState(const CStdString &path, int windowID, CViewState &state, const CStdString &skin);
+ bool SetViewState(const CStdString &path, int windowID, const CViewState &state, const CStdString &skin);
bool ClearViewStates(int windowID);
protected:
virtual bool CreateTables();
virtual bool UpdateOldVersion(int version);
- virtual int GetMinVersion() const { return 3; };
+ virtual int GetMinVersion() const { return 4; };
const char *GetBaseDBName() const { return "ViewModes"; };
};

0 comments on commit d6c609d

Please sign in to comment.