def add_custom_type(self, urlpattern, label): customtypes = qosmsettings.get(qosmsettings.CUSTOM_TILE_TYPES) customtypes[urlpattern] = label qosmsettings.put(qosmsettings.CUSTOM_TILE_TYPES, customtypes) self.customUrl.setText("") self.customUrl.clearFocus()
def apply_customtypes(self): customtypes = s.get(s.CUSTOM_TILE_TYPES) customtypes.clear() for originalpattern, pattern, label in self.customtypes: if originalpattern != pattern: del customtypes[originalpattern] customtypes[pattern] = label s.put(s.CUSTOM_TILE_TYPES, customtypes)
def apply(self): #validate newcachedir = unicode(self.generalCacheLocation.text()) newcachedir = newcachedir.strip() if newcachedir.endswith(os.path.sep): newcachedir = newcachedir[:-1] if not os.path.isdir(newcachedir): QMessageBox.information(self, "QOSM Error", "'%s' is not a directory" % newcachedir) return False if (not len(os.listdir(newcachedir)) == 0) and \ ((newcachedir != s._defaultsetting(s.CACHE_DIRECTORY)) and (newcachedir != s.get(s.CACHE_DIRECTORY))): if QMessageBox.Ok != QMessageBox.question(self, "Question", "Use non-emtpy directory for cache?", QMessageBox.Ok | QMessageBox.Cancel): return False if newcachedir == s._defaultsetting(s.CACHE_DIRECTORY): s.reset(s.CACHE_DIRECTORY) self.generalCacheLocation.setText(s.get(s.CACHE_DIRECTORY)) else: s.put(s.CACHE_DIRECTORY, newcachedir) self.generalCacheLocation.setText(newcachedir) if self.generalMaxTiles.value() == s._defaultsetting(s.MAX_TILES): s.reset(s.MAX_TILES) else: s.put(s.MAX_TILES, self.generalMaxTiles.value()) s.put(s.AUTODOWNLOAD, self.autoDownload.isChecked()) self.apply_customtypes() self.calculate_cachesize() return True