From dfce6e714663030f1093c0a78e1b92abe6a43d45 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 27 Nov 2021 09:36:49 +0800 Subject: [PATCH] - enhancement: change project name in the project view --- NEWS.md | 1 + RedPandaIDE/project.cpp | 12 +++++++++--- RedPandaIDE/project.h | 2 -- .../environmentfileassociationwidget.cpp | 1 - RedPandaIDE/utils.cpp | 1 - 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8af7b668..66d50f5e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ Version 0.10.2 For Dev-C++ 7 Beta - fix: dragging text from lines in the front to lines back will cause error - fix: dragging text onto itself should do nothing - fix:license info in the about dialog should be readonly + - enhancement: change project name in the project view Version 0.10.1 For Dev-C++ 7 Beta - fix: can't correctly expand watch expression that has spaces in it diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 3257e6c9..c548b9d0 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -1597,6 +1597,7 @@ void Project::setName(const QString &newName) if (newName != mName) { mName = newName; mNode->text = newName; + setModified(true); } } @@ -1883,7 +1884,7 @@ Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const if (!p) return Qt::NoItemFlags; if (p==mProject->node().get()) - return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled; + return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable; Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; if (p->unitIndex<0) { flags.setFlag(Qt::ItemIsDropEnabled); @@ -1901,8 +1902,13 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int if (!node) return false; if (role == Qt::EditRole) { - if (node == mProject->node()) - return false; + if (node == mProject->node()) { + QString newName = value.toString().trimmed(); + if (newName.isEmpty()) + return false; + mProject->setName(newName); + return true; + } int idx = node->unitIndex; if (idx >= 0) { //change unit name diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h index e5f6f392..bcd04b6e 100644 --- a/RedPandaIDE/project.h +++ b/RedPandaIDE/project.h @@ -2,8 +2,6 @@ #define PROJECT_H #include -#include -#include #include #include "projectoptions.h" #include "utils.h" diff --git a/RedPandaIDE/settingsdialog/environmentfileassociationwidget.cpp b/RedPandaIDE/settingsdialog/environmentfileassociationwidget.cpp index 89c70630..39e007ab 100644 --- a/RedPandaIDE/settingsdialog/environmentfileassociationwidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentfileassociationwidget.cpp @@ -4,7 +4,6 @@ #include "../settings.h" #include -#include #include EnvironmentFileAssociationWidget::EnvironmentFileAssociationWidget(const QString& name, const QString& group, QWidget *parent) : diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 1a7551a5..3dab6c78 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include