26 #include <QStandardItemModel> 46 QModelIndex index = currentIndex();
48 if (!index.isValid()) {
49 QTreeView::startDrag(supportedActions);
53 if (QStandardItemModel *qsim = static_cast<QStandardItemModel *>(model())) {
62 QTreeView::startDrag(supportedActions);
72 if (!location.
exist())
75 QDrag *drag =
new QDrag(
this);
77 QString location_str = location.
toString();
78 QMimeData *mime_data =
new QMimeData();
79 mime_data->setText(location_str);
83 mime_data->setData(
"application/x-qet-category-uri", location_str.toLatin1());
88 mime_data->setData(
"application/x-qet-element-uri", location_str.toLatin1());
91 int elmt_creation_state;
93 if (elmt_creation_state)
99 QPixmap elmt_pixmap(temp_elmt->
pixmap());
100 QPoint elmt_hotspot(temp_elmt->
hotspot());
103 QPoint elmt_pixmap_size(elmt_pixmap.width(), elmt_pixmap.height());
107 elmt_hotspot = QPoint(
108 elmt_hotspot.x() * elmt_pixmap.width() / elmt_pixmap_size.x(),
109 elmt_hotspot.y() * elmt_pixmap.height() / elmt_pixmap_size.y()
113 drag->setPixmap(elmt_pixmap);
114 drag->setHotSpot(elmt_hotspot);
120 drag->setMimeData(mime_data);
121 drag->exec(Qt::CopyAction);
The ElementCollectionItem class This class represent a item (a directory or an element) in a element ...
static int MAX_DND_PIXMAP_WIDTH
static int MAX_DND_PIXMAP_HEIGHT
QPixmap pixmap()
Element::pixmap.
Element * createElement(const ElementsLocation &, QGraphicsItem *=nullptr, int *=nullptr)
ElementFactory::createElement.
ElementsTreeView(QWidget *parent=nullptr)
ElementsTreeView::ElementsTreeView.
virtual void startElementDrag(const ElementsLocation &location)
ElementsTreeView::startElementDrag Build a QDrag according to the content of .
bool exist() const
ElementsLocation::exist.
bool isDirectory() const
ElementsLocation::isDirectory.
bool isElement() const
ElementsLocation::isElement.
void startDrag(Qt::DropActions supportedActions) override
ElementsTreeView::startDrag Reimplemented from QTreeView.
static ElementFactory * Instance()