Ejemplo n.º 1
0
    def dragMoveEvent(self, event: QDragMoveEvent):
        pos = event.pos()
        row = self.rowAt(pos.y())

        index = self.model().createIndex(row, 0)  # this always get the default 0 column index

        rect = self.visualRect(index)
        rect_left = self.visualRect(index.sibling(index.row(), 0))
        rect_right = self.visualRect(index.sibling(index.row(),
                                                   self.horizontalHeader().logicalIndex(
                                                       self.model().columnCount() - 1)))  # in case section has been moved

        self.drop_indicator_position = self.position(event.pos(), rect)

        if self.drop_indicator_position == self.AboveItem:
            self.drop_indicator_rect = QRect(rect_left.left(), rect_left.top(), rect_right.right() - rect_left.left(), 0)
            event.accept()
        elif self.drop_indicator_position == self.BelowItem:
            self.drop_indicator_rect = QRect(rect_left.left(), rect_left.bottom(), rect_right.right() - rect_left.left(),
                                             0)
            event.accept()
        elif self.drop_indicator_position == self.OnItem:
            self.drop_indicator_rect = QRect(rect_left.left(), rect_left.bottom(), rect_right.right() - rect_left.left(),
                                             0)
            event.accept()
        else:
            self.drop_indicator_rect = QRect()

        # This is necessary or else the previously drawn rect won't be erased
        self.viewport().update()
Ejemplo n.º 2
0
    def dragMoveEvent(self, event: QtGui.QDragMoveEvent) -> None:
        obj: TextWidget = event.source()
        modifier_pressed = QtWidgets.QApplication.keyboardModifiers()
        shift_pressed = (int(modifier_pressed)
                         & QtCore.Qt.ShiftModifier) == QtCore.Qt.ShiftModifier
        if self.manager.widget_manager.get_dor() == DRAG:

            obj.move(event.pos().x() - self.manager.widget_manager.drag_dot[0],
                     event.pos().y() - self.manager.widget_manager.drag_dot[1])

            x, y, _, _, x_mod, y_mod, widgets = self.manager.widget_manager.drag_magnet_checker(
                obj)
            if shift_pressed:
                if not x_mod:

                    x = x - (x - self.manager.grid_manager.zero_point_dot.get_pos()[0]) \
                        % (OFFSET_MAGNET * 2)

                if not y_mod:

                    y = y - (y - self.manager.grid_manager.zero_point_dot.get_pos()[1]) \
                        % (OFFSET_MAGNET * 2)

            x, y = max(x, 0), max(y, 0)
            if self.manager.grid_manager.grid.show:

                x, y, widgets = \
                    self.manager.grid_manager.check_and_set_grid_magnet_lines_for_resizing(
                         obj, x, y, x_mod, y_mod, widgets
                    )

            self.manager.widget_manager.set_coords_on_widgets(
                widgets, event, x, y)
            obj.move_event(x, y)
            obj.update_arrows()
        elif self.manager.widget_manager.get_dor() == RESIZE:

            obj_x1, obj_y1, obj_x2, obj_y2, x_mod, y_mod, widgets = \
                self.manager.widget_manager.resize_magnet_checker(obj, event.pos())

            x, y = obj_x2 - obj_x1, obj_y2 - obj_y1
            if shift_pressed:
                if not x_mod:
                    x = max(x - x % (OFFSET_MAGNET * 2), 0)
                if not y_mod:
                    y = max(y - y % (OFFSET_MAGNET * 2), 0)
            self.manager.widget_manager.set_coords_on_widgets(
                widgets, event, x, y)
            obj.resize_event(x, y)

        self.update()
Ejemplo n.º 3
0
 def dragMoveEvent(self, e: QDragMoveEvent):
     e.setDropAction(Qt.CopyAction)
     e.accept()
     if not self.hasFocus():
         self.update()
     self._mousePos = e.pos()
     self.startAnimation()
Ejemplo n.º 4
0
 def _drag_move_event(self, event: QDragMoveEvent):
     index = self.ui.dirTree.indexAt(event.pos())
     mime_data = event.mimeData()
     if mime_data.hasFormat(MimeTypes[real_folder]):
         if not self.ui.dirTree.model().is_virtual(index):
             event.ignore()
         else:
             event.accept()
     else:
         event.accept()
Ejemplo n.º 5
0
    def dragMoveEvent(self, event: QDragMoveEvent):
        if event.mimeData().hasText():
            self.curRow = 0
            index = self.indexAt(event.pos())
            if index.isValid():
                if event.pos().y(
                ) - index.row() * self.itemRowHeight >= self.itemRowHeight / 2:
                    self.curRow = index.row() + 1
                else:
                    self.curRow = index.row()
            else:
                self.curRow = self.model.rowCount()

            self.targetRow = self.curRow
            self.lineLabel.setGeometry(
                1, self.headerHeight + self.targetRow * self.itemRowHeight,
                self.width() - 2, 2)
            event.acceptProposedAction()
            return
        event.ignore()
        QTableView.dragMoveEvent(self, event)
Ejemplo n.º 6
0
    def dragMoveEvent(self, event: QDragMoveEvent):
        pos = event.pos()
        row = self.rowAt(pos.y())

        index = self.model().createIndex(
            row, 0)  # this always get the default 0 column index

        rect = self.visualRect(index)
        rect_left = self.visualRect(index.sibling(index.row(), 0))
        rect_right = self.visualRect(
            index.sibling(
                index.row(),
                self.horizontalHeader().logicalIndex(
                    self.model().columnCount() -
                    1)))  # in case section has been moved

        self.drop_indicator_position = self.position(event.pos(), rect)

        if self.drop_indicator_position == self.AboveItem:
            self.drop_indicator_rect = QRect(
                rect_left.left(), rect_left.top(),
                rect_right.right() - rect_left.left(), 0)
            event.accept()
        elif self.drop_indicator_position == self.BelowItem:
            self.drop_indicator_rect = QRect(
                rect_left.left(), rect_left.bottom(),
                rect_right.right() - rect_left.left(), 0)
            event.accept()
        elif self.drop_indicator_position == self.OnItem:
            self.drop_indicator_rect = QRect(
                rect_left.left(), rect_left.bottom(),
                rect_right.right() - rect_left.left(), 0)
            event.accept()
        else:
            self.drop_indicator_rect = QRect()

        # This is necessary or else the previously drawn rect won't be erased
        self.viewport().update()
Ejemplo n.º 7
0
 def dragMoveEvent(self, event: QDragMoveEvent):
     self.cleanDraggingEffects()
     loc = self.getDraggedLocation(event.pos())
     if loc == -1:
         palette = self.ui.line.palette()
         palette.setColor(QPalette.Dark, QColor(89, 173, 223))
         self.ui.line.setPalette(palette)
     else:
         self.ui.setStyleSheet("""
                 .QWidget {
                     border: 1px solid qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 blue,"""
                               """ stop:0.5 rgb(89, 173, 223), stop:1 red);
                 }
                 """)
Ejemplo n.º 8
0
 def dragMoveEvent(self, event: QDragMoveEvent):
     target = self.itemAt(event.pos())
     if isinstance(target, FolderWidgetItem):
         QTreeWidget.dragMoveEvent(self, event)
     else:
         event.ignore()
Ejemplo n.º 9
0
 def dragMoveEvent(self, event: QtGui.QDragMoveEvent) -> None:
     logger.debug("TreeListWidget.dragMoveEvent")
     if isinstance(self.itemAt(event.pos()), self.leafItem):
         event.ignore()
     else:
         event.accept()
Ejemplo n.º 10
0
 def dragMoveEvent(self, event: QtGui.QDragMoveEvent) -> None:
     if self.itemAt(event.pos()):
         event.accept()
     else:
         event.ignore()
Ejemplo n.º 11
0
 def dragMoveEvent(self, a0: QtGui.QDragMoveEvent) -> None:
     print(a0.pos())
Ejemplo n.º 12
0
 def dragMoveEvent(self, event: QDragMoveEvent):
     current_item = self.itemAt(event.pos())
     if not current_item or current_item.parent():
         event.ignore()
     else:
         super().dragMoveEvent(event)
Ejemplo n.º 13
0
 def dragMoveEvent(self, event: QDragMoveEvent):
     target = self.itemAt(event.pos())
     if isinstance(target, FolderWidgetItem):
         QTreeWidget.dragMoveEvent(self, event)
     else:
         event.ignore()