- added a secondary link in the bookmark manager

- fixed the bookmark manager order of bookmark links; first two links are always protected from deletion or drag-and-drop to other positions
This commit is contained in:
Marius Stanciu
2019-10-15 01:05:27 +03:00
committed by Marius
parent d43ec01cdd
commit dff5b262eb
4 changed files with 123 additions and 33 deletions

View File

@@ -1711,7 +1711,7 @@ class FCTable(QtWidgets.QTableWidget):
drag_drop_sig = pyqtSignal()
def __init__(self, drag_drop=False, parent=None):
def __init__(self, drag_drop=False, protected_rows=None, parent=None):
super(FCTable, self).__init__(parent)
if drag_drop:
@@ -1725,6 +1725,14 @@ class FCTable(QtWidgets.QTableWidget):
self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
self.rows_not_for_drag_and_drop = list()
if protected_rows:
try:
for r in protected_rows:
self.rows_not_for_drag_and_drop.append(r)
except TypeError:
self.rows_not_for_drag_and_drop = [protected_rows]
self.rows_to_move = list()
def sizeHint(self):
@@ -1843,6 +1851,12 @@ class FCTable(QtWidgets.QTableWidget):
"""
if event.source() == self:
rows = set([mi.row() for mi in self.selectedIndexes()])
# if one of the selected rows for drag and drop is within the protected list, return
for r in rows:
if r in self.rows_not_for_drag_and_drop:
return
targetRow = self.indexAt(event.pos()).row()
rows.discard(targetRow)
rows = sorted(rows)