| 286 | } |
| 287 | |
| 288 | bool ReadingListModel::dropSublist(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
| 289 | { |
| 290 | Q_UNUSED(action); |
| 291 | Q_UNUSED(column); |
| 292 | |
| 293 | QList<QPair<int, int>> sublistsRows; |
| 294 | QByteArray rawData = data->data(YACReader::YACReaderLibrarSubReadingListMimeDataFormat); |
| 295 | QDataStream in(&rawData, QIODevice::ReadOnly); |
| 296 | in >> sublistsRows; // deserialize the list of indentifiers |
| 297 | |
| 298 | QLOG_DEBUG() << "dropped : " << sublistsRows; |
| 299 | |
| 300 | int sourceRow = sublistsRows.at(0).first; |
| 301 | int destRow = row; |
| 302 | QModelIndex destParent = parent; |
| 303 | if (row == -1) { |
| 304 | QLOG_DEBUG() << "droping inside parent"; |
| 305 | destRow = parent.row(); |
| 306 | destParent = parent.parent(); |
| 307 | } |
| 308 | QLOG_DEBUG() << "move " << sourceRow << "-" << destRow; |
| 309 | |
| 310 | if (sourceRow == destRow) |
| 311 | return false; |
| 312 | |
| 313 | // beginMoveRows(destParent,sourceRow,sourceRow,destParent,destRow); |
| 314 | |
| 315 | auto parentItem = static_cast<ReadingListItem *>(destParent.internalPointer()); |
| 316 | ReadingListItem *child = parentItem->child(sourceRow); |
| 317 | parentItem->removeChild(child); |
| 318 | parentItem->appendChild(child, destRow); |
| 319 | |
| 320 | reorderingChildren(parentItem->children()); |
| 321 | // endMoveRows(); |
| 322 | |
| 323 | return true; |
| 324 | } |
| 325 | |
| 326 | QMimeData *ReadingListModel::mimeData(const QModelIndexList &indexes) const |
| 327 | { |
nothing calls this directly
no test coverage detected