- enhancement: change project name in the project view

This commit is contained in:
Roy Qu 2021-11-27 09:36:49 +08:00
parent 564bf02e59
commit dfce6e7146
5 changed files with 10 additions and 7 deletions

View File

@ -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 from lines in the front to lines back will cause error
- fix: dragging text onto itself should do nothing - fix: dragging text onto itself should do nothing
- fixlicense info in the about dialog should be readonly - fixlicense 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 Version 0.10.1 For Dev-C++ 7 Beta
- fix: can't correctly expand watch expression that has spaces in it - fix: can't correctly expand watch expression that has spaces in it

View File

@ -1597,6 +1597,7 @@ void Project::setName(const QString &newName)
if (newName != mName) { if (newName != mName) {
mName = newName; mName = newName;
mNode->text = newName; mNode->text = newName;
setModified(true);
} }
} }
@ -1883,7 +1884,7 @@ Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const
if (!p) if (!p)
return Qt::NoItemFlags; return Qt::NoItemFlags;
if (p==mProject->node().get()) 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; Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
if (p->unitIndex<0) { if (p->unitIndex<0) {
flags.setFlag(Qt::ItemIsDropEnabled); flags.setFlag(Qt::ItemIsDropEnabled);
@ -1901,8 +1902,13 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
if (!node) if (!node)
return false; return false;
if (role == Qt::EditRole) { if (role == Qt::EditRole) {
if (node == mProject->node()) if (node == mProject->node()) {
QString newName = value.toString().trimmed();
if (newName.isEmpty())
return false; return false;
mProject->setName(newName);
return true;
}
int idx = node->unitIndex; int idx = node->unitIndex;
if (idx >= 0) { if (idx >= 0) {
//change unit name //change unit name

View File

@ -2,8 +2,6 @@
#define PROJECT_H #define PROJECT_H
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QObject>
#include <QSettings>
#include <memory> #include <memory>
#include "projectoptions.h" #include "projectoptions.h"
#include "utils.h" #include "utils.h"

View File

@ -4,7 +4,6 @@
#include "../settings.h" #include "../settings.h"
#include <QMessageBox> #include <QMessageBox>
#include <QSettings>
#include <windows.h> #include <windows.h>
EnvironmentFileAssociationWidget::EnvironmentFileAssociationWidget(const QString& name, const QString& group, QWidget *parent) : EnvironmentFileAssociationWidget::EnvironmentFileAssociationWidget(const QString& name, const QString& group, QWidget *parent) :

View File

@ -7,7 +7,6 @@
#include <QFileInfo> #include <QFileInfo>
#include <QProcess> #include <QProcess>
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QSettings>
#include <QString> #include <QString>
#include <QTextCodec> #include <QTextCodec>
#include <QtGlobal> #include <QtGlobal>