Пример #1
0
    def set_filter_date(self):

        dialog = xbmcgui.Dialog()
        if self.start_date == '':
            self.start_date = str(datetime.datetime.now())[:10]
        if self.end_date == '':
            self.end_date = str(datetime.datetime.now())[:10]

        try:
            d = dialog.numeric(1, common.getstring(30117) ,strftime("%d/%m/%Y",strptime(self.start_date,"%Y-%m-%d")) )
            if d != '':    
                self.start_date = strftime("%Y-%m-%d",strptime(d.replace(" ","0"),"%d/%m/%Y"))
            else:
                self.start_date =''
            common.log('', str(self.start_date))
            
            d = dialog.numeric(1, common.getstring(30118) ,strftime("%d/%m/%Y",strptime(self.end_date,"%Y-%m-%d")) )
            if d != '':
                self.end_date = strftime("%Y-%m-%d",strptime(d.replace(" ","0"),"%d/%m/%Y"))
            else:
                self.end_date =''
            common.log('', str(self.end_date))
        except:
            pass

        if self.start_date != '' or self.end_date != '':
            self.getControl( BUTTON_DATE ).setLabel( self.start_date + ' ... ' + self.end_date )
        else:
            self.getControl( BUTTON_DATE ).setLabel( common.getstring(30164) )
        self.getControl( BUTTON_DATE ).setVisible(False)
        self.getControl( BUTTON_DATE ).setVisible(True)        
Пример #2
0
    def save_filter_settings(self):
        # Display a list of already saved filters to give the possibility to override a filter
        filters = []
        filters.append(common.getstring(30653))
        filters = filters + self.MPDB.filterwizard_list_filters()
        try:
            filters.remove(self.last_used_filter_name)
        except:
            pass
        dialog = xbmcgui.Dialog()
        ret = dialog.select(common.getstring(30608), filters)
        if ret > 0:
            self.MPDB.filterwizard_save_filter(filters[ret], self.active_tags,
                                               self.use_and, self.start_date,
                                               self.end_date)
        if ret == 0:
            kb = xbmc.Keyboard()
            kb.setHeading(common.getstring(30609))
            kb.doModal()
            filtersettings = ""
            if (kb.isConfirmed()):
                filtersettings = kb.getText()
                self.MPDB.filterwizard_save_filter(filtersettings,
                                                   self.active_tags,
                                                   self.use_and,
                                                   self.start_date,
                                                   self.end_date)

                if filtersettings != '':
                    self.getControl(FILTER_NAME).setLabel(
                        common.getstring(30652) + ' ' + filtersettings)
                else:
                    self.getControl(FILTER_NAME).setLabel('')
        self.getControl(FILTER_NAME).setVisible(False)
        self.getControl(FILTER_NAME).setVisible(True)
Пример #3
0
    def save_filter_settings(self):
        # Display a list of already saved filters to give the possibility to override a filter
        filters = []
        filters.append( common.getstring(30653) )
        filters = filters + self.MPDB.filterwizard_list_filters()
        try:
            filters.remove(self.last_used_filter_name)
        except:
            pass
        dialog = xbmcgui.Dialog()
        ret = dialog.select(common.getstring(30608), filters)
        if ret > 0:
            self.MPDB.filterwizard_save_filter(filters[ret], self.active_tags, self.use_and, self.start_date, self.end_date)
        if ret == 0:
            kb = xbmc.Keyboard()
            kb.setHeading(common.getstring(30609))
            kb.doModal()
            filtersettings = ""
            if (kb.isConfirmed()):
                filtersettings = kb.getText()
                self.MPDB.filterwizard_save_filter(filtersettings, self.active_tags, self.use_and, self.start_date, self.end_date)

                if filtersettings != '':
                    self.getControl( FILTER_NAME ).setLabel( common.getstring(30652) +' '+filtersettings)
                else:
                    self.getControl( FILTER_NAME ).setLabel( '' )
        self.getControl( FILTER_NAME ).setVisible(False)
        self.getControl( FILTER_NAME ).setVisible(True)   
Пример #4
0
 def delete_filter_settings(self):
     filters = self.MPDB.filterwizard_list_filters()
     # don't delete the last used filter
     filters.remove(self.last_used_filter_name)
     dialog = xbmcgui.Dialog()
     ret = dialog.select(common.getstring(30608), filters)
     if ret > -1:
         if dialog.yesno(common.getstring(30250), common.getstring(30251)%filters[ret]) :
             self.MPDB.filterwizard_delete_filter(filters[ret])
Пример #5
0
 def delete_filter_settings(self):
     filters = self.MPDB.filterwizard_list_filters()
     # don't delete the last used filter
     filters.remove(self.last_used_filter_name)
     dialog = xbmcgui.Dialog()
     ret = dialog.select(common.getstring(30608), filters)
     if ret > -1:
         if dialog.yesno(common.getstring(30250),
                         common.getstring(30251) % filters[ret]):
             self.MPDB.filterwizard_delete_filter(filters[ret])
Пример #6
0
    def setup_all(self, filtersettings=""):
        self.getControl(LABEL_TEXT).setLabel(common.getstring(30220))

        self.getControl(BUTTON_CLOSE).setLabel(common.getstring(30224))
        self.getControl(BUTTON_ZOOM_IN).setLabel(common.getstring(30225))
        self.getControl(BUTTON_ZOOM_OUT).setLabel(common.getstring(30226))
        self.zoomlevel = 15
        self.zoom_max = 21
        self.zoom_min = 0
        self.load_map()
Пример #7
0
 def setup_all( self, filtersettings = ""):
     self.getControl( LABEL_TEXT ).setLabel( common.getstring(30220) )
     
     self.getControl( BUTTON_CLOSE ).setLabel( common.getstring(30224) )
     self.getControl( BUTTON_ZOOM_IN ).setLabel( common.getstring(30225) )
     self.getControl( BUTTON_ZOOM_OUT ).setLabel(  common.getstring(30226) )  
     self.zoomlevel = 15
     self.zoom_max = 21
     self.zoom_min = 0
     self.load_map()
    def onInit( self ):  
        self.getControl( STATUS_LABEL ).setLabel( common.getstring(30620) )
        self.getControl( STATUS_LABEL2 ).setLabel( common.getstring(30622) )
        self.getControl( BUTTON_OK ).setLabel( common.getstring(30621) )
        self.getControl( TAGS_LIST ).reset()
        
        tagtypes_translations =  self.MPDB.get_tagtypes_translation()

        for tagtype_translation in tagtypes_translations:
            listitem = xbmcgui.ListItem( label=tagtype_translation[0], label2=tagtype_translation[1]) 
            self.getControl( TAGS_LIST ).addItem( listitem )

        self.setFocus( self.getControl( TAGS_LIST ) )
        self.getControl( TAGS_LIST ).selectItem( 0 )
Пример #9
0
    def onInit(self):
        self.getControl(STATUS_LABEL).setLabel(common.getstring(30620))
        self.getControl(STATUS_LABEL2).setLabel(common.getstring(30622))
        self.getControl(BUTTON_OK).setLabel(common.getstring(30621))
        self.getControl(TAGS_LIST).reset()

        tagtypes_translations = self.MPDB.get_tagtypes_translation()

        for tagtype_translation in tagtypes_translations:
            listitem = xbmcgui.ListItem(label=tagtype_translation[0],
                                        label2=tagtype_translation[1])
            self.getControl(TAGS_LIST).addItem(listitem)

        self.setFocus(self.getControl(TAGS_LIST))
        self.getControl(TAGS_LIST).selectItem(0)
Пример #10
0
    def onAction(self, action):
        # Cancel
        if (action.getId() in CANCEL_DIALOG
                or self.getFocusId() == BUTTON_CANCEL
                and action.getId() in SELECT_ITEM):
            self.close()
        # Okay
        if (self.getFocusId() == BUTTON_OK and action.getId() in SELECT_ITEM):
            self.close()

        # Select or deselect item in list
        if (action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_LIST):
            item = self.getControl(TAGS_LIST).getSelectedItem()
            #pos  = self.getControl( TAGS_LIST ).getSelectedPosition()

            kb = xbmc.Keyboard(
                item.getLabel2(),
                common.getstring(30623) % (common.smart_utf8(item.getLabel())),
                False)
            kb.doModal()
            if (kb.isConfirmed()):
                item.setLabel2(kb.getText())
                self.MPDB.set_tagtype_translation(
                    common.smart_unicode(item.getLabel()),
                    common.smart_unicode(item.getLabel2()))
                self.getControl(TAGS_LIST).setVisible(False)
                self.getControl(TAGS_LIST).setVisible(True)
Пример #11
0
    def clear_settings(self):
        self.active_tags.clear()
        self.checked_tags = 0
        self.use_and = False
        self.getControl( BUTTON_MATCHALL ).setSelected(0)

        self.load_tag_content_list(self.tag_types[0])

        self.getControl( CHECKED_LABEL ).setLabel(  common.getstring(30612)% (self.checked_tags) )
        self.getControl( CHECKED_LABEL ).setVisible(False)
        self.getControl( CHECKED_LABEL ).setVisible(True)

        self.getControl( BUTTON_DATE ).setLabel( common.getstring(30164) )
        self.getControl( BUTTON_DATE ).setVisible(False)
        self.getControl( BUTTON_DATE ).setVisible(True)   

        self.getControl( FILTER_NAME ).setLabel( '' )
        self.getControl( FILTER_NAME ).setVisible(False)
        self.getControl( FILTER_NAME ).setVisible(True)   
Пример #12
0
    def clear_settings(self):
        self.active_tags.clear()
        self.checked_tags = 0
        self.use_and = 0
        self.getControl(BUTTON_MATCHALL).setSelected(0)

        self.load_tag_content_list(self.tag_types[0])

        self.getControl(CHECKED_LABEL).setLabel(
            common.getstring(30612) % (self.checked_tags))
        self.getControl(CHECKED_LABEL).setVisible(False)
        self.getControl(CHECKED_LABEL).setVisible(True)

        self.getControl(BUTTON_DATE).setLabel(common.getstring(30164))
        self.getControl(BUTTON_DATE).setVisible(False)
        self.getControl(BUTTON_DATE).setVisible(True)

        self.getControl(FILTER_NAME).setLabel('')
        self.getControl(FILTER_NAME).setVisible(False)
        self.getControl(FILTER_NAME).setVisible(True)
Пример #13
0
    def set_filter_date(self):

        dialog = xbmcgui.Dialog()
        if self.start_date == '':
            self.start_date = str(datetime.datetime.now())[:10]
        if self.end_date == '':
            self.end_date = str(datetime.datetime.now())[:10]

        try:
            d = dialog.numeric(
                1, common.getstring(30117),
                strftime("%d/%m/%Y", strptime(self.start_date, "%Y-%m-%d")))
            if d != '':
                self.start_date = strftime(
                    "%Y-%m-%d", strptime(d.replace(" ", "0"), "%d/%m/%Y"))
            else:
                self.start_date = ''
            common.log('', str(self.start_date))

            d = dialog.numeric(
                1, common.getstring(30118),
                strftime("%d/%m/%Y", strptime(self.end_date, "%Y-%m-%d")))
            if d != '':
                self.end_date = strftime(
                    "%Y-%m-%d", strptime(d.replace(" ", "0"), "%d/%m/%Y"))
            else:
                self.end_date = ''
            common.log('', str(self.end_date))
        except:
            pass

        if self.start_date != '' or self.end_date != '':
            self.getControl(BUTTON_DATE).setLabel(self.start_date + ' ... ' +
                                                  self.end_date)
        else:
            self.getControl(BUTTON_DATE).setLabel(common.getstring(30164))
        self.getControl(BUTTON_DATE).setVisible(False)
        self.getControl(BUTTON_DATE).setVisible(True)
 def onAction( self, action ):
     # Cancel
     if ( action.getId() in CANCEL_DIALOG or self.getFocusId() == BUTTON_CANCEL and action.getId() in SELECT_ITEM ):
         self.close()
     # Okay
     if ( self.getFocusId() == BUTTON_OK and action.getId() in SELECT_ITEM ):
         self.close()
     
     # Select or deselect item in list
     if ( action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_LIST ):
         item = self.getControl( TAGS_LIST ).getSelectedItem()
         #pos  = self.getControl( TAGS_LIST ).getSelectedPosition()
         
         kb = xbmc.Keyboard(item.getLabel2(),  common.getstring(30623)%( common.smart_utf8(item.getLabel())), False)
         kb.doModal()
         if (kb.isConfirmed()):
             item.setLabel2(kb.getText())
             self.MPDB.set_tagtype_translation(common.smart_unicode(item.getLabel()), common.smart_unicode(item.getLabel2()))
             self.getControl( TAGS_LIST ).setVisible(False)
             self.getControl( TAGS_LIST ).setVisible(True)
Пример #15
0
    def setup_all(self, filtersettings=""):
        self.getControl(STATUS_LABEL).setLabel(common.getstring(30610))
        #self.getControl( FILTER_LABEL ).setLabel( common.getstring(30652) )
        self.getControl(TAGS_COLUMN).setLabel(common.getstring(30601))
        self.getControl(CONTENT_COLUMN).setLabel(common.getstring(30602))
        self.getControl(BUTTON_OK).setLabel(common.getstring(30613))
        self.getControl(BUTTON_CANCEL).setLabel(common.getstring(30614))
        self.getControl(BUTTON_MATCHALL).setLabel(common.getstring(30615))
        self.getControl(LOAD_FILTER).setLabel(common.getstring(30616))
        self.getControl(SAVE_FILTER).setLabel(common.getstring(30617))
        self.getControl(CLEAR_FILTER).setLabel(common.getstring(30618))
        self.getControl(DELETE_FILTER).setLabel(common.getstring(30619))
        self.getControl(BUTTON_DATE).setLabel(common.getstring(30164))
        if filtersettings != '':
            self.getControl(FILTER_NAME).setLabel(
                common.getstring(30652) + ' ' + filtersettings)
        else:
            self.getControl(FILTER_NAME).setLabel('')

        self.getControl(TAGS_LIST).reset()

        self.tag_types = [u"%s" % k for k in self.MPDB.list_TagTypes()]
        self.currently_selected_tagtypes = ''
        self.checked_tags = 0
        self.use_and = 0
        self.start_date = ''
        self.end_date = ''
        self.active_tags = {}
        self.last_used_filter_name = "  " + common.getstring(30607)

        self.getControl(TAGS_CONTENT_LIST).reset()
        self.getControl(TAGS_LIST).reset()

        # load last filter settings
        if filtersettings != "":
            self.active_tags, self.use_and, self.start_date, self.end_date = self.MPDB.filterwizard_load_filter(
                filtersettings)
            if self.use_and == 1:
                self.getControl(BUTTON_MATCHALL).setSelected(1)

            if self.start_date is None:
                self.start_date = ""
            if self.end_date is None:
                self.end_date = ""
            if str(self.start_date) != "" or str(self.end_date) != "":
                self.getControl(BUTTON_DATE).setLabel(self.start_date +
                                                      ' ... ' + self.end_date)
            else:
                self.getControl(BUTTON_DATE).setLabel(common.getstring(30164))
            self.getControl(BUTTON_DATE).setVisible(False)
            self.getControl(BUTTON_DATE).setVisible(True)

        for key in self.active_tags:
            if self.active_tags[key] != 0:
                self.checked_tags += 1

        if self.checked_tags == 1:
            self.getControl(CHECKED_LABEL).setLabel(common.getstring(30611))
        else:
            self.getControl(CHECKED_LABEL).setLabel(
                common.getstring(30612) % (self.checked_tags))

        self.init_tags()
Пример #16
0
 def show_filter_settings(self):
     filters = self.MPDB.filterwizard_list_filters()
     dialog = xbmcgui.Dialog()
     ret = dialog.select(common.getstring(30608), filters)
     if ret > -1:
         self.setup_all(filters[ret])
Пример #17
0
    def setup_all( self, filtersettings = ""):
        self.getControl( STATUS_LABEL ).setLabel( common.getstring(30610) )
        #self.getControl( FILTER_LABEL ).setLabel( common.getstring(30652) )
        self.getControl( TAGS_COLUMN ).setLabel(  common.getstring(30601) )        
        self.getControl( CONTENT_COLUMN ).setLabel( common.getstring(30602) )        
        self.getControl( BUTTON_OK ).setLabel( common.getstring(30613) )
        self.getControl( BUTTON_CANCEL ).setLabel( common.getstring(30614) )
        self.getControl( BUTTON_MATCHALL ).setLabel( common.getstring(30615) )
        self.getControl( LOAD_FILTER ).setLabel( common.getstring(30616) )
        self.getControl( SAVE_FILTER ).setLabel( common.getstring(30617) )
        self.getControl( CLEAR_FILTER ).setLabel( common.getstring(30618) )
        self.getControl( DELETE_FILTER ).setLabel( common.getstring(30619) )
        self.getControl( BUTTON_DATE ).setLabel( common.getstring(30164) )
        if filtersettings != '':
            self.getControl( FILTER_NAME ).setLabel( common.getstring(30652) +' '+filtersettings)
        else:
            self.getControl( FILTER_NAME ).setLabel( '' )

        self.getControl( TAGS_LIST ).reset()

        self.tag_types = [u"%s"%k  for k in self.MPDB.list_TagTypes()]
        self.currently_selected_tagtypes = ''
        self.checked_tags = 0
        self.use_and = False
        self.start_date = ''
        self.end_date   = ''
        self.active_tags = {}
        self.last_used_filter_name = "  " + common.getstring(30607)

        self.getControl( TAGS_CONTENT_LIST ).reset()
        self.getControl( TAGS_LIST ).reset()

        # load last filter settings
        if filtersettings != "":
            self.active_tags, self.use_and, self.start_date, self.end_date = self.MPDB.filterwizard_load_filter(filtersettings)
            if self.use_and:
                self.getControl( BUTTON_MATCHALL ).setSelected(1)

            if self.start_date is None:
                self.start_date = ""
            if self.end_date is None:
                self.end_date = ""
            if str(self.start_date) != "" or str(self.end_date) != "":
                self.getControl( BUTTON_DATE ).setLabel( self.start_date + ' ... ' + self.end_date )
            else:
                self.getControl( BUTTON_DATE ).setLabel( common.getstring(30164) )
            self.getControl( BUTTON_DATE ).setVisible(False)
            self.getControl( BUTTON_DATE ).setVisible(True)                   

        for key in self.active_tags:
            if self.active_tags[key] != 0:
                self.checked_tags += 1

        if self.checked_tags == 1:
            self.getControl( CHECKED_LABEL ).setLabel(  common.getstring(30611) )
        else:
            self.getControl( CHECKED_LABEL ).setLabel(  common.getstring(30612)% (self.checked_tags) )

        self.init_tags()     
Пример #18
0
 def show_filter_settings(self):
     filters = self.MPDB.filterwizard_list_filters()
     dialog = xbmcgui.Dialog()
     ret = dialog.select(common.getstring(30608), filters)
     if ret > -1:
         self.setup_all(filters[ret])
Пример #19
0
    def load_map(self):
        #google geolocalisation
        static_url = "http://maps.google.com/maps/api/staticmap?"
        param_dic = {#location parameters (http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html)
                     "center":"",       #(required if markers not present)
                     "zoom":self.zoomlevel,         # 0 to 21+ (req if no markers
                     #map parameters
                     "size":"640x640",  #widthxheight (required)
                     "format":"jpg",    #"png8","png","png32","gif","jpg","jpg-baseline" (opt)
                     "maptype":"hybrid",      #"roadmap","satellite","hybrid","terrain" (opt)
                     "language":"",
                     #Feature Parameters:
                     "markers" :"color:red|label:P|%s",#(opt)
                                        #markers=color:red|label:P|lyon|12%20rue%20madiraa|marseille|Lille
                                        #&markers=color:blue|label:P|Australie
                     "path" : "",       #(opt)
                     "visible" : "",    #(opt)
                     #Reporting Parameters:
                     "sensor" : "false" #is there a gps on system ? (req)
                     }

        param_dic["markers"]=param_dic["markers"]%self.place

        request_headers = { 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10' }
        request = Request(static_url+urlencode(param_dic), None, request_headers)
        try:
            urlfile = urlopen(request)
        except:
            dialog = xbmcgui.Dialog()
            dialog.ok('XBMC Network Error', 'Google maps is not reachable')
            self.close()
            return
            
        extension = urlfile.info().getheader("Content-Type","").split("/")[1]
        filesize = int(urlfile.info().getheader("Content-Length",""))

        mappath = xbmc.translatePath(self.datapath)
        mapfile = join(self.datapath,basename(self.filename).split(".")[0]+"_maps%s."%self.zoomlevel+extension)

        mapfile = xbmc.translatePath(mapfile)

        # test existence of path
        if not os.path.exists(mappath):
            os.makedirs(mappath)
        
        label = self.getControl( LABEL_TEXT )
        if not isfile(mapfile):
            #mapfile is not downloaded yet, download it now...
            try:
                #f=open(unicode(mapfile, 'utf-8'),"wb")
                f=open(common.smart_unicode(mapfile), "wb")
            except:
                try:
                    f=open(common.smart_utf8(mapfile), "wb")
                except:
                    print_exc()
                #print "GEO Exception: "+mapfile
            for i in range(1+(filesize/10)):
                f.write(urlfile.read(10))
                label.setLabel(common.getstring(30221)%(100*(float(i*10)/filesize)))#getting map... (%0.2f%%)
            urlfile.close()
            #pDialog.close()
            try:
                f.close()
            except:
                print_exc()
        self.set_pic(self.filename)
        self.set_map(mapfile)
        label.setLabel(common.getstring(30222)%int(100*(float(self.zoomlevel)/self.zoom_max)))#Zoom level %s
Пример #20
0
    def onAction(self, action):
        # Cancel
        if (action.getId() in CANCEL_DIALOG
                or self.getFocusId() == BUTTON_CANCEL
                and action.getId() in SELECT_ITEM):
            arraytrue = []
            arrayfalse = []
            self.filter(arraytrue, arrayfalse, 0, '', '')
            self.close()

        # Okay
        elif (self.getFocusId() == BUTTON_OK
              and action.getId() in SELECT_ITEM):
            arraytrue = []
            arrayfalse = []

            for key, value in self.active_tags.iteritems():
                if value == 1:
                    arraytrue.append(key)

                if value == -1:
                    arrayfalse.append(key)

            arraytrue.sort()
            arrayfalse.sort()
            self.filter(arraytrue, arrayfalse, self.use_and, self.start_date,
                        self.end_date)

            self.getControl(BUTTON_OK).setEnabled(False)
            self.getControl(BUTTON_CANCEL).setEnabled(False)
            self.getControl(BUTTON_MATCHALL).setEnabled(False)
            self.getControl(LOAD_FILTER).setEnabled(False)
            self.getControl(SAVE_FILTER).setEnabled(False)
            self.getControl(CLEAR_FILTER).setEnabled(False)
            self.getControl(DELETE_FILTER).setEnabled(False)
            self.getControl(TAGS_LIST).setEnabled(False)
            self.getControl(TAGS_CONTENT_LIST).setEnabled(False)

            self.MPDB.filterwizard_save_filter(self.last_used_filter_name,
                                               self.active_tags, self.use_and,
                                               self.start_date, self.end_date)

            self.close()

        # Match all button
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == BUTTON_MATCHALL):
            if self.use_and == 1:
                self.use_and = 0
            else:
                self.use_and = 1

        # Load filter settings
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == LOAD_FILTER):
            self.show_filter_settings()

        # Save filter settings
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == SAVE_FILTER):
            self.save_filter_settings()

        # Clear filter settings
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == CLEAR_FILTER):
            self.clear_settings()

        # Delete filter settings
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == DELETE_FILTER):
            self.delete_filter_settings()

        # Set start and end date
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == BUTTON_DATE):
            self.set_filter_date()

        # Select or deselect item in TagTypes list
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == TAGS_LIST):
            item = self.getControl(TAGS_LIST).getSelectedItem()
            pos = self.getControl(TAGS_LIST).getSelectedPosition()
            if self.currently_selected_tagtypes != self.tag_types[pos]:
                self.load_tag_content_list(self.tag_types[pos])

        # Select or deselect item in TagContents list
        elif (action.getId() in SELECT_ITEM
              and self.getFocusId() == TAGS_CONTENT_LIST):
            # get selected item
            item = self.getControl(TAGS_CONTENT_LIST).getSelectedItem()
            pos = self.getControl(TAGS_CONTENT_LIST).getSelectedPosition()
            if pos != -1 and item != None:

                checked = item.getProperty("checked")
                key = common.smart_unicode(self.currently_selected_tagtypes
                                           ) + '||' + common.smart_unicode(
                                               item.getLabel2())

                if checked == "checkbutton.png":
                    self.check_gui_tag_content(item, -1)
                    self.active_tags[key] = -1
                elif checked == "uncheckbutton.png":
                    self.check_gui_tag_content(item, 0)
                    self.active_tags[key] = 0
                else:
                    self.check_gui_tag_content(item, 1)
                    self.active_tags[key] = 1

                if self.checked_tags == 1:
                    self.getControl(CHECKED_LABEL).setLabel(
                        common.getstring(30611))
                else:
                    self.getControl(CHECKED_LABEL).setLabel(
                        common.getstring(30612) % (self.checked_tags))
                self.getControl(CHECKED_LABEL).setVisible(False)
                self.getControl(CHECKED_LABEL).setVisible(True)
Пример #21
0
    def onAction( self, action ):
        # Cancel
        if ( action.getId() in CANCEL_DIALOG or self.getFocusId() == BUTTON_CANCEL and action.getId() in SELECT_ITEM ):
            arraytrue = []
            arrayfalse = []
            self.filter (arraytrue,arrayfalse,False,'','')
            self.close()

        # Okay
        elif ( self.getFocusId() == BUTTON_OK and action.getId() in SELECT_ITEM ):
            arraytrue = []
            arrayfalse = []

            for key, value in self.active_tags.iteritems():
                if value == 1:
                    arraytrue.append( key)

                if value == -1:
                    arrayfalse.append( key)

            arraytrue.sort()
            arrayfalse.sort()
            self.filter (arraytrue, arrayfalse, self.use_and, self.start_date, self.end_date )

            self.getControl( BUTTON_OK ).setEnabled(False)
            self.getControl( BUTTON_CANCEL ).setEnabled(False)
            self.getControl( BUTTON_MATCHALL ).setEnabled(False)
            self.getControl( LOAD_FILTER ).setEnabled(False)
            self.getControl( SAVE_FILTER ).setEnabled(False)
            self.getControl( CLEAR_FILTER ).setEnabled(False)
            self.getControl( DELETE_FILTER ).setEnabled(False)
            self.getControl( TAGS_LIST ).setEnabled(False)
            self.getControl( TAGS_CONTENT_LIST ).setEnabled(False)

            self.MPDB.filterwizard_save_filter( self.last_used_filter_name, self.active_tags, self.use_and, self.start_date, self.end_date)

            self.close()

        # Match all button
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == BUTTON_MATCHALL ):
            self.use_and = not self.use_and

        # Load filter settings
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == LOAD_FILTER ):
            self.show_filter_settings()

        # Save filter settings
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == SAVE_FILTER ):
            self.save_filter_settings()

        # Clear filter settings
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == CLEAR_FILTER ):
            self.clear_settings()

        # Delete filter settings
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == DELETE_FILTER ):
            self.delete_filter_settings()

        # Set start and end date
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == BUTTON_DATE ):
            self.set_filter_date()            

        # Select or deselect item in TagTypes list
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_LIST ):
            item = self.getControl( TAGS_LIST ).getSelectedItem()
            pos  = self.getControl( TAGS_LIST ).getSelectedPosition()
            if self.currently_selected_tagtypes != self.tag_types[pos]:
                self.load_tag_content_list(self.tag_types[pos])

        # Select or deselect item in TagContents list
        elif ( action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_CONTENT_LIST ):
            # get selected item
            item = self.getControl( TAGS_CONTENT_LIST ).getSelectedItem()
            pos  = self.getControl( TAGS_CONTENT_LIST ).getSelectedPosition()
            if pos != -1 and item != None:            

                checked = item.getProperty("checked")
                key = common.smart_unicode(self.currently_selected_tagtypes) + '||' + common.smart_unicode(item.getLabel2())

                if checked == "checkbutton.png":
                    self.check_gui_tag_content(item, -1)
                    self.active_tags[ key ] = -1
                elif checked == "uncheckbutton.png":
                    self.check_gui_tag_content(item, 0)
                    self.active_tags[ key ] = 0
                else :
                    self.check_gui_tag_content(item, 1)
                    self.active_tags[ key ] = 1

                if self.checked_tags == 1:
                    self.getControl( CHECKED_LABEL ).setLabel(  common.getstring(30611) )
                else:
                    self.getControl( CHECKED_LABEL ).setLabel(  common.getstring(30612)% (self.checked_tags) )
                self.getControl( CHECKED_LABEL ).setVisible(False)
                self.getControl( CHECKED_LABEL ).setVisible(True)
Пример #22
0
    def load_map(self):
        #google geolocalisation
        static_url = "http://maps.google.com/maps/api/staticmap?"
        param_dic = {  #location parameters (http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html)
            "center": "",  #(required if markers not present)
            "zoom": self.zoomlevel,  # 0 to 21+ (req if no markers
            #map parameters
            "size": "640x640",  #widthxheight (required)
            "format":
            "jpg",  #"png8","png","png32","gif","jpg","jpg-baseline" (opt)
            "maptype":
            "hybrid",  #"roadmap","satellite","hybrid","terrain" (opt)
            "language": "",
            #Feature Parameters:
            "markers": "color:red|label:P|%s",  #(opt)
            #markers=color:red|label:P|lyon|12%20rue%20madiraa|marseille|Lille
            #&markers=color:blue|label:P|Australie
            "path": "",  #(opt)
            "visible": "",  #(opt)
            #Reporting Parameters:
            "sensor": "false"  #is there a gps on system ? (req)
        }

        param_dic["markers"] = param_dic["markers"] % self.place

        request_headers = {
            'User-Agent':
            'Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10'
        }
        request = Request(static_url + urlencode(param_dic), None,
                          request_headers)
        try:
            urlfile = urlopen(request)
        except:
            dialog = xbmcgui.Dialog()
            dialog.ok('XBMC Network Error', 'Google maps is not reachable')
            self.close()
            return

        extension = urlfile.info().getheader("Content-Type", "").split("/")[1]
        filesize = int(urlfile.info().getheader("Content-Length", ""))

        mappath = xbmc.translatePath(self.datapath)
        mapfile = join(
            self.datapath,
            basename(self.filename).split(".")[0] +
            "_maps%s." % self.zoomlevel + extension)

        mapfile = xbmc.translatePath(mapfile)

        # test existence of path
        if not os.path.exists(mappath):
            os.makedirs(mappath)

        label = self.getControl(LABEL_TEXT)
        if not isfile(mapfile):
            #mapfile is not downloaded yet, download it now...
            try:
                #f=open(unicode(mapfile, 'utf-8'),"wb")
                f = open(common.smart_unicode(mapfile), "wb")
            except:
                try:
                    f = open(common.smart_utf8(mapfile), "wb")
                except:
                    print_exc()
                #print "GEO Exception: "+mapfile
            for i in range(1 + (filesize / 10)):
                f.write(urlfile.read(10))
                label.setLabel(
                    common.getstring(30221) %
                    (100 *
                     (float(i * 10) / filesize)))  #getting map... (%0.2f%%)
            urlfile.close()
            #pDialog.close()
            try:
                f.close()
            except:
                print_exc()
        self.set_pic(self.filename)
        self.set_map(mapfile)
        label.setLabel(
            common.getstring(30222) %
            int(100 * (float(self.zoomlevel) / self.zoom_max)))  #Zoom level %s