~didrocks/ubuntu/raring/unity-lens-radios/raring

« back to all changes in this revision

Viewing changes to private_lib/radiohandler.py

  • Committer: Didier Roche
  • Date: 2012-06-25 18:49:43 UTC
  • Revision ID: didier.roche@canonical.com-20120625184943-6mawnm5qlr7ubifw
fix some format due to real data passed

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        unity_filters.append(filt)
69
69
        return unity_filters
70
70
 
71
 
    def search_content(self, search_terms, model, scope):
72
 
        '''Search current content, eventually filtered, returns an updated model'''
 
71
    def get_model_data_from_content_search(self, search_terms, scope):
 
72
        '''Search current content, eventually filtered
 
73
 
 
74
        returns a tuple with the radio itself and an updated model data ready to be appended (iterator)'''
73
75
 
74
76
        radios_dict = self._last_all_radios_dict
75
77
        # first, the search itself
76
78
        if self._last_search is None or search_terms != self._last_search:
77
 
            model.clear()
78
79
            if search_terms == "":
79
80
                radios_dict = OnlineRadioInfo().get_most_wanted_stations()
80
81
                # change the generator to a list for copying them back in cache
101
102
            elif category == "local":
102
103
                cat = CATEGORIES.LOCAL
103
104
            for valid_radio in validate_function(radios_dict[category], filters):
104
 
                model.append(valid_radio.id, valid_radio.picture_url, cat, "text/html", valid_radio.name, valid_radio.current_track, "")
 
105
                yield (valid_radio, (str(valid_radio.id), valid_radio.picture_url, cat, "text/html", valid_radio.name, valid_radio.current_track, ""))
105
106
 
106
107
    def _return_active_filters(self, scope):
107
108
        '''Return current active filters for the scope
116
117
            filters["decade"] = [decade_filter.get_first_active(), decade_filter.get_last_active()]
117
118
        for category in ("genre", "country"):
118
119
            for option in scope.get_filter(category).options:
119
 
                if option.active:
 
120
                if option.props.active:
120
121
                    if category not in filters:
121
122
                        filters[category] = set()
122
 
                    filters[category].add(option.id)
 
123
                    filters[category].add(option.props.id)
123
124
        return filters
124
125
 
125
126
    def _filter_radios(self, radios, filters):