schema_editor/comdel/display/library_list.cpp

31 lines
955 B
C++

//
// Created by bbr on 22.05.22..
//
#include "library_list.h"
#include <QMouseEvent>
#include <QDrag>
#include <QMimeData>
namespace display {
LibraryList::LibraryList(QWidget *parent): QListWidget(parent) {
setDragDropMode(DragOnly);
}
QMimeData *LibraryList::mimeData(const QList<QListWidgetItem *> items) const {
for(auto qItem: items) {
// we only allow one item to be dragged at a time
auto item = dynamic_cast<LibraryListItem*>(qItem);
auto* md = new QMimeData();
md->setData(QString::fromStdString(item->mimeType), QByteArray::fromStdString(item->value));
return md;
}
return nullptr;
}
LibraryListItem::LibraryListItem(std::string title, std::string mimeType, std::string value, QListWidget *parent): QListWidgetItem(parent), mimeType(mimeType), value(value) {
setText(QString::fromStdString(title));
}
} // display