Exemplo n.º 1
0
    def __init_configuration(self):
        """
        initializes the configuration. This method is called every time the config file changes
        """
        self.__log.info("initialize configuration")
        if self.__main_config is None:
            self.__main_config = ConfigWrapper(TsConstants.CONFIG_PATH)
            #self.connect(self.__main_config, QtCore.SIGNAL("changed()"), self.__init_configuration)

        self.CURRENT_LANGUAGE = self.__main_config.get_current_language()

        if self.CURRENT_LANGUAGE is None or self.CURRENT_LANGUAGE == "":
            self.CURRENT_LANGUAGE = self.__get_locale_language()

        # switch back to the configured language
        self.change_language(self.CURRENT_LANGUAGE)

        ## connect to all the signals the admin gui is sending
        if self.__admin_dialog is None:
            self.__admin_dialog = StorePreferencesController()
            self.connect(self.__admin_dialog,
                         QtCore.SIGNAL("create_new_store"),
                         self.__handle_new_store)
            self.connect(self.__admin_dialog, QtCore.SIGNAL("rename_desc_tag"),
                         self.__handle_tag_rename)
            self.connect(self.__admin_dialog, QtCore.SIGNAL("rename_cat_tag"),
                         self.__handle_tag_rename)
            self.connect(self.__admin_dialog, QtCore.SIGNAL("retag"),
                         self.__handle_retagging)

            self.connect(self.__admin_dialog, QtCore.SIGNAL("rebuild_store"),
                         self.__handle_store_rebuild)
            self.connect(self.__admin_dialog, QtCore.SIGNAL("rename_store"),
                         self.__handle_store_rename)
            self.connect(self.__admin_dialog, QtCore.SIGNAL("delete_store"),
                         self.__handle_store_delete)

            self.connect(self.__admin_dialog, QtCore.SIGNAL("synchronize"),
                         self.__handle_synchronization)

        self.__admin_dialog.set_main_config(self.__main_config)

        self.__prepare_store_params()
        self.__create_stores()

        ## create a temporary store list
        ## add the desc and cat tags which are needed in the admin-dialog
        tmp_store_list = []
        for current_store_item in self.__main_config.get_stores():
            store_name = current_store_item["path"].split("/").pop()
            current_store_item["desc_tags"] = self.__store_dict[
                store_name].get_tags()
            current_store_item["cat_tags"] = self.__store_dict[
                store_name].get_categorizing_tags()
            tmp_store_list.append(current_store_item)

        self.__admin_dialog.set_store_list(tmp_store_list)
        if self.__main_config.get_first_start():
            self.__admin_dialog.set_first_start(True)