Exemple #1
0
    def _updateCacheView(self, build_dir):
        # Do nothing if build dir is not configured
        if not build_dir:
            return

        self.cacheViewPage.cacheItems.clear()               # Remove previously collected cache
        is_advanced = self.cfgPage.mode.isChecked()

        try:
            items = cmake_help_parser.get_cache_content(build_dir, is_advanced)
        except ValueError as error:
            kate.ui.popup(
                i18nc('@title:window', 'Error')
              , i18nc(
                    '@info:tooltip'
                  , 'Unable to get CMake cache content:<nl/><message>%1</message>'
                  , str(error)
                  )
              , 'dialog-error'
              )
            return

        # Add items to a list
        for key, value in items.items():
            item = QTreeWidgetItem(self.cacheViewPage.cacheItems, [key, value[1], value[0]])
            item.setToolTip(0, value[2])

        self.cacheViewPage.cacheItems.resizeColumnToContents(0)
        self.cacheViewPage.cacheItems.resizeColumnToContents(1)
        self.cacheViewPage.cacheItems.resizeColumnToContents(2)
    def populate(self):
        groups = {}
        count = 0
        provider = Processing.algs[self.providerName]
        algs = provider.values()

        name = 'ACTIVATE_' + self.providerName.upper().replace(' ', '_')
        active = ProcessingConfig.getSetting(name)

        # Add algorithms
        for alg in algs:
            if not alg.showInToolbox:
                continue
            if alg.group in groups:
                groupItem = groups[alg.group]
            else:
                groupItem = QTreeWidgetItem()
                name = alg.i18n_group or alg.group
                if not active:
                    groupItem.setForeground(0, Qt.darkGray)
                groupItem.setText(0, name)
                groupItem.setToolTip(0, name)
                groups[alg.group] = groupItem
            algItem = TreeAlgorithmItem(alg)
            if not active:
                algItem.setForeground(0, Qt.darkGray)
            groupItem.addChild(algItem)
            count += 1

        actions = Processing.actions[self.providerName]
        for action in actions:
            if action.group in groups:
                groupItem = groups[action.group]
            else:
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, action.group)
                groups[action.group] = groupItem
            algItem = TreeActionItem(action)
            groupItem.addChild(algItem)

        text = self.provider.getDescription()

        if not active:
            def activateProvider():
                self.toolbox.activateProvider(self.providerName)
            label = QLabel(text + "&nbsp;&nbsp;&nbsp;&nbsp;<a href='%s'>Activate</a>")
            label.setStyleSheet("QLabel {background-color: white; color: grey;}")
            label.linkActivated.connect(activateProvider)
            self.tree.setItemWidget(self, 0, label)

        else:
            text += QCoreApplication.translate("TreeProviderItem", " [{0} geoalgorithms]").format(count)
        self.setText(0, text)
        self.setToolTip(0, self.text(0))
        for groupItem in groups.values():
            self.addChild(groupItem)
    def populate_classified_values(self, unassigned_values, assigned_values,
                                   default_classes):
        """Populate lstUniqueValues and treeClasses.from the parameters.

        :param unassigned_values: List of values that haven't been assigned
            to a class. It will be put in self.lstUniqueValues.
        :type unassigned_values: list

        :param assigned_values: Dictionary with class as the key and list of
            value as the value of the dictionary. It will be put in
            self.treeClasses.
        :type assigned_values: dict

        :param default_classes: Default classes from unit.
        :type default_classes: list
        """
        # Populate the unique values list
        self.lstUniqueValues.clear()
        self.lstUniqueValues.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        for value in unassigned_values:
            value_as_string = value is not None and unicode(value) or 'NULL'
            list_item = QListWidgetItem(self.lstUniqueValues)
            list_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable
                               | Qt.ItemIsDragEnabled)
            list_item.setData(Qt.UserRole, value)
            list_item.setText(value_as_string)
            self.lstUniqueValues.addItem(list_item)
        # Populate assigned values tree
        self.treeClasses.clear()
        self.treeClasses.invisibleRootItem().setFlags(Qt.ItemIsEnabled)
        for default_class in default_classes:
            # Create branch for class
            tree_branch = QTreeWidgetItem(self.treeClasses)
            tree_branch.setFlags(Qt.ItemIsDropEnabled | Qt.ItemIsEnabled)
            tree_branch.setExpanded(True)
            tree_branch.setFont(0, bold_font)
            if 'name' in default_class:
                default_class_name = default_class['name']
            else:
                default_class_name = default_class['key']
            tree_branch.setText(0, default_class_name)
            tree_branch.setData(0, Qt.UserRole, default_class['key'])
            if 'description' in default_class:
                tree_branch.setToolTip(0, default_class['description'])
            # Assign known values
            for value in assigned_values[default_class['key']]:
                string_value = value is not None and unicode(value) or 'NULL'
                tree_leaf = QTreeWidgetItem(tree_branch)
                tree_leaf.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable
                                   | Qt.ItemIsDragEnabled)
                tree_leaf.setData(0, Qt.UserRole, value)
                tree_leaf.setText(0, string_value)
Exemple #4
0
    def _load_folder(self, folderStructure, folder, parentItem):
        items = folderStructure[folder]

        if items[1] is not None:
            items[1].sort()
        for _file in items[1]:
            if _file.startswith("."):
                continue
            subfolder = QTreeWidgetItem(parentItem)
            subfolder.setText(0, _file)
            subfolder.setToolTip(0, os.path.join(folder, _file))
            subfolder.setIcon(0, QIcon(resources.IMAGES["tree-folder"]))
            self._load_folder(folderStructure, os.path.join(folder, _file), subfolder)
Exemple #5
0
    def _load_project(self, folderStructure, folder):
        if not folder:
            return

        name = file_manager.get_basename(folder)
        item = QTreeWidgetItem(self._tree)
        item.setText(0, name)
        item.setToolTip(0, folder)
        item.setIcon(0, QIcon(resources.IMAGES['tree-folder']))
        if folderStructure[folder][1] is not None:
            folderStructure[folder][1].sort()
        self._load_folder(folderStructure, folder, item)
        item.setExpanded(True)
        self._root = item
Exemple #6
0
    def __populate( self, importsList ):
        " Populates the dialogue with imports "
        count = len( importsList )
        info = str( count ) + " resolved import"
        if count > 1:
            info += "s"
        self.__importList.setHeaderLabels( [ "Import (" + info + ")", "Path" ] )
        for item in importsList:
            importItem = QTreeWidgetItem( [ item[ 0 ], item[ 1 ] ] )
            importItem.setToolTip( 0, self.__getFileTooltip( item[ 1 ] ) )
            self.__importList.addTopLevelItem( importItem )

        self.__importList.header().resizeSections(
                                        QHeaderView.ResizeToContents )
        return
Exemple #7
0
    def fillAlgorithmTreeUsingProviders(self):
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        allAlgs = ModelerUtils.allAlgs
        for providerName in allAlgs.keys():
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            groups = {}
            provider = allAlgs[providerName]
            algs = provider.values()

            # Add algorithms
            for alg in algs:
                if not alg.showInModeler or alg.allowOnlyOpenedLayers:
                    continue
                if alg.commandLineName() == self.alg.commandLineName():
                    continue
                if text == '' or text.lower() in alg.name.lower():
                    if alg.group in groups:
                        groupItem = groups[alg.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        name = alg.i18n_group or alg.group
                        groupItem.setText(0, name)
                        groupItem.setToolTip(0, name)
                        groups[alg.group] = groupItem
                    algItem = TreeAlgorithmItem(alg)
                    groupItem.addChild(algItem)

            if len(groups) > 0:
                providerItem = QTreeWidgetItem()
                providerItem.setText(0,
                                     ModelerUtils.providers[providerName].getDescription())
                providerItem.setToolTip(0,
                                        ModelerUtils.providers[providerName].getDescription())
                providerItem.setIcon(0,
                                     ModelerUtils.providers[providerName].getIcon())
                for groupItem in groups.values():
                    providerItem.addChild(groupItem)
                self.algorithmTree.addTopLevelItem(providerItem)
                providerItem.setExpanded(text != '')
                for groupItem in groups.values():
                    if text != '':
                        groupItem.setExpanded(True)

        self.algorithmTree.sortItems(0, Qt.AscendingOrder)
 def populate(self):
     self.ui.treeWidget.setColumnCount(1)
     for pluginName, features in self.featureDict.iteritems():
         if pluginName=="TestFeatures" and not ilastik_config.getboolean("ilastik", "debug"):
             continue
         parent = QTreeWidgetItem(self.ui.treeWidget)
         parent.setText(0, pluginName)
         parent.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
         # hack to ensure checkboxes visible
         parent.setCheckState(0, Qt.Checked)
         parent.setCheckState(0, Qt.Unchecked)
         parent.setExpanded(False)
         self.countChecked[pluginName]=0
         self.countAll[pluginName]=len(self.featureDict[pluginName])
         advanced_names = []
         simple_names = []
         for name in sorted(features.keys()):
             parameters = features[name]
             if 'advanced' in parameters:
                 advanced_names.append(name)
             else:
                 simple_names.append(name)
         
         for name in simple_names+advanced_names:
             parameters = features[name]
             
             item = QTreeWidgetItem(parent)
             item.setText(0, name)
             item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
             if 'tooltip' in parameters:
                 item.setToolTip(0, parameters['tooltip'])
             # hack to ensure checkboxes visible
             item.setCheckState(0, Qt.Checked)
             item.setCheckState(0, Qt.Unchecked)
             if pluginName in self.selectedFeatures:
                 if name in self.selectedFeatures[pluginName]:
                     item.setCheckState(0, Qt.Checked)
                     self.countChecked[pluginName]+=1
         if self.countChecked[pluginName] == 0:
             parent.setCheckState(0, Qt.Unchecked)
         elif self.countChecked[pluginName] == self.countAll[pluginName]:
             parent.setCheckState(0, Qt.Checked)
         else:
             parent.setCheckState(0, Qt.PartiallyChecked)
         self.updateToolTip(parent)
     # facilitates switching of the CheckBox when clicking on the Text of a QTreeWidgetItem
     self.ui.treeWidget.setCurrentItem(None)
Exemple #9
0
 def createTreeItem(self, object):
     icon = object.getIcon()
     label = object.formatID()
     tree = QTreeWidgetItem([label])
     tree.setData(0, Qt.UserRole, QVariant(object['id']))
     tooltip = object.getToolTip()
     if tooltip:
         tree.setToolTip(0, tooltip)
     if icon:
         tree.setIcon(0, QIcon(icon))
     font = tree.font(0)
     if object['editable']:
         font.setBold(True)
     if not object['references']:
         font.setItalic(True)
     tree.setFont(0, font)
     if not object['editable']:
         unsetFlag(tree, Qt.ItemIsEditable)
     return tree
Exemple #10
0
    def __init__( self, statusList, parent = None ):
        QDialog.__init__( self, parent )

        # Split statuses
        paths = []
        ignoredPaths = []
        for status in statusList:
            if status[ 1 ] == IND_IGNORED:
                ignoredPaths.append( status )
            else:
                paths.append( status )

        self.__createLayout( paths, ignoredPaths )
        self.setWindowTitle( "SVN status" )

        # Fill the lists
        for item in paths:
            message = ""
            if item[ 2 ]:
                message = item[ 2 ]
            newItem = QTreeWidgetItem( [ "", item[ 0 ],
                                         STATUS[ item[ 1 ] ], message ] )
            pixmap = getIndicatorPixmap( item[ 1 ] )
            if pixmap:
                newItem.setIcon( 0, QIcon( pixmap ) )
            newItem.setToolTip( 1, item[ 0 ] )
            newItem.setToolTip( 2, STATUS[ item[ 1 ] ] )
            if message:
                newItem.setToolTip( 3, message )
            self.__pathView.addTopLevelItem( newItem )
        self.__pathView.header().resizeSections( QHeaderView.ResizeToContents )
        self.__pathView.header().resizeSection( 0, 20 )
        self.__pathView.header().setResizeMode( QHeaderView.Fixed )

        for item in ignoredPaths:
            newItem = QTreeWidgetItem( [ item[ 0 ], STATUS[ item[ 1 ] ] ] )
            newItem.setToolTip( 0, item[ 0 ] )
            newItem.setToolTip( 1, STATUS[ item[ 1 ] ] )
            self.__ignoredPathView.addTopLevelItem( newItem )
        self.__ignoredPathView.header().resizeSections( QHeaderView.ResizeToContents )

        return
Exemple #11
0
    def __init__( self, pathsToAdd, parent = None ):
        QDialog.__init__( self, parent )

        self.addPaths = []

        self.__createLayout( pathsToAdd )
        self.setWindowTitle( "SVN add" )

        # Fill the lists
        for item in pathsToAdd:
            newItem = QTreeWidgetItem( [ "", item ] )
            newItem.setCheckState( CHECK_COL, Qt.Checked )
            newItem.setToolTip( PATH_COL, item[ 0 ] )
            self.__pathToAddView.addTopLevelItem( newItem )

        self.__resizeAddPaths()
        self.__sortAddPaths()

        self.__updateOKStatus()
        return
 def populate(self):
     self.ui.treeWidget.setColumnCount(1)
     for pluginName, features in self.featureDict.iteritems():
         parent = QTreeWidgetItem(self.ui.treeWidget)
         parent.setText(0, pluginName)
         parent.setExpanded(True)
         for name in sorted(features.keys()):
             parameters = features[name]
             
             item = QTreeWidgetItem(parent)
             item.setText(0, name)
             item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
             if 'tooltip' in parameters:
                 item.setToolTip(0, parameters['tooltip'])
             # hack to ensure checkboxes visible
             item.setCheckState(0, Qt.Checked)
             item.setCheckState(0, Qt.Unchecked)
             
             if pluginName in self.selectedFeatures:
                 if name in self.selectedFeatures[pluginName]:
                     item.setCheckState(0, Qt.Checked)
    def populate(self):
        groups = {}
        count = 0
        provider = Processing.algs[self.providerName]
        algs = provider.values()

        # Add algorithms
        for alg in algs:
            if not alg.showInToolbox:
                continue
            if alg.group in groups:
                groupItem = groups[alg.group]
            else:
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, alg.group)
                groupItem.setToolTip(0, alg.group)
                groups[alg.group] = groupItem
            algItem = TreeAlgorithmItem(alg)
            groupItem.addChild(algItem)
            count += 1

        actions = Processing.actions[self.providerName]
        for action in actions:
            if action.group in groups:
                groupItem = groups[action.group]
            else:
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, action.group)
                groups[action.group] = groupItem
            algItem = TreeActionItem(action)
            groupItem.addChild(algItem)

        self.setText(
            0,
            self.provider.getDescription()
            + QCoreApplication.translate("TreeProviderItem", " [{0} geoalgorithms]").format(count),
        )
        self.setToolTip(0, self.text(0))
        for groupItem in groups.values():
            self.addChild(groupItem)
Exemple #14
0
    def populate_tree(self,parentItem,childrenList):
        '''Recursive method to create each item (and associated data) in the tree.'''
        for childKey in childrenList:
            self.itemDepth +=1
            fileName,lineNumber,functionName,fileAndLine,nodeType = self.function_info(childKey)
            primCalls,totalCalls,locTime,cumTime,callers = self.stats[childKey]
            childItem = QTreeWidgetItem(parentItem)
            self.itemsList.append(childItem)
            childItem.setData(0,Qt.UserRole,self.itemDepth)

            # FIXME: indexes to data should be defined by a dictionary on init
            childItem.setToolTip(0,'Function or module name')
            childItem.setData(0,Qt.DisplayRole,functionName)
            childItem.setIcon(0,get_icon(self.iconDict[nodeType]))

            childItem.setToolTip(1,'Time in function (including sub-functions)')
            #childItem.setData(1,Qt.DisplayRole,cumTime)
            childItem.setData(1,Qt.DisplayRole,QString('%1').arg(cumTime,0,'f',3))
            childItem.setTextAlignment(1,Qt.AlignCenter)

            childItem.setToolTip(2,'Local time in function (not in sub-functions)')
            #childItem.setData(2,Qt.DisplayRole,locTime)
            childItem.setData(2,Qt.DisplayRole,QString('%1').arg(locTime,0,'f',3))
            childItem.setTextAlignment(2,Qt.AlignCenter)

            childItem.setToolTip(3,'Total number of calls (including recursion)')
            childItem.setData(3,Qt.DisplayRole,totalCalls)
            childItem.setTextAlignment(3,Qt.AlignCenter)

            childItem.setToolTip(4,'File:line where function is defined')
            childItem.setData(4,Qt.DisplayRole,fileAndLine)
            #childItem.setExpanded(True)
            if self.is_recursive(childItem):
                childItem.setData(4,Qt.DisplayRole,'(recursion)')
                childItem.setDisabled(True)
            else:
                self.populate_tree(childItem,self.find_callees(childKey))
            self.itemDepth -= 1
Exemple #15
0
 def populate(self):
     self.ui.treeWidget.setColumnCount(1)
     for pluginName, features in self.featureDict.iteritems():
         if pluginName=="TestFeatures" and not ilastik_config.getboolean("ilastik", "debug"):
             continue
             
         parent = QTreeWidgetItem(self.ui.treeWidget)
         if pluginName == "Standard Object Features":
             parent.setText(0, pluginName)
             parent.setToolTip(0, 'http://hci.iwr.uni-heidelberg.de/vigra/doc/vigra/group__FeatureAccumulators.html')
         else:
             parent.setText(0, pluginName)
         parent.setExpanded(True)
         advanced_names = []
         simple_names = []
         for name in sorted(features.keys()):
             parameters = features[name]
             if 'advanced' in parameters:
                 advanced_names.append(name)
             else:
                 simple_names.append(name)
         
         for name in simple_names+advanced_names:
             parameters = features[name]
             
             item = QTreeWidgetItem(parent)
             item.setText(0, name)
             item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
             if 'tooltip' in parameters:
                 item.setToolTip(0, parameters['tooltip'])
             # hack to ensure checkboxes visible
             item.setCheckState(0, Qt.Checked)
             item.setCheckState(0, Qt.Unchecked)
             
             if pluginName in self.selectedFeatures:
                 if name in self.selectedFeatures[pluginName]:
                     item.setCheckState(0, Qt.Checked)
Exemple #16
0
    def __init__( self, plugin, pathsToCommit, pathsToIgnore, parent = None ):
        QDialog.__init__( self, parent )

        self.__plugin = plugin

        self.__createLayout( pathsToCommit, pathsToIgnore )
        self.setWindowTitle( "SVN commit" )

        # Fill the lists
        for item in pathsToCommit:
            newItem = QTreeWidgetItem( [ "", item[ 0 ], STATUS[ item[ 1 ] ] ] )
            newItem.setCheckState( CHECK_COL, Qt.Checked )
            newItem.setToolTip( PATH_COL, item[ 0 ] )
            newItem.setToolTip( STATUS_COL, STATUS[ item[ 1 ] ] )
            self.__pathToCommitView.addTopLevelItem( newItem )

            diffButton = self.__createDiffButton()
            diffButton.path = item[ 0 ]
            diffButton.status = item[ 1 ]

            fileType = detectFileType( item[ 0 ] )

            if os.path.isdir( item[ 0 ] ) or item[ 1 ] in [ IND_REPLACED ] \
                or not isFileTypeSearchable( fileType ):
                diffButton.setEnabled( False )
                diffButton.setToolTip( "Diff is not available" )
            else:
                diffButton.setEnabled( True )
                diffButton.setToolTip( "Click to see diff" )
            self.__pathToCommitView.setItemWidget( newItem, DIFF_COL, diffButton )

        self.__resizeCommitPaths()
        self.__sortCommitPaths()

        for item in pathsToIgnore:
            newItem = QTreeWidgetItem( [ item[ 0 ], STATUS[ item[ 1 ] ] ] )
            newItem.setToolTip( 0, item[ 0 ] )
            newItem.setToolTip( 1, STATUS[ item[ 1 ] ] )
            self.__pathToIgnoreView.addTopLevelItem( newItem )
        self.__pathToIgnoreView.header().resizeSections( QHeaderView.ResizeToContents )

        self.__updateSelectAllStatus()
        self.__updateOKStatus()
        self.__message.setFocus()
        return
    def populate(self):
        #self.ui.treeWidget.setColumnCount(2)
        for pluginName, features in self.featureDict.iteritems():
            if pluginName=="TestFeatures" and not ilastik_config.getboolean("ilastik", "debug"):
                continue
            parent = QTreeWidgetItem(self.ui.treeWidget)
            parent.setText(0, pluginName)

            parent.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            # hack to ensure checkboxes visible
            parent.setCheckState(0, Qt.Checked)
            parent.setCheckState(0, Qt.Unchecked)
            parent.setExpanded(False)
            self.countChecked[pluginName]=0
            self.countAll[pluginName]=len(self.featureDict[pluginName])

            advanced_names = []
            simple_names = []
            selected_names = []

            groups = set()
            plugin = pluginManager.getPluginByName(pluginName, "ObjectFeatures")
            features_with_props = deepcopy(features)
            if plugin is not None:
                plugin.plugin_object.fill_properties(features_with_props)

            for name in sorted(features.keys()):
                parameters = features[name]

                for prop, prop_value in features_with_props[name].iteritems():
                    if not prop in parameters.keys():
                        # this property has not been added yet (perhaps the feature dictionary has been read from file)
                        # set it now
                        parameters[prop] = prop_value

                try:
                    if parameters['advanced'] is True:
                        advanced_names.append(name)
                    else:
                        simple_names.append(name)
                except KeyError:
                    simple_names.append(name)
                try:
                    groups.add(parameters["group"])
                except KeyError:
                    pass

                if pluginName in self.selectedFeatures:
                    if name in self.selectedFeatures[pluginName]:
                        selected_names.append(name)
            gr_items = {}
            for gr in groups:
                gr_items[gr] = QTreeWidgetItem(parent)
                gr_items[gr].setText(0, gr)
                #gr_items[gr].setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
                gr_items[gr].setExpanded(True)
            
            for name in simple_names+advanced_names:
                if name in advanced_names and (not name in selected_names):
                    # do not display advanced features, if they have not been selected previously
                    continue
                parameters = features[name]
                if "group" in parameters:
                    item = QTreeWidgetItem(gr_items[parameters["group"]])
                else:
                    item = QTreeWidgetItem(parent)
                if 'displaytext' in parameters:
                    itemtext = parameters['displaytext']
                else:
                    itemtext = name
                item.setText(0, itemtext)

                self.displayNamesDict[itemtext] = name
                item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                if 'tooltip' in parameters:
                    item.setToolTip(0, parameters['tooltip'])

                # hack to ensure checkboxes visible
                item.setCheckState(0, Qt.Checked)
                item.setCheckState(0, Qt.Unchecked)
                if name in selected_names:
                    item.setCheckState(0, Qt.Checked)
                    self.countChecked[pluginName]+=1
            if self.countChecked[pluginName] == 0:
                parent.setCheckState(0, Qt.Unchecked)
            elif self.countChecked[pluginName] == self.countAll[pluginName]:
                parent.setCheckState(0, Qt.Checked)
            else:
                parent.setCheckState(0, Qt.PartiallyChecked)
            self.updateToolTip(parent)
        # facilitates switching of the CheckBox when clicking on the Text of a QTreeWidgetItem
        self.ui.treeWidget.setCurrentItem(None)
Exemple #18
0
    def fillAlgorithmTreeUsingCategories(self):
        providersToExclude = ['model', 'script']
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        groups = {}
        allAlgs = ModelerUtils.allAlgs
        for providerName in allAlgs.keys():
            provider = allAlgs[providerName]
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName in providersToExclude \
                    or len(ModelerUtils.providers[providerName].actions) != 0:
                continue
            algs = provider.values()

            # Add algorithms
            for alg in algs:
                if not alg.showInModeler or alg.allowOnlyOpenedLayers:
                    continue
                altgroup, altsubgroup = AlgorithmClassification.getClassification(alg)
                if altgroup is None:
                    continue
                algName = AlgorithmClassification.getDisplayName(alg)
                if text == '' or text.lower() in algName.lower():
                    if altgroup not in groups:
                        groups[altgroup] = {}
                    group = groups[altgroup]
                    if altsubgroup not in group:
                        groups[altgroup][altsubgroup] = []
                    subgroup = groups[altgroup][altsubgroup]
                    subgroup.append(alg)

        if len(groups) > 0:
            mainItem = QTreeWidgetItem()
            mainItem.setText(0, self.tr('Geoalgorithms'))
            mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
            mainItem.setToolTip(0, mainItem.text(0))
            for (groupname, group) in groups.items():
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, groupname)
                groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                groupItem.setToolTip(0, groupItem.text(0))
                mainItem.addChild(groupItem)
                for (subgroupname, subgroup) in group.items():
                    subgroupItem = QTreeWidgetItem()
                    subgroupItem.setText(0, subgroupname)
                    subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                    subgroupItem.setToolTip(0, subgroupItem.text(0))
                    groupItem.addChild(subgroupItem)
                    for alg in subgroup:
                        algItem = TreeAlgorithmItem(alg)
                        subgroupItem.addChild(algItem)
            self.algorithmTree.addTopLevelItem(mainItem)

        for providerName in allAlgs.keys():
            groups = {}
            provider = allAlgs[providerName]
            name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName not in providersToExclude:
                continue
            algs = provider.values()

            # Add algorithms
            for alg in algs:
                if not alg.showInModeler or alg.allowOnlyOpenedLayers:
                    continue
                if text == '' or text.lower() in alg.name.lower():
                    if alg.group in groups:
                        groupItem = groups[alg.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        name = alg.i18n_group
                        groupItem.setText(0, name)
                        groupItem.setToolTip(0, name)
                        groups[alg.group] = groupItem
                    algItem = TreeAlgorithmItem(alg)
                    groupItem.addChild(algItem)

            if len(groups) > 0:
                providerItem = QTreeWidgetItem()
                providerItem.setText(0,
                                     ModelerUtils.providers[providerName].getDescription())
                providerItem.setIcon(0,
                                     ModelerUtils.providers[providerName].getIcon())
                providerItem.setToolTip(0, providerItem.text(0))
                for groupItem in groups.values():
                    providerItem.addChild(groupItem)
                self.algorithmTree.addTopLevelItem(providerItem)
                providerItem.setExpanded(text != '')
                for groupItem in groups.values():
                    if text != '':
                        groupItem.setExpanded(True)
Exemple #19
0
 def update_result(self, items):
     self._tree.clear()
     for i in items:
         item = QTreeWidgetItem(self._tree, (i[3], i[0], str(i[2] + 1)))
         item.setToolTip(1, i[1])
    def showReport( self, metrics, reportOption, fileName, uuid ):
        " Shows the pymetrics results "
        self.__clear()
        self.__noneLabel.hide()

        self.__report = metrics
        self.__reportUUID = uuid
        self.__reportFileName = fileName
        self.__reportOption = reportOption

        if len( metrics.report ) > 1:
            accumulatedBasic = self.__accumulateBasicMetrics()
            accItem = QTreeWidgetItem( [ "Cumulative basic metrics" ] )
            self.__totalResultsTree.addTopLevelItem( accItem )
            for key in accumulatedBasic:
                bmItem = [ BasicMetrics.metricsOfInterest[ key ],
                           splitThousands( str( accumulatedBasic[ key ] ) ) ]
                basicMetric = QTreeWidgetItem( bmItem )
                accItem.addChild( basicMetric )

        # Add the complete information
        for fileName in metrics.report:
            if reportOption == self.SingleBuffer:
                fileItem = QTreeWidgetItem( [ "Editor buffer" ] )
            else:
                fileItem = QTreeWidgetItem( [ fileName ] )
                info = GlobalData().briefModinfoCache.get( fileName )
                if info.docstring is not None:
                    fileItem.setToolTip( 0, info.docstring.text )
                else:
                    fileItem.setToolTip( 0, "" )
            self.__totalResultsTree.addTopLevelItem( fileItem )

            # Messages part
            messages = metrics.report[ fileName ].messages
            if len( messages ) > 0:
                messagesItem = QTreeWidgetItem( [ "Messages" ] )
                fileItem.addChild( messagesItem )
                for message in messages:
                    mItem = [ message, "", "E" ]
                    messagesItem.addChild( QTreeWidgetItem( mItem ) )

            # Basic metrics part
            basicItem = QTreeWidgetItem( [ "Basic metrics" ] )
            fileItem.addChild( basicItem )
            basic = metrics.report[ fileName ].basicMetrics
            for key in basic.metrics:
                bmItem = [ BasicMetrics.metricsOfInterest[ key ],
                           str( basic.metrics[ key ] ) ]
                basicMetric = QTreeWidgetItem( bmItem )
                basicItem.addChild( basicMetric )

            # McCabe part
            mccabeItem = QTreeWidgetItem( [ "McCabe metrics" ] )
            fileItem.addChild( mccabeItem )
            mccabe = metrics.report[ fileName ].mcCabeMetrics.metrics
            for objName in mccabe:
                objItem = [ objName, str( mccabe[ objName ] ), "M" ]
                mccabeMetric = QTreeWidgetItem( objItem )
                mccabeItem.addChild( mccabeMetric )


            # COCOMO 2 part
            cocomo = [ "COCOMO 2", str( metrics.report[ fileName ].cocomo2Metrics.value ) ]
            cocomoItem = QTreeWidgetItem( cocomo )
            fileItem.addChild( cocomoItem )



        # Resizing the table
        self.__totalResultsTree.header().resizeSections(
                                            QHeaderView.ResizeToContents )


        # Add McCabe complexity information
        for fileName in metrics.report:
            mccabe = metrics.report[ fileName ].mcCabeMetrics.metrics
            for objName in mccabe:
                values = [ "", fileName, objName, str( mccabe[ objName ] ) ]
                self.__mcCabeTable.addTopLevelItem( McCabeTableItem( values ) )

        if not self.__shouldShowFileName( self.__mcCabeTable, 1 ):
            self.__mcCabeTable.setColumnHidden( 1, True )

        # Resizing and sorting the table
        self.__mcCabeTable.header().setSortIndicator( 3, Qt.DescendingOrder )
        self.__mcCabeTable.sortItems( 3,
                          self.__mcCabeTable.header().sortIndicatorOrder() )
        self.__mcCabeTable.header().resizeSections(
                          QHeaderView.ResizeToContents )

        # Show the complete information
        self.__mcCabeTable.hide()
        self.__totalResultsTree.show()

        self.__reportShown = True
        self.__updateButtonsStatus()
        self.__updateTooltip()

        # It helps, but why do I have flickering?
        QApplication.processEvents()
        return
Exemple #21
0
 def update_result(self, items):
     """Update the result tree with the new items."""
     self._tree.clear()
     for i in items:
         item = QTreeWidgetItem(self._tree, (i[3], i[0], str(i[2] + 1)))
         item.setToolTip(1, i[1])
Exemple #22
0
    def updateHelpIndex(self):
        # Add commands group
        commands = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Commands')]
          , cmake_help_parser.help_category.COMMAND
          )
        deprecated = [cmd[0] for cmd in cmake_help_parser.get_cmake_deprecated_commands_list()]
        for cmd in cmake_help_parser.get_cmake_commands_list():
            c = QTreeWidgetItem(
                commands
              , [cmd]
              , cmake_help_parser.help_category.HELP_ITEM
              )
            global _cmake_completion_model
            schema = KColorScheme(QPalette.Normal, KColorScheme.Selection)
            if _cmake_completion_model.has_completion_for_command(cmd):
                c.setForeground(0, schema.foreground(KColorScheme.PositiveText).color())
            else:
                if cmd in deprecated:
                    c.setForeground(0, schema.foreground(KColorScheme.NeutralText).color())
                else:
                    c.setForeground(0, schema.foreground(KColorScheme.NegativeText).color())

        # Add modules group
        standard_modules = cmake_help_parser.get_cmake_modules_list()
        total_modules_count = len(standard_modules)
        custom_modules = {}
        for path in kate.sessionConfiguration[settings.AUX_MODULE_DIRS]:
            modules_list = cmake_help_parser.get_cmake_modules_list(path)
            filtered_modules_list = [mod for mod in modules_list if mod not in standard_modules]
            filtered_modules_list.sort()
            custom_modules[
                i18nc('@item:inlistbox', 'Modules from %1 (%2)', path, len(path))
              ] = filtered_modules_list
            total_modules_count += len(filtered_modules_list)
        custom_modules[
            i18nc('@item:inlistbox', 'Standard modules (%1)', len(standard_modules))
          ] = standard_modules
        #
        modules = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Modules (%1)', total_modules_count)]
          , cmake_help_parser.help_category.MODULE
          )
        for from_path, modules_list in custom_modules.items():
            ss_item = QTreeWidgetItem(
                modules
              , [from_path]
              , cmake_help_parser.help_category.MODULE
              )
            for mod in modules_list:
                m = QTreeWidgetItem(
                    ss_item
                  , [mod]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )

        # Add policies group
        policies = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Policies')]
          , cmake_help_parser.help_category.POLICY
          )
        for pol in cmake_help_parser.get_cmake_policies_list():
            p = QTreeWidgetItem(
                policies
              , [pol]
              , cmake_help_parser.help_category.HELP_ITEM
              )

        # Add properties group
        properties = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Properties')]
          , cmake_help_parser.help_category.PROPERTY
          )
        for subsection, props_list in cmake_help_parser.get_cmake_properties_list().items():
            ss_item = QTreeWidgetItem(
                properties
              , [subsection]
              , cmake_help_parser.help_category.PROPERTY
              )
            for prop in props_list:
                v = QTreeWidgetItem(
                    ss_item
                  , [prop[0]]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )
                v.setToolTip(0, prop[1])

        # Add variables group
        variables = QTreeWidgetItem(
            self.vewHelpPage.helpTargets
          , [i18nc('@item::inlistbox/plain', 'Variables')]
          , cmake_help_parser.help_category.VARIABLE
          )
        for subsection, vars_list in cmake_help_parser.get_cmake_vars_list().items():
            ss_item = QTreeWidgetItem(
                variables
              , [subsection]
              , cmake_help_parser.help_category.VARIABLE
              )
            for var in vars_list:
                v = QTreeWidgetItem(
                    ss_item
                  , [var[0]]
                  , cmake_help_parser.help_category.HELP_ITEM
                  )
                v.setToolTip(0, var[1])
        #
        self.vewHelpPage.helpTargets.resizeColumnToContents(0)
    def fillTreeUsingCategories(self):
        providersToExclude = ["model", "script"]
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        groups = {}
        for providerName in Processing.algs.keys():
            provider = Processing.algs[providerName]
            name = "ACTIVATE_" + providerName.upper().replace(" ", "_")
            if not ProcessingConfig.getSetting(name):
                continue
            if providerName in providersToExclude or len(ModelerUtils.providers[providerName].actions) != 0:
                continue
            algs = provider.values()

            # add algorithms

            for alg in algs:
                if not alg.showInToolbox:
                    continue
                (altgroup, altsubgroup, altname) = AlgorithmDecorator.getGroupsAndName(alg)
                if altgroup is None:
                    continue
                if text == "" or text.lower() in altname.lower():
                    if altgroup not in groups:
                        groups[altgroup] = {}
                    group = groups[altgroup]
                    if altsubgroup not in group:
                        groups[altgroup][altsubgroup] = []
                    subgroup = groups[altgroup][altsubgroup]
                    subgroup.append(alg)

        if len(groups) > 0:
            mainItem = QTreeWidgetItem()
            mainItem.setText(0, "Geoalgorithms")
            mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
            mainItem.setToolTip(0, mainItem.text(0))
            for (groupname, group) in groups.items():
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, groupname)
                groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                groupItem.setToolTip(0, groupItem.text(0))
                mainItem.addChild(groupItem)
                for (subgroupname, subgroup) in group.items():
                    subgroupItem = QTreeWidgetItem()
                    subgroupItem.setText(0, subgroupname)
                    subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                    subgroupItem.setToolTip(0, subgroupItem.text(0))
                    groupItem.addChild(subgroupItem)
                    for alg in subgroup:
                        algItem = TreeAlgorithmItem(alg)
                        subgroupItem.addChild(algItem)

            self.algorithmTree.addTopLevelItem(mainItem)

        for providerName in Processing.algs.keys():
            if providerName not in providersToExclude:
                continue
            name = "ACTIVATE_" + providerName.upper().replace(" ", "_")
            if not ProcessingConfig.getSetting(name):
                continue
            providerItem = TreeProviderItem(providerName)
            self.algorithmTree.addTopLevelItem(providerItem)
Exemple #24
0
    def __createLayout(self, action, title, files):
        """ Creates the dialog layout """

        self.resize(400, 300)
        self.setSizeGripEnabled(True)

        # Top level layout
        layout = QVBoxLayout(self)

        # Pixmap and the message
        topLayout = QHBoxLayout()
        pixmap = QLabel()
        pixmap.setPixmap(PixmapCache().getPixmap('warning.png'))
        topLayout.addWidget(pixmap)
        hSpacer = QWidget()
        hSpacer.setFixedSize(15, 15)
        topLayout.addWidget(hSpacer)
        message = QLabel( "All the project files must be " \
                          "saved before start debugging" )
        message.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        message.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        message.setWordWrap(True)
        topLayout.addWidget(message)
        layout.addLayout(topLayout)

        vSpacer = QWidget()
        vSpacer.setFixedSize(15, 15)
        layout.addWidget(vSpacer)

        layout.addWidget(QLabel(title + ":"))
        filesList = QTreeWidget()
        filesList.setRootIsDecorated(False)
        filesList.setAlternatingRowColors(True)
        filesList.setUniformRowHeights(True)
        filesList.setItemsExpandable(False)
        filesList.setItemDelegate(NoOutlineHeightDelegate(4))
        filesList.setSelectionMode(QAbstractItemView.NoSelection)
        filesList.setHeaderHidden(True)
        for item in files:
            fileName = item[0]
            fileItem = QTreeWidgetItem([fileName])
            fileType = detectFileType(fileName)
            fileItem.setIcon(0, getFileIcon(fileType))
            if fileType in [PythonFileType, Python3FileType]:
                infoSrc = GlobalData().briefModinfoCache
                info = infoSrc.get(fileName)
                if info.docstring is not None:
                    fileItem.setToolTip(0, info.docstring.text)
                else:
                    fileItem.setToolTip(0, "")
            filesList.addTopLevelItem(fileItem)
        layout.addWidget(filesList)

        # Buttons at the bottom
        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
        continueButton = buttonBox.addButton(action,
                                             QDialogButtonBox.ActionRole)
        continueButton.setDefault(True)
        layout.addWidget(buttonBox)

        continueButton.clicked.connect(self.accept)
        buttonBox.rejected.connect(self.close)
        continueButton.setFocus()
        return
Exemple #25
0
    def findTables(self):
        self.ui.testBT.setEnabled(True)

        cl = CartoDBAPIKey(self.currentApiKey, self.currentUser)
        try:
            if not str(self.currentMultiuser) in ['true', '1', 'True']:
                sqlTables = "SELECT CDB_UserTables() table_name"
                res = cl.sql(
                    "WITH usertables AS (" + sqlTables + ") \
                        SELECT ut.table_name, c.column_name, c.data_type column_type \
                          FROM usertables ut \
                          JOIN information_schema.columns c ON c.table_name = ut.table_name \
                        WHERE c.data_type != 'USER-DEFINED' \
                        ORDER BY ut.table_name, c.column_name")
            else:
                sqlTables = "SELECT string_agg(privilege_type, ', ') AS privileges, table_schema, table_name \
                                FROM information_schema.role_table_grants tg \
                                JOIN ( \
                                    SELECT DISTINCT u.usename \
                                    FROM information_schema.tables t \
                                    JOIN pg_catalog.pg_class c ON (t.table_name = c.relname) \
                                    JOIN pg_catalog.pg_user u ON (c.relowner = u.usesysid) \
                                    WHERE t.table_schema = '" + self.currentUser + "') u ON u.usename = tg.grantee \
                            WHERE table_schema NOT IN ('pg_catalog', 'information_schema', 'cartodb', 'public', 'cdb_importer') \
                            GROUP BY table_schema, table_name \
                            ORDER BY table_schema, table_name"
                res = cl.sql(
                    "WITH usertables AS (" + sqlTables + ") \
                     SELECT ut.table_name, c.column_name, c.data_type column_type, ut.privileges \
                        FROM usertables ut \
                        JOIN information_schema.columns c ON c.table_name = ut.table_name \
                     WHERE c.data_type != 'USER-DEFINED' \
                     ORDER BY ut.table_name, c.column_name")

            tables = []
            oldTableName = None
            parentTableItem = None
            for table in res['rows']:

                if table['table_name'] != oldTableName:
                    parentTableItem = QTreeWidgetItem()
                    oldTableName = table['table_name']
                    parentTableItem.setText(0, self.tr(oldTableName))
                    parentTableItem.setIcon(0, QIcon(":/plugins/qgis-cartodb/images/icons/layers.png"))
                    if str(self.currentMultiuser) in ['true', '1', 'True'] and table['privileges'] == 'SELECT':
                        parentTableItem.setTextColor(0, QColor('#999999'))
                    tables.append(parentTableItem)

                tableItem = QTreeWidgetItem(parentTableItem)
                tableItem.setText(0, self.tr(table['column_name']))
                if str(self.currentMultiuser) in ['true', '1', 'True'] and table['privileges'] == 'SELECT':
                    tableItem.setTextColor(0, QColor('#999999'))
                tableItem.setToolTip(0, self.tr(table['column_type']))
                tableItem.setIcon(0, QIcon(":/plugins/qgis-cartodb/images/icons/text.png"))
                if table['column_type'] == 'integer' or table['column_type'] == 'double precision':
                    tableItem.setIcon(0, QIcon(":/plugins/qgis-cartodb/images/icons/number.png"))
                elif table['column_type'] == 'timestamp with time zone':
                    tableItem.setIcon(0, QIcon(":/plugins/qgis-cartodb/images/icons/calendar.png"))
            self.setTablesListItems(tables)
        except CartoDBException as e:
            QgsMessageLog.logMessage('Some error ocurred getting tables: ' + str(e.args), 'CartoDB Plugin', QgsMessageLog.CRITICAL)
            QMessageBox.information(self, QApplication.translate('CartoDBPlugin', 'Error'), QApplication.translate('CartoDBPlugin', 'Error getting tables'), QMessageBox.Ok)
            self.ui.tablesTree.clear()
    def populate_classified_values(
            unassigned_values, assigned_values, default_classes,
            list_unique_values, tree_mapping_widget):
        """Populate lstUniqueValues and treeClasses.from the parameters.

        :param unassigned_values: List of values that haven't been assigned
            to a class. It will be put in list_unique_values.
        :type unassigned_values: list

        :param assigned_values: Dictionary with class as the key and list of
            value as the value of the dictionary. It will be put in
            tree_mapping_widget.
        :type assigned_values: dict

        :param default_classes: Default classes from unit.
        :type default_classes: list

        :param list_unique_values: List Widget for unique values
        :type list_unique_values: QListWidget

        :param tree_mapping_widget: Tree Widget for classifying.
        :type tree_mapping_widget: QTreeWidget
        """
        # Populate the unique values list
        list_unique_values.clear()
        list_unique_values.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        for value in unassigned_values:
            value_as_string = value is not None and unicode(value) or 'NULL'
            list_item = QListWidgetItem(list_unique_values)
            list_item.setFlags(
                Qt.ItemIsEnabled |
                Qt.ItemIsSelectable |
                Qt.ItemIsDragEnabled)
            list_item.setData(Qt.UserRole, value)
            list_item.setText(value_as_string)
            list_unique_values.addItem(list_item)
        # Populate assigned values tree
        tree_mapping_widget.clear()
        bold_font = QFont()
        bold_font.setItalic(True)
        bold_font.setBold(True)
        bold_font.setWeight(75)
        tree_mapping_widget.invisibleRootItem().setFlags(
            Qt.ItemIsEnabled)
        for default_class in default_classes:
            # Create branch for class
            tree_branch = QTreeWidgetItem(tree_mapping_widget)
            tree_branch.setFlags(
                Qt.ItemIsDropEnabled | Qt.ItemIsEnabled)
            tree_branch.setExpanded(True)
            tree_branch.setFont(0, bold_font)
            if 'name' in default_class:
                default_class_name = default_class['name']
            else:
                default_class_name = default_class['key']
            tree_branch.setText(0, default_class_name)
            tree_branch.setData(0, Qt.UserRole, default_class['key'])
            if 'description' in default_class:
                tree_branch.setToolTip(0, default_class['description'])
            # Assign known values
            for value in assigned_values[default_class['key']]:
                string_value = value is not None and unicode(value) or 'NULL'
                tree_leaf = QTreeWidgetItem(tree_branch)
                tree_leaf.setFlags(
                    Qt.ItemIsEnabled |
                    Qt.ItemIsSelectable |
                    Qt.ItemIsDragEnabled)
                tree_leaf.setData(0, Qt.UserRole, value)
                tree_leaf.setText(0, string_value)
Exemple #27
-1
    def __createLayout( self, action, title, files ):
        """ Creates the dialog layout """

        self.resize( 400, 300 )
        self.setSizeGripEnabled( True )

        # Top level layout
        layout = QVBoxLayout( self )


        # Pixmap and the message
        topLayout = QHBoxLayout()
        pixmap = QLabel()
        pixmap.setPixmap( PixmapCache().getPixmap( 'warning.png' ) )
        topLayout.addWidget( pixmap )
        hSpacer = QWidget()
        hSpacer.setFixedSize( 15, 15 )
        topLayout.addWidget( hSpacer )
        message = QLabel( "All the project files must be " \
                          "saved before start debugging" )
        message.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
        message.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding )
        message.setWordWrap( True )
        topLayout.addWidget( message )
        layout.addLayout( topLayout )

        vSpacer = QWidget()
        vSpacer.setFixedSize( 15, 15 )
        layout.addWidget( vSpacer )

        layout.addWidget( QLabel( title + ":" ) )
        filesList = QTreeWidget()
        filesList.setRootIsDecorated( False )
        filesList.setAlternatingRowColors( True )
        filesList.setUniformRowHeights( True )
        filesList.setItemsExpandable( False )
        filesList.setItemDelegate( NoOutlineHeightDelegate( 4 ) )
        filesList.setSelectionMode( QAbstractItemView.NoSelection )
        filesList.setHeaderHidden( True )
        for item in files:
            fileName = item[ 0 ]
            fileItem = QTreeWidgetItem( [ fileName ] )
            fileType = detectFileType( fileName )
            fileItem.setIcon( 0, getFileIcon( fileType ) )
            if fileType in [ PythonFileType, Python3FileType ]:
                infoSrc = GlobalData().briefModinfoCache
                info = infoSrc.get( fileName )
                if info.docstring is not None:
                    fileItem.setToolTip( 0, info.docstring.text )
                else:
                    fileItem.setToolTip( 0, "" )
            filesList.addTopLevelItem( fileItem )
        layout.addWidget( filesList )

        # Buttons at the bottom
        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Cancel )
        continueButton = buttonBox.addButton( action,
                                              QDialogButtonBox.ActionRole )
        continueButton.setDefault( True )
        layout.addWidget( buttonBox )

        continueButton.clicked.connect( self.accept )
        buttonBox.rejected.connect( self.close )
        continueButton.setFocus()
        return