FreeCAD

Форк
0
/
ListWidgetDragBugFix.cpp 
55 строк · 2.4 Кб
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2

3
 /****************************************************************************
4
  *   Copyright (c) 2023 Boyer Pierre-louis <pierrelouis.boyer@gmail.com>    *
5
  *   Copyright (c) 2023 FreeCAD Project Association                         *
6
  *                                                                          *
7
  *   This file is part of FreeCAD.                                          *
8
  *                                                                          *
9
  *   FreeCAD is free software: you can redistribute it and/or modify it     *
10
  *   under the terms of the GNU Lesser General Public License as            *
11
  *   published by the Free Software Foundation, either version 2.1 of the   *
12
  *   License, or (at your option) any later version.                        *
13
  *                                                                          *
14
  *   FreeCAD is distributed in the hope that it will be useful, but         *
15
  *   WITHOUT ANY WARRANTY; without even the implied warranty of             *
16
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU       *
17
  *   Lesser General Public License for more details.                        *
18
  *                                                                          *
19
  *   You should have received a copy of the GNU Lesser General Public       *
20
  *   License along with FreeCAD. If not, see                                *
21
  *   <https://www.gnu.org/licenses/>.                                       *
22
  *                                                                          *
23
  ***************************************************************************/
24

25
#include "PreCompiled.h"
26
#ifndef _PreComp_
27
# include <QDragMoveEvent>
28
#endif
29

30
#include "ListWidgetDragBugFix.h"
31

32

33
ListWidgetDragBugFix::ListWidgetDragBugFix(QWidget * parent)
34
  : QListWidget(parent)
35
{
36
}
37

38
ListWidgetDragBugFix::~ListWidgetDragBugFix() = default;
39

40
void ListWidgetDragBugFix::dragMoveEvent(QDragMoveEvent *event)
41
{
42
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
43
    QPoint pos = event->pos();
44
#else
45
    QPoint pos = event->position().toPoint();
46
#endif
47
    if ((row(itemAt(pos)) == currentRow() + 1)
48
        || (currentRow() == count() - 1 && row(itemAt(pos)) == -1)) {
49
        event->ignore();
50
        return;
51
    }
52
    QListWidget::dragMoveEvent(event);
53
}
54

55
#include "moc_ListWidgetDragBugFix.cpp"
56

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.