Commit 9756bab6 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

projectmanagerview: port foreach -> range-based for

parent 92f0214c
......@@ -172,8 +172,8 @@ void ProjectBuildSetWidget::showContextMenu( const QPoint& p )
void ProjectBuildSetWidget::addItems()
{
foreach( KDevelop::ProjectBaseItem* item, m_view->selectedItems() )
{
const auto selectedItems = m_view->selectedItems();
for (KDevelop::ProjectBaseItem* item : selectedItems) {
KDevelop::ICore::self()->projectController()->buildSetModel()->addProjectItem( item );
}
}
......
......@@ -199,8 +199,8 @@ ProjectManagerView::~ProjectManagerView()
QList<KDevelop::ProjectBaseItem*> ProjectManagerView::selectedItems() const
{
QList<KDevelop::ProjectBaseItem*> items;
foreach( const QModelIndex &idx, m_ui->projectTreeView->selectionModel()->selectedIndexes() )
{
const auto selectedIndexes = m_ui->projectTreeView->selectionModel()->selectedIndexes();
for (const QModelIndex& idx : selectedIndexes) {
KDevelop::ProjectBaseItem* item = ICore::self()->projectController()->projectModel()->itemFromIndex(indexFromView(idx));
if( item )
items << item;
......@@ -249,8 +249,10 @@ void ProjectManagerView::locateCurrentDocument()
}
QModelIndex bestMatch;
foreach (IProject* proj, ICore::self()->projectController()->projects()) {
foreach (KDevelop::ProjectFileItem* item, proj->filesForPath(IndexedString(doc->url()))) {
const auto projects = ICore::self()->projectController()->projects();
for (IProject* proj : projects) {
const auto files = proj->filesForPath(IndexedString(doc->url()));
for (KDevelop::ProjectFileItem* item : files) {
QModelIndex index = indexToView(item->index());
if (index.isValid()) {
if (!bestMatch.isValid()) {
......
......@@ -381,8 +381,7 @@ void ProjectManagerViewPlugin::closeProjects()
{
QList<KDevelop::IProject*> projectsToClose;
ProjectModel* model = ICore::self()->projectController()->projectModel();
foreach( const QModelIndex& index, d->ctxProjectItemList )
{
for (const QModelIndex& index : qAsConst(d->ctxProjectItemList)) {
KDevelop::ProjectBaseItem* item = model->itemFromIndex(index);
if( !projectsToClose.contains( item->project() ) )
{
......@@ -390,8 +389,7 @@ void ProjectManagerViewPlugin::closeProjects()
}
}
d->ctxProjectItemList.clear();
foreach( KDevelop::IProject* proj, projectsToClose )
{
for (KDevelop::IProject* proj : qAsConst(projectsToClose)) {
core()->projectController()->closeProject( proj );
}
}
......@@ -489,16 +487,16 @@ void ProjectManagerViewPlugin::buildProjectItems()
void ProjectManagerViewPlugin::addItemsFromContextMenuToBuildset( )
{
foreach( KDevelop::ProjectBaseItem* item, itemsFromIndexes( d->ctxProjectItemList ))
{
const auto items = itemsFromIndexes(d->ctxProjectItemList);
for (KDevelop::ProjectBaseItem* item : items) {
ICore::self()->projectController()->buildSetModel()->addProjectItem( item );
}
}
void ProjectManagerViewPlugin::runTargetsFromContextMenu( )
{
foreach( KDevelop::ProjectBaseItem* item, itemsFromIndexes( d->ctxProjectItemList ))
{
const auto items = itemsFromIndexes(d->ctxProjectItemList);
for (KDevelop::ProjectBaseItem* item : items) {
KDevelop::ProjectExecutableTargetItem* t=item->executable();
if(t)
{
......@@ -519,12 +517,13 @@ void ProjectManagerViewPlugin::projectConfiguration( )
void ProjectManagerViewPlugin::reloadFromContextMenu( )
{
QList< KDevelop::ProjectFolderItem* > folders;
foreach( KDevelop::ProjectBaseItem* item, itemsFromIndexes( d->ctxProjectItemList ) )
{
const auto items = itemsFromIndexes(d->ctxProjectItemList);
for (KDevelop::ProjectBaseItem* item : items) {
if ( item->folder() ) {
// since reloading should be recursive, only pass the upper-most items
bool found = false;
foreach ( KDevelop::ProjectFolderItem* existing, folders ) {
const auto currentFolders = folders;
for (KDevelop::ProjectFolderItem* existing : currentFolders) {
if ( existing->path().isParentOf(item->folder()->path()) ) {
// simply skip this child
found = true;
......@@ -540,15 +539,15 @@ void ProjectManagerViewPlugin::reloadFromContextMenu( )
}
}
}
foreach( KDevelop::ProjectFolderItem* folder, folders ) {
for (KDevelop::ProjectFolderItem* folder : qAsConst(folders)) {
folder->project()->projectFileManager()->reload(folder);
}
}
void ProjectManagerViewPlugin::createFolderFromContextMenu( )
{
foreach( KDevelop::ProjectBaseItem* item, itemsFromIndexes( d->ctxProjectItemList ))
{
const auto items = itemsFromIndexes(d->ctxProjectItemList);
for (KDevelop::ProjectBaseItem* item : items) {
if ( item->folder() ) {
QWidget* window(ICore::self()->uiController()->activeMainWindow()->window());
QString name = QInputDialog::getText ( window,
......@@ -578,8 +577,7 @@ void ProjectManagerViewPlugin::removeItems(const QList< ProjectBaseItem* >& item
Path lastFolder;
QHash< IProjectFileManager*, QList<KDevelop::ProjectBaseItem*> > filteredItems;
QStringList itemPaths;
foreach( KDevelop::ProjectBaseItem* item, sortedItems )
{
for (KDevelop::ProjectBaseItem* item : qAsConst(sortedItems)) {
if (item->isProjectRoot()) {
continue;
} else if (item->folder() || item->file()) {
......@@ -702,8 +700,8 @@ ProjectFileItem* createFile(const ProjectFolderItem* item)
void ProjectManagerViewPlugin::createFileFromContextMenu( )
{
foreach( KDevelop::ProjectBaseItem* item, itemsFromIndexes( d->ctxProjectItemList ) )
{
const auto items = itemsFromIndexes(d->ctxProjectItemList);
for (KDevelop::ProjectBaseItem* item : items) {
if ( item->folder() ) {
createFile(item->folder());
} else if ( item->target() ) {
......
......@@ -192,7 +192,7 @@ void ProjectTreeView::dropEvent(QDropEvent* event)
filterDroppedItems(usefulItems, destItem);
Path::List paths;
paths.reserve(usefulItems.size());
foreach (ProjectBaseItem* i, usefulItems) {
for (ProjectBaseItem* i : qAsConst(usefulItems)) {
paths << i->path();
}
bool success = false;
......@@ -208,9 +208,10 @@ void ProjectTreeView::dropEvent(QDropEvent* event)
//and select new items
QItemSelection selection;
foreach (const Path &path, paths) {
for (const Path& path : qAsConst(paths)) {
const Path targetPath(folder->path(), path.lastPathSegment());
foreach (ProjectBaseItem *item, folder->children()) {
const auto folderChildren = folder->children();
for (ProjectBaseItem* item : folderChildren) {
if (item->path() == targetPath) {
QModelIndex indx = mapFromItem( item );
selection.append(QItemSelectionRange(indx, indx));
......@@ -359,8 +360,7 @@ void ProjectTreeView::popupContextMenu( const QPoint &pos )
{
QMenu* analyzeMenu = new QMenu(i18n("Analyze With"), &menu);
analyzeMenu->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok")));
foreach( QAction* act, analyzeActions )
{
for (QAction* act : qAsConst(analyzeActions)) {
analyzeMenu->addAction( act );
}
analyzeActions = {analyzeMenu->menuAction()};
......
......@@ -46,7 +46,8 @@ VcsOverlayProxyModel::VcsOverlayProxyModel(QObject* parent): QIdentityProxyModel
connect(ICore::self()->projectController(), &IProjectController::projectClosing,
this, &VcsOverlayProxyModel::removeProject);
foreach (const auto project, ICore::self()->projectController()->projects()) {
const auto projects = ICore::self()->projectController()->projects();
for (const auto project : projects) {
addProject(project);
}
}
......
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