- 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 onto itself should do nothing
- 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
- 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) {
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())
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

View File

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

View File

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

View File

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