Beispiel #1
0
 def scanDirectory(self, subroot):
     items = {}
     for (dir, subdirs, files) in os.walk(os.path.join(self.root, subroot)):
         if dir and not dir[0] == '.':
             if not dir in items:
                 topItem = QtGui.QTreeWidgetItem([subroot])
                 if subroot == 'src':
                     self.src = topItem
                 topItem.setIcon(0, self.folderIcon)
                 topItem.setData(0, DirectoryRole, dir)
                 items[dir] = topItem
                 self.rootItem.addChild(topItem)
             item = items.get(dir)
             for sub in subdirs:
                 path = os.path.join(dir, sub)
                 child = QtGui.QTreeWidgetItem([sub])
                 child.setIcon(0, self.folderIcon)
                 child.setData(0, DirectoryRole, path)
                 items[path] = child
                 item.addChild(child)
             for filename in files:
                 if is_src_ext(filename) or is_header(filename):
                     child = QtGui.QTreeWidgetItem([filename])
                     child.setIcon(0, self.docIcon)
                     item.addChild(child)
                     path = os.path.join(dir, filename)
                     child.setData(0, FileRole, path)
                     self.fileItems[path] = child
Beispiel #2
0
def isSourceDir(dir, files):
    if dir.count('/') == 0:
        return False
    for f in files:
        if is_src_ext(f):
            return True
    return False
Beispiel #3
0
def filterSources(files):
    alt = []
    for f in files:
        if is_src_ext(f):
            alt.append(f)
    return alt
Beispiel #4
0
def isSourceFile(f):
    '''
    Check if a file is a C++ source file
    '''
    return is_src_ext(f)