예제 #1
0
    def __init__(self):
        self.SCRIPTDIR = SCRIPTDIR

        #Localization
        urls = [
            File(File.separator.join([self.SCRIPTDIR, "data",
                                      "locale"])).toURI().toURL()
        ]
        loader = URLClassLoader(urls)
        currentLocale = Locale.getDefault()
        self.strings = ResourceBundle.getBundle("MessagesBundle",
                                                currentLocale, loader)

        #Read config
        self.favZone = None
        self.zones = None
        self.config = ConfigLoader(self)
        """Build tools instances"""
        self.allTools = AllTools(self).tools
        for tool in self.allTools:
            if tool.name == "favourites":
                self.favouritesTool = tool
                break
        self.realTools = [
            tool for tool in self.allTools
            if tool.name not in ("favourites", "localfile")
        ]

        #remove tools disabled from config file
        self.tools = [
            tool for tool in self.allTools
            if tool.isActive or tool.name in ("favourites")
        ]

        #add favourite checks to Favourites tool
        if "favourites" in self.toolsPrefs:
            favChecks = self.toolsPrefs["favourites"]["checks"]
            if favChecks != "":
                for favCheck in favChecks.split("|"):
                    (toolName, viewName, checkName) = favCheck.split(".")
                    for tool in self.tools:
                        if tool.name == toolName:
                            for view in tool.views:
                                if view.name == viewName:
                                    for check in view.checks:
                                        if check.name == checkName:
                                            self.favouritesTool.views[
                                                0].checks.append(check)
        """Build dialog for manual reporting of false positive"""
        self.falsePositiveDlg = FalsePositiveDialog(
            Main.parent, self.strings.getString("false_positives_title"), True,
            self)
        """Build qat_script toggleDialog"""
        #BUG: it steals icon from validator.
        #Is it possible ot use an icon not from 'dialogs' dir?
        icon = "validator.png"
        self.dlg = QatDialog(self.strings.getString("qat_dialog_title"), icon,
                             "Show ", None, 250, self)
        self.create_new_dataset_if_empty()
        Main.map.addToggleDialog(self.dlg)
        """Build processing dialog"""
        self.downloadAndReadDlg = DownloadAndReadDialog(
            Main.parent, self.strings.getString("download_dialog_title"),
            False, self)
        """Build quality assurance tools menu"""
        self.menu = QatMenu(self, "QA Tools")
        menu.add(self.menu)
        menu.repaint()
        """Initialization"""
        #Read ids of OSM objects that the user wants to be ignored
        self.ignore_file = File.separator.join(
            [self.SCRIPTDIR, "data", "ignoreids.csv"])
        self.read_ignore()
        self.falsePositive = []  # info regarding false positive

        self.selectedTool = self.tools[0]
        self.selectedView = self.selectedTool.views[0]  # first view
        self.selectedTableModel = self.selectedView.tableModel
        self.selectedChecks = []
        self.downloadingChecks = []
        self.clickedError = None
        self.errorsData = None
        self.zoneBbox = None  # bbox of current JOSM view
        self.selectedError = None
        self.url = None  # url of errors
        self.errorLayers = []  # list of layers with error markers
        self.selectionChangedFromMenuOrLayer = False
        self.dlg.toolsCombo.setSelectedIndex(0)
        print "\nINFO: Quality Assurance Tools script is running: ", self.SCRIPTVERSION

        # Check if using the latest version
        if self.checkUpdate == "on":
            update_checker.Updater(self, "auto")