Commit 1a7175ca authored by Michael Pyne's avatar Michael Pyne
Browse files

clazy: Fix warnings about needlessly detaching Qt containers.

parent d097745d
......@@ -139,7 +139,7 @@ void AdvancedSearchDialog::accept()
m_search->addPlaylist(CollectionList::instance());
for(const auto &searchLine : m_searchLines)
for(const auto &searchLine : qAsConst(m_searchLines))
m_search->addComponent(searchLine->searchComponent());
PlaylistSearch::SearchMode m = PlaylistSearch::SearchMode(!m_matchAnyButton->isChecked());
......
......@@ -194,18 +194,19 @@ void CoverInfo::applyCoverToWholeAlbum(bool overwriteExistingCovers) const
// Search done, iterate through results.
const auto playlistFoundItems = search.matchedItems();
PlaylistItemList results;
for(QModelIndex i : search.matchedItems())
for(QModelIndex i : playlistFoundItems)
results.append(static_cast<PlaylistItem*>(CollectionList::instance()->itemAt(i.row(), i.column())));
PlaylistItemList::ConstIterator it = results.constBegin();
for(; it != results.constEnd(); ++it) {
for(const auto &playlistItem : qAsConst(results)) {
// Don't worry about files that somehow already have a tag,
// unless the conversion is forced.
if(!overwriteExistingCovers && (*it)->file().coverInfo()->coverId() != CoverManager::NoMatch)
if(!overwriteExistingCovers && playlistItem->file().coverInfo()->coverId() != CoverManager::NoMatch)
continue;
(*it)->file().coverInfo()->setCoverId(m_coverKey);
playlistItem->file().coverInfo()->setCoverId(m_coverKey);
}
}
......
......@@ -83,7 +83,7 @@ void DynamicPlaylist::setPlaylists(const PlaylistList &playlists)
void DynamicPlaylist::slotReload()
{
for(const auto &playlist : m_playlists) {
for(const auto &playlist : qAsConst(m_playlists)) {
if(!playlist)
continue;
playlist->slotReload();
......@@ -101,7 +101,7 @@ void DynamicPlaylist::lower(QWidget *top)
PlaylistList l;
l.append(this);
for(const auto &playlist : m_playlists) {
for(const auto &playlist : qAsConst(m_playlists)) {
if(!playlist)
continue;
playlist->synchronizePlayingItems(l, true);
......@@ -156,7 +156,7 @@ void DynamicPlaylist::updateItems()
this->synchronizeItemsTo(siblings);
if(m_synchronizePlaying) {
for(const auto &playlist : m_playlists) {
for(const auto &playlist : qAsConst(m_playlists)) {
synchronizePlayingItems(playlist, true);
}
}
......
......@@ -346,10 +346,9 @@ int FileRenamerWidget::addRowCategory(TagType category)
static QIcon down = QIcon::fromTheme("go-down");
// Find number of categories already of this type.
int categoryCount = 0;
for(const auto &row : m_rows)
if(row.category.category == category)
++categoryCount;
int categoryCount = std::count_if(m_rows.cbegin(), m_rows.cend(),
[category](const Row &r) { return r.category.category == category; }
);
Row row;
......
......@@ -162,7 +162,8 @@ bool MediaFiles::isMediaFile(const QString &fileName)
return false;
// Search through our table of media types for a match
for(const auto &mimeType : mimeTypes()) {
const auto validMimeTypes(mimeTypes());
for(const auto &mimeType : validMimeTypes) {
if(result.inherits(mimeType))
return true;
}
......
......@@ -400,10 +400,11 @@ void Playlist::setSearchEnabled(bool enabled)
topLevelItem(row)->setHidden(true);
setItemsVisible(m_search->matchedItems(), true);
}
else
for(PlaylistItem* item : items())
else {
const auto &playlistItems = items();
for(PlaylistItem* item : playlistItems)
item->setHidden(false);
}
}
// Mostly seems to be for DynamicPlaylist
......
......@@ -867,7 +867,7 @@ void PlaylistCollection::readConfig()
m_excludedFolderList = canonicalizeFolderPaths(
config.readEntry("ExcludeDirectoryList", QStringList()));
for(const auto &folder : m_folderList) {
for(const auto &folder : qAsConst(m_folderList)) {
m_dirLister.openUrl(QUrl::fromUserInput(folder), KDirLister::Keep);
}
}
......
......@@ -166,9 +166,9 @@ PlaylistSearch::Component::Component(const QRegExp &query, const ColumnList& col
bool PlaylistSearch::Component::matches(int row, QModelIndex parent, QAbstractItemModel* model) const
{
for(int column : m_columns){
for(int column : qAsConst(m_columns)) {
const QString str = model->index(row, column, parent).data().toString();
if(m_re){
if(m_re) {
return str.contains(m_queryRe);
}
......@@ -178,18 +178,18 @@ bool PlaylistSearch::Component::matches(int row, QModelIndex parent, QAbstractIt
return true;
break;
case Exact:
if(str.length() == m_query.length()) {
if(m_caseSensitive) {
if(str == m_query)
return true;
}
else if(str.toLower() == m_query.toLower())
return true;
// If lengths match, move on to check strings themselves
if(str.length() == m_query.length() &&
(( m_caseSensitive && str == m_query) ||
(!m_caseSensitive && str.toLower() == m_query.toLower()))
)
{
return true;
}
break;
case ContainsWord:
{
int i = str.indexOf(m_query, 0, m_caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive );
int i = str.indexOf(m_query, 0, m_caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
if(i >= 0) {
......
......@@ -129,7 +129,7 @@ Playlist::SharedSettings::SharedSettings()
// Convert the int list into a bool list.
m_columnsVisible.fill(false);
for(int i : l) {
for(int i : qAsConst(l)) {
if(Q_LIKELY(i < m_columnsVisible.size()))
m_columnsVisible[i] = true;
}
......
......@@ -56,7 +56,8 @@ void SearchPlaylist::updateItems()
// items() which would in turn call this method...
PlaylistItemList items;
for(const QModelIndex index: m_search->matchedItems())
const auto matchingItems = m_search->matchedItems();
for(const QModelIndex &index : matchingItems)
items.push_back(static_cast<PlaylistItem*>(itemFromIndex(index)));
synchronizeItemsTo(items);
......
......@@ -117,7 +117,8 @@ void DefaultSequenceIterator::advance()
if(!m_albumSearch.isNull()) {
PlaylistItemList albumMatches;
const Playlist* const playlist = m_albumSearch.playlists().constFirst();
for(QModelIndex index : m_albumSearch.matchedItems())
const auto matchingItems = m_albumSearch.matchedItems();
for(const QModelIndex &index : matchingItems)
playlist->itemAt(index.row(), index.column());
if(albumMatches.isEmpty()) {
qCCritical(JUK_LOG) << "Unable to initialize album random play.\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment