Beispiel #1
0
    def cleanup(self):
        if not self.isVisible():
            return

        items = []
        for item in self.items[:]:
            if not self.match(item.userData()):
                md5 = item.userData()['md5']
                if md5 in self.match_md5s:
                    self.match_md5s.remove(md5)
                ind = self.ui.tree.indexOfTopLevelItem(item)
                self.ui.tree.takeTopLevelItem(ind)
            else:
                items.append(item)
        self.items = items
        items = []

        for meta in self.pcs.cache.itervalues():
            if (not meta['isdir'] and self.match(meta)
                    and meta['md5'] not in self.match_md5s):

                item = eqt.SortableTreeItem([
                    self.pcs.basename(meta['path']),
                    eqt.Cell(meta['size'], fmt_size(meta['size']))
                ], meta)
                self.match_md5s.add(meta['md5'])
                items.append(item)
        self.items.extend(items)
        self.ui.tree.addTopLevelItems(items)
        self.update_count()
Beispiel #2
0
    def load(self, vfs, path=None):
        self.path_d = {}
        old_path = path and [path] or self.current_path_stack()

        self.tree.clear()
        root_item = eqt.SortableTreeItem([u'网盘', fmt_size(vfs.root.size)],
                                         vfs.root)
        root_item._path = '/'
        self.path_d['/'] = root_item

        def fillin_nodes(wgtitem, fsnode):
            for f in fsnode.sorted_subnodes:
                if not f.meta['isdir'] and self.marks.get(f.meta['md5']):
                    fname = u'[★]' + f.name
                else:
                    fname = f.name
                item = eqt.SortableTreeItem([fname, fmt_size(f.size)],
                                            f)
                item._path = f.meta.get('path')
                self.path_d[item._path] = item
                wgtitem.addChild(item)
                if vfs.isdir(f):
                    fillin_nodes(item, f)

        fillin_nodes(root_item, vfs.root)
        self.tree.addTopLevelItem(root_item)
        self.focus_path_stack(old_path)
Beispiel #3
0
 def fillin_nodes(wgtitem, fsnode):
     for f in fsnode.sorted_subnodes:
         if not f.meta['isdir'] and self.marks.get(f.meta['md5']):
             fname = u'[★]' + f.name
         else:
             fname = f.name
         item = eqt.SortableTreeItem([fname, fmt_size(f.size)],
                                     f)
         item._path = f.meta.get('path')
         self.path_d[item._path] = item
         wgtitem.addChild(item)
         if vfs.isdir(f):
             fillin_nodes(item, f)
Beispiel #4
0
 def load_pcs_nodes(self, nodes):
     groups = find_red(nodes)
     total, red = get_size(groups)
     self.ui.lblStatus.setText(u'共%s重复文件,去重可节省%s' %
                               (fmt_size(total), fmt_size(red)))
     sizesum = lambda g: sum([f['size'] for f in g])
     groups.sort(lambda a, b: cmp(sizesum(a), sizesum(b)), reverse=True)
     self.ui.treeDir.clear()
     self.path_d = {}
     self.groups = []
     for g in groups:
         f = g[0]
         diritem = eqt.SortableTreeItem([self.pcs.basename(f['path'])])
         grp = []
         self.groups.append(grp)
         for f in g:
             item = eqt.SortableTreeItem([f['path']], f)
             item.setCheckState(0, QtCore.Qt.Unchecked)
             self.path_d[f['path']] = item
             diritem.addChild(item)
             grp.append((f, item))
         self.ui.treeDir.addTopLevelItem(diritem)
         diritem.setExpanded(True)
Beispiel #5
0
    def reload(self):
        self.ui.tree.clear()
        self.match_md5s = set()
        items = []

        for meta in self.pcs.cache.itervalues():
            if not meta['isdir'] and self.match(meta):
                item = eqt.SortableTreeItem([
                    self.pcs.basename(meta['path']),
                    eqt.Cell(meta['size'], fmt_size(meta['size']))
                ], meta)
                self.match_md5s.add(meta['md5'])
                items.append(item)
        self.items = items
        self.ui.tree.addTopLevelItems(items)
        self.update_count()