Permalink
Browse files

changed: switch to view type of "info" when more than 25% of items ha…

…ve metadata in a auto folder
  • Loading branch information...
1 parent a339fc6 commit e753cc3219811205c14aa8d393f693e2e29ba2c4 @elupus elupus committed May 19, 2011
@@ -12,7 +12,7 @@
<onright>60</onright>
<onup>550</onup>
<ondown>550</ondown>
- <viewtype label="$LOCALIZE[31033]">list</viewtype>
+ <viewtype label="$LOCALIZE[31033]">info</viewtype>
<visible>Window.IsVisible(AddonBrowser) | Container.Content(Addons)</visible>
<pagecontrol>60</pagecontrol>
<scrolltime>200</scrolltime>
@@ -255,7 +255,7 @@
<onright>60</onright>
<onup>551</onup>
<ondown>551</ondown>
- <viewtype label="$LOCALIZE[31033] 2">list</viewtype>
+ <viewtype label="$LOCALIZE[31033] 2">biginfo</viewtype>
<visible>Window.IsVisible(AddonBrowser) | Container.Content(Addons)</visible>
<pagecontrol>60</pagecontrol>
<scrolltime>200</scrolltime>
View
@@ -76,9 +76,16 @@ int CAutoSwitch::GetView(const CFileItemList &vecItems)
iPercent = 50; // 50% of thumbs -> use thumbs.
}
break;
+
+ default:
+ {
+ if(MetadataPercentage(vecItems) > 0.25)
+ return DEFAULT_VIEW_INFO;
+ else
+ return DEFAULT_VIEW_LIST;
+ }
+ break;
}
- // if this was called by an unknown window just return listtview
- if (iSortMethod < 0) return DEFAULT_VIEW_LIST;
bool bThumbs = false;
@@ -232,3 +239,20 @@ bool CAutoSwitch::ByFolderThumbPercentage(bool hideParentDirItems, int percent,
return false;
}
+float CAutoSwitch::MetadataPercentage(const CFileItemList &vecItems)
+{
+ int count = 0;
+ int total = vecItems.Size();
+ for (int i = 0; i < vecItems.Size(); i++)
+ {
+ const CFileItemPtr item = vecItems[i];
+ if(item->HasMusicInfoTag()
+ || item->HasVideoInfoTag()
+ || item->HasPictureInfoTag()
+ || item->HasProperty("Addon.ID"))
+ count++;
+ if(item->IsParentFolder())
+ total--;
+ }
+ return (float)count / total;
+}
View
@@ -37,7 +37,7 @@ class CAutoSwitch
static bool ByThumbPercent(bool bHideParentDirItems, int iPercent, const CFileItemList& vecItems);
static bool ByFileCount(const CFileItemList& vecItems);
static bool ByFolderThumbPercentage(bool hideParentDirItems, int percent, const CFileItemList &vecItems);
-
+ static float MetadataPercentage(const CFileItemList &vecItems);
protected:
};
View
@@ -81,6 +81,8 @@ void CGUIViewControl::SetCurrentView(int viewMode)
newView = GetView(type, 0);
if (newView < 0 && type == VIEW_TYPE_BIG_ICON) // try icon view if they want big icon
newView = GetView(VIEW_TYPE_ICON, 0);
+ if (newView < 0 && type == VIEW_TYPE_BIG_INFO)
+ newView = GetView(VIEW_TYPE_INFO, 0);
if (newView < 0) // try a list view
newView = GetView(VIEW_TYPE_LIST, 0);
if (newView < 0) // try anything!
View
@@ -26,6 +26,8 @@
#define DEFAULT_VIEW_LIST (VIEW_TYPE_LIST << 16)
#define DEFAULT_VIEW_ICONS (VIEW_TYPE_ICON << 16)
#define DEFAULT_VIEW_BIG_ICONS (VIEW_TYPE_BIG_ICON << 16)
+#define DEFAULT_VIEW_INFO (VIEW_TYPE_INFO << 16)
+#define DEFAULT_VIEW_BIG_INFO (VIEW_TYPE_BIG_INFO << 16)
#define DEFAULT_VIEW_MAX (((VIEW_TYPE_MAX - 1) << 16) | 60)
class CViewState
@@ -37,7 +37,7 @@ CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items)
AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date
SetSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS);
- SetViewAsControl(DEFAULT_VIEW_LIST);
+ SetViewAsControl(DEFAULT_VIEW_AUTO);
SetSortOrder(SORT_ORDER_ASC);
LoadViewState(items.m_strPath, WINDOW_ADDON_BROWSER);
@@ -1000,6 +1000,10 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
viewType = VIEW_TYPE_WRAP;
else if (type == "bigwrap")
viewType = VIEW_TYPE_BIG_WRAP;
+ else if (type == "info")
+ viewType = VIEW_TYPE_INFO;
+ else if (type == "biginfo")
+ viewType = VIEW_TYPE_BIG_INFO;
const char *label = itemElement->Attribute("label");
if (label)
viewLabel = CGUIInfoLabel::GetLabel(FilterLabel(label));
@@ -57,6 +57,8 @@ enum VIEW_TYPE { VIEW_TYPE_NONE = 0,
VIEW_TYPE_BIG_WIDE,
VIEW_TYPE_WRAP,
VIEW_TYPE_BIG_WRAP,
+ VIEW_TYPE_INFO,
+ VIEW_TYPE_BIG_INFO,
VIEW_TYPE_AUTO,
VIEW_TYPE_MAX };

0 comments on commit e753cc3

Please sign in to comment.