Skip to content

Commit b824ab5

Browse files
zjefferguihkx
authored andcommitted
Fix build deprecation warnings
1 parent ac1ef05 commit b824ab5

13 files changed

+121
-120
lines changed

src/dbmanager.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ void DBManager::recalculateChildNotesCount()
408408
qDebug() << __FUNCTION__ << __LINE__ << query.lastError();
409409
}
410410
query.clear();
411-
for (const auto &id : qAsConst(tagIds)) {
411+
for (const auto &id : std::as_const(tagIds)) {
412412
query.prepare("SELECT count(*) FROM tag_relationship WHERE tag_id=:id");
413413
query.bindValue(QStringLiteral(":id"), id);
414414
status = query.exec();
@@ -925,7 +925,7 @@ QList<NodeData> DBManager::readOldNBK(const QString &fileName)
925925
// notified
926926
}
927927
if (!nl.isEmpty()) {
928-
for (const auto &n : qAsConst(nl)) {
928+
for (const auto &n : std::as_const(nl)) {
929929
noteList.append(*n);
930930
}
931931
}
@@ -1175,14 +1175,14 @@ void DBManager::moveNode(int nodeId, const NodeData &target)
11751175
&& target.id() == SpecialNodeID::TrashFolder) {
11761176
decreaseChildNotesCountFolder(SpecialNodeID::RootFolder);
11771177
auto allTagInNote = getAllTagForNote(node.id());
1178-
for (const auto &tagId : qAsConst(allTagInNote)) {
1178+
for (const auto &tagId : std::as_const(allTagInNote)) {
11791179
decreaseChildNotesCountTag(tagId);
11801180
}
11811181
} else if (node.parentId() == SpecialNodeID::TrashFolder
11821182
&& target.id() != SpecialNodeID::TrashFolder) {
11831183
increaseChildNotesCountFolder(SpecialNodeID::RootFolder);
11841184
auto allTagInNote = getAllTagForNote(node.id());
1185-
for (const auto &tagId : qAsConst(allTagInNote)) {
1185+
for (const auto &tagId : std::as_const(allTagInNote)) {
11861186
increaseChildNotesCountTag(tagId);
11871187
}
11881188
}
@@ -1325,7 +1325,7 @@ void DBManager::searchForNotes(const QString &keyword, const ListViewInfo &inf)
13251325
nds_id = i;
13261326
}
13271327
}
1328-
for (const int id : qAsConst(nds[nds_id])) {
1328+
for (const int id : std::as_const(nds[nds_id])) {
13291329
bool ok = true;
13301330
for (int i = 0; i < nds.size(); ++i) {
13311331
if (i == nds_id) {
@@ -1680,7 +1680,7 @@ void DBManager::onNotesListInTagsRequested(const QSet<int> &tagIds, bool newNote
16801680
nds_id = i;
16811681
}
16821682
}
1683-
for (const int id : qAsConst(nds[nds_id])) {
1683+
for (const int id : std::as_const(nds[nds_id])) {
16841684
bool ok = true;
16851685
for (int i = 0; i < nds.size(); ++i) {
16861686
if (i == nds_id) {
@@ -1784,7 +1784,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
17841784
out_qr.finish();
17851785
std::sort(tagList.begin(), tagList.end(),
17861786
[](auto a, auto b) { return a.relativePosition() < b.relativePosition(); });
1787-
for (const auto &tag : qAsConst(tagList)) {
1787+
for (const auto &tag : std::as_const(tagList)) {
17881788
QSqlQuery qr(m_db);
17891789
qr.prepare(R"(SELECT "id" FROM tag_table WHERE name = :name AND color = :color;)");
17901790
qr.bindValue(QStringLiteral(":name"), tag.name());
@@ -1877,7 +1877,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
18771877
}
18781878
} else {
18791879
auto prL = NodePath(node.absolutePath()).separate();
1880-
for (const auto &pr : qAsConst(prL)) {
1880+
for (const auto &pr : std::as_const(prL)) {
18811881
matchFolderFunctor(pr.toInt(), matchFolderFunctor);
18821882
}
18831883
}
@@ -1891,7 +1891,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
18911891
};
18921892
Folder *rootFolder = nullptr;
18931893
QHash<int, Folder> needImportFolderMap;
1894-
for (const auto &node : qAsConst(nodeList)) {
1894+
for (const auto &node : std::as_const(nodeList)) {
18951895
Folder f;
18961896
f.id = node.id();
18971897
f.parentId = node.parentId();
@@ -1901,7 +1901,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
19011901
}
19021902
}
19031903
if (rootFolder) {
1904-
for (const auto &folder : qAsConst(needImportFolderMap)) {
1904+
for (const auto &folder : std::as_const(needImportFolderMap)) {
19051905
if (folder.id != SpecialNodeID::RootFolder) {
19061906
needImportFolderMap[folder.parentId].children.push_back(
19071907
&needImportFolderMap[folder.id]);
@@ -1930,7 +1930,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
19301930
matchFunc(rootFolder, matchFunc);
19311931
} else {
19321932
qDebug() << __FUNCTION__ << "Error while keeping folder position";
1933-
for (const auto &node : qAsConst(nodeList)) {
1933+
for (const auto &node : std::as_const(nodeList)) {
19341934
matchFolderFunc(node.id(), matchFolderFunc);
19351935
}
19361936
}
@@ -1960,7 +1960,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
19601960
bool status = out_qr.exec();
19611961
QVector<NodeData> nodeList;
19621962
QMap<int, std::pair<NodeData, int>> parents;
1963-
for (const auto &id : qAsConst(folderIdMap)) {
1963+
for (const auto &id : std::as_const(folderIdMap)) {
19641964
if (parents.contains(id)) {
19651965
continue;
19661966
}
@@ -1993,7 +1993,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
19931993
}
19941994
m_db.transaction();
19951995
auto nodeId = nextAvailableNodeId();
1996-
for (auto node : qAsConst(nodeList)) {
1996+
for (auto node : std::as_const(nodeList)) {
19971997
if (folderIdMap.contains(node.parentId())
19981998
&& parents.contains(folderIdMap[node.parentId()])) {
19991999
auto parentId = folderIdMap[node.parentId()];
@@ -2035,7 +2035,7 @@ void DBManager::onImportNotesRequested(const QString &fileName)
20352035
std::make_pair(out_qr.value(0).toInt(), out_qr.value(1).toInt()));
20362036
}
20372037
m_db.transaction();
2038-
for (const auto &rel : qAsConst(tagRela)) {
2038+
for (const auto &rel : std::as_const(tagRela)) {
20392039
if (tagIdMap.contains(rel.first) && noteIdMap.contains(rel.second)) {
20402040
addNoteToTag(noteIdMap[rel.second], tagIdMap[rel.first]);
20412041
} else {

src/foldertreedelegateeditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void FolderTreeDelegateEditor::paintEvent(QPaintEvent *event)
221221

222222
void FolderTreeDelegateEditor::mouseDoubleClickEvent(QMouseEvent *event)
223223
{
224-
if (m_label->geometry().contains(event->pos())) {
224+
if (m_label->geometry().contains(event->position().toPoint())) {
225225
m_label->openEditor();
226226
} else {
227227
QWidget::mouseDoubleClickEvent(event);

src/listviewlogic.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static bool isInvalidCurrentNotesId(const QSet<int> &currentNotesId)
1616
return true;
1717
}
1818
bool isInvalid = true;
19-
for (const auto &id : qAsConst(currentNotesId)) {
19+
for (const auto &id : std::as_const(currentNotesId)) {
2020
if (id != SpecialNodeID::InvalidNodeId) {
2121
isInvalid = false;
2222
}
@@ -179,7 +179,7 @@ void ListViewLogic::setNoteData(const NodeData &note)
179179
m_listModel->setItemData(noteIndex, dataValue);
180180
if (wasTemp) {
181181
auto tagIds = noteIndex.data(NoteListModel::NoteTagsList).value<QSet<int>>();
182-
for (const auto tagId : qAsConst(tagIds)) {
182+
for (const auto tagId : std::as_const(tagIds)) {
183183
emit requestAddTagDb(note.id(), tagId);
184184
}
185185
}
@@ -276,7 +276,7 @@ void ListViewLogic::onSearchEditTextChanged(const QString &keyword)
276276
if (!m_listViewInfo.isInSearch) {
277277
auto indexes = m_listView->selectedIndex();
278278
m_listViewInfo.currentNotesId.clear();
279-
for (const auto &index : qAsConst(indexes)) {
279+
for (const auto &index : std::as_const(indexes)) {
280280
if (index.isValid()) {
281281
m_listViewInfo.currentNotesId.insert(index.data(NoteListModel::NoteID).toInt());
282282
}
@@ -334,7 +334,7 @@ void ListViewLogic::loadNoteListModel(const QVector<NodeData> &noteList, const L
334334
}
335335
if (!currentNotesId.isEmpty()) {
336336
QModelIndexList indexes;
337-
for (const auto &id : qAsConst(currentNotesId)) {
337+
for (const auto &id : std::as_const(currentNotesId)) {
338338
if (id != SpecialNodeID::InvalidNodeId) {
339339
indexes.append(m_listModel->getNoteIndex(id));
340340
}
@@ -349,7 +349,7 @@ void ListViewLogic::loadNoteListModel(const QVector<NodeData> &noteList, const L
349349
m_needLoadSavedState -= 1;
350350
if (!m_lastSelectedNotes.isEmpty()) {
351351
QModelIndexList indexes;
352-
for (const auto &id : qAsConst(m_lastSelectedNotes)) {
352+
for (const auto &id : std::as_const(m_lastSelectedNotes)) {
353353
if (id != SpecialNodeID::InvalidNodeId) {
354354
indexes.append(m_listModel->getNoteIndex(id));
355355
}
@@ -419,7 +419,7 @@ void ListViewLogic::setLastSelectedNote()
419419
{
420420
auto indexes = m_listView->selectedIndex();
421421
QSet<int> ids;
422-
for (const auto &index : qAsConst(indexes)) {
422+
for (const auto &index : std::as_const(indexes)) {
423423
if (index.isValid()) {
424424
ids.insert(index.data(NoteListModel::NoteID).toInt());
425425
}
@@ -470,7 +470,7 @@ void ListViewLogic::selectNotes(const QModelIndexList &indexes)
470470
m_listView->clearSelection();
471471
m_listView->setSelectionMode(QAbstractItemView::MultiSelection);
472472
QModelIndex lastIdx;
473-
for (const auto index : qAsConst(indexes)) {
473+
for (const auto index : std::as_const(indexes)) {
474474
if (index.isValid()) {
475475
lastIdx = index;
476476
m_listView->selectionModel()->select(index, QItemSelectionModel::Select);
@@ -533,7 +533,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
533533
bool isInTrash = false;
534534
QVector<NodeData> needDelete;
535535
QModelIndexList needDeleteI;
536-
for (const auto &index : qAsConst(indexes)) {
536+
for (const auto &index : std::as_const(indexes)) {
537537
if (index.isValid()) {
538538
auto id = index.data(NoteListModel::NoteID).toInt();
539539
NodeData note;
@@ -561,7 +561,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
561561
if (needClose) {
562562
emit closeNoteEditor();
563563
}
564-
for (const auto &note : qAsConst(needDelete)) {
564+
for (const auto &note : std::as_const(needDelete)) {
565565
emit requestRemoveNoteDb(note);
566566
}
567567
}
@@ -575,7 +575,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
575575
if (needClose) {
576576
emit closeNoteEditor();
577577
}
578-
for (const auto &note : qAsConst(needDelete)) {
578+
for (const auto &note : std::as_const(needDelete)) {
579579
emit requestRemoveNoteDb(note);
580580
}
581581
}
@@ -586,7 +586,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes)
586586
{
587587
QModelIndexList needRestoredI;
588588
QSet<int> needRestored;
589-
for (const auto &index : qAsConst(indexes)) {
589+
for (const auto &index : std::as_const(indexes)) {
590590
if (index.isValid()) {
591591
auto id = index.data(NoteListModel::NoteID).toInt();
592592
NodeData note;
@@ -612,7 +612,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes)
612612
QMetaObject::invokeMethod(m_dbManager, "getNode", Qt::BlockingQueuedConnection,
613613
Q_RETURN_ARG(NodeData, defaultNotesFolder),
614614
Q_ARG(int, SpecialNodeID::DefaultNotesFolder));
615-
for (const auto &id : qAsConst(needRestored)) {
615+
for (const auto &id : std::as_const(needRestored)) {
616616
emit requestMoveNoteDb(id, defaultNotesFolder);
617617
}
618618
}

0 commit comments

Comments
 (0)