2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2016-02-02 18:26:51 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "projectexplorer_export.h"
|
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
|
2016-10-20 13:27:10 +02:00
|
|
|
#include <QFutureInterface>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QIcon>
|
2011-08-18 13:46:52 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QStringList>
|
2014-02-10 16:05:35 +01:00
|
|
|
#include <QDebug>
|
2011-01-20 18:05:58 +01:00
|
|
|
|
2016-10-20 13:27:10 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QFileInfo;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
2011-08-18 13:46:52 +02:00
|
|
|
class RunConfiguration;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-10-31 13:33:13 +01:00
|
|
|
enum class NodeType : quint16 {
|
|
|
|
|
File = 1,
|
|
|
|
|
Folder,
|
|
|
|
|
VirtualFolder,
|
|
|
|
|
Project,
|
|
|
|
|
Session
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// File types common for qt projects
|
2016-10-31 13:47:42 +01:00
|
|
|
enum class FileType : quint16 {
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
Header,
|
|
|
|
|
Source,
|
|
|
|
|
Form,
|
|
|
|
|
StateChart,
|
|
|
|
|
Resource,
|
|
|
|
|
QML,
|
|
|
|
|
Project,
|
2008-12-02 12:01:29 +01:00
|
|
|
FileTypeSize
|
|
|
|
|
};
|
|
|
|
|
|
2014-02-03 14:45:28 +01:00
|
|
|
enum ProjectAction {
|
2014-02-18 16:31:36 +01:00
|
|
|
// Special value to indicate that the actions are handled by the parent
|
|
|
|
|
InheritedFromParent,
|
2014-02-03 14:45:28 +01:00
|
|
|
AddSubProject,
|
|
|
|
|
RemoveSubProject,
|
|
|
|
|
// Let's the user select to which project file
|
|
|
|
|
// the file is added
|
|
|
|
|
AddNewFile,
|
|
|
|
|
AddExistingFile,
|
|
|
|
|
// Add files, which match user defined filters,
|
|
|
|
|
// from an existing directory and its subdirectories
|
|
|
|
|
AddExistingDirectory,
|
|
|
|
|
// Removes a file from the project, optionally also
|
|
|
|
|
// delete it on disc
|
|
|
|
|
RemoveFile,
|
|
|
|
|
// Deletes a file from the file system, informs the project
|
|
|
|
|
// that a file was deleted
|
|
|
|
|
// DeleteFile is a define on windows...
|
|
|
|
|
EraseFile,
|
|
|
|
|
Rename,
|
2016-04-08 16:25:29 +02:00
|
|
|
DuplicateFile,
|
2014-02-07 12:35:47 +01:00
|
|
|
// hides actions that use the path(): Open containing folder, open terminal here and Find in Directory
|
|
|
|
|
HidePathActions,
|
2014-03-17 16:51:15 +01:00
|
|
|
HideFileActions,
|
|
|
|
|
HideFolderActions,
|
2014-02-03 14:45:28 +01:00
|
|
|
HasSubProjectRunConfigurations
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class Node;
|
|
|
|
|
class FileNode;
|
|
|
|
|
class FileContainerNode;
|
|
|
|
|
class FolderNode;
|
|
|
|
|
class ProjectNode;
|
2015-02-18 13:10:40 +01:00
|
|
|
class SessionNode;
|
2008-12-02 12:01:29 +01:00
|
|
|
class NodesVisitor;
|
2012-01-31 13:40:59 +01:00
|
|
|
class SessionManager;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2015-01-09 15:50:06 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT Node
|
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2016-10-31 13:33:13 +01:00
|
|
|
virtual ~Node() = default;
|
2008-12-02 12:01:29 +01:00
|
|
|
NodeType nodeType() const;
|
|
|
|
|
ProjectNode *projectNode() const; // managing project
|
|
|
|
|
FolderNode *parentFolderNode() const; // parent folder or project
|
2015-10-29 17:53:47 +01:00
|
|
|
const Utils::FileName &filePath() const; // file system path
|
2014-02-18 18:06:05 +01:00
|
|
|
int line() const;
|
2012-05-04 11:49:37 +02:00
|
|
|
virtual QString displayName() const;
|
|
|
|
|
virtual QString tooltip() const;
|
2016-10-31 13:55:52 +01:00
|
|
|
bool isEnabled() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-02-03 14:45:28 +01:00
|
|
|
virtual QList<ProjectAction> supportedActions(Node *node) const;
|
|
|
|
|
|
2016-10-31 13:55:52 +01:00
|
|
|
void setEnabled(bool enabled);
|
2015-10-29 17:53:47 +01:00
|
|
|
void setAbsoluteFilePathAndLine(const Utils::FileName &filePath, int line);
|
|
|
|
|
|
2013-01-30 18:13:46 +01:00
|
|
|
void emitNodeUpdated();
|
|
|
|
|
|
2015-02-18 13:10:40 +01:00
|
|
|
virtual FileNode *asFileNode();
|
|
|
|
|
virtual FolderNode *asFolderNode();
|
|
|
|
|
virtual ProjectNode *asProjectNode();
|
|
|
|
|
virtual SessionNode *asSessionNode();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
protected:
|
2015-10-29 17:53:47 +01:00
|
|
|
Node(NodeType nodeType, const Utils::FileName &filePath, int line = -1);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
void setProjectNode(ProjectNode *project);
|
|
|
|
|
void setParentFolderNode(FolderNode *parentFolder);
|
|
|
|
|
|
2013-02-01 12:20:15 +01:00
|
|
|
void emitNodeSortKeyAboutToChange();
|
|
|
|
|
void emitNodeSortKeyChanged();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2016-04-13 15:52:14 +02:00
|
|
|
ProjectNode *m_projectNode = nullptr;
|
|
|
|
|
FolderNode *m_folderNode = nullptr;
|
2015-10-29 17:53:47 +01:00
|
|
|
Utils::FileName m_filePath;
|
2016-10-31 13:33:13 +01:00
|
|
|
int m_line;
|
|
|
|
|
NodeType m_nodeType;
|
2016-10-31 13:55:52 +01:00
|
|
|
bool m_isEnabled = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2015-01-09 15:50:06 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT FileNode : public Node
|
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2015-02-02 00:37:38 +02:00
|
|
|
FileNode(const Utils::FileName &filePath, const FileType fileType, bool generated, int line = -1);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
FileType fileType() const;
|
|
|
|
|
bool isGenerated() const;
|
|
|
|
|
|
2015-10-29 16:59:27 +01:00
|
|
|
FileNode *asFileNode() override;
|
2015-02-18 13:10:40 +01:00
|
|
|
|
2016-10-20 13:27:10 +02:00
|
|
|
static QList<FileNode *> scanForFiles(const Utils::FileName &directory,
|
|
|
|
|
const std::function<FileNode *(const Utils::FileName &fileName)> factory,
|
|
|
|
|
QFutureInterface<QList<FileNode *>> *future = nullptr);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
// managed by ProjectNode
|
2014-02-18 19:49:55 +01:00
|
|
|
friend class FolderNode;
|
2008-12-02 12:01:29 +01:00
|
|
|
friend class ProjectNode;
|
|
|
|
|
|
|
|
|
|
FileType m_fileType;
|
|
|
|
|
bool m_generated;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2015-01-09 15:50:06 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT FolderNode : public Node
|
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2016-10-31 13:33:13 +01:00
|
|
|
explicit FolderNode(const Utils::FileName &folderPath, NodeType nodeType = NodeType::Folder,
|
2014-09-23 13:05:00 +02:00
|
|
|
const QString &displayName = QString());
|
2015-10-29 16:59:27 +01:00
|
|
|
~FolderNode() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-10-29 16:59:27 +01:00
|
|
|
QString displayName() const override;
|
2008-12-02 12:01:29 +01:00
|
|
|
QIcon icon() const;
|
|
|
|
|
|
2016-09-30 20:33:34 +02:00
|
|
|
QList<FileNode *> fileNodes() const;
|
|
|
|
|
QList<FileNode *> recursiveFileNodes() const;
|
|
|
|
|
QList<FolderNode *> subFolderNodes() const;
|
|
|
|
|
FolderNode *findOrCreateSubFolderNode(const QString &directory);
|
|
|
|
|
void buildTree(QList<FileNode *> &files);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
virtual void accept(NodesVisitor *visitor);
|
|
|
|
|
|
2010-02-24 15:03:54 +01:00
|
|
|
void setDisplayName(const QString &name);
|
2008-12-02 12:01:29 +01:00
|
|
|
void setIcon(const QIcon &icon);
|
|
|
|
|
|
2015-11-02 17:00:46 +01:00
|
|
|
virtual QString addFileFilter() const;
|
|
|
|
|
|
2014-02-03 15:18:33 +01:00
|
|
|
virtual bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
|
|
|
|
|
virtual bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0);
|
|
|
|
|
virtual bool deleteFiles(const QStringList &filePaths);
|
2015-09-14 15:33:50 +02:00
|
|
|
virtual bool canRenameFile(const QString &filePath, const QString &newFilePath);
|
2014-02-03 15:18:33 +01:00
|
|
|
virtual bool renameFile(const QString &filePath, const QString &newFilePath);
|
|
|
|
|
|
2014-02-18 16:31:36 +01:00
|
|
|
class AddNewInformation
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AddNewInformation(const QString &name, int p)
|
|
|
|
|
:displayName(name), priority(p)
|
2016-04-13 15:52:14 +02:00
|
|
|
{ }
|
2014-02-18 16:31:36 +01:00
|
|
|
QString displayName;
|
|
|
|
|
int priority;
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-07 16:23:04 +01:00
|
|
|
virtual AddNewInformation addNewInformation(const QStringList &files, Node *context) const;
|
2014-02-18 16:31:36 +01:00
|
|
|
|
2014-03-17 11:52:45 +01:00
|
|
|
|
|
|
|
|
// determines if node will be shown in the flat view, by default folder and projects aren't shown
|
|
|
|
|
virtual bool showInSimpleTree() const;
|
|
|
|
|
|
2014-02-18 19:49:55 +01:00
|
|
|
void addFileNodes(const QList<FileNode*> &files);
|
|
|
|
|
void removeFileNodes(const QList<FileNode*> &files);
|
|
|
|
|
|
|
|
|
|
void addFolderNodes(const QList<FolderNode*> &subFolders);
|
|
|
|
|
void removeFolderNodes(const QList<FolderNode*> &subFolders);
|
|
|
|
|
|
2015-10-29 16:59:27 +01:00
|
|
|
FolderNode *asFolderNode() override;
|
2014-03-17 11:52:45 +01:00
|
|
|
|
2009-08-17 17:59:57 +02:00
|
|
|
protected:
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<FolderNode*> m_subFolderNodes;
|
|
|
|
|
QList<FileNode*> m_fileNodes;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// managed by ProjectNode
|
|
|
|
|
friend class ProjectNode;
|
2010-02-24 15:03:54 +01:00
|
|
|
QString m_displayName;
|
2010-07-07 12:16:09 +02:00
|
|
|
mutable QIcon m_icon;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2012-05-04 11:49:37 +02:00
|
|
|
class PROJECTEXPLORER_EXPORT VirtualFolderNode : public FolderNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-02-02 00:37:38 +02:00
|
|
|
explicit VirtualFolderNode(const Utils::FileName &folderPath, int priority);
|
2012-05-04 11:49:37 +02:00
|
|
|
|
|
|
|
|
int priority() const;
|
2016-04-13 15:52:14 +02:00
|
|
|
|
2012-05-04 11:49:37 +02:00
|
|
|
private:
|
|
|
|
|
int m_priority;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2008-12-02 12:01:29 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT ProjectNode : public FolderNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-11-07 21:17:11 +02:00
|
|
|
QString vcsTopic() const;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// all subFolders that are projects
|
|
|
|
|
QList<ProjectNode*> subProjectNodes() const;
|
|
|
|
|
|
2015-09-10 17:47:57 +02:00
|
|
|
virtual bool canAddSubProject(const QString &proFilePath) const;
|
|
|
|
|
virtual bool addSubProjects(const QStringList &proFilePaths);
|
|
|
|
|
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
2010-08-26 18:33:16 +02:00
|
|
|
|
2015-09-10 17:47:57 +02:00
|
|
|
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override;
|
|
|
|
|
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0) override;
|
|
|
|
|
bool deleteFiles(const QStringList &filePaths) override;
|
2015-09-14 15:33:50 +02:00
|
|
|
bool canRenameFile(const QString &filePath, const QString &newFilePath) override;
|
2015-09-10 17:47:57 +02:00
|
|
|
bool renameFile(const QString &filePath, const QString &newFilePath) override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-08-24 17:17:11 +02:00
|
|
|
// by default returns false
|
|
|
|
|
virtual bool deploysFolder(const QString &folder) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
virtual QList<RunConfiguration *> runConfigurations() const;
|
2011-01-20 18:05:58 +01:00
|
|
|
|
2015-09-10 17:47:57 +02:00
|
|
|
void accept(NodesVisitor *visitor) override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// to be called in implementation of
|
2013-10-07 13:34:40 +02:00
|
|
|
// the corresponding public functions
|
2008-12-02 12:01:29 +01:00
|
|
|
void addProjectNodes(const QList<ProjectNode*> &subProjects);
|
|
|
|
|
void removeProjectNodes(const QList<ProjectNode*> &subProjects);
|
|
|
|
|
|
2015-09-10 17:47:57 +02:00
|
|
|
ProjectNode *asProjectNode() override;
|
2015-02-18 13:10:40 +01:00
|
|
|
|
2013-05-17 17:18:40 +02:00
|
|
|
protected:
|
|
|
|
|
// this is just the in-memory representation, a subclass
|
|
|
|
|
// will add the persistent stuff
|
2015-02-02 00:37:38 +02:00
|
|
|
explicit ProjectNode(const Utils::FileName &projectFilePath);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QList<ProjectNode*> m_subProjectNodes;
|
|
|
|
|
|
|
|
|
|
// let SessionNode call setParentFolderNode
|
|
|
|
|
friend class SessionNode;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2015-01-09 15:50:06 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT SessionNode : public FolderNode
|
|
|
|
|
{
|
2012-01-31 13:40:59 +01:00
|
|
|
friend class SessionManager;
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2015-01-09 15:50:06 +01:00
|
|
|
SessionNode();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-10-29 16:59:27 +01:00
|
|
|
QList<ProjectAction> supportedActions(Node *node) const override;
|
2014-02-03 14:45:28 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<ProjectNode*> projectNodes() const;
|
|
|
|
|
|
2015-11-02 17:00:46 +01:00
|
|
|
QString addFileFilter() const override;
|
|
|
|
|
|
2015-10-29 16:59:27 +01:00
|
|
|
void accept(NodesVisitor *visitor) override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-10-29 16:59:27 +01:00
|
|
|
bool showInSimpleTree() const override;
|
2014-07-14 17:39:46 +02:00
|
|
|
void projectDisplayNameChanged(Node *node);
|
2015-02-18 13:10:40 +01:00
|
|
|
|
2015-10-29 16:59:27 +01:00
|
|
|
SessionNode *asSessionNode() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
protected:
|
|
|
|
|
void addProjectNodes(const QList<ProjectNode*> &projectNodes);
|
|
|
|
|
void removeProjectNodes(const QList<ProjectNode*> &projectNodes);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QList<ProjectNode*> m_projectNodes;
|
|
|
|
|
};
|
|
|
|
|
|
2014-02-10 16:05:35 +01:00
|
|
|
template<class T1, class T3>
|
|
|
|
|
bool isSorted(const T1 &list, T3 sorter)
|
|
|
|
|
{
|
|
|
|
|
typename T1::const_iterator it, iit, end;
|
|
|
|
|
end = list.constEnd();
|
|
|
|
|
it = list.constBegin();
|
|
|
|
|
if (it == end)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
iit = list.constBegin();
|
|
|
|
|
++iit;
|
|
|
|
|
|
|
|
|
|
while (iit != end) {
|
|
|
|
|
if (!sorter(*it, *iit))
|
|
|
|
|
return false;
|
|
|
|
|
it = iit++;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class T1, class T2, class T3>
|
|
|
|
|
void compareSortedLists(T1 oldList, T2 newList, T1 &removedList, T2 &addedList, T3 sorter)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(isSorted(oldList, sorter));
|
|
|
|
|
Q_ASSERT(isSorted(newList, sorter));
|
|
|
|
|
|
|
|
|
|
typename T1::const_iterator oldIt, oldEnd;
|
|
|
|
|
typename T2::const_iterator newIt, newEnd;
|
|
|
|
|
|
|
|
|
|
oldIt = oldList.constBegin();
|
|
|
|
|
oldEnd = oldList.constEnd();
|
|
|
|
|
|
|
|
|
|
newIt = newList.constBegin();
|
|
|
|
|
newEnd = newList.constEnd();
|
|
|
|
|
|
|
|
|
|
while (oldIt != oldEnd && newIt != newEnd) {
|
|
|
|
|
if (sorter(*oldIt, *newIt)) {
|
|
|
|
|
removedList.append(*oldIt);
|
|
|
|
|
++oldIt;
|
|
|
|
|
} else if (sorter(*newIt, *oldIt)) {
|
|
|
|
|
addedList.append(*newIt);
|
|
|
|
|
++newIt;
|
|
|
|
|
} else {
|
|
|
|
|
++oldIt;
|
|
|
|
|
++newIt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (oldIt != oldEnd) {
|
|
|
|
|
removedList.append(*oldIt);
|
|
|
|
|
++oldIt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (newIt != newEnd) {
|
|
|
|
|
addedList.append(*newIt);
|
|
|
|
|
++newIt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class T1, class T3>
|
|
|
|
|
T1 subtractSortedList(T1 list1, T1 list2, T3 sorter)
|
|
|
|
|
{
|
2014-10-13 22:37:28 +03:00
|
|
|
Q_ASSERT(isSorted(list1, sorter));
|
|
|
|
|
Q_ASSERT(isSorted(list2, sorter));
|
2014-02-10 16:05:35 +01:00
|
|
|
|
|
|
|
|
typename T1::const_iterator list1It, list1End;
|
|
|
|
|
typename T1::const_iterator list2It, list2End;
|
|
|
|
|
|
|
|
|
|
list1It = list1.constBegin();
|
|
|
|
|
list1End = list1.constEnd();
|
|
|
|
|
|
|
|
|
|
list2It = list2.constBegin();
|
|
|
|
|
list2End = list2.constEnd();
|
|
|
|
|
|
|
|
|
|
T1 result;
|
|
|
|
|
|
|
|
|
|
while (list1It != list1End && list2It != list2End) {
|
|
|
|
|
if (sorter(*list1It, *list2It)) {
|
|
|
|
|
result.append(*list1It);
|
|
|
|
|
++list1It;
|
|
|
|
|
} else if (sorter(*list2It, *list1It)) {
|
|
|
|
|
qWarning() << "subtractSortedList: subtracting value that isn't in set";
|
|
|
|
|
} else {
|
|
|
|
|
++list1It;
|
|
|
|
|
++list2It;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (list1It != list1End) {
|
|
|
|
|
result.append(*list1It);
|
|
|
|
|
++list1It;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
2014-02-18 16:31:36 +01:00
|
|
|
Q_DECLARE_METATYPE(ProjectExplorer::Node *)
|
2015-01-09 15:50:06 +01:00
|
|
|
Q_DECLARE_METATYPE(ProjectExplorer::FolderNode *)
|