From: <nor...@us...> - 2007-07-03 20:43:08
|
Revision: 670 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=670&view=rev Author: northern_sky Date: 2007-07-03 13:43:01 -0700 (Tue, 03 Jul 2007) Log Message: ----------- some redundant stuff removed Modified Paths: -------------- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramViewHandler.cs Modified: trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramViewHandler.cs =================================================================== --- trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramViewHandler.cs 2007-07-03 17:14:59 UTC (rev 669) +++ trunk/plugins/myGUIProgramsAlt/GUIProgramsAlt/ProgramViewHandler.cs 2007-07-03 20:43:01 UTC (rev 670) @@ -60,6 +60,7 @@ public ProgramViewHandler() { + #region create default filter //create default views if file not exist if (!System.IO.File.Exists(defaultProgramViews)) { @@ -147,6 +148,7 @@ fileStream.Close(); } } + #endregion create default filter if (!File.Exists(customProgramViews)) { @@ -280,7 +282,7 @@ { bool res = false; FilterDefinition definition = (FilterDefinition)currentView.Filters[CurrentLevel]; - definition.SelectedValue = GetFieldValue(filterItem, definition.Where); + definition.SelectedValue = filterItem.Title; if (currentLevel + 1 < currentView.Filters.Count) { currentLevel++; @@ -463,7 +465,7 @@ void BuildFilter(FilterDefinition filter, SQLSelectBuilder sqlSelect,int appId) { - sqlSelect.AddWhereCond(String.Format(" {0}='{1}'", GetFieldId(filter.Where), ProgramUtils.Encode(filter.SelectedValue))); + sqlSelect.AddWhereCond(String.Format(" {0}='{1}'", GetField(filter.Where), ProgramUtils.Encode(filter.SelectedValue))); } @@ -493,7 +495,7 @@ filter.SqlOperator = "like"; } } - whereClause = String.Format(" {0} {1} '{2}'", GetFieldName(filter.Where), filter.SqlOperator, restriction); + whereClause = String.Format(" {0} {1} '{2}'", GetField(filter.Where), filter.SqlOperator, restriction); sqlSelect.AddWhereCond(whereClause); } } @@ -536,14 +538,7 @@ void BuildOrder(FilterDefinition filter, SQLSelectBuilder sqlSelect) { string orderClause = GetField(filter.Where); - if (orderClause == "mainGenre") - { - orderClause = "tblMainGenre.genre"; - } - else if(orderClause == "subGenre") { - orderClause = "tblSubGenre.genre"; - } if (orderClause != "") { if (!filter.SortAscending) orderClause += " desc"; @@ -560,8 +555,8 @@ { if (where == "title") return "title"; if (where == "mainGenreId") return "mainGenreId"; - if (where == "mainGenre") return "mainGenre"; - if (where == "subGenre") return "subGenre"; + if (where == "mainGenre") return "tblMainGenre.genre"; + if (where == "subGenre") return "tblSubGenre.genre"; if (where == "subGenreId") return "subGenreId"; if (where == "country") return "country"; if (where == "manufacturer") return "manufacturer"; @@ -573,43 +568,6 @@ return ""; } - string GetFieldId(string where) - { - if (where == "title") return "title"; - if (where == "mainGenreId") return "mainGenreId"; - if (where == "subGenreId") return "subGenreId"; - if (where == "mainGenre") return "tblMainGenre.Genre"; - if (where == "subGenre") return "tblSubGenre.Genre"; - if (where == "country") return "country"; - if (where == "manufacturer") return "manufacturer"; - if (where == "manufacturerId") return "manufacturerId"; - if (where == "year") return "year"; - if (where == "rating") return "rating"; - if (where == "launchcount") return "launchcount"; - if (where == "lastTimeLaunched") return "lastTimeLaunched"; - return ""; - } - - string GetFieldName(string where) - { - // yeah, that's great code :-) - // maps WHERE-fieldname to a SQL-fieldname - // and the MAY be different in the future..... - if (where == "title") return "title"; - else if (where == "mainGenreId") return "mainGenreId"; - else if (where == "subGenre") return "tblSubGenre.genre"; - else if (where == "subGenreId") return "subGenreId"; - else if (where == "mainGenre") return "tblMainGenre.genre"; - else if (where == "manufacturer") return "manufacturer"; - else if (where == "manufacturerId") return "manufacturerId"; - else if (where == "country") return "country"; - else if (where == "year") return "year"; - else if (where == "rating") return "rating"; - else if (where == "launchcount") return "launchcount"; - else if (where == "lastTimeLaunched") return "lastTimeLaunched"; - else return ""; - } - string GetFieldNameForSelect(string where) { string res = ""; @@ -623,7 +581,7 @@ } else { - res = GetFieldName(where); + res = GetField(where); if (res == "") { res = "tblFileItem.*"; @@ -674,7 +632,6 @@ else if (where == "country") return "'STR' as fieldtype"; else if (where == "year") return "'INT' as fieldtype"; else if (where == "rating") return "'INT' as fieldtype"; - // else if (where == "launchcount") return "'INT'"; else if (where == "launchcount") return "'STR' as fieldtype"; else if (where == "lastTimeLaunched") return "'STR' as fieldtype"; else return "'STR' as fieldtype"; @@ -687,6 +644,11 @@ else return "'' as fieldtype2"; } + /// <summary> + /// Should the query be distinct... + /// </summary> + /// <param name="where"></param> + /// <returns></returns> bool GetDistinct(string where) { if (where == "title") return false; @@ -701,43 +663,5 @@ else if (where == "lastTimeLaunched") return false; else return false; } - - string GetFieldValue(ProgramFilterItem filterItem, string where) - { - return filterItem.Title; - /* - * if (where == "title") return filterItem.Title; - else if (where == "genre") return filterItem.Genre; - else if (where == "manufacturer") return filterItem.Manufacturer; - else if (where == "country") return filterItem.Country; - else if (where == "year") return ((int) filterItem.Year).ToString(); - else if (where == "rating") return ((int) filterItem.Rating).ToString(); - else return ""; - */ - } - - public void SetLabel(ProgramFilterItem filterItem, ref GUIListItem guiListItem) - { - if (filterItem == null) return; - FilterDefinition definition = (FilterDefinition)currentView.Filters[CurrentLevel]; - if ((definition.Where == "mainGenreId") || (definition.Where == "subGenre")) - { - guiListItem.Label = filterItem.Genre; - guiListItem.Label2 = String.Empty; - guiListItem.Label3 = String.Empty; - } - if (definition.Where == "year") - { - guiListItem.Label = (filterItem.Year).ToString(); - guiListItem.Label2 = String.Empty; - guiListItem.Label3 = String.Empty; - } - else - { - guiListItem.Label = filterItem.Title; - guiListItem.Label2 = String.Empty; - guiListItem.Label3 = String.Empty; - } - } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |