2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-05-04 12:19:22 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-05-04 12:19:22 +02: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.
|
2009-05-04 12:19:22 +02: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
|
|
|
****************************************************************************/
|
2009-05-04 12:19:22 +02:00
|
|
|
|
|
|
|
|
#include "qmlprojectnodes.h"
|
|
|
|
|
#include "qmlproject.h"
|
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2010-04-01 17:21:18 +02:00
|
|
|
#include <coreplugin/fileiconprovider.h>
|
2009-05-04 12:19:22 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
|
2016-10-06 11:31:06 +02:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QStyle>
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2015-10-29 17:18:23 +01:00
|
|
|
QmlProjectNode::QmlProjectNode(QmlProject *project)
|
2016-10-06 11:31:06 +02:00
|
|
|
: ProjectExplorer::ProjectNode(project->projectDirectory()),
|
2015-10-29 17:18:23 +01:00
|
|
|
m_project(project)
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2015-10-29 17:18:23 +01:00
|
|
|
setDisplayName(project->projectFilePath().toFileInfo().completeBaseName());
|
2010-04-01 17:21:18 +02:00
|
|
|
// make overlay
|
|
|
|
|
const QSize desiredSize = QSize(16, 16);
|
|
|
|
|
const QIcon projectBaseIcon(QLatin1String(":/qmlproject/images/qmlfolder.png"));
|
|
|
|
|
const QPixmap projectPixmap = Core::FileIconProvider::overlayIcon(QStyle::SP_DirIcon,
|
|
|
|
|
projectBaseIcon,
|
|
|
|
|
desiredSize);
|
|
|
|
|
setIcon(QIcon(projectPixmap));
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProjectNode::~QmlProjectNode()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
void QmlProjectNode::refresh()
|
|
|
|
|
{
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
FileNode *projectFilesNode = new FileNode(m_project->filesFileName(),
|
|
|
|
|
ProjectFileType,
|
|
|
|
|
/* generated = */ false);
|
|
|
|
|
|
|
|
|
|
QStringList files = m_project->files();
|
2015-02-02 00:37:38 +02:00
|
|
|
files.removeAll(m_project->filesFileName().toString());
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2016-10-06 11:31:06 +02:00
|
|
|
QList<FileNode *> fileNodes = Utils::transform(files, [](const QString &f) {
|
|
|
|
|
FileType fileType = SourceType; // ### FIXME
|
|
|
|
|
return new FileNode(Utils::FileName::fromString(f), fileType, false);
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2016-10-06 11:31:06 +02:00
|
|
|
});
|
|
|
|
|
fileNodes.append(projectFilesNode);
|
2009-12-09 14:43:13 +01:00
|
|
|
|
2016-10-06 11:31:06 +02:00
|
|
|
buildTree(fileNodes);
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-17 11:52:45 +01:00
|
|
|
bool QmlProjectNode::showInSimpleTree() const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-03 14:45:28 +01:00
|
|
|
QList<ProjectExplorer::ProjectAction> QmlProjectNode::supportedActions(Node *node) const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2010-05-11 14:13:38 +02:00
|
|
|
Q_UNUSED(node);
|
2014-02-03 14:45:28 +01:00
|
|
|
QList<ProjectExplorer::ProjectAction> actions;
|
|
|
|
|
actions.append(ProjectExplorer::AddNewFile);
|
|
|
|
|
actions.append(ProjectExplorer::EraseFile);
|
2013-12-02 15:30:17 +01:00
|
|
|
if (node->nodeType() == ProjectExplorer::FileNodeType) {
|
|
|
|
|
ProjectExplorer::FileNode *fileNode = static_cast<ProjectExplorer::FileNode *>(node);
|
|
|
|
|
if (fileNode->fileType() != ProjectExplorer::ProjectFileType)
|
2014-02-03 14:45:28 +01:00
|
|
|
actions.append(ProjectExplorer::Rename);
|
2013-12-02 15:30:17 +01:00
|
|
|
}
|
2009-05-07 15:43:59 +02:00
|
|
|
return actions;
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-01 16:13:48 +02:00
|
|
|
bool QmlProjectNode::addFiles(const QStringList &filePaths, QStringList * /*notAdded*/)
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2010-02-17 11:20:35 +01:00
|
|
|
return m_project->addFiles(filePaths);
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-01 16:13:48 +02:00
|
|
|
bool QmlProjectNode::deleteFiles(const QStringList & /*filePaths*/)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
2010-09-30 11:16:51 +02:00
|
|
|
return true;
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-01 16:13:48 +02:00
|
|
|
bool QmlProjectNode::renameFile(const QString & /*filePath*/, const QString & /*newFilePath*/)
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2010-09-30 11:16:51 +02:00
|
|
|
return true;
|
2009-05-04 12:19:22 +02:00
|
|
|
}
|
2010-02-16 13:39:13 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProjectManager
|