Debian Codegraph @

src/Gui/PreferencePages/ListWidgetDragBugFix.cpp

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /****************************************************************************
4 * Copyright (c) 2023 Boyer Pierre-louis <[email protected]> *
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
26 #include <QDragMoveEvent>
27
28
29 #include "ListWidgetDragBugFix.h"
30
31
32 ListWidgetDragBugFix::ListWidgetDragBugFix(QWidget* parent)
33 : QListWidget(parent)
34 {}
35
36 ListWidgetDragBugFix::~ListWidgetDragBugFix() = default;
37
38 void ListWidgetDragBugFix::dragMoveEvent(QDragMoveEvent* event)
39 {
40 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
41 QPoint pos = event->pos();
42 #else
43 QPoint pos = event->position().toPoint();
44 #endif
45 if ((row(itemAt(pos)) == currentRow() + 1)
46 || (currentRow() == count() - 1 && row(itemAt(pos)) == -1)) {
47 event->ignore();
48 return;
49 }
50 QListWidget::dragMoveEvent(event);
51 }
52
53 #include "moc_ListWidgetDragBugFix.cpp"