Debian Codegraph @

src/Gui/PreferencePages/ListWidgetDragBugFix.h

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 #ifndef QLISTWIDGETDRAGBUGFIX_HPP
26 #define QLISTWIDGETDRAGBUGFIX_HPP
27
28 #include <QDragMoveEvent>
29 #include <QListWidget>
30
31 /* Qt has a recent bug (2023, https://bugreports.qt.io/browse/QTBUG-100128)
32 * where the items disappears in certain conditions when drag and dropping.
33 * Here we prevent the situation where this happens.
34 * 1 - If the item is dropped on the item below such that the item doesn't move (ie superior half of
35 * the below item) 2 - The item is the last one and user drop it on the empty space below. In both
36 * those cases the item widget was lost. When Qt solve this bug, this class should not be required
37 * anymore.
38 */
39 class ListWidgetDragBugFix: public QListWidget
40 {
41 Q_OBJECT
42
43 public:
44 explicit ListWidgetDragBugFix(QWidget* parent);
45 ~ListWidgetDragBugFix() override;
46
47 protected:
48 void dragMoveEvent(QDragMoveEvent* e) override;
49 };
50
51 #endif