| 324 | } |
| 325 | |
| 326 | QMimeData *ReadingListModel::mimeData(const QModelIndexList &indexes) const |
| 327 | { |
| 328 | QLOG_DEBUG() << "mimeData requested" << indexes; |
| 329 | |
| 330 | if (indexes.length() == 0) { |
| 331 | QLOG_ERROR() << "mimeData requested: indexes is empty"; |
| 332 | return new QMimeData(); // TODO what happens if 0 is returned? |
| 333 | } |
| 334 | |
| 335 | if (indexes.length() > 1) { |
| 336 | QLOG_DEBUG() << "mimeData requested for more than one index, this shouldn't be possible"; |
| 337 | } |
| 338 | |
| 339 | QModelIndex modelIndex = indexes.at(0); |
| 340 | |
| 341 | QList<QPair<int, int>> rows; |
| 342 | rows << QPair<int, int>(modelIndex.row(), modelIndex.parent().row()); |
| 343 | QLOG_DEBUG() << "mimeData requested for row : " << modelIndex.row(); |
| 344 | |
| 345 | QByteArray data; |
| 346 | QDataStream out(&data, QIODevice::WriteOnly); |
| 347 | out << rows; // serialize the list of identifiers |
| 348 | |
| 349 | auto mimeData = new QMimeData(); |
| 350 | mimeData->setData(YACReader::YACReaderLibrarSubReadingListMimeDataFormat, data); |
| 351 | |
| 352 | return mimeData; |
| 353 | } |
| 354 | |
| 355 | void ReadingListModel::setupReadingListsData(QString path) |
| 356 | { |