summaryrefslogtreecommitdiff
path: root/src/plugins/pythoneditor/pythoneditorplugin.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2018-09-28 17:30:58 +0300
committerOrgad Shaneh <orgads@gmail.com>2018-10-01 16:44:31 +0000
commitd585b85550797f1d6bb384b51c376ce871394255 (patch)
treefc82b2a13e94a3932778f2b0d3599baf29481e53 /src/plugins/pythoneditor/pythoneditorplugin.cpp
parenta31655cde705996d501a0eb869a706029c2c8c90 (diff)
downloadqt-creator-d585b85550797f1d6bb384b51c376ce871394255.tar.gz
PythonEditor: Support file operations
Change-Id: I0fc5a3e1795fe56c753e300ed1c1ca7514964401 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/pythoneditor/pythoneditorplugin.cpp')
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp
index 1441ba0ee4..b17f1990a4 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.cpp
+++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp
@@ -113,6 +113,10 @@ public:
bool showInSimpleTree() const override;
QString addFileFilter() const override;
+ bool supportsAction(ProjectAction action, const Node *node) const override;
+ bool addFiles(const QStringList &filePaths, QStringList *) override;
+ bool removeFiles(const QStringList &filePaths, QStringList *) override;
+ bool deleteFiles(const QStringList &) override;
bool renameFile(const QString &filePath, const QString &newFilePath) override;
private:
@@ -388,7 +392,7 @@ bool PythonProject::removeFiles(const QStringList &filePaths)
bool PythonProject::setFiles(const QStringList &filePaths)
{
QStringList newList;
- QDir baseDir(projectFilePath().toString());
+ QDir baseDir(projectDirectory().toString());
foreach (const QString &filePath, filePaths)
newList.append(baseDir.relativeFilePath(filePath));
@@ -403,7 +407,7 @@ bool PythonProject::renameFile(const QString &filePath, const QString &newFilePa
if (i != m_rawListEntries.end()) {
int index = newList.indexOf(i.value());
if (index != -1) {
- QDir baseDir(projectFilePath().toString());
+ QDir baseDir(projectDirectory().toString());
newList.replace(index, baseDir.relativeFilePath(newFilePath));
}
}
@@ -576,6 +580,37 @@ QString PythonProjectNode::addFileFilter() const
return QLatin1String("*.py");
}
+bool PythonProjectNode::supportsAction(ProjectAction action, const Node *node) const
+{
+ switch (node->nodeType()) {
+ case NodeType::File:
+ return action == ProjectAction::Rename
+ || action == ProjectAction::RemoveFile;
+ case NodeType::Folder:
+ case NodeType::Project:
+ return action == ProjectAction::AddNewFile
+ || action == ProjectAction::RemoveFile
+ || action == ProjectAction::AddExistingFile;
+ default:
+ return ProjectNode::supportsAction(action, node);
+ }
+}
+
+bool PythonProjectNode::addFiles(const QStringList &filePaths, QStringList *)
+{
+ return m_project->addFiles(filePaths);
+}
+
+bool PythonProjectNode::removeFiles(const QStringList &filePaths, QStringList *)
+{
+ return m_project->removeFiles(filePaths);
+}
+
+bool PythonProjectNode::deleteFiles(const QStringList &)
+{
+ return true;
+}
+
bool PythonProjectNode::renameFile(const QString &filePath, const QString &newFilePath)
{
return m_project->renameFile(filePath, newFilePath);