on xenial help sign in
MenuItemFactory: move more checks to utility functions
f2e7fdfMarco Trevisan (Treviño)
qml/Panel/Indicators/MenuItemFactory.qml+20−12
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013,2015 Canonical Ltd.
2+ * Copyright 2013-2016 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -93,6 +93,10 @@ Item {
93 var map = _userMap || _typeToComponent
93 var map = _userMap || _typeToComponent
94 var indicatorComponents = map[indicator];
94 var indicatorComponents = map[indicator];
95
95
96+ if (type === undefined || type === "") {
97+ return component
98+ }
99+
96 if (indicatorComponents !== undefined) {
100 if (indicatorComponents !== undefined) {
97 component = indicatorComponents[type];
101 component = indicatorComponents[type];
98 }
102 }
@@ -101,6 +105,10 @@ Item {
101 component = map["default"][type];
105 component = map["default"][type];
102 }
106 }
103
107
108+ if (component === undefined) {
109+ console.debug("Don't know how to make " + modelData.type + " for " + indicator);
110+ }
111+
104 return component
112 return component
105 }
113 }
106
114
@@ -108,6 +116,10 @@ Item {
108 var component = undefined;
116 var component = undefined;
109 var indicatorFilter = _action_filter_map[indicator]
117 var indicatorFilter = _action_filter_map[indicator]
110
118
119+ if (action === undefined || action === "") {
120+ return component
121+ }
122+
111 if (indicatorFilter !== undefined) {
123 if (indicatorFilter !== undefined) {
112 component = indicatorFilter[action];
124 component = indicatorFilter[action];
113 }
125 }
@@ -1000,20 +1012,16 @@ Item {
1000 if (context && context.indexOf("fake-") == 0)
1012 if (context && context.indexOf("fake-") == 0)
1001 context = context.substring("fake-".length)
1013 context = context.substring("fake-".length)
1002
1014
1003− if (modelData.action !== undefined && modelData.action !== "") {
1004− var component = getComponentForIndicatorEntryAction(context, modelData.action)
1015+ var component = getComponentForIndicatorEntryAction(context, modelData.action)
1005− if (component !== undefined) {
1016+ if (component !== undefined) {
1006− return component
1017+ return component
1007− }
1008 }
1018 }
1009
1019
1010− if (modelData.type !== undefined && modelData.type !== "") {
1011− var component = getComponentForIndicatorEntryType(context, modelData.type)
1020+ component = getComponentForIndicatorEntryType(context, modelData.type)
1012− if (component !== undefined) {
1021+ if (component !== undefined) {
1013− return component;
1022+ return component;
1014− }
1015− console.debug("Don't know how to make " + modelData.type + " for " + context);
1016 }
1023 }
1024+
1017 if (modelData.isCheck || modelData.isRadio) {
1025 if (modelData.isCheck || modelData.isRadio) {
1018 return checkableMenu;
1026 return checkableMenu;
1019 }
1027 }