2022-05-23 06:48:13 +00:00
|
|
|
//
|
|
|
|
// 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) {
|
2022-05-23 06:48:13 +00:00
|
|
|
setDragDropMode(DragOnly);
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeData *LibraryList::mimeData(const QList<QListWidgetItem *> items) const {
|
2022-05-27 06:18:17 +00:00
|
|
|
for (auto qItem: items) {
|
2022-05-23 06:48:13 +00:00
|
|
|
// 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();
|
2022-05-23 06:48:13 +00:00
|
|
|
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) {
|
2022-05-23 06:48:13 +00:00
|
|
|
setText(QString::fromStdString(title));
|
|
|
|
}
|
2022-06-09 18:24:27 +00:00
|
|
|
} // display
|