• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/project

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • project
projectutils.cpp
Go to the documentation of this file.
1 /*
2  <one line to give the program's name and a brief idea of what it does.>
3  Copyright (C) 2011 David Nolden <[email protected]>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 
21 #include "projectutils.h"
22 #include <project/projectmodel.h>
23 #include "path.h"
24 
25 
26 namespace KDevelop {
27 
28 ProjectItemContextImpl::ProjectItemContextImpl(const QList<ProjectBaseItem*>& items)
29  : ProjectItemContext(items)
30 {
31 }
32 
33 QList<QUrl> ProjectItemContextImpl::urls() const
34 {
35  QList<QUrl> urls;
36  const auto items = this->items();
37  for (const auto& item : items) {
38  const auto url = item->path().toUrl();
39  if (url.isValid()) {
40  urls << url;
41  }
42  }
43  return urls;
44 }
45 
49 void forEachFile(const ProjectBaseItem* projectItem,
50  const std::function<void(ProjectFileItem*)>& callback)
51 {
52  if (auto* file = projectItem->file()) {
53  callback(file);
54  return;
55  }
56 
57  const auto children = projectItem->children();
58  for (const auto *child : children) {
59  forEachFile(child, callback);
60  }
61 }
62 
63 QList<ProjectFileItem*> allFiles(const ProjectBaseItem* projectItem)
64 {
65  QList<ProjectFileItem*> files;
66  forEachFile(projectItem, [&files](ProjectFileItem *fileItem) {
67  files.append(fileItem);
68  });
69  return files;
70 }
71 
72 }
QList::append
void append(const T &value)
projectutils.h
KDevelop::ProjectItemContextImpl::urls
QList< QUrl > urls() const override
Definition: projectutils.cpp:33
KDevelop::ProjectFileItem
Object which represents a file.
Definition: projectmodel.h:383
KDevelop::ProjectBaseItem
Interface that allows a developer to implement the three basic types of items you would see in a mult...
Definition: projectmodel.h:101
KDevelop::ProjectBaseItem::file
virtual ProjectFileItem * file() const
Definition: projectmodel.cpp:525
QList
Definition: projectmodel.h:31
KDevelop::forEachFile
void forEachFile(const ProjectBaseItem *projectItem, const std::function< void(ProjectFileItem *)> &callback)
Runs the callback on all files that have projectItem as ancestor.
Definition: projectutils.cpp:49
KDevelop::allFiles
QList< ProjectFileItem * > allFiles(const ProjectBaseItem *projectItem)
Returns all the files that have projectItem as ancestor.
Definition: projectutils.cpp:63
KDevelop::ProjectItemContextImpl::ProjectItemContextImpl
ProjectItemContextImpl(const QList< ProjectBaseItem * > &items)
Definition: projectutils.cpp:28
projectmodel.h
ProjectItemContext
KDevelop::ProjectBaseItem::children
QList< ProjectBaseItem * > children() const
Definition: projectmodel.cpp:207
KDevelop
Definition: abstractfilemanagerplugin.h:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 23:39:05 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/project

Skip menu "kdevplatform/project"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal