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

Method deleteItem

YACReaderLibrary/db/reading_list_model.cpp:519–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void ReadingListModel::deleteItem(const QModelIndex &mi)
520{
521 if (isEditable(mi)) {
522 QLOG_DEBUG() << "parent row :" << mi.parent().data() << "-" << mi.row();
523 beginRemoveRows(mi.parent(), mi.row(), mi.row());
524 QString connectionName = "";
525 {
526 QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
527
528 auto item = static_cast<ListItem *>(mi.internalPointer());
529
530 if (typeid(*item) == typeid(ReadingListItem)) {
531 auto rli = static_cast<ReadingListItem *>(item);
532 QLOG_DEBUG() << "num children : " << rli->parent->childCount();
533 rli->parent->removeChild(rli);
534 QLOG_DEBUG() << "num children : " << rli->parent->childCount();
535 DBHelper::removeListFromDB(item->getId(), db);
536 if (rli->parent->getId() != 0) {
537 reorderingChildren(rli->parent->children());
538 }
539 QLOG_DEBUG() << "num children : " << rli->parent->childCount();
540 } else if (typeid(*item) == typeid(LabelItem)) {
541 auto li = static_cast<LabelItem *>(item);
542 labels.removeOne(li);
543 DBHelper::removeLabelFromDB(item->getId(), db);
544 }
545 connectionName = db.connectionName();
546 }
547 QSqlDatabase::removeDatabase(connectionName);
548
549 endRemoveRows();
550 }
551}
552
553const QList<LabelItem *> ReadingListModel::getLabels()
554{

Callers 1

Calls 7

dataMethod · 0.45
parentMethod · 0.45
rowMethod · 0.45
childCountMethod · 0.45
removeChildMethod · 0.45
getIdMethod · 0.45
childrenMethod · 0.45

Tested by

no test coverage detected