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

Method rename

YACReaderLibrary/db/reading_list_model.cpp:488–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488void ReadingListModel::rename(const QModelIndex &mi, const QString &name)
489{
490 if (!isEditable(mi))
491 return;
492 QString connectionName = "";
493 {
494 QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
495
496 auto item = static_cast<ListItem *>(mi.internalPointer());
497
498 if (typeid(*item) == typeid(ReadingListItem)) {
499 auto rli = static_cast<ReadingListItem *>(item);
500 rli->setName(name);
501 DBHelper::renameList(item->getId(), name, db);
502
503 if (rli->parent->getId() != 0) {
504 // TODO
505 // move row depending on the name
506 } else
507 emit dataChanged(index(mi.row(), 0), index(mi.row(), 0));
508 } else if (typeid(*item) == typeid(LabelItem)) {
509 auto li = static_cast<LabelItem *>(item);
510 li->setName(name);
511 DBHelper::renameLabel(item->getId(), name, db);
512 emit dataChanged(index(mi.row(), 0), index(mi.row(), 0));
513 }
514 connectionName = db.connectionName();
515 }
516 QSqlDatabase::removeDatabase(connectionName);
517}
518
519void ReadingListModel::deleteItem(const QModelIndex &mi)
520{

Callers

nothing calls this directly

Calls 3

setNameMethod · 0.45
getIdMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected