22 #include <QDataStream>
28 const std::string ExperimentalDataMimeType =
"darefl/ExperimentalDataMime";
47 result |= Qt::ItemIsDragEnabled;
49 result |= Qt::ItemIsDropEnabled;
59 auto result =
new QMimeData;
62 QStringList identifiers;
64 identifiers.append(QString::fromStdString(item->identifier()));
66 result->setData(QString::fromStdString(ExperimentalDataMimeType),
76 return Qt::TargetMoveAction;
83 return Qt::TargetMoveAction;
89 const QModelIndex& parent)
const
91 if (
data->hasFormat(QString::fromStdString(ExperimentalDataMimeType)))
99 const QModelIndex& parent)
106 int requested_row =
parent.isValid() ?
parent.row() : row;
111 for (
auto id : identifiers) {
114 int row = std::clamp(requested_row, 0, item->parent()->itemCount(item->tagRow().tag) - 1);
void moveItem(SessionItem *item, SessionItem *new_parent, const TagRow &tagrow)
Move item from it's current parent to a new parent under given tag and row.
SessionItem * findItem(const identifier_type &id)
Returns SessionItem for given identifier.
View model to show top level items of SessionModel in Qt trees and tables.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
QModelIndex parent(const QModelIndex &child) const override
SessionModel * sessionModel() const
SessionItem * sessionItemFromIndex(const QModelIndex &index) const
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Returns true if we can drop item here.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Qt::DropActions supportedDropActions() const override
Supported drop actions.
Qt::DropActions supportedDragActions() const override
Supported drag actions.
Qt::ItemFlags flags(const QModelIndex &index) const override
Return the Qt flags for given index. We allow GraphItem drag, they can be dropped on CanvasItem.
QMimeData * mimeData(const QModelIndexList &index_list) const override
Generate the mime data for all selected items.
The model to store imported reflectometry data.
const model_type GraphItemType
MVVM_VIEW_EXPORT QStringList deserialize(const QByteArray &byteArray)
Converts byte array to vector of strings.
MVVM_VIEW_EXPORT QByteArray serialize(const QStringList &data)
Converts vector of strings to byte array.
MVVM_VIEWMODEL_EXPORT std::vector< SessionItem * > UniqueItemsFromIndex(const QModelIndexList &index_list)
Returns vector of underlying SessionItem's for given index list. Removes repetitions.
materialitems.h Collection of materials to populate MaterialModel.
const std::string CanvasItemType
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.