Skip to content

Commit

Permalink
ItemSync: Refactor IndexData
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Nov 17, 2021
1 parent ae1124b commit 0a64dfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion plugins/itemsync/filewatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,10 @@ void FileWatcher::onRowsRemoved(const QModelIndex &, int first, int last)

FileWatcher::IndexDataList::iterator FileWatcher::findIndexData(const QModelIndex &index)
{
return std::find(m_indexData.begin(), m_indexData.end(), index);
return std::find_if(
m_indexData.begin(), m_indexData.end(), [index](const IndexData &data) {
return index == data.index;
});
}

FileWatcher::IndexData &FileWatcher::indexData(const QModelIndex &index)
Expand Down
5 changes: 2 additions & 3 deletions plugins/itemsync/filewatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ class FileWatcher final : public QObject {
QString baseName;
QMap<QString, Hash> formatHash;

IndexData() {}
explicit IndexData(const QModelIndex &index) : index(index) {}
bool operator==(const QModelIndex &otherIndex) const { return otherIndex == index; }
IndexData() = default;
explicit IndexData(const QModelIndex &ind) : index(ind) {}
};

using IndexDataList = QVector<IndexData>;
Expand Down

0 comments on commit 0a64dfe

Please sign in to comment.