6 #include <QDragEnterEvent>
7 #include <QDragLeaveEvent>
8 #include <QDragMoveEvent>
23 CDropSite::CDropSite(QWidget *parent) : QLabel(parent)
25 this->setFrameStyle(
static_cast<int>(QFrame::Sunken) | QFrame::StyledPanel);
26 this->setAlignment(Qt::AlignCenter);
27 this->setAcceptDrops(
true);
28 this->setTextFormat(Qt::RichText);
30 this->onStyleSheetsChanged();
32 Qt::QueuedConnection);
37 m_infoText = dropSiteText;
44 this->setEnabled(allowed);
45 this->setVisible(allowed);
48 void CDropSite::resetText()
50 const QString html =
"<img src=':/own/icons/own/drophere16.png'> " + m_infoText.toHtmlEscaped();
56 if (!event || !
acceptDrop(event->mimeData())) {
return; }
57 setBackgroundRole(QPalette::Highlight);
58 event->acceptProposedAction();
63 if (!event || !
acceptDrop(event->mimeData())) {
return; }
64 setBackgroundRole(QPalette::Highlight);
65 event->acceptProposedAction();
70 if (!event || !m_allowDrop) {
return; }
77 if (!event || !
acceptDrop(event->mimeData())) {
return; }
83 void CDropSite::onStyleSheetsChanged()
bool acceptDrop(const QMimeData *mime) const
Accept drop?
virtual void allowDrop(bool allowed)
Drop allowed.
swift::misc::CVariant toCVariant(const QMimeData *mime) const
Mime data to CVariant (normally encapsulating a value object)
void droppedValueObject(const swift::misc::CVariant &droppedObject)
Dropped value object.
virtual void dragEnterEvent(QDragEnterEvent *event)
void setInfoText(const QString &dropSiteText)
Set text for drop site.
virtual void dropEvent(QDropEvent *event)
void allowDrop(bool allowed)
Drop allowed.
virtual void dragLeaveEvent(QDragLeaveEvent *event)
virtual void dragMoveEvent(QDragMoveEvent *event)
void styleSheetsChanged()
Style sheet changed.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
bool isValid() const
True if this variant is valid.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Free functions in swift::misc.