schema_editor/comdel/display/library_list.cpp

32 lines
971 B
C++
Raw Normal View History

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