mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Compile without foreach
This commit is contained in:
parent
360a8dd883
commit
a24327cd50
|
@ -16,6 +16,7 @@ remove_definitions(
|
|||
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
|
||||
-DQT_NO_CAST_FROM_ASCII
|
||||
-DQT_NO_CAST_TO_ASCII
|
||||
-DQT_NO_FOREACH
|
||||
)
|
||||
|
||||
##########################################
|
||||
|
|
|
@ -163,7 +163,7 @@ void DolphinContextMenu::openTrashItemContextMenu()
|
|||
if (exec(m_pos) == restoreAction) {
|
||||
QList<QUrl> selectedUrls;
|
||||
selectedUrls.reserve(m_selectedItems.count());
|
||||
foreach (const KFileItem &item, m_selectedItems) {
|
||||
for (const KFileItem &item : qAsConst(m_selectedItems)) {
|
||||
selectedUrls.append(item.url());
|
||||
}
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ void DolphinMainWindow::openInNewTab()
|
|||
const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
|
||||
bool tabCreated = false;
|
||||
|
||||
foreach (const KFileItem& item, list) {
|
||||
for (const KFileItem& item : list) {
|
||||
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
|
||||
if (!url.isEmpty()) {
|
||||
openNewTabAfterCurrentTab(url);
|
||||
|
@ -861,7 +861,8 @@ void DolphinMainWindow::replaceLocation()
|
|||
void DolphinMainWindow::togglePanelLockState()
|
||||
{
|
||||
const bool newLockState = !GeneralSettings::lockPanels();
|
||||
foreach (QObject* child, children()) {
|
||||
const auto childrenObjects = children();
|
||||
for (QObject* child : childrenObjects) {
|
||||
DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
|
||||
if (dock) {
|
||||
dock->setLocked(newLockState);
|
||||
|
@ -2083,7 +2084,8 @@ bool DolphinMainWindow::addActionToMenu(QAction* action, QMenu* menu)
|
|||
Q_ASSERT(menu);
|
||||
|
||||
const KToolBar* toolBarWidget = toolBar();
|
||||
foreach (const QWidget* widget, action->associatedWidgets()) {
|
||||
const auto associatedWidgets = action->associatedWidgets();
|
||||
for (const QWidget* widget : associatedWidgets) {
|
||||
if (widget == toolBarWidget) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ void DolphinPart::slotItemActivated(const KFileItem& item)
|
|||
|
||||
void DolphinPart::slotItemsActivated(const KFileItemList& items)
|
||||
{
|
||||
foreach (const KFileItem& item, items) {
|
||||
for (const KFileItem& item : items) {
|
||||
slotItemActivated(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView)
|
|||
// for each directory. If the "split view" option is enabled, two
|
||||
// directories are shown inside one tab (see openDirectories()).
|
||||
QList<QUrl> dirs;
|
||||
foreach (const QUrl& url, files) {
|
||||
for (const QUrl& url : files) {
|
||||
const QUrl dir(url.adjusted(QUrl::RemoveFilename));
|
||||
if (!dirs.contains(dir)) {
|
||||
dirs.append(dir);
|
||||
|
|
|
@ -22,7 +22,7 @@ QList<QUrl> Dolphin::validateUris(const QStringList& uriList)
|
|||
{
|
||||
const QString currentDir = QDir::currentPath();
|
||||
QList<QUrl> urls;
|
||||
foreach (const QString& str, uriList) {
|
||||
for (const QString& str : uriList) {
|
||||
const QUrl url = QUrl::fromUserInput(str, currentDir, QUrl::AssumeLocalFile);
|
||||
if (url.isValid()) {
|
||||
urls.append(url);
|
||||
|
|
|
@ -420,7 +420,8 @@ int KFileItemModel::index(const QUrl& url) const
|
|||
indexesForUrl.insert(m_itemData.at(i)->item.url(), i);
|
||||
}
|
||||
|
||||
foreach (const QUrl& url, indexesForUrl.uniqueKeys()) {
|
||||
const auto uniqueKeys = indexesForUrl.uniqueKeys();
|
||||
for (const QUrl& url : uniqueKeys) {
|
||||
if (indexesForUrl.count(url) > 1) {
|
||||
qCWarning(DolphinDebug) << "Multiple items found with the URL" << url;
|
||||
|
||||
|
@ -524,7 +525,7 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
|
|||
m_dirLister->openUrl(url, KDirLister::Keep);
|
||||
|
||||
const QVariantList previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<QVariantList>();
|
||||
foreach (const QVariant& var, previouslyExpandedChildren) {
|
||||
for (const QVariant& var : previouslyExpandedChildren) {
|
||||
m_urlsToExpand.insert(var.toUrl());
|
||||
}
|
||||
} else {
|
||||
|
@ -728,7 +729,7 @@ void KFileItemModel::removeFilteredChildren(const KItemRangeList& itemRanges)
|
|||
}
|
||||
|
||||
QSet<ItemData*> parents;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
for (int index = range.index; index < range.index + range.count; ++index) {
|
||||
parents.insert(m_itemData.at(index));
|
||||
}
|
||||
|
@ -848,7 +849,7 @@ void KFileItemModel::resortAllItems()
|
|||
// been moved because of the resorting.
|
||||
QList<QUrl> oldUrls;
|
||||
oldUrls.reserve(itemCount);
|
||||
foreach (const ItemData* itemData, m_itemData) {
|
||||
for (const ItemData* itemData : qAsConst(m_itemData)) {
|
||||
oldUrls.append(itemData->item.url());
|
||||
}
|
||||
|
||||
|
@ -916,7 +917,7 @@ void KFileItemModel::slotCompleted()
|
|||
// Note that the parent folder must be expanded before any of its subfolders become visible.
|
||||
// Therefore, some URLs in m_restoredExpandedUrls might not be visible yet
|
||||
// -> we expand the first visible URL we find in m_restoredExpandedUrls.
|
||||
foreach (const QUrl& url, m_urlsToExpand) {
|
||||
for (const QUrl& url : qAsConst(m_urlsToExpand)) {
|
||||
const int indexForUrl = index(url);
|
||||
if (indexForUrl >= 0) {
|
||||
m_urlsToExpand.remove(url);
|
||||
|
@ -982,7 +983,7 @@ void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemLis
|
|||
}
|
||||
}
|
||||
|
||||
QList<ItemData*> itemDataList = createItemDataList(parentUrl, items);
|
||||
const QList<ItemData*> itemDataList = createItemDataList(parentUrl, items);
|
||||
|
||||
if (!m_filter.hasSetFilters()) {
|
||||
m_pendingItemsToInsert.append(itemDataList);
|
||||
|
@ -990,7 +991,7 @@ void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemLis
|
|||
// The name or type filter is active. Hide filtered items
|
||||
// before inserting them into the model and remember
|
||||
// the filtered items in m_filteredItems.
|
||||
foreach (ItemData* itemData, itemDataList) {
|
||||
for (ItemData* itemData : itemDataList) {
|
||||
if (m_filter.matches(itemData->item)) {
|
||||
m_pendingItemsToInsert.append(itemData);
|
||||
} else {
|
||||
|
@ -1013,7 +1014,7 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
|
|||
QVector<int> indexesToRemove;
|
||||
indexesToRemove.reserve(items.count());
|
||||
|
||||
foreach (const KFileItem& item, items) {
|
||||
for (const KFileItem& item : items) {
|
||||
const int indexForItem = index(item);
|
||||
if (indexForItem >= 0) {
|
||||
indexesToRemove.append(indexForItem);
|
||||
|
@ -1035,7 +1036,7 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items)
|
|||
indexesToRemoveWithChildren.reserve(m_itemData.count());
|
||||
|
||||
const int itemCount = m_itemData.count();
|
||||
foreach (int index, indexesToRemove) {
|
||||
for (int index : qAsConst(indexesToRemove)) {
|
||||
indexesToRemoveWithChildren.append(index);
|
||||
|
||||
const int parentLevel = expandedParentsCount(index);
|
||||
|
@ -1275,7 +1276,7 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe
|
|||
|
||||
// Step 1: Remove the items from m_itemData, and free the ItemData.
|
||||
int removedItemsCount = 0;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
removedItemsCount += range.count;
|
||||
|
||||
for (int index = range.index; index < range.index + range.count; ++index) {
|
||||
|
@ -1329,7 +1330,7 @@ QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const QUrl&
|
|||
QList<ItemData*> itemDataList;
|
||||
itemDataList.reserve(items.count());
|
||||
|
||||
foreach (const KFileItem& item, items) {
|
||||
for (const KFileItem& item : items) {
|
||||
ItemData* itemData = new ItemData();
|
||||
itemData->item = item;
|
||||
itemData->parent = parentItem;
|
||||
|
@ -1350,7 +1351,7 @@ void KFileItemModel::prepareItemsForSorting(QList<ItemData*>& itemDataList)
|
|||
case DeletionTimeRole:
|
||||
// These roles can be determined with retrieveData, and they have to be stored
|
||||
// in the QHash "values" for the sorting.
|
||||
foreach (ItemData* itemData, itemDataList) {
|
||||
for (ItemData* itemData : qAsConst(itemDataList)) {
|
||||
if (itemData->values.isEmpty()) {
|
||||
itemData->values = retrieveData(itemData->item, itemData->parent);
|
||||
}
|
||||
|
@ -1359,7 +1360,7 @@ void KFileItemModel::prepareItemsForSorting(QList<ItemData*>& itemDataList)
|
|||
|
||||
case TypeRole:
|
||||
// At least store the data including the file type for items with known MIME type.
|
||||
foreach (ItemData* itemData, itemDataList) {
|
||||
for (ItemData* itemData : qAsConst(itemDataList)) {
|
||||
if (itemData->values.isEmpty()) {
|
||||
const KFileItem item = itemData->item;
|
||||
if (item.isDir() || item.isMimeTypeKnown()) {
|
||||
|
@ -1432,7 +1433,7 @@ void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList& i
|
|||
// Trigger a resorting if necessary. Note that this can happen even if the sort
|
||||
// role has not changed at all because the file name can be used as a fallback.
|
||||
if (changedRoles.contains(sortRole()) || changedRoles.contains(roleForType(NameRole))) {
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
bool needsResorting = false;
|
||||
|
||||
const int first = range.index;
|
||||
|
@ -2365,7 +2366,7 @@ void KFileItemModel::determineMimeTypes(const KFileItemList& items, int timeout)
|
|||
{
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
foreach (const KFileItem& item, items) { // krazy:exclude=foreach
|
||||
for (const KFileItem& item : items) {
|
||||
// Only determine mime types for files here. For directories,
|
||||
// KFileItem::determineMimeType() reads the .directory file inside to
|
||||
// load the icon, but this is not necessary at all if we just need the
|
||||
|
|
|
@ -113,8 +113,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
|
|||
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
|
||||
this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
|
||||
|
||||
auto plugins = KPluginLoader::instantiatePlugins(QStringLiteral("kf5/overlayicon"), nullptr, qApp);
|
||||
foreach (QObject *it, plugins) {
|
||||
const auto plugins = KPluginLoader::instantiatePlugins(QStringLiteral("kf5/overlayicon"), nullptr, qApp);
|
||||
for (QObject *it : plugins) {
|
||||
auto plugin = qobject_cast<KOverlayIconPlugin*>(it);
|
||||
if (plugin) {
|
||||
m_overlayIconsPlugin.append(plugin);
|
||||
|
@ -324,7 +324,7 @@ void KFileItemModelRolesUpdater::slotItemsInserted(const KItemRangeList& itemRan
|
|||
// Determine the sort role synchronously for as many items as possible.
|
||||
if (m_resolvableRoles.contains(m_model->sortRole())) {
|
||||
int insertedCount = 0;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
const int lastIndex = insertedCount + range.index + range.count - 1;
|
||||
for (int i = insertedCount + range.index; i <= lastIndex; ++i) {
|
||||
if (timer.elapsed() < MaxBlockTimeout) {
|
||||
|
@ -364,7 +364,8 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang
|
|||
m_balooFileMonitor->clear();
|
||||
} else {
|
||||
QStringList newFileList;
|
||||
foreach (const QString& file, m_balooFileMonitor->files()) {
|
||||
const QStringList oldFileList = m_balooFileMonitor->files();
|
||||
for (const QString& file : oldFileList) {
|
||||
if (m_model->index(QUrl::fromLocalFile(file)) >= 0) {
|
||||
newFileList.append(file);
|
||||
}
|
||||
|
@ -424,7 +425,7 @@ void KFileItemModelRolesUpdater::slotItemsChanged(const KItemRangeList& itemRang
|
|||
|
||||
QSet<KFileItem>& targetSet = itemsChangedRecently ? m_recentlyChangedItems : m_changedItems;
|
||||
|
||||
foreach (const KItemRange& itemRange, itemRanges) {
|
||||
for (const KItemRange& itemRange : itemRanges) {
|
||||
int index = itemRange.index;
|
||||
for (int count = itemRange.count; count > 0; --count) {
|
||||
const KFileItem item = m_model->fileItem(index);
|
||||
|
@ -537,7 +538,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
|||
// It is more efficient to do it here, as KIconLoader::drawOverlays()
|
||||
// assumes that an overlay will be drawn and has some additional
|
||||
// setup time.
|
||||
foreach (const QString& overlay, overlays) {
|
||||
for (const QString& overlay : overlays) {
|
||||
if (!overlay.isEmpty()) {
|
||||
// There is at least one overlay, draw all overlays above m_pixmap
|
||||
// and cancel the check
|
||||
|
@ -722,7 +723,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesForItem(const KFileItem &
|
|||
const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
|
||||
QHash<QByteArray, QVariant> data;
|
||||
|
||||
foreach (const QByteArray& role, rolesProvider.roles()) {
|
||||
const auto roles = rolesProvider.roles();
|
||||
for (const QByteArray& role : roles) {
|
||||
// Overwrite all the role values with an empty QVariant, because the roles
|
||||
// provider doesn't overwrite it when the property value list is empty.
|
||||
// See bug 322348
|
||||
|
@ -808,7 +810,7 @@ void KFileItemModelRolesUpdater::startUpdating()
|
|||
m_pendingPreviewItems.clear();
|
||||
m_pendingPreviewItems.reserve(indexes.count());
|
||||
|
||||
foreach (int index, indexes) {
|
||||
for (int index : qAsConst(indexes)) {
|
||||
const KFileItem item = m_model->fileItem(index);
|
||||
if (!m_finishedItems.contains(item)) {
|
||||
m_pendingPreviewItems.append(item);
|
||||
|
@ -941,7 +943,7 @@ void KFileItemModelRolesUpdater::updateChangedItems()
|
|||
QList<int> visibleChangedIndexes;
|
||||
QList<int> invisibleChangedIndexes;
|
||||
|
||||
foreach (const KFileItem& item, m_changedItems) {
|
||||
for (const KFileItem& item : qAsConst(m_changedItems)) {
|
||||
const int index = m_model->index(item);
|
||||
|
||||
if (index < 0) {
|
||||
|
@ -959,11 +961,11 @@ void KFileItemModelRolesUpdater::updateChangedItems()
|
|||
std::sort(visibleChangedIndexes.begin(), visibleChangedIndexes.end());
|
||||
|
||||
if (m_previewShown) {
|
||||
foreach (int index, visibleChangedIndexes) {
|
||||
for (int index : qAsConst(visibleChangedIndexes)) {
|
||||
m_pendingPreviewItems.append(m_model->fileItem(index));
|
||||
}
|
||||
|
||||
foreach (int index, invisibleChangedIndexes) {
|
||||
for (int index : qAsConst(invisibleChangedIndexes)) {
|
||||
m_pendingPreviewItems.append(m_model->fileItem(index));
|
||||
}
|
||||
|
||||
|
@ -1078,7 +1080,7 @@ QHash<QByteArray, QVariant> KFileItemModelRolesUpdater::rolesData(const KFileIte
|
|||
}
|
||||
|
||||
QStringList overlays = item.overlays();
|
||||
foreach(KOverlayIconPlugin *it, m_overlayIconsPlugin) {
|
||||
for (KOverlayIconPlugin *it : qAsConst(m_overlayIconsPlugin)) {
|
||||
overlays.append(it->getOverlays(item.url()));
|
||||
}
|
||||
data.insert("iconOverlays", overlays);
|
||||
|
@ -1101,7 +1103,7 @@ void KFileItemModelRolesUpdater::slotOverlaysChanged(const QUrl& url, const QStr
|
|||
const int index = m_model->index(item);
|
||||
QHash<QByteArray, QVariant> data = m_model->data(index);
|
||||
QStringList overlays = item.overlays();
|
||||
foreach (KOverlayIconPlugin *it, m_overlayIconsPlugin) {
|
||||
for (KOverlayIconPlugin *it : qAsConst(m_overlayIconsPlugin)) {
|
||||
overlays.append(it->getOverlays(url));
|
||||
}
|
||||
data.insert("iconOverlays", overlays);
|
||||
|
|
|
@ -864,7 +864,8 @@ bool KItemListController::hoverLeaveEvent(QGraphicsSceneHoverEvent* event, const
|
|||
return false;
|
||||
}
|
||||
|
||||
foreach (KItemListWidget* widget, m_view->visibleItemListWidgets()) {
|
||||
const auto widgets = m_view->visibleItemListWidgets();
|
||||
for (KItemListWidget* widget : widgets) {
|
||||
if (widget->isHovered()) {
|
||||
widget->setHovered(false);
|
||||
emit itemUnhovered(widget->index());
|
||||
|
@ -1195,7 +1196,8 @@ void KItemListController::slotRubberBandChanged()
|
|||
KItemSet selectedItems;
|
||||
|
||||
// Select all visible items that intersect with the rubberband
|
||||
foreach (const KItemListWidget* widget, m_view->visibleItemListWidgets()) {
|
||||
const auto widgets = m_view->visibleItemListWidgets();
|
||||
for (const KItemListWidget* widget : widgets) {
|
||||
const int index = widget->index();
|
||||
|
||||
const QRectF widgetRect = m_view->itemRect(index);
|
||||
|
@ -1284,7 +1286,8 @@ KItemListWidget* KItemListController::hoveredWidget() const
|
|||
{
|
||||
Q_ASSERT(m_view);
|
||||
|
||||
foreach (KItemListWidget* widget, m_view->visibleItemListWidgets()) {
|
||||
const auto widgets = m_view->visibleItemListWidgets();
|
||||
for (KItemListWidget* widget : widgets) {
|
||||
if (widget->isHovered()) {
|
||||
return widget;
|
||||
}
|
||||
|
@ -1297,7 +1300,8 @@ KItemListWidget* KItemListController::widgetForPos(const QPointF& pos) const
|
|||
{
|
||||
Q_ASSERT(m_view);
|
||||
|
||||
foreach (KItemListWidget* widget, m_view->visibleItemListWidgets()) {
|
||||
const auto widgets = m_view->visibleItemListWidgets();
|
||||
for (KItemListWidget* widget : widgets) {
|
||||
const QPointF mappedPos = widget->mapFromItem(m_view, pos);
|
||||
|
||||
const bool hovered = widget->contains(mappedPos) &&
|
||||
|
|
|
@ -45,7 +45,8 @@ qreal KItemListHeader::columnWidth(const QByteArray& role) const
|
|||
void KItemListHeader::setColumnWidths(const QHash<QByteArray, qreal>& columnWidths)
|
||||
{
|
||||
if (!m_headerWidget->automaticColumnResizing()) {
|
||||
foreach (const QByteArray& role, m_view->visibleRoles()) {
|
||||
const auto visibleRoles = m_view->visibleRoles();
|
||||
for (const QByteArray& role : visibleRoles) {
|
||||
const qreal width = columnWidths.value(role);
|
||||
m_headerWidget->setColumnWidth(role, width);
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ void KItemListSelectionManager::itemsInserted(const KItemRangeList& itemRanges)
|
|||
} else {
|
||||
const int previousCurrent = m_currentItem;
|
||||
int inc = 0;
|
||||
foreach (const KItemRange& itemRange, itemRanges) {
|
||||
for (const KItemRange& itemRange : itemRanges) {
|
||||
if (m_currentItem < itemRange.index) {
|
||||
break;
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ void KItemListSelectionManager::itemsInserted(const KItemRangeList& itemRanges)
|
|||
m_anchorItem = 0;
|
||||
} else {
|
||||
int inc = 0;
|
||||
foreach (const KItemRange& itemRange, itemRanges) {
|
||||
for (const KItemRange& itemRange : itemRanges) {
|
||||
if (m_anchorItem < itemRange.index) {
|
||||
break;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ void KItemListSelectionManager::itemsInserted(const KItemRangeList& itemRanges)
|
|||
|
||||
for (int index: previous) {
|
||||
int inc = 0;
|
||||
foreach (const KItemRange& itemRange, itemRanges) {
|
||||
for (const KItemRange& itemRange : itemRanges) {
|
||||
if (index < itemRange.index) {
|
||||
break;
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa
|
|||
const RangesRemovingBehaviour behaviour) const
|
||||
{
|
||||
int dec = 0;
|
||||
foreach (const KItemRange& itemRange, itemRanges) {
|
||||
for (const KItemRange& itemRange : itemRanges) {
|
||||
if (index < itemRange.index) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ void KItemListView::setVisibleRoles(const QList<QByteArray>& roles)
|
|||
if (!m_headerWidget->automaticColumnResizing()) {
|
||||
// The column-width of new roles are still 0. Apply the preferred
|
||||
// column-width as default with.
|
||||
foreach (const QByteArray& role, m_visibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
|
||||
if (m_headerWidget->columnWidth(role) == 0) {
|
||||
const qreal width = m_headerWidget->preferredColumnWidth(role);
|
||||
m_headerWidget->setColumnWidth(role, width);
|
||||
|
@ -1029,7 +1029,7 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
|
|||
m_sizeHintResolver->itemsInserted(itemRanges);
|
||||
|
||||
int previouslyInsertedCount = 0;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
// range.index is related to the model before anything has been inserted.
|
||||
// As in each loop the current item-range gets inserted the index must
|
||||
// be increased by the already previously inserted items.
|
||||
|
@ -1155,7 +1155,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
|
|||
QVector<int> itemsToMove;
|
||||
|
||||
// Remove all KItemListWidget instances that got deleted
|
||||
foreach (KItemListWidget* widget, m_visibleItems) {
|
||||
for (KItemListWidget* widget : qAsConst(m_visibleItems)) {
|
||||
const int i = widget->index();
|
||||
if (i < firstRemovedIndex) {
|
||||
continue;
|
||||
|
@ -1191,7 +1191,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
|
|||
// after the deleted items. It is important to update them in ascending
|
||||
// order to prevent overlaps when setting the new index.
|
||||
std::sort(itemsToMove.begin(), itemsToMove.end());
|
||||
foreach (int i, itemsToMove) {
|
||||
for (int i : qAsConst(itemsToMove)) {
|
||||
KItemListWidget* widget = m_visibleItems.value(i);
|
||||
Q_ASSERT(widget);
|
||||
const int newIndex = i - count;
|
||||
|
@ -1269,7 +1269,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
|
|||
updatePreferredColumnWidths(itemRanges);
|
||||
}
|
||||
|
||||
foreach (const KItemRange& itemRange, itemRanges) {
|
||||
for (const KItemRange& itemRange : itemRanges) {
|
||||
const int index = itemRange.index;
|
||||
const int count = itemRange.count;
|
||||
|
||||
|
@ -1823,7 +1823,7 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
|
|||
}
|
||||
|
||||
// Delete invisible KItemListWidget instances that have not been reused
|
||||
foreach (int index, reusableItems) {
|
||||
for (int index : qAsConst(reusableItems)) {
|
||||
recycleWidget(m_visibleItems.value(index));
|
||||
}
|
||||
|
||||
|
@ -2197,7 +2197,7 @@ QHash<QByteArray, qreal> KItemListView::preferredColumnWidths(const KItemRangeLi
|
|||
const QFontMetricsF fontMetrics(m_headerWidget->font());
|
||||
const int gripMargin = m_headerWidget->style()->pixelMetric(QStyle::PM_HeaderGripMargin);
|
||||
const int headerMargin = m_headerWidget->style()->pixelMetric(QStyle::PM_HeaderMargin);
|
||||
foreach (const QByteArray& visibleRole, visibleRoles()) {
|
||||
for (const QByteArray& visibleRole : qAsConst(m_visibleRoles)) {
|
||||
const QString headerText = m_model->roleDescription(visibleRole);
|
||||
const qreal headerWidth = fontMetrics.width(headerText) + gripMargin + headerMargin * 2;
|
||||
widths.insert(visibleRole, headerWidth);
|
||||
|
@ -2208,12 +2208,12 @@ QHash<QByteArray, qreal> KItemListView::preferredColumnWidths(const KItemRangeLi
|
|||
const KItemListWidgetCreatorBase* creator = widgetCreator();
|
||||
int calculatedItemCount = 0;
|
||||
bool maxTimeExceeded = false;
|
||||
foreach (const KItemRange& itemRange, itemRanges) {
|
||||
for (const KItemRange& itemRange : itemRanges) {
|
||||
const int startIndex = itemRange.index;
|
||||
const int endIndex = startIndex + itemRange.count - 1;
|
||||
|
||||
for (int i = startIndex; i <= endIndex; ++i) {
|
||||
foreach (const QByteArray& visibleRole, visibleRoles()) {
|
||||
for (const QByteArray& visibleRole : qAsConst(m_visibleRoles)) {
|
||||
qreal maxWidth = widths.value(visibleRole, 0);
|
||||
const qreal width = creator->preferredRoleColumnWidth(visibleRole, i, this);
|
||||
maxWidth = qMax(width, maxWidth);
|
||||
|
@ -2255,7 +2255,7 @@ void KItemListView::applyColumnWidthsFromHeader()
|
|||
|
||||
void KItemListView::updateWidgetColumnWidths(KItemListWidget* widget)
|
||||
{
|
||||
foreach (const QByteArray& role, m_visibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
|
||||
widget->setColumnWidth(role, m_headerWidget->columnWidth(role));
|
||||
}
|
||||
}
|
||||
|
@ -2265,13 +2265,13 @@ void KItemListView::updatePreferredColumnWidths(const KItemRangeList& itemRanges
|
|||
Q_ASSERT(m_itemSize.isEmpty());
|
||||
const int itemCount = m_model->count();
|
||||
int rangesItemCount = 0;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
rangesItemCount += range.count;
|
||||
}
|
||||
|
||||
if (itemCount == rangesItemCount) {
|
||||
const QHash<QByteArray, qreal> preferredWidths = preferredColumnWidths(itemRanges);
|
||||
foreach (const QByteArray& role, m_visibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
|
||||
m_headerWidget->setPreferredColumnWidth(role, preferredWidths.value(role));
|
||||
}
|
||||
} else {
|
||||
|
@ -2326,7 +2326,7 @@ void KItemListView::applyAutomaticColumnWidths()
|
|||
// size does not use the available view-size the size of the
|
||||
// first role will get stretched.
|
||||
|
||||
foreach (const QByteArray& role, m_visibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
|
||||
const qreal preferredWidth = m_headerWidget->preferredColumnWidth(role);
|
||||
m_headerWidget->setColumnWidth(role, preferredWidth);
|
||||
}
|
||||
|
@ -2373,7 +2373,7 @@ void KItemListView::applyAutomaticColumnWidths()
|
|||
qreal KItemListView::columnWidthsSum() const
|
||||
{
|
||||
qreal widthsSum = 0;
|
||||
foreach (const QByteArray& role, m_visibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
|
||||
widthsSum += m_headerWidget->columnWidth(role);
|
||||
}
|
||||
return widthsSum;
|
||||
|
|
|
@ -31,7 +31,7 @@ KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) :
|
|||
|
||||
KItemListViewAccessible::~KItemListViewAccessible()
|
||||
{
|
||||
foreach (AccessibleIdWrapper idWrapper, m_cells) {
|
||||
for (AccessibleIdWrapper idWrapper : qAsConst(m_cells)) {
|
||||
if (idWrapper.isValid) {
|
||||
QAccessible::deleteAccessibleInterface(idWrapper.id);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ void KItemListWidget::setData(const QHash<QByteArray, QVariant>& data,
|
|||
m_data = data;
|
||||
dataChanged(m_data);
|
||||
} else {
|
||||
foreach (const QByteArray& role, roles) {
|
||||
for (const QByteArray& role : roles) {
|
||||
m_data[role] = data[role];
|
||||
}
|
||||
dataChanged(m_data, roles);
|
||||
|
|
|
@ -197,14 +197,14 @@ KItemSet KItemSet::operator^(const KItemSet& other) const
|
|||
const QVector<int>::iterator end = rangeBoundaries.end();
|
||||
QVector<int>::iterator it = begin;
|
||||
|
||||
foreach (const KItemRange& range, m_itemRanges) {
|
||||
for (const KItemRange& range : qAsConst(m_itemRanges)) {
|
||||
*it++ = range.index;
|
||||
*it++ = range.index + range.count;
|
||||
}
|
||||
|
||||
const QVector<int>::iterator middle = it;
|
||||
|
||||
foreach (const KItemRange& range, other.m_itemRanges) {
|
||||
for (const KItemRange& range : qAsConst(other.m_itemRanges)) {
|
||||
*it++ = range.index;
|
||||
*it++ = range.index + range.count;
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ inline KItemSet& KItemSet::operator=(const KItemSet& other)
|
|||
inline int KItemSet::count() const
|
||||
{
|
||||
int result = 0;
|
||||
foreach (const KItemRange& range, m_itemRanges) {
|
||||
for (const KItemRange& range : qAsConst(m_itemRanges)) {
|
||||
result += range.count;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -80,7 +80,8 @@ bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& c
|
|||
// Even if the icons have a different size they are always aligned within
|
||||
// the area defined by KItemStyleOption.iconSize and hence result in no
|
||||
// change of the item-size.
|
||||
foreach (const QByteArray& role, visibleRoles()) {
|
||||
const auto roles = visibleRoles();
|
||||
for (const QByteArray& role : roles) {
|
||||
if (changedRoles.contains(role)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -152,7 +153,8 @@ void KStandardItemListView::applyDefaultStyleOption(int iconSize,
|
|||
void KStandardItemListView::updateLayoutOfVisibleItems()
|
||||
{
|
||||
if (model()) {
|
||||
foreach (KItemListWidget* widget, visibleItemListWidgets()) {
|
||||
const auto widgets = visibleItemListWidgets();
|
||||
for (KItemListWidget* widget : widgets) {
|
||||
initializeItemListWidget(widget);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ void KStandardItemListWidgetInformant::calculateCompactLayoutItemSizeHints(QVect
|
|||
maximumRequiredWidth = fontMetrics.horizontalAdvance(itemText(index, view));
|
||||
} else {
|
||||
const QHash<QByteArray, QVariant>& values = view->model()->data(index);
|
||||
foreach (const QByteArray& role, visibleRoles) {
|
||||
for (const QByteArray& role : visibleRoles) {
|
||||
const QString& text = roleText(role, values);
|
||||
const qreal requiredWidth = fontMetrics.horizontalAdvance(text);
|
||||
maximumRequiredWidth = qMax(maximumRequiredWidth, requiredWidth);
|
||||
|
@ -1205,7 +1205,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
|
|||
|
||||
// Calculate the position for each additional information
|
||||
qreal y = nameTextInfo->pos.y() + nameHeight;
|
||||
foreach (const QByteArray& role, m_sortedVisibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_sortedVisibleRoles)) {
|
||||
if (role == "text") {
|
||||
continue;
|
||||
}
|
||||
|
@ -1268,7 +1268,7 @@ void KStandardItemListWidget::updateCompactLayoutTextCache()
|
|||
const qreal x = option.padding * 3 + scaledIconSize;
|
||||
qreal y = qRound((widgetHeight - textLinesHeight) / 2);
|
||||
const qreal maxWidth = size().width() - x - option.padding;
|
||||
foreach (const QByteArray& role, m_sortedVisibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_sortedVisibleRoles)) {
|
||||
const QString text = roleText(role, values);
|
||||
TextInfo* textInfo = m_textInfo.value(role);
|
||||
textInfo->staticText.setText(text);
|
||||
|
@ -1319,7 +1319,7 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
|
|||
qreal x = firstColumnInc;
|
||||
const qreal y = qMax(qreal(option.padding), (widgetHeight - fontHeight) / 2);
|
||||
|
||||
foreach (const QByteArray& role, m_sortedVisibleRoles) {
|
||||
for (const QByteArray& role : qAsConst(m_sortedVisibleRoles)) {
|
||||
QString text = roleText(role, values);
|
||||
|
||||
// Elide the text in case it does not fit into the available column-width
|
||||
|
@ -1493,7 +1493,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin
|
|||
// It is more efficient to do it here, as KIconLoader::drawOverlays()
|
||||
// assumes that an overlay will be drawn and has some additional
|
||||
// setup time.
|
||||
foreach (const QString& overlay, overlays) {
|
||||
for (const QString& overlay : overlays) {
|
||||
if (!overlay.isEmpty()) {
|
||||
int state = KIconLoader::DefaultState;
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ bool KFileItemModelFilter::matchesPattern(const KFileItem& item) const
|
|||
|
||||
bool KFileItemModelFilter::matchesType(const KFileItem& item) const
|
||||
{
|
||||
foreach (const QString& mimeType, m_mimeTypes) {
|
||||
for (const QString& mimeType : qAsConst(m_mimeTypes)) {
|
||||
if (item.mimetype() == mimeType) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ bool KItemListHeaderWidget::automaticColumnResizing() const
|
|||
|
||||
void KItemListHeaderWidget::setColumns(const QList<QByteArray>& roles)
|
||||
{
|
||||
foreach (const QByteArray& role, roles) {
|
||||
for (const QByteArray& role : roles) {
|
||||
if (!m_columnWidths.contains(role)) {
|
||||
m_preferredColumnWidths.remove(role);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ void KItemListHeaderWidget::paint(QPainter* painter, const QStyleOptionGraphicsI
|
|||
|
||||
qreal x = -m_offset;
|
||||
int orderIndex = 0;
|
||||
foreach (const QByteArray& role, m_columns) {
|
||||
for (const QByteArray& role : qAsConst(m_columns)) {
|
||||
const qreal roleWidth = m_columnWidths.value(role);
|
||||
const QRectF rect(x, 0, roleWidth, size().height());
|
||||
paintRole(painter, role, rect, orderIndex, widget);
|
||||
|
@ -468,7 +468,7 @@ int KItemListHeaderWidget::roleIndexAt(const QPointF& pos) const
|
|||
int index = -1;
|
||||
|
||||
qreal x = -m_offset;
|
||||
foreach (const QByteArray& role, m_columns) {
|
||||
for (const QByteArray& role : qAsConst(m_columns)) {
|
||||
++index;
|
||||
x += m_columnWidths.value(role);
|
||||
if (pos.x() <= x) {
|
||||
|
@ -549,7 +549,7 @@ int KItemListHeaderWidget::targetOfMovingRole() const
|
|||
qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
|
||||
{
|
||||
qreal x = -m_offset;
|
||||
foreach (const QByteArray& visibleRole, m_columns) {
|
||||
for (const QByteArray& visibleRole : qAsConst(m_columns)) {
|
||||
if (visibleRole == role) {
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ QSizeF KItemListSizeHintResolver::sizeHint(int index)
|
|||
void KItemListSizeHintResolver::itemsInserted(const KItemRangeList& itemRanges)
|
||||
{
|
||||
int insertedCount = 0;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
insertedCount += range.count;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,10 +139,10 @@ void TreeViewContextMenu::open(const QPoint& pos)
|
|||
popup->addAction(propertiesAction);
|
||||
}
|
||||
|
||||
QList<QAction*> customActions = m_parent->customContextMenuActions();
|
||||
const QList<QAction*> customActions = m_parent->customContextMenuActions();
|
||||
if (!customActions.isEmpty()) {
|
||||
popup->addSeparator();
|
||||
foreach (QAction* action, customActions) {
|
||||
for (QAction* action : customActions) {
|
||||
popup->addAction(action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,7 +322,8 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
|
|||
menu.addMenu(iconSizeSubMenu);
|
||||
|
||||
menu.addSeparator();
|
||||
foreach (QAction* action, customContextMenuActions()) {
|
||||
const auto actions = customContextMenuActions();
|
||||
for (QAction* action : actions) {
|
||||
menu.addAction(action);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void DolphinQuery::parseBalooQuery()
|
|||
QString fileName;
|
||||
|
||||
const QStringList subTerms = splitOutsideQuotes(query.searchString());
|
||||
foreach (const QString& subTerm, subTerms) {
|
||||
for (const QString& subTerm : subTerms) {
|
||||
const QString token = searchTermToken(subTerm);
|
||||
const QString value = stripQuotes(subTerm.mid(token.length()));
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ ApplyViewPropsJob::~ApplyViewPropsJob()
|
|||
|
||||
void ApplyViewPropsJob::slotEntries(KIO::Job*, const KIO::UDSEntryList& list)
|
||||
{
|
||||
foreach (const KIO::UDSEntry& entry, list) {
|
||||
for (const KIO::UDSEntry& entry : list) {
|
||||
const QString name = entry.stringValue(KIO::UDSEntry::UDS_NAME);
|
||||
if (name != QLatin1Char('.') && name != QLatin1String("..") && entry.isDir()) {
|
||||
++m_progress;
|
||||
|
|
|
@ -118,7 +118,7 @@ void DolphinSettingsDialog::enableApply()
|
|||
|
||||
void DolphinSettingsDialog::applySettings()
|
||||
{
|
||||
foreach (SettingsPageBase* page, m_pages) {
|
||||
for (SettingsPageBase* page : qAsConst(m_pages)) {
|
||||
page->applySettings();
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void DolphinSettingsDialog::applySettings()
|
|||
|
||||
void DolphinSettingsDialog::restoreDefaults()
|
||||
{
|
||||
foreach (SettingsPageBase* page, m_pages) {
|
||||
for (SettingsPageBase* page : qAsConst(m_pages)) {
|
||||
page->restoreDefaults();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,14 +59,14 @@ GeneralSettingsPage::~GeneralSettingsPage()
|
|||
|
||||
void GeneralSettingsPage::applySettings()
|
||||
{
|
||||
foreach (SettingsPageBase* page, m_pages) {
|
||||
for (SettingsPageBase* page : qAsConst(m_pages)) {
|
||||
page->applySettings();
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::restoreDefaults()
|
||||
{
|
||||
foreach (SettingsPageBase* page, m_pages) {
|
||||
for (SettingsPageBase* page : qAsConst(m_pages)) {
|
||||
page->restoreDefaults();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ void PreviewsSettingsPage::loadPreviewPlugins()
|
|||
QAbstractItemModel* model = m_listView->model();
|
||||
|
||||
const KService::List plugins = KServiceTypeTrader::self()->query(QStringLiteral("ThumbCreator"));
|
||||
foreach (const KService::Ptr& service, plugins) {
|
||||
for (const KService::Ptr& service : plugins) {
|
||||
const bool configurable = service->property(QStringLiteral("Configurable"), QVariant::Bool).toBool();
|
||||
const bool show = m_enabledPreviewPlugins.contains(service->desktopEntryName());
|
||||
|
||||
|
|
|
@ -51,14 +51,14 @@ ViewSettingsPage::~ViewSettingsPage()
|
|||
|
||||
void ViewSettingsPage::applySettings()
|
||||
{
|
||||
foreach (ViewSettingsTab* tab, m_tabs) {
|
||||
for (ViewSettingsTab* tab : qAsConst(m_tabs)) {
|
||||
tab->applySettings();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewSettingsPage::restoreDefaults()
|
||||
{
|
||||
foreach (ViewSettingsTab* tab, m_tabs) {
|
||||
for (ViewSettingsTab* tab : qAsConst(m_tabs)) {
|
||||
tab->restoreDefaultSettings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
|
||||
m_sorting = new QComboBox();
|
||||
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
|
||||
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
|
||||
for (const KFileItemModel::RoleInfo& info : rolesInfo) {
|
||||
m_sorting->addItem(info.translation, info.role);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
connect(m_listWidget, &QListWidget::itemChanged, this, &ViewPropertiesDialog::slotItemChanged);
|
||||
m_listWidget->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
|
||||
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
|
||||
for (const KFileItemModel::RoleInfo& info : rolesInfo) {
|
||||
QListWidgetItem* item = new QListWidgetItem(info.translation, m_listWidget);
|
||||
item->setCheckState(visibleRoles.contains(info.role) ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
|
@ -325,7 +325,7 @@ void ViewPropertiesDialog::applyViewProperties()
|
|||
QList<QByteArray> visibleRoles;
|
||||
int index = 0;
|
||||
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
|
||||
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
|
||||
for (const KFileItemModel::RoleInfo& info : rolesInfo) {
|
||||
const QListWidgetItem* item = m_listWidget->item(index);
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
visibleRoles.append(info.role);
|
||||
|
|
|
@ -67,7 +67,7 @@ void KFileItemModelBenchmark::insertAndRemoveManyItems_data()
|
|||
QList<int> sizes;
|
||||
sizes << 100000;
|
||||
|
||||
foreach (int n, sizes) {
|
||||
for (int n : qAsConst(sizes)) {
|
||||
QStringList allStrings;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
allStrings << QString::number(i);
|
||||
|
@ -197,7 +197,7 @@ KFileItemList KFileItemModelBenchmark::createFileItemList(const QStringList& fil
|
|||
qInstallMessageHandler(myMessageOutput);
|
||||
|
||||
KFileItemList result;
|
||||
foreach (const QString& name, fileNames) {
|
||||
for (const QString& name : fileNames) {
|
||||
const KFileItem item(QUrl::fromLocalFile(prefix + name), QString(), KFileItem::Unknown);
|
||||
result << item;
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ void KItemListControllerTest::testKeyboardNavigation_data()
|
|||
groupingEnabledList.append(true);
|
||||
groupingEnabledNames[true] = "grouping enabled";
|
||||
|
||||
foreach (const KFileItemListView::ItemLayout& layout, layoutList) {
|
||||
for (const KFileItemListView::ItemLayout& layout : layoutList) {
|
||||
// The following settings depend on the layout.
|
||||
// Note that 'columns' are actually 'rows' in
|
||||
// Compact layout.
|
||||
|
@ -279,9 +279,9 @@ void KItemListControllerTest::testKeyboardNavigation_data()
|
|||
break;
|
||||
}
|
||||
|
||||
foreach (int columnCount, columnCountList) {
|
||||
foreach (const KItemListController::SelectionBehavior& selectionBehavior, selectionBehaviorList) {
|
||||
foreach (bool groupingEnabled, groupingEnabledList) { // krazy:exclude=foreach
|
||||
for (int columnCount : qAsConst(columnCountList)) {
|
||||
for (const KItemListController::SelectionBehavior& selectionBehavior : qAsConst(selectionBehaviorList)) {
|
||||
for (bool groupingEnabled : qAsConst(groupingEnabledList)) {
|
||||
QList<QPair<KeyPress, ViewState> > testList;
|
||||
|
||||
// First, key presses which should have the same effect
|
||||
|
|
|
@ -16,7 +16,7 @@ Q_DECLARE_METATYPE(KItemRangeList)
|
|||
KItemSet KItemRangeList2KItemSet(const KItemRangeList& itemRanges)
|
||||
{
|
||||
KItemSet result;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
for (int i = range.index; i < range.index + range.count; ++i) {
|
||||
result.insert(i);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ KItemSet KItemRangeList2KItemSet(const KItemRangeList& itemRanges)
|
|||
QSet<int> KItemRangeList2QSet(const KItemRangeList& itemRanges)
|
||||
{
|
||||
QSet<int> result;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
for (int i = range.index; i < range.index + range.count; ++i) {
|
||||
result.insert(i);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ QSet<int> KItemRangeList2QSet(const KItemRangeList& itemRanges)
|
|||
QVector<int> KItemRangeList2QVector(const KItemRangeList& itemRanges)
|
||||
{
|
||||
QVector<int> result;
|
||||
foreach (const KItemRange& range, itemRanges) {
|
||||
for (const KItemRange& range : itemRanges) {
|
||||
for (int i = range.index; i < range.index + range.count; ++i) {
|
||||
result.append(i);
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ static QSet<int> KItemSet2QSet(const KItemSet& itemSet)
|
|||
// Check that the conversion was successful.
|
||||
Q_ASSERT(itemSet.count() == result.count());
|
||||
|
||||
for (int i : itemSet) {
|
||||
for (int i : qAsConst(itemSet)) {
|
||||
Q_ASSERT(result.contains(i));
|
||||
}
|
||||
|
||||
foreach (int i, result) {
|
||||
for (int i : qAsConst(result)) {
|
||||
Q_ASSERT(itemSet.contains(i));
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void TestDir::createFile(const QString& path, const QByteArray& data, const QDat
|
|||
|
||||
void TestDir::createFiles(const QStringList& files)
|
||||
{
|
||||
foreach (const QString& path, files) {
|
||||
for (const QString& path : files) {
|
||||
createFile(path);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void TestDir::createDir(const QString& path, const QDateTime& time)
|
|||
|
||||
void TestDir::removeFiles(const QStringList& files)
|
||||
{
|
||||
foreach (const QString& path, files) {
|
||||
for (const QString& path : files) {
|
||||
removeFile(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -512,7 +512,7 @@ QString DolphinView::statusBarText() const
|
|||
if (m_container->controller()->selectionManager()->hasSelection()) {
|
||||
// Give a summary of the status of the selected files
|
||||
const KFileItemList list = selectedItems();
|
||||
foreach (const KFileItem& item, list) {
|
||||
for (const KFileItem& item : list) {
|
||||
if (item.isDir()) {
|
||||
++folderCount;
|
||||
} else {
|
||||
|
@ -976,7 +976,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
|
|||
|
||||
// Add all roles to the menu that can be shown or hidden by the user
|
||||
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
|
||||
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
|
||||
for (const KFileItemModel::RoleInfo& info : rolesInfo) {
|
||||
if (info.role == "text") {
|
||||
// It should not be possible to hide the "text" role
|
||||
continue;
|
||||
|
@ -1033,8 +1033,9 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
|
|||
// Apply the current column-widths as custom column-widths and turn
|
||||
// off the automatic resizing of the columns
|
||||
QList<int> columnWidths;
|
||||
columnWidths.reserve(view->visibleRoles().count());
|
||||
foreach (const QByteArray& role, view->visibleRoles()) {
|
||||
const auto visibleRoles = view->visibleRoles();
|
||||
columnWidths.reserve(visibleRoles.count());
|
||||
for (const QByteArray& role : visibleRoles) {
|
||||
columnWidths.append(header->columnWidth(role));
|
||||
}
|
||||
props.setHeaderColumnWidths(columnWidths);
|
||||
|
@ -1055,8 +1056,9 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
|
|||
|
||||
QList<int> columnWidths;
|
||||
if (!header->automaticColumnResizing()) {
|
||||
columnWidths.reserve(view->visibleRoles().count());
|
||||
foreach (const QByteArray& role, view->visibleRoles()) {
|
||||
const auto visibleRoles = view->visibleRoles();
|
||||
columnWidths.reserve(visibleRoles.count());
|
||||
for (const QByteArray& role : visibleRoles) {
|
||||
columnWidths.append(header->columnWidth(role));
|
||||
}
|
||||
}
|
||||
|
@ -1077,7 +1079,7 @@ void DolphinView::slotHeaderColumnWidthChangeFinished(const QByteArray& role, qr
|
|||
columnWidths.clear();
|
||||
columnWidths.reserve(visibleRoles.count());
|
||||
const KItemListHeader* header = m_view->header();
|
||||
foreach (const QByteArray& role, visibleRoles) {
|
||||
for (const QByteArray& role : visibleRoles) {
|
||||
const int width = header->columnWidth(role);
|
||||
columnWidths.append(width);
|
||||
}
|
||||
|
@ -1876,7 +1878,7 @@ QList<QUrl> DolphinView::simplifiedSelectedUrls() const
|
|||
|
||||
const KFileItemList items = selectedItems();
|
||||
urls.reserve(items.count());
|
||||
foreach (const KFileItem& item, items) {
|
||||
for (const KFileItem& item : items) {
|
||||
urls.append(item.url());
|
||||
}
|
||||
|
||||
|
|
|
@ -227,7 +227,8 @@ void DolphinViewActionHandler::createActions()
|
|||
sortByActionMenu->setText(i18nc("@action:inmenu View", "Sort By"));
|
||||
sortByActionMenu->setDelayed(false);
|
||||
|
||||
foreach (QAction* action, sortByActionGroup->actions()) {
|
||||
const auto sortByActionGroupActions = sortByActionGroup->actions();
|
||||
for (QAction* action : sortByActionGroupActions) {
|
||||
sortByActionMenu->addAction(action);
|
||||
}
|
||||
|
||||
|
@ -261,7 +262,8 @@ void DolphinViewActionHandler::createActions()
|
|||
visibleRolesMenu->setIcon(QIcon::fromTheme(QStringLiteral("documentinfo")));
|
||||
visibleRolesMenu->setDelayed(false);
|
||||
|
||||
foreach (QAction* action, visibleRolesGroup->actions()) {
|
||||
const auto visibleRolesGroupActions = visibleRolesGroup->actions();
|
||||
for (QAction* action : visibleRolesGroupActions) {
|
||||
visibleRolesMenu->addAction(action);
|
||||
}
|
||||
|
||||
|
@ -317,7 +319,7 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
|
|||
#endif
|
||||
|
||||
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
|
||||
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
|
||||
for (const KFileItemModel::RoleInfo& info : rolesInfo) {
|
||||
if (!isSortGroup && info.role == "text") {
|
||||
// It should not be possible to hide the "text" role
|
||||
continue;
|
||||
|
@ -654,7 +656,8 @@ void DolphinViewActionHandler::slotSortTriggered(QAction* action)
|
|||
for (QAction *groupAction : qAsConst(m_sortByActions)) {
|
||||
KActionMenu* actionMenu = qobject_cast<KActionMenu*>(groupAction);
|
||||
if (actionMenu) {
|
||||
foreach (QAction* subAction, actionMenu->menu()->actions()) {
|
||||
const auto actions = actionMenu->menu()->actions();
|
||||
for (QAction* subAction : actions) {
|
||||
subAction->setChecked(false);
|
||||
}
|
||||
} else if (groupAction->actionGroup()) {
|
||||
|
|
|
@ -97,7 +97,7 @@ DolphinView* VersionControlObserver::view() const
|
|||
QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
|
||||
{
|
||||
bool hasNullItems = false;
|
||||
foreach (const KFileItem& item, items) {
|
||||
for (const KFileItem& item : items) {
|
||||
if (item.isNull()) {
|
||||
qCWarning(DolphinDebug) << "Requesting version-control-actions for empty items";
|
||||
hasNullItems = true;
|
||||
|
@ -189,7 +189,7 @@ void VersionControlObserver::slotThreadFinished()
|
|||
for (; it != itemStates.constEnd(); ++it) {
|
||||
const QVector<ItemState>& items = it.value();
|
||||
|
||||
foreach (const ItemState& item, items) {
|
||||
for (const ItemState& item : items) {
|
||||
const KFileItem& fileItem = item.first;
|
||||
const KVersionControlPlugin::ItemVersion version = item.second;
|
||||
QHash<QByteArray, QVariant> values;
|
||||
|
|
|
@ -266,7 +266,7 @@ void ViewProperties::setVisibleRoles(const QList<QByteArray>& roles)
|
|||
|
||||
// Add the updated values for the current view-mode
|
||||
newVisibleRoles.reserve(roles.count());
|
||||
foreach (const QByteArray& role, roles) {
|
||||
for (const QByteArray& role : roles) {
|
||||
newVisibleRoles.append(prefix + role);
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const
|
|||
const int prefixLength = prefix.length();
|
||||
|
||||
const QStringList visibleRoles = m_node->visibleRoles();
|
||||
foreach (const QString& visibleRole, visibleRoles) {
|
||||
for (const QString& visibleRole : visibleRoles) {
|
||||
if (visibleRole.startsWith(prefix)) {
|
||||
const QByteArray role = visibleRole.right(visibleRole.length() - prefixLength).toLatin1();
|
||||
if (role != "text") {
|
||||
|
@ -422,7 +422,7 @@ void ViewProperties::convertAdditionalInfo()
|
|||
// the internal role. One special-case must be handled: "LinkDestination"
|
||||
// has been used for "destination".
|
||||
visibleRoles.reserve(additionalInfo.count());
|
||||
foreach (const QString& info, additionalInfo) {
|
||||
for (const QString& info : additionalInfo) {
|
||||
QString visibleRole = info;
|
||||
int index = visibleRole.indexOf('_');
|
||||
if (index >= 0 && index + 1 < visibleRole.length()) {
|
||||
|
|
Loading…
Reference in a new issue