Exemplo n.º 1
0
 def move(self, row, col):
     if self.col != col or self.row != row:
         with updateLocker(self.parent):
             items = self.getItemsToMove(col)
             maxRow = self.parent.reflow()
             row = min(row, maxRow)
             self.parent.insertItems(row, col, items, select=True)
         return True
     else:
         return False
Exemplo n.º 2
0
    def move(self, row, col):
        if self.col != col or self.row != row:
            with updateLocker(self.parent):
                if self.col is not None:
                    self.parent.removeItem(self.row, self.col)
                    row = min(row, self.parent.GetItemCount())

                self.parent.insertItem(row, col, self.newItem, select=True)
                self.col = col
                self.row = row
Exemplo n.º 3
0
    def apply(self, row, col, paths):
        with updateLocker(self.parent):
            if self.col is not None:
                self.parent.removeItem(self.row, self.col)
                row = min(row, self.parent.GetItemCount())

            # CallAfter because we don't wan't to block drop source
            wx.CallAfter(self.parent.addFiles, paths, row=row, col=col)

            self.col = None
            self.row = None
Exemplo n.º 4
0
    def onMenuStreamSelClick(self, event, cell=None):
        cell = cell or self.getFirstSelected(0, 1)
        col = [SubFile.types, RefFile.types].index(cell.item.types)
        cells = list(self.iterSelected(col))
        self.clearSelection((col + 1) % 2, 2)

        items = [c.item for c in cells]
        dlg = StreamSelectionWin(self, items, cell.item.types)
        if dlg.ShowModal() == wx.ID_OK:
            with updateLocker(self):
                for c, selection in zip(cells, dlg.getSelection()):
                    if selection != None:
                        c.item.select(selection)
                        c.setState(c.item, selected=True, force=True)
                self.updateOutputs()
Exemplo n.º 5
0
    def addFiles(self, paths, skipMissing=False, row=None, col=None):
        if isinstance(self.GetDropTarget(), DropInternal):
            # files are dragged from inside so we are removing them to avoid duplication
            self.removeSelected()

        type = RefFile
        if col == 0:
            type = SubFile
        items = self.loadFiles(paths, type, skipMissing=skipMissing)

        subs, refs = [], []
        if col == 0:
            subs = items
        elif col == 1:
            refs = items
        else:
            subs = sorted(
                [item for item in items if item.filetype == 'subtitle/text'])
            refs = sorted(
                [item for item in items if item.filetype != 'subtitle/text'])

        with updateLocker(self):
            self.clearSelection()

            if row is None:
                row = self.GetItemCount()
                for r in reversed(range(self.GetItemCount())):
                    if subs and self.GetItemWindow(r, 0).item is not None:
                        break
                    if refs and self.GetItemWindow(r, 1).item is not None:
                        break
                    row = r

            if subs:
                self.insertItems(row, 0, subs, select=True)
            if refs:
                self.insertItems(row, 1, refs, select=True)

            self.updateOutputs()
            self.EnsureVisible(row)