From b824ab5ddbc7f9b48eec7661e2978ffa94507e40 Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:48:16 +0200 Subject: [PATCH] Fix build deprecation warnings --- src/dbmanager.cpp | 28 ++++++++--------- src/foldertreedelegateeditor.cpp | 2 +- src/listviewlogic.cpp | 24 +++++++------- src/mainwindow.cpp | 54 ++++++++++++++++---------------- src/nodetreemodel.cpp | 6 ++-- src/nodetreeview.cpp | 40 +++++++++++------------ src/notelistdelegate.cpp | 12 +++---- src/notelistmodel.cpp | 14 ++++----- src/notelistview.cpp | 40 +++++++++++------------ src/taglistmodel.cpp | 2 +- src/tagtreedelegateeditor.cpp | 4 +-- src/treeviewlogic.cpp | 2 +- src/updaterwindow.cpp | 13 ++++---- 13 files changed, 121 insertions(+), 120 deletions(-) diff --git a/src/dbmanager.cpp b/src/dbmanager.cpp index 8b32bc06c..6249ee8b8 100644 --- a/src/dbmanager.cpp +++ b/src/dbmanager.cpp @@ -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(); @@ -925,7 +925,7 @@ QList 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); } } @@ -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); } } @@ -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) { @@ -1680,7 +1680,7 @@ void DBManager::onNotesListInTagsRequested(const QSet &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) { @@ -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()); @@ -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); } } @@ -1891,7 +1891,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) }; Folder *rootFolder = nullptr; QHash 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(); @@ -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]); @@ -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); } } @@ -1960,7 +1960,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) bool status = out_qr.exec(); QVector nodeList; QMap> parents; - for (const auto &id : qAsConst(folderIdMap)) { + for (const auto &id : std::as_const(folderIdMap)) { if (parents.contains(id)) { continue; } @@ -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()]; @@ -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 { diff --git a/src/foldertreedelegateeditor.cpp b/src/foldertreedelegateeditor.cpp index 6e5aab28f..cff1d36c4 100644 --- a/src/foldertreedelegateeditor.cpp +++ b/src/foldertreedelegateeditor.cpp @@ -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); diff --git a/src/listviewlogic.cpp b/src/listviewlogic.cpp index 3b248c474..9fa437f78 100644 --- a/src/listviewlogic.cpp +++ b/src/listviewlogic.cpp @@ -16,7 +16,7 @@ static bool isInvalidCurrentNotesId(const QSet ¤tNotesId) 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; } @@ -179,7 +179,7 @@ void ListViewLogic::setNoteData(const NodeData ¬e) m_listModel->setItemData(noteIndex, dataValue); if (wasTemp) { auto tagIds = noteIndex.data(NoteListModel::NoteTagsList).value>(); - for (const auto tagId : qAsConst(tagIds)) { + for (const auto tagId : std::as_const(tagIds)) { emit requestAddTagDb(note.id(), tagId); } } @@ -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()); } @@ -334,7 +334,7 @@ void ListViewLogic::loadNoteListModel(const QVector ¬eList, 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)); } @@ -349,7 +349,7 @@ void ListViewLogic::loadNoteListModel(const QVector ¬eList, 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)); } @@ -419,7 +419,7 @@ void ListViewLogic::setLastSelectedNote() { auto indexes = m_listView->selectedIndex(); QSet 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()); } @@ -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); @@ -533,7 +533,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) bool isInTrash = false; QVector 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; @@ -561,7 +561,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) if (needClose) { emit closeNoteEditor(); } - for (const auto ¬e : qAsConst(needDelete)) { + for (const auto ¬e : std::as_const(needDelete)) { emit requestRemoveNoteDb(note); } } @@ -575,7 +575,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) if (needClose) { emit closeNoteEditor(); } - for (const auto ¬e : qAsConst(needDelete)) { + for (const auto ¬e : std::as_const(needDelete)) { emit requestRemoveNoteDb(note); } } @@ -586,7 +586,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes) { QModelIndexList needRestoredI; QSet 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; @@ -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); } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ca7e8a6d2..7c84be029 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1941,7 +1941,7 @@ void MainWindow::restoreStates() m_settingsDatabase->value(QStringLiteral("currentSelectTagsId"), QStringList{}) .toStringList(); QSet tags; - for (const auto &tagId : qAsConst(currentSelectTagsId)) { + for (const auto &tagId : std::as_const(currentSelectTagsId)) { tags.insert(tagId.toInt()); } m_treeViewLogic->setLastSavedState(isSelectingFolder, currentSelectFolder, tags, @@ -1950,7 +1950,7 @@ void MainWindow::restoreStates() m_settingsDatabase->value(QStringLiteral("currentSelectNotesId"), QStringList{}) .toStringList(); QSet notesId; - for (const auto &id : qAsConst(currentSelectNotes)) { + for (const auto &id : std::as_const(currentSelectNotes)) { notesId.insert(id.toInt()); } m_listViewLogic->setLastSavedState(notesId); @@ -3180,8 +3180,8 @@ void MainWindow::mousePressEvent(QMouseEvent *event) return; } - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); if (event->buttons() == Qt::LeftButton) { if (isTitleBar(m_mousePressX, m_mousePressY)) { @@ -3243,8 +3243,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) # ifndef __APPLE__ if (!m_canStretchWindow && !m_canMoveWindow) { - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); if ((m_mousePressX < width() && m_mousePressX > width() - m_layoutMargin) && (m_mousePressY < m_layoutMargin && m_mousePressY > 0)) { @@ -3298,8 +3298,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) # endif if (m_canMoveWindow) { - int dx = event->globalX() - m_mousePressX; - int dy = event->globalY() - m_mousePressY; + int dx = event->globalPosition().x() - m_mousePressX; + int dy = event->globalPosition().y() - m_mousePressY; move(dx, dy); } @@ -3314,11 +3314,11 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) switch (m_stretchSide) { case StretchSide::Right: - newWidth = abs(event->globalPos().x() - x() + 1); + newWidth = abs(event->globalPosition().x() - x() + 1); newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; break; case StretchSide::Left: - newX = event->globalPos().x() - m_mousePressX; + newX = event->globalPosition().x() - m_mousePressX; newX = newX > 0 ? newX : 0; newX = newX > geometry().bottomRight().x() - minimumWidth() ? geometry().bottomRight().x() - minimumWidth() @@ -3327,7 +3327,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; break; case StretchSide::Top: - newY = event->globalY() - m_mousePressY; + newY = event->globalPosition().y() - m_mousePressY; newY = newY < minY ? minY : newY; newY = newY > geometry().bottomRight().y() - minimumHeight() ? geometry().bottomRight().y() - minimumHeight() @@ -3337,18 +3337,18 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) break; case StretchSide::Bottom: - newHeight = abs(event->globalY() - y() + 1); + newHeight = abs(event->globalPosition().y() - y() + 1); newHeight = newHeight < minimumHeight() ? minimumHeight() : newHeight; break; case StretchSide::TopLeft: - newX = event->globalPos().x() - m_mousePressX; + newX = event->globalPosition().x() - m_mousePressX; newX = newX < 0 ? 0 : newX; newX = newX > geometry().bottomRight().x() - minimumWidth() ? geometry().bottomRight().x() - minimumWidth() : newX; - newY = event->globalY() - m_mousePressY; + newY = event->globalPosition().y() - m_mousePressY; newY = newY < minY ? minY : newY; newY = newY > geometry().bottomRight().y() - minimumHeight() ? geometry().bottomRight().y() - minimumHeight() @@ -3362,7 +3362,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) break; case StretchSide::BottomLeft: - newX = event->globalPos().x() - m_mousePressX; + newX = event->globalPosition().x() - m_mousePressX; newX = newX < 0 ? 0 : newX; newX = newX > geometry().bottomRight().x() - minimumWidth() ? geometry().bottomRight().x() - minimumWidth() @@ -3371,18 +3371,18 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) newWidth = geometry().bottomRight().x() - newX + 1; newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; - newHeight = event->globalY() - y() + 1; + newHeight = event->globalPosition().y() - y() + 1; newHeight = newHeight < minimumHeight() ? minimumHeight() : newHeight; break; case StretchSide::TopRight: - newY = event->globalY() - m_mousePressY; + newY = event->globalPosition().y() - m_mousePressY; newY = newY > geometry().bottomRight().y() - minimumHeight() ? geometry().bottomRight().y() - minimumHeight() : newY; newY = newY < minY ? minY : newY; - newWidth = event->globalPos().x() - x() + 1; + newWidth = event->globalPosition().x() - x() + 1; newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; newHeight = geometry().bottomRight().y() - newY + 1; @@ -3390,10 +3390,10 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) break; case StretchSide::BottomRight: - newWidth = event->globalPos().x() - x() + 1; + newWidth = event->globalPosition().x() - x() + 1; newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; - newHeight = event->globalY() - y() + 1; + newHeight = event->globalPosition().y() - y() + 1; newHeight = newHeight < minimumHeight() ? minimumHeight() : newHeight; break; @@ -3438,15 +3438,15 @@ void MainWindow::mousePressEvent(QMouseEvent *event) } if (event->button() == Qt::LeftButton) { - if (isTitleBar(event->pos().x(), event->pos().y())) { + if (isTitleBar(event->position().toPoint().x(), event->position().toPoint().y())) { # if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_canMoveWindow = !window()->windowHandle()->startSystemMove(); # else m_canMoveWindow = true; # endif - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); } } @@ -3467,8 +3467,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) if (m_canMoveWindow) { // setCursor(Qt::ClosedHandCursor); - int dx = event->globalPos().x() - m_mousePressX; - int dy = event->globalY() - m_mousePressY; + int dx = event->globalPosition().x() - m_mousePressX; + int dy = event->globalPosition().y() - m_mousePressY; move(dx, dy); } } @@ -3766,7 +3766,7 @@ double MainWindow::gaussianDist(double x, const double center, double sigma) con void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) { if (m_useNativeWindowFrame || event->buttons() != Qt::LeftButton - || !isTitleBar(event->pos().x(), event->pos().y())) { + || !isTitleBar(event->position().toPoint().x(), event->position().toPoint().y())) { MainWindowBase::mouseDoubleClickEvent(event); return; } @@ -3782,7 +3782,7 @@ void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) /*! * \brief MainWindow::leaveEvent */ -void MainWindow::leaveEvent(QEvent *) +void MainWindow::leaveEvent(QEvent * /*event*/) { unsetCursor(); } diff --git a/src/nodetreemodel.cpp b/src/nodetreemodel.cpp index 84cce7b09..6c47540f3 100644 --- a/src/nodetreemodel.cpp +++ b/src/nodetreemodel.cpp @@ -121,7 +121,7 @@ void NodeTreeItem::recursiveSort() } else if (type == NodeItem::Type::RootItem) { QVector allNoteButton, trashFolder, folderSep, folderItems, tagSep, tagItems; - for (const auto child : qAsConst(m_childItems)) { + for (const auto child : std::as_const(m_childItems)) { auto childType = static_cast(child->data(NodeItem::Roles::ItemType).toInt()); if (childType == NodeItem::Type::AllNoteButton) { @@ -333,7 +333,7 @@ QModelIndex NodeTreeModel::folderIndexFromIdPath(const NodePath &idPath) } auto ps = idPath.separate(); auto item = rootItem; - for (const auto &ite : qAsConst(ps)) { + for (const auto &ite : std::as_const(ps)) { bool ok = false; auto id = ite.toInt(&ok); if (!ok) { @@ -769,7 +769,7 @@ bool NodeTreeModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i auto idl = QString::fromUtf8(mime->data(TAG_MIME)).split(QStringLiteral(PATH_SEPARATOR)); beginResetModel(); QSet movedIds; - for (const auto &id_s : qAsConst(idl)) { + for (const auto &id_s : std::as_const(idl)) { auto id = id_s.toInt(); for (int i = 0; i < rootItem->childCount(); ++i) { auto child = rootItem->child(i); diff --git a/src/nodetreeview.cpp b/src/nodetreeview.cpp index a155816ac..46fa14b5e 100644 --- a/src/nodetreeview.cpp +++ b/src/nodetreeview.cpp @@ -138,7 +138,7 @@ void NodeTreeView::onTagsDropSuccessful(const QSet &ids) setCurrentIndex(QModelIndex()); clearSelection(); setSelectionMode(QAbstractItemView::MultiSelection); - for (const auto &id : qAsConst(ids)) { + for (const auto &id : std::as_const(ids)) { auto index = m_model->tagIndexFromId(id); if (index.isValid()) { setCurrentIndex(index); @@ -239,7 +239,7 @@ void NodeTreeView::selectionChanged(const QItemSelection &selected, } auto indexes = selectedIndexes(); QSet tagIds; - for (const auto index : qAsConst(indexes)) { + for (const auto index : std::as_const(indexes)) { auto itemType = static_cast(index.data(NodeItem::Roles::ItemType).toInt()); switch (itemType) { case NodeItem::Type::RootItem: @@ -314,32 +314,32 @@ void NodeTreeView::dragEnterEvent(QDragEnterEvent *event) void NodeTreeView::dragMoveEvent(QDragMoveEvent *event) { if (event->mimeData()->hasFormat(NOTE_MIME)) { - auto index = indexAt(event->pos()); + auto index = indexAt(event->position().toPoint()); auto itemType = static_cast(index.data(NodeItem::Roles::ItemType).toInt()); if (itemType != NodeItem::Type::AllNoteButton) { - updateEditingIndex(event->pos()); + updateEditingIndex(event->position().toPoint()); event->acceptProposedAction(); } } else { if (event->mimeData()->hasFormat(TAG_MIME)) { - if (event->pos().y() < visualRect(m_treeSeparator[1]).y() + 25) { + if (event->position().toPoint().y() < visualRect(m_treeSeparator[1]).y() + 25) { event->ignore(); return; } } else if (event->mimeData()->hasFormat(FOLDER_MIME)) { auto trashRect = visualRect(dynamic_cast(model())->getTrashButtonIndex()); - if (event->pos().y() > (trashRect.y() + 5) - && event->pos().y() < (trashRect.bottom() - 5)) { + if (event->position().toPoint().y() > (trashRect.y() + 5) + && event->position().toPoint().y() < (trashRect.bottom() - 5)) { setDropIndicatorShown(true); QTreeView::dragMoveEvent(event); return; } - if (event->pos().y() > visualRect(m_treeSeparator[1]).y()) { + if (event->position().toPoint().y() > visualRect(m_treeSeparator[1]).y()) { event->ignore(); return; } - if (event->pos().y() < visualRect(m_defaultNotesIndex).y() + 25) { + if (event->position().toPoint().y() < visualRect(m_defaultNotesIndex).y() + 25) { event->ignore(); return; } @@ -358,14 +358,14 @@ void NodeTreeView::reset() void NodeTreeView::dropEvent(QDropEvent *event) { if (event->mimeData()->hasFormat(NOTE_MIME)) { - auto dropIndex = indexAt(event->pos()); + auto dropIndex = indexAt(event->position().toPoint()); if (dropIndex.isValid()) { auto itemType = static_cast(dropIndex.data(NodeItem::Roles::ItemType).toInt()); bool ok = false; auto idl = QString::fromUtf8(event->mimeData()->data(NOTE_MIME)) .split(QStringLiteral(PATH_SEPARATOR)); - for (const auto &s : qAsConst(idl)) { + for (const auto &s : std::as_const(idl)) { auto nodeId = s.toInt(&ok); if (ok) { if (itemType == NodeItem::Type::FolderItem) { @@ -474,11 +474,11 @@ void NodeTreeView::onCustomContextMenu(QPoint point) void NodeTreeView::setTreeSeparator(const QVector &newTreeSeparator, const QModelIndex &defaultNotesIndex) { - for (const auto &sep : qAsConst(m_treeSeparator)) { + for (const auto &sep : std::as_const(m_treeSeparator)) { closePersistentEditor(sep); } m_treeSeparator = newTreeSeparator; - for (const auto &sep : qAsConst(m_treeSeparator)) { + for (const auto &sep : std::as_const(m_treeSeparator)) { openPersistentEditor(sep); } m_defaultNotesIndex = defaultNotesIndex; @@ -488,12 +488,12 @@ void NodeTreeView::mouseMoveEvent(QMouseEvent *event) { Q_D(NodeTreeView); QPoint topLeft; - QPoint bottomRight = event->pos(); + QPoint bottomRight = event->position().toPoint(); if (state() == ExpandingState || state() == CollapsingState) { return; } - updateEditingIndex(event->pos()); + updateEditingIndex(event->position().toPoint()); if (state() == DraggingState) { topLeft = d->pressedPosition - d->offset(); if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) { @@ -516,7 +516,7 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) Q_D(NodeTreeView); d->delayedAutoScroll.stop(); { - auto index = indexAt(event->pos()); + auto index = indexAt(event->position().toPoint()); if (index.isValid()) { auto itemType = static_cast(index.data(NodeItem::Roles::ItemType).toInt()); @@ -524,7 +524,7 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) case NodeItem::Type::FolderItem: { auto rect = visualRect(index); auto iconRect = QRect(rect.x() + 5, rect.y() + (rect.height() - 20) / 2, 20, 20); - if (iconRect.contains(event->pos())) { + if (iconRect.contains(event->position().toPoint())) { if (isExpanded(index)) { collapse(index); } else { @@ -537,7 +537,7 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) } case NodeItem::Type::TagItem: { auto oldIndexes = selectionModel()->selectedIndexes(); - for (const auto &ix : qAsConst(oldIndexes)) { + for (const auto &ix : std::as_const(oldIndexes)) { auto selectedItemType = static_cast(ix.data(NodeItem::Roles::ItemType).toInt()); if (selectedItemType != NodeItem::Type::TagItem) { @@ -567,14 +567,14 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) } } } - QPoint pos = event->pos(); + QPoint pos = event->position().toPoint(); QPersistentModelIndex index = indexAt(pos); d->pressedAlreadySelected = d->selectionModel->isSelected(index); d->pressedIndex = index; d->pressedModifiers = event->modifiers(); QPoint offset = d->offset(); d->pressedPosition = pos + offset; - updateEditingIndex(event->pos()); + updateEditingIndex(event->position().toPoint()); } void NodeTreeView::leaveEvent(QEvent *event) diff --git a/src/notelistdelegate.cpp b/src/notelistdelegate.cpp index 4030c4d8b..aaa1a5506 100644 --- a/src/notelistdelegate.cpp +++ b/src/notelistdelegate.cpp @@ -61,21 +61,21 @@ NoteListDelegate::NoteListDelegate(NoteListView *view, TagPool *tagPool, QObject m_timeLine->setEasingCurve(QEasingCurve::InCurve); m_folderIcon = QImage(":/images/folder.png"); connect(m_timeLine, &QTimeLine::frameChanged, this, [this]() { - for (const auto &index : qAsConst(m_animatedIndexes)) { + for (const auto &index : std::as_const(m_animatedIndexes)) { emit sizeHintChanged(index); } }); connect(m_timeLine, &QTimeLine::finished, this, [this]() { emit animationFinished(m_state); - for (const auto &index : qAsConst(m_animatedIndexes)) { + for (const auto &index : std::as_const(m_animatedIndexes)) { m_view->openPersistentEditorC(index); } if (!animationQueue.empty()) { auto a = animationQueue.front(); animationQueue.pop_front(); QModelIndexList indexes; - for (const auto &id : qAsConst(a.first)) { + for (const auto &id : std::as_const(a.first)) { auto model = dynamic_cast(m_view->model()); if (model) { auto index = model->getNoteIndex(id); @@ -96,7 +96,7 @@ void NoteListDelegate::setState(NoteListState NewState, QModelIndexList indexes) { if (animationState() != QTimeLine::NotRunning) { QSet ids; - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { auto noteId = index.data(NoteListModel::NoteID).toInt(); if (noteId != SpecialNodeID::InvalidNodeId) { ids.insert(noteId); @@ -813,7 +813,7 @@ void NoteListDelegate::paintTagList(int top, QPainter *painter, const QStyleOpti auto tagIds = index.data(NoteListModel::NoteTagsList).value>(); int left = option.rect.x() + 10; - for (const auto &id : qAsConst(tagIds)) { + for (const auto &id : std::as_const(tagIds)) { if (left >= option.rect.width()) { break; } @@ -911,7 +911,7 @@ void NoteListDelegate::setStateI(NoteListState NewState, const QModelIndexList & m_animatedIndexes = indexes; auto startAnimation = [this](QTimeLine::Direction diretion, int duration) { - for (const auto &index : qAsConst(m_animatedIndexes)) { + for (const auto &index : std::as_const(m_animatedIndexes)) { m_view->closePersistentEditorC(index); } m_timeLine->setDirection(diretion); diff --git a/src/notelistmodel.cpp b/src/notelistmodel.cpp index 7c814f715..d9f3bcec1 100644 --- a/src/notelistmodel.cpp +++ b/src/notelistmodel.cpp @@ -93,7 +93,7 @@ void NoteListModel::setListNote(const QVector ¬es, const ListViewIn m_listViewInfo = inf; if ((!m_listViewInfo.isInTag) && (m_listViewInfo.parentFolderId != SpecialNodeID::TrashFolder)) { - for (const auto ¬e : qAsConst(notes)) { + for (const auto ¬e : std::as_const(notes)) { if (note.isPinnedNote()) { m_pinnedList.append(note); } else { @@ -404,14 +404,14 @@ bool NoteListModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i auto idl = QString::fromUtf8(mime->data(NOTE_MIME)).split(QStringLiteral(PATH_SEPARATOR)); QSet movedIds; QModelIndexList idxe; - for (const auto &id_s : qAsConst(idl)) { + for (const auto &id_s : std::as_const(idl)) { auto nodeId = id_s.toInt(); idxe.append(getNoteIndex(nodeId)); } emit rowsAboutToBeMovedC(idxe); beginResetModel(); if (toPinned) { - for (const auto &index : qAsConst(idxe)) { + for (const auto &index : std::as_const(idxe)) { auto ¬e = getRef(index.row()); if (!note.isPinnedNote()) { note.setIsPinnedNote(true); @@ -419,7 +419,7 @@ bool NoteListModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i m_pinnedList.prepend(m_noteList.takeAt(index.row() - m_pinnedList.size())); } } - for (const auto &id_s : qAsConst(idl)) { + for (const auto &id_s : std::as_const(idl)) { auto nodeId = id_s.toInt(); for (int i = 0; i < m_pinnedList.size(); ++i) { if (m_pinnedList[i].id() == nodeId) { @@ -430,7 +430,7 @@ bool NoteListModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i movedIds.insert(nodeId); } } else { - for (const auto &index : qAsConst(idxe)) { + for (const auto &index : std::as_const(idxe)) { auto ¬e = getRef(index.row()); movedIds.insert(note.id()); if (!note.isPinnedNote()) { @@ -514,7 +514,7 @@ void NoteListModel::setNotesIsPinned(const QModelIndexList &indexes, bool isPinn if (isPinned) { emit rowsAboutToBeMovedC(needMovingIndexes); beginResetModel(); - for (const auto &id : qAsConst(needMovingIds)) { + for (const auto &id : std::as_const(needMovingIds)) { auto index = getNoteIndex(id); if (!index.isValid()) { continue; @@ -541,7 +541,7 @@ void NoteListModel::setNotesIsPinned(const QModelIndexList &indexes, bool isPinn } else { emit rowsAboutToBeMovedC(needMovingIndexes); beginResetModel(); - for (const auto &id : qAsConst(needMovingIds)) { + for (const auto &id : std::as_const(needMovingIds)) { auto index = getNoteIndex(id); if (!index.isValid()) { continue; diff --git a/src/notelistview.cpp b/src/notelistview.cpp index d4a7553d0..71e12d007 100644 --- a/src/notelistview.cpp +++ b/src/notelistview.cpp @@ -132,7 +132,7 @@ QModelIndexList NoteListView::selectedIndex() const void NoteListView::onRemoveRowRequested(const QModelIndexList &indexes) { if (!indexes.isEmpty()) { - for (const auto index : qAsConst(indexes)) { + for (const auto index : std::as_const(indexes)) { m_needRemovedNotes.push_back(index.data(NoteListModel::NoteID).toInt()); } NoteListDelegate *delegate = dynamic_cast(itemDelegate()); @@ -272,7 +272,7 @@ void NoteListView::mouseMoveEvent(QMouseEvent *event) return; } if (event->buttons() & Qt::LeftButton) { - if ((event->pos() - m_dragStartPosition).manhattanLength() + if ((event->position().toPoint() - m_dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) { startDrag(Qt::MoveAction); } @@ -284,7 +284,7 @@ void NoteListView::mousePressEvent(QMouseEvent *e) { Q_D(NoteListView); m_isMousePressed = true; - auto index = indexAt(e->pos()); + auto index = indexAt(e->position().toPoint()); if (!index.isValid()) { emit noteListViewClicked(); return; @@ -293,7 +293,7 @@ void NoteListView::mousePressEvent(QMouseEvent *e) if (model && model->isFirstPinnedNote(index)) { auto rect = visualRect(index); auto iconRect = QRect(rect.right() - 25, rect.y() + 2, 20, 20); - if (iconRect.contains(e->pos())) { + if (iconRect.contains(e->position().toPoint())) { setIsPinnedNotesCollapsed(!isPinnedNotesCollapsed()); m_mousePressHandled = true; return; @@ -301,7 +301,7 @@ void NoteListView::mousePressEvent(QMouseEvent *e) } if (e->button() == Qt::LeftButton) { - m_dragStartPosition = e->pos(); + m_dragStartPosition = e->position().toPoint(); auto oldIndexes = selectionModel()->selectedIndexes(); if (!oldIndexes.contains(index)) { if (e->modifiers() == Qt::ControlModifier) { @@ -324,13 +324,13 @@ void NoteListView::mousePressEvent(QMouseEvent *e) } } QPoint offset = d->offset(); - d->pressedPosition = e->pos() + offset; + d->pressedPosition = e->position().toPoint() + offset; } void NoteListView::mouseReleaseEvent(QMouseEvent *e) { m_isMousePressed = false; - auto index = indexAt(e->pos()); + auto index = indexAt(e->position().toPoint()); if (!index.isValid()) { return; } @@ -392,7 +392,7 @@ void NoteListView::dragEnterEvent(QDragEnterEvent *event) void NoteListView::dragMoveEvent(QDragMoveEvent *event) { if (event->mimeData()->hasFormat(NOTE_MIME)) { - auto index = indexAt(event->pos()); + auto index = indexAt(event->position().toPoint()); auto isPinned = index.data(NoteListModel::NoteIsPinned).toBool(); if (!index.isValid()) { event->ignore(); @@ -512,7 +512,7 @@ void NoteListView::startDrag(Qt::DropActions supportedActions) rect = px.rect(); } m_isDraggingPinnedNotes = false; - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { if (index.data(NoteListModel::NoteIsPinned).toBool()) { m_isDraggingPinnedNotes = true; break; @@ -542,7 +542,7 @@ void NoteListView::startDrag(Qt::DropActions supportedActions) d->dropIndicatorRect = QRect(); d->dropIndicatorPosition = OnItem; closeAllEditor(); - for (const auto &id : qAsConst(openedEditors)) { + for (const auto &id : std::as_const(openedEditors)) { auto index = dynamic_cast(model())->getNoteIndex(id); openPersistentEditorC(index); } @@ -646,7 +646,7 @@ void NoteListView::setupStyleSheet() void NoteListView::addNotesToTag(QSet notesId, int tagId) { - for (const auto &id : qAsConst(notesId)) { + for (const auto &id : std::as_const(notesId)) { auto model = dynamic_cast(this->model()); if (model) { auto index = model->getNoteIndex(id); @@ -659,7 +659,7 @@ void NoteListView::addNotesToTag(QSet notesId, int tagId) void NoteListView::removeNotesFromTag(QSet notesId, int tagId) { - for (const auto &id : qAsConst(notesId)) { + for (const auto &id : std::as_const(notesId)) { auto model = dynamic_cast(this->model()); if (model) { auto index = model->getNoteIndex(id); @@ -699,13 +699,13 @@ void NoteListView::onCustomContextMenu(QPoint point) indexList = selectionModel()->selectedIndexes(); } QSet notes; - for (const auto &idx : qAsConst(indexList)) { + for (const auto &idx : std::as_const(indexList)) { notes.insert(idx.data(NoteListModel::NoteID).toInt()); } contextMenu->clear(); if (m_tagPool) { m_tagsMenu = contextMenu->addMenu("Tags ..."); - for (auto action : qAsConst(m_noteTagActions)) { + for (auto action : std::as_const(m_noteTagActions)) { delete action; } m_noteTagActions.clear(); @@ -730,7 +730,7 @@ void NoteListView::onCustomContextMenu(QPoint point) const auto tagIds = m_tagPool->tagIds(); for (const auto &id : tagIds) { bool all = true; - for (const auto &selectedIndex : qAsConst(indexList)) { + for (const auto &selectedIndex : std::as_const(indexList)) { auto tags = selectedIndex.data(NoteListModel::NoteTagsList).value>(); if (!tags.contains(id)) { all = false; @@ -741,7 +741,7 @@ void NoteListView::onCustomContextMenu(QPoint point) tagInNote.insert(id); } } - for (auto id : qAsConst(tagInNote)) { + for (auto id : std::as_const(tagInNote)) { auto tag = m_tagPool->getTag(id); auto tagAction = new QAction(QString("✓ Remove tag ") + tag.name(), this); connect(tagAction, &QAction::triggered, this, @@ -786,7 +786,7 @@ void NoteListView::onCustomContextMenu(QPoint point) unpinNoteAction->setText(tr("Unpin Notes")); enum class ShowAction { NotInit, ShowPin, ShowBoth, ShowUnpin }; ShowAction a = ShowAction::NotInit; - for (const auto &idx : qAsConst(indexList)) { + for (const auto &idx : std::as_const(indexList)) { if (idx.data(NoteListModel::NoteIsPinned).toBool()) { if (a == ShowAction::ShowPin) { a = ShowAction::ShowBoth; @@ -827,7 +827,7 @@ void NoteListView::onCustomContextMenu(QPoint point) } contextMenu->addSeparator(); if (m_dbManager) { - for (auto action : qAsConst(m_folderActions)) { + for (auto action : std::as_const(m_folderActions)) { delete action; } m_folderActions.clear(); @@ -842,7 +842,7 @@ void NoteListView::onCustomContextMenu(QPoint point) auto action = new QAction(folders[id], this); connect(action, &QAction::triggered, this, [this, id] { auto indexes = selectedIndexes(); - for (const auto &selectedIndex : qAsConst(indexes)) { + for (const auto &selectedIndex : std::as_const(indexes)) { if (selectedIndex.isValid()) { emit moveNoteRequested( selectedIndex.data(NoteListModel::NoteID).toInt(), id); @@ -866,7 +866,7 @@ void NoteListView::onAnimationFinished(NoteListState state) if (state == NoteListState::Remove) { auto model = dynamic_cast(this->model()); if (model) { - for (const auto id : qAsConst(m_needRemovedNotes)) { + for (const auto id : std::as_const(m_needRemovedNotes)) { auto index = model->getNoteIndex(id); model->removeRow(index.row()); } diff --git a/src/taglistmodel.cpp b/src/taglistmodel.cpp index caf9779d2..3938e5f34 100644 --- a/src/taglistmodel.cpp +++ b/src/taglistmodel.cpp @@ -69,7 +69,7 @@ QVariant TagListModel::data(const QModelIndex &index, int role) const void TagListModel::updateTagData() { m_data.clear(); - for (const auto &id : qAsConst(m_ids)) { + for (const auto &id : std::as_const(m_ids)) { if (m_tagPool->contains(id)) { m_data.append(m_tagPool->getTag(id)); } else { diff --git a/src/tagtreedelegateeditor.cpp b/src/tagtreedelegateeditor.cpp index a6e6d2bc2..799675ee0 100644 --- a/src/tagtreedelegateeditor.cpp +++ b/src/tagtreedelegateeditor.cpp @@ -174,9 +174,9 @@ void TagTreeDelegateEditor::paintEvent(QPaintEvent *event) void TagTreeDelegateEditor::mouseDoubleClickEvent(QMouseEvent *event) { auto iconRect = QRect(rect().x() + 10, rect().y() + (rect().height() - 14) / 2, 14, 14); - if (iconRect.contains(event->pos())) { + if (iconRect.contains(event->position().toPoint())) { dynamic_cast(m_view)->onChangeTagColorAction(); - } else if (m_label->geometry().contains(event->pos())) { + } else if (m_label->geometry().contains(event->position().toPoint())) { m_label->openEditor(); } else { QWidget::mouseDoubleClickEvent(event); diff --git a/src/treeviewlogic.cpp b/src/treeviewlogic.cpp index 67bce015a..b1cb155b4 100644 --- a/src/treeviewlogic.cpp +++ b/src/treeviewlogic.cpp @@ -129,7 +129,7 @@ void TreeViewLogic::loadTreeModel(const NodeTagTreeData &treeData) m_treeView->setCurrentIndexC(m_treeModel->getAllNotesButtonIndex()); } } else { - for (const auto &id : qAsConst(m_lastSelectTags)) { + for (const auto &id : std::as_const(m_lastSelectTags)) { m_treeView->setCurrentIndexNC(m_treeModel->tagIndexFromId(id)); } } diff --git a/src/updaterwindow.cpp b/src/updaterwindow.cpp index 22f06150d..1af4ba45d 100644 --- a/src/updaterwindow.cpp +++ b/src/updaterwindow.cpp @@ -554,15 +554,16 @@ void UpdaterWindow::onDownloadFinished() void UpdaterWindow::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (event->x() < width() - 5 && event->x() > 5 && event->pos().y() < height() - 5 - && event->pos().y() > 5) { + if (event->position().x() < width() - 5 && event->position().x() > 5 + && event->position().toPoint().y() < height() - 5 + && event->position().toPoint().y() > 5) { #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_canMoveWindow = !window()->windowHandle()->startSystemMove(); #else m_canMoveWindow = true; #endif - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); } } event->accept(); @@ -576,8 +577,8 @@ void UpdaterWindow::mousePressEvent(QMouseEvent *event) void UpdaterWindow::mouseMoveEvent(QMouseEvent *event) { if (m_canMoveWindow) { - int dx = event->globalX() - m_mousePressX; - int dy = event->globalY() - m_mousePressY; + int dx = event->globalPosition().x() - m_mousePressX; + int dy = event->globalPosition().y() - m_mousePressY; move(dx, dy); } }