MCPcopy Create free account
hub / github.com/YACReader/yacreader / dropSublist

Method dropSublist

YACReaderLibrary/db/reading_list_model.cpp:288–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288bool 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
326QMimeData *ReadingListModel::mimeData(const QModelIndexList &indexes) const
327{

Callers

nothing calls this directly

Calls 7

dataMethod · 0.45
rowMethod · 0.45
parentMethod · 0.45
childMethod · 0.45
removeChildMethod · 0.45
appendChildMethod · 0.45
childrenMethod · 0.45

Tested by

no test coverage detected