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

Method canDropMimeData

YACReaderLibrary/db/reading_list_model.cpp:184–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184bool ReadingListModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
185{
186 Q_UNUSED(action);
187
188 QLOG_DEBUG() << "trying to drop into row = " << row << "column column = " << column << "parent" << parent;
189
190 if (row == -1)
191 return false;
192
193 if (!parent.isValid()) // top level items
194 {
195 if (row == -1) // no list
196 return false;
197
198 if (row == 1) // reading is just a smart list
199 return false;
200
201 if (row == 2) // recent is just a smart list
202 return false;
203
204 if (rowIsSeparator(row, parent))
205 return false;
206 }
207
208 if (data->formats().contains(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat))
209 return true;
210
211 if (rowIsReadingList(row, parent)) // TODO avoid droping in a different parent
212 {
213 if (!parent.isValid())
214 return false;
215 else {
216 QList<QPair<int, int>> sublistsRows;
217 QByteArray rawData = data->data(YACReader::YACReaderLibrarSubReadingListMimeDataFormat);
218 QDataStream in(&rawData, QIODevice::ReadOnly);
219 in >> sublistsRows; // deserialize the list of indentifiers
220
221 if (sublistsRows.isEmpty())
222 return false;
223
224 if (parent.row() != sublistsRows.at(0).second)
225 return false;
226
227 return data->formats().contains(YACReader::YACReaderLibrarSubReadingListMimeDataFormat);
228 }
229 }
230
231 return false;
232}
233
234bool ReadingListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
235{

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
isValidMethod · 0.45
containsMethod · 0.45
dataMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected