swift
dropsite.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_DROPSITE_H
7 #define SWIFT_GUI_DROPSITE_H
8 
9 #include <QLabel>
10 #include <QList>
11 #include <QObject>
12 #include <QString>
13 
14 #include "gui/dropbase.h"
15 #include "gui/swiftguiexport.h"
16 #include "misc/variant.h"
17 
18 class QDragEnterEvent;
19 class QDragLeaveEvent;
20 class QDragMoveEvent;
21 class QDropEvent;
22 class QPaintEvent;
23 class QWidget;
24 
25 namespace swift::gui
26 {
31  class SWIFT_GUI_EXPORT CDropSite : public QLabel, public CDropBase
32  {
33  Q_OBJECT
34 
35  public:
37  CDropSite(QWidget *parent = nullptr);
38 
40  void setInfoText(const QString &dropSiteText);
41 
43  void allowDrop(bool allowed) override;
44 
45  signals:
47  void droppedValueObject(const swift::misc::CVariant &droppedObject);
48 
49  protected:
51  virtual void dragEnterEvent(QDragEnterEvent *event) override;
52 
54  virtual void dragMoveEvent(QDragMoveEvent *event) override;
55 
57  virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
58 
60  virtual void dropEvent(QDropEvent *event) override;
61 
62  private:
64  void onStyleSheetsChanged();
65 
67  void resetText();
68 
69  QString m_infoText;
70  bool m_allowDrop = true;
71  QList<int> m_acceptedMetaTypes;
72  };
73 } // namespace swift::gui
74 
75 #endif // SWIFT_GUI_DROPSITE_H
Utilities for dropping swift value objects.
Definition: dropbase.h:19
Area where items can be dropped.
Definition: dropsite.h:32
void droppedValueObject(const swift::misc::CVariant &droppedObject)
Dropped value object.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition: variant.h:66
GUI related classes.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.