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 <QStyle>
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2017-02-28 14:46:14 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2017-03-01 14:26:46 +01:00
|
|
|
QmlProjectNode::QmlProjectNode(QmlProject *project) : ProjectNode(project->projectDirectory()),
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2014-03-17 11:52:45 +01:00
|
|
|
bool QmlProjectNode::showInSimpleTree() const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 15:48:45 +02:00
|
|
|
bool QmlProjectNode::supportsAction(ProjectAction action, const Node *node) const
|
2009-05-04 12:19:22 +02:00
|
|
|
{
|
2017-03-15 15:46:48 +01:00
|
|
|
if (action == AddNewFile || action == EraseFile)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (action == Rename && node->nodeType() == NodeType::File) {
|
2017-05-31 15:48:45 +02:00
|
|
|
const FileNode *fileNode = dynamic_cast<const FileNode *>(node);
|
2017-03-15 15:46:48 +01:00
|
|
|
return fileNode->fileType() != FileType::Project;
|
2013-12-02 15:30:17 +01:00
|
|
|
}
|
2017-03-15 15:46:48 +01:00
|
|
|
|
|
|
|
|
return false;
|
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
|