Skip to content

Commit

Permalink
Fix build deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zjeffer authored and guihkx committed Oct 25, 2024
1 parent ac1ef05 commit b824ab5
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 120 deletions.
28 changes: 14 additions & 14 deletions src/dbmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void DBManager::recalculateChildNotesCount()
qDebug() << __FUNCTION__ << __LINE__ << query.lastError();
}
query.clear();
for (const auto &id : qAsConst(tagIds)) {
for (const auto &id : std::as_const(tagIds)) {
query.prepare("SELECT count(*) FROM tag_relationship WHERE tag_id=:id");
query.bindValue(QStringLiteral(":id"), id);
status = query.exec();
Expand Down Expand Up @@ -925,7 +925,7 @@ QList<NodeData> DBManager::readOldNBK(const QString &fileName)
// notified
}
if (!nl.isEmpty()) {
for (const auto &n : qAsConst(nl)) {
for (const auto &n : std::as_const(nl)) {
noteList.append(*n);
}
}
Expand Down Expand Up @@ -1175,14 +1175,14 @@ void DBManager::moveNode(int nodeId, const NodeData &target)
&& target.id() == SpecialNodeID::TrashFolder) {
decreaseChildNotesCountFolder(SpecialNodeID::RootFolder);
auto allTagInNote = getAllTagForNote(node.id());
for (const auto &tagId : qAsConst(allTagInNote)) {
for (const auto &tagId : std::as_const(allTagInNote)) {
decreaseChildNotesCountTag(tagId);
}
} else if (node.parentId() == SpecialNodeID::TrashFolder
&& target.id() != SpecialNodeID::TrashFolder) {
increaseChildNotesCountFolder(SpecialNodeID::RootFolder);
auto allTagInNote = getAllTagForNote(node.id());
for (const auto &tagId : qAsConst(allTagInNote)) {
for (const auto &tagId : std::as_const(allTagInNote)) {
increaseChildNotesCountTag(tagId);
}
}
Expand Down Expand Up @@ -1325,7 +1325,7 @@ void DBManager::searchForNotes(const QString &keyword, const ListViewInfo &inf)
nds_id = i;
}
}
for (const int id : qAsConst(nds[nds_id])) {
for (const int id : std::as_const(nds[nds_id])) {
bool ok = true;
for (int i = 0; i < nds.size(); ++i) {
if (i == nds_id) {
Expand Down Expand Up @@ -1680,7 +1680,7 @@ void DBManager::onNotesListInTagsRequested(const QSet<int> &tagIds, bool newNote
nds_id = i;
}
}
for (const int id : qAsConst(nds[nds_id])) {
for (const int id : std::as_const(nds[nds_id])) {
bool ok = true;
for (int i = 0; i < nds.size(); ++i) {
if (i == nds_id) {
Expand Down Expand Up @@ -1784,7 +1784,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
out_qr.finish();
std::sort(tagList.begin(), tagList.end(),
[](auto a, auto b) { return a.relativePosition() < b.relativePosition(); });
for (const auto &tag : qAsConst(tagList)) {
for (const auto &tag : std::as_const(tagList)) {
QSqlQuery qr(m_db);
qr.prepare(R"(SELECT "id" FROM tag_table WHERE name = :name AND color = :color;)");
qr.bindValue(QStringLiteral(":name"), tag.name());
Expand Down Expand Up @@ -1877,7 +1877,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
}
} else {
auto prL = NodePath(node.absolutePath()).separate();
for (const auto &pr : qAsConst(prL)) {
for (const auto &pr : std::as_const(prL)) {
matchFolderFunctor(pr.toInt(), matchFolderFunctor);
}
}
Expand All @@ -1891,7 +1891,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
};
Folder *rootFolder = nullptr;
QHash<int, Folder> needImportFolderMap;
for (const auto &node : qAsConst(nodeList)) {
for (const auto &node : std::as_const(nodeList)) {
Folder f;
f.id = node.id();
f.parentId = node.parentId();
Expand All @@ -1901,7 +1901,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
}
}
if (rootFolder) {
for (const auto &folder : qAsConst(needImportFolderMap)) {
for (const auto &folder : std::as_const(needImportFolderMap)) {
if (folder.id != SpecialNodeID::RootFolder) {
needImportFolderMap[folder.parentId].children.push_back(
&needImportFolderMap[folder.id]);
Expand Down Expand Up @@ -1930,7 +1930,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
matchFunc(rootFolder, matchFunc);
} else {
qDebug() << __FUNCTION__ << "Error while keeping folder position";
for (const auto &node : qAsConst(nodeList)) {
for (const auto &node : std::as_const(nodeList)) {
matchFolderFunc(node.id(), matchFolderFunc);
}
}
Expand Down Expand Up @@ -1960,7 +1960,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
bool status = out_qr.exec();
QVector<NodeData> nodeList;
QMap<int, std::pair<NodeData, int>> parents;
for (const auto &id : qAsConst(folderIdMap)) {
for (const auto &id : std::as_const(folderIdMap)) {
if (parents.contains(id)) {
continue;
}
Expand Down Expand Up @@ -1993,7 +1993,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
}
m_db.transaction();
auto nodeId = nextAvailableNodeId();
for (auto node : qAsConst(nodeList)) {
for (auto node : std::as_const(nodeList)) {
if (folderIdMap.contains(node.parentId())
&& parents.contains(folderIdMap[node.parentId()])) {
auto parentId = folderIdMap[node.parentId()];
Expand Down Expand Up @@ -2035,7 +2035,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
std::make_pair(out_qr.value(0).toInt(), out_qr.value(1).toInt()));
}
m_db.transaction();
for (const auto &rel : qAsConst(tagRela)) {
for (const auto &rel : std::as_const(tagRela)) {
if (tagIdMap.contains(rel.first) && noteIdMap.contains(rel.second)) {
addNoteToTag(noteIdMap[rel.second], tagIdMap[rel.first]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/foldertreedelegateeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void FolderTreeDelegateEditor::paintEvent(QPaintEvent *event)

void FolderTreeDelegateEditor::mouseDoubleClickEvent(QMouseEvent *event)
{
if (m_label->geometry().contains(event->pos())) {
if (m_label->geometry().contains(event->position().toPoint())) {
m_label->openEditor();
} else {
QWidget::mouseDoubleClickEvent(event);
Expand Down
24 changes: 12 additions & 12 deletions src/listviewlogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static bool isInvalidCurrentNotesId(const QSet<int> &currentNotesId)
return true;
}
bool isInvalid = true;
for (const auto &id : qAsConst(currentNotesId)) {
for (const auto &id : std::as_const(currentNotesId)) {
if (id != SpecialNodeID::InvalidNodeId) {
isInvalid = false;
}
Expand Down Expand Up @@ -179,7 +179,7 @@ void ListViewLogic::setNoteData(const NodeData &note)
m_listModel->setItemData(noteIndex, dataValue);
if (wasTemp) {
auto tagIds = noteIndex.data(NoteListModel::NoteTagsList).value<QSet<int>>();
for (const auto tagId : qAsConst(tagIds)) {
for (const auto tagId : std::as_const(tagIds)) {
emit requestAddTagDb(note.id(), tagId);
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ void ListViewLogic::onSearchEditTextChanged(const QString &keyword)
if (!m_listViewInfo.isInSearch) {
auto indexes = m_listView->selectedIndex();
m_listViewInfo.currentNotesId.clear();
for (const auto &index : qAsConst(indexes)) {
for (const auto &index : std::as_const(indexes)) {
if (index.isValid()) {
m_listViewInfo.currentNotesId.insert(index.data(NoteListModel::NoteID).toInt());
}
Expand Down Expand Up @@ -334,7 +334,7 @@ void ListViewLogic::loadNoteListModel(const QVector<NodeData> &noteList, const L
}
if (!currentNotesId.isEmpty()) {
QModelIndexList indexes;
for (const auto &id : qAsConst(currentNotesId)) {
for (const auto &id : std::as_const(currentNotesId)) {
if (id != SpecialNodeID::InvalidNodeId) {
indexes.append(m_listModel->getNoteIndex(id));
}
Expand All @@ -349,7 +349,7 @@ void ListViewLogic::loadNoteListModel(const QVector<NodeData> &noteList, const L
m_needLoadSavedState -= 1;
if (!m_lastSelectedNotes.isEmpty()) {
QModelIndexList indexes;
for (const auto &id : qAsConst(m_lastSelectedNotes)) {
for (const auto &id : std::as_const(m_lastSelectedNotes)) {
if (id != SpecialNodeID::InvalidNodeId) {
indexes.append(m_listModel->getNoteIndex(id));
}
Expand Down Expand Up @@ -419,7 +419,7 @@ void ListViewLogic::setLastSelectedNote()
{
auto indexes = m_listView->selectedIndex();
QSet<int> ids;
for (const auto &index : qAsConst(indexes)) {
for (const auto &index : std::as_const(indexes)) {
if (index.isValid()) {
ids.insert(index.data(NoteListModel::NoteID).toInt());
}
Expand Down Expand Up @@ -470,7 +470,7 @@ void ListViewLogic::selectNotes(const QModelIndexList &indexes)
m_listView->clearSelection();
m_listView->setSelectionMode(QAbstractItemView::MultiSelection);
QModelIndex lastIdx;
for (const auto index : qAsConst(indexes)) {
for (const auto index : std::as_const(indexes)) {
if (index.isValid()) {
lastIdx = index;
m_listView->selectionModel()->select(index, QItemSelectionModel::Select);
Expand Down Expand Up @@ -533,7 +533,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
bool isInTrash = false;
QVector<NodeData> needDelete;
QModelIndexList needDeleteI;
for (const auto &index : qAsConst(indexes)) {
for (const auto &index : std::as_const(indexes)) {
if (index.isValid()) {
auto id = index.data(NoteListModel::NoteID).toInt();
NodeData note;
Expand Down Expand Up @@ -561,7 +561,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
if (needClose) {
emit closeNoteEditor();
}
for (const auto &note : qAsConst(needDelete)) {
for (const auto &note : std::as_const(needDelete)) {
emit requestRemoveNoteDb(note);
}
}
Expand All @@ -575,7 +575,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
if (needClose) {
emit closeNoteEditor();
}
for (const auto &note : qAsConst(needDelete)) {
for (const auto &note : std::as_const(needDelete)) {
emit requestRemoveNoteDb(note);
}
}
Expand All @@ -586,7 +586,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes)
{
QModelIndexList needRestoredI;
QSet<int> needRestored;
for (const auto &index : qAsConst(indexes)) {
for (const auto &index : std::as_const(indexes)) {
if (index.isValid()) {
auto id = index.data(NoteListModel::NoteID).toInt();
NodeData note;
Expand All @@ -612,7 +612,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes)
QMetaObject::invokeMethod(m_dbManager, "getNode", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(NodeData, defaultNotesFolder),
Q_ARG(int, SpecialNodeID::DefaultNotesFolder));
for (const auto &id : qAsConst(needRestored)) {
for (const auto &id : std::as_const(needRestored)) {
emit requestMoveNoteDb(id, defaultNotesFolder);
}
}
Expand Down
Loading

0 comments on commit b824ab5

Please sign in to comment.