File indexing completed on 2024-07-07 07:09:16

0001 /*
0002     SPDX-FileCopyrightText: 2005 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QListWidget>
0010 
0011 class QDragEnterEvent;
0012 class QDropEvent;
0013 class QMouseEvent;
0014 
0015 /**
0016  * @class DragListBox
0017  * @short Extension of KListWidget that allows Drag-and-Drop with other DragListBoxes
0018  *
0019  * @author Jason Harris
0020  * @version 1.0
0021  */
0022 class DragListBox : public QListWidget
0023 {
0024     Q_OBJECT
0025   public:
0026     explicit DragListBox(QWidget *parent = nullptr, const char *name = nullptr);
0027 
0028     int ignoreIndex() const { return IgnoreIndex; }
0029     bool contains(const QString &s) const;
0030 
0031     void dragEnterEvent(QDragEnterEvent *evt) override;
0032     void dragMoveEvent(QDragMoveEvent *evt) override;
0033     void dropEvent(QDropEvent *evt) override;
0034     void mousePressEvent(QMouseEvent *evt) override;
0035     void mouseMoveEvent(QMouseEvent *) override;
0036     void mouseReleaseEvent(QMouseEvent *) override;
0037 
0038   private:
0039     bool leftButtonDown { false };
0040     int IgnoreIndex { 0 };
0041 };