- enhancement: use icon to indicate missing project files in the project view
This commit is contained in:
parent
7e0e9873f6
commit
a40c818e54
1
NEWS.md
1
NEWS.md
|
@ -7,6 +7,7 @@ Red Panda C++ Version 1.0.2
|
||||||
- fix: auto syntax check use wrong charset, if a file in editing is not encoded with ANSI encoding
|
- fix: auto syntax check use wrong charset, if a file in editing is not encoded with ANSI encoding
|
||||||
- enhancement: timeout for problem case test
|
- enhancement: timeout for problem case test
|
||||||
- enhancement: slightly reduce start up time
|
- enhancement: slightly reduce start up time
|
||||||
|
- enhancement: use icon to indicate missing project files in the project view
|
||||||
|
|
||||||
Red Panda C++ Version 1.0.1
|
Red Panda C++ Version 1.0.1
|
||||||
- fix: only convert project icon file when it's filename doesn't end with ".ico"
|
- fix: only convert project icon file when it's filename doesn't end with ".ico"
|
||||||
|
|
|
@ -53,7 +53,9 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
|
||||||
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER_VCS_NOCHANGE);
|
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER_VCS_NOCHANGE);
|
||||||
} else
|
} else
|
||||||
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER);
|
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER);
|
||||||
} else if (isHFile(info.fileName())) {
|
} else if (!info.exists()) {
|
||||||
|
icon = pIconsManager->getIcon(IconsManager::ACTION_MISC_CROSS);
|
||||||
|
} else if (isHFile(info.fileName())) {
|
||||||
if (mVCSRepository->isFileInRepository(info)) {
|
if (mVCSRepository->isFileInRepository(info)) {
|
||||||
if (mVCSRepository->isFileConflicting(info))
|
if (mVCSRepository->isFileConflicting(info))
|
||||||
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE_VCS_CONFLICT);
|
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE_VCS_CONFLICT);
|
||||||
|
|
|
@ -160,37 +160,37 @@ void Project::open()
|
||||||
newUnit->setFileName(
|
newUnit->setFileName(
|
||||||
dir.absoluteFilePath(
|
dir.absoluteFilePath(
|
||||||
fromByteArray(ini.GetValue(groupName,"FileName",""))));
|
fromByteArray(ini.GetValue(groupName,"FileName",""))));
|
||||||
if (!QFileInfo(newUnit->fileName()).exists()) {
|
// if (!QFileInfo(newUnit->fileName()).exists()) {
|
||||||
QMessageBox::critical(nullptr,
|
// QMessageBox::critical(nullptr,
|
||||||
tr("File Not Found"),
|
// tr("File Not Found"),
|
||||||
tr("Project file '%1' can't be found!")
|
// tr("Project file '%1' can't be found!")
|
||||||
.arg(newUnit->fileName()),
|
// .arg(newUnit->fileName()),
|
||||||
QMessageBox::Ok);
|
// QMessageBox::Ok);
|
||||||
newUnit->setModified(true);
|
// newUnit->setModified(true);
|
||||||
} else {
|
// } else {
|
||||||
newUnit->setFolder(fromByteArray(ini.GetValue(groupName,"Folder","")));
|
newUnit->setFileMissing(!QFileInfo(newUnit->fileName()).exists());
|
||||||
newUnit->setCompile(ini.GetBoolValue(groupName,"Compile", true));
|
newUnit->setFolder(fromByteArray(ini.GetValue(groupName,"Folder","")));
|
||||||
newUnit->setCompileCpp(
|
newUnit->setCompile(ini.GetBoolValue(groupName,"Compile", true));
|
||||||
ini.GetBoolValue(groupName,"CompileCpp",mOptions.isCpp));
|
newUnit->setCompileCpp(
|
||||||
|
ini.GetBoolValue(groupName,"CompileCpp",mOptions.isCpp));
|
||||||
|
|
||||||
newUnit->setLink(ini.GetBoolValue(groupName,"Link", true));
|
newUnit->setLink(ini.GetBoolValue(groupName,"Link", true));
|
||||||
newUnit->setPriority(ini.GetLongValue(groupName,"Priority", 1000));
|
newUnit->setPriority(ini.GetLongValue(groupName,"Priority", 1000));
|
||||||
newUnit->setOverrideBuildCmd(ini.GetBoolValue(groupName,"OverrideBuildCmd", false));
|
newUnit->setOverrideBuildCmd(ini.GetBoolValue(groupName,"OverrideBuildCmd", false));
|
||||||
newUnit->setBuildCmd(fromByteArray(ini.GetValue(groupName,"BuildCmd", "")));
|
newUnit->setBuildCmd(fromByteArray(ini.GetValue(groupName,"BuildCmd", "")));
|
||||||
QByteArray defaultEncoding = toByteArray(mOptions.encoding);
|
QByteArray defaultEncoding = toByteArray(mOptions.encoding);
|
||||||
if (ini.GetBoolValue(groupName,"DetectEncoding",true)){
|
if (ini.GetBoolValue(groupName,"DetectEncoding",true)){
|
||||||
defaultEncoding = ENCODING_AUTO_DETECT;
|
defaultEncoding = ENCODING_AUTO_DETECT;
|
||||||
}
|
|
||||||
newUnit->setEncoding(ini.GetValue(groupName, "FileEncoding",defaultEncoding));
|
|
||||||
if (QTextCodec::codecForName(newUnit->encoding())==nullptr) {
|
|
||||||
newUnit->setEncoding(ENCODING_AUTO_DETECT);
|
|
||||||
}
|
|
||||||
newUnit->setNew(false);
|
|
||||||
newUnit->setParent(this);
|
|
||||||
newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, folderNodeFromName(newUnit->folder())));
|
|
||||||
newUnit->node()->unitIndex = mUnits.count();
|
|
||||||
mUnits.append(newUnit);
|
|
||||||
}
|
}
|
||||||
|
newUnit->setEncoding(ini.GetValue(groupName, "FileEncoding",defaultEncoding));
|
||||||
|
if (QTextCodec::codecForName(newUnit->encoding())==nullptr) {
|
||||||
|
newUnit->setEncoding(ENCODING_AUTO_DETECT);
|
||||||
|
}
|
||||||
|
newUnit->setNew(false);
|
||||||
|
newUnit->setParent(this);
|
||||||
|
newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, folderNodeFromName(newUnit->folder())));
|
||||||
|
newUnit->node()->unitIndex = mUnits.count();
|
||||||
|
mUnits.append(newUnit);
|
||||||
}
|
}
|
||||||
rebuildNodes();
|
rebuildNodes();
|
||||||
}
|
}
|
||||||
|
@ -296,9 +296,8 @@ Editor *Project::openUnit(int index)
|
||||||
|
|
||||||
PProjectUnit unit = mUnits[index];
|
PProjectUnit unit = mUnits[index];
|
||||||
|
|
||||||
if (!unit->fileName().isEmpty()) {
|
if (!unit->fileName().isEmpty() && fileExists(unit->fileName())) {
|
||||||
QString fullPath = unitFullPath(unit);
|
Editor * editor = mEditorList->getOpenedEditorByFilename(unit->fileName());
|
||||||
Editor * editor = mEditorList->getOpenedEditorByFilename(fullPath);
|
|
||||||
if (editor) {//already opened in the editors
|
if (editor) {//already opened in the editors
|
||||||
editor->setInProject(true);
|
editor->setInProject(true);
|
||||||
editor->activate();
|
editor->activate();
|
||||||
|
@ -306,36 +305,26 @@ Editor *Project::openUnit(int index)
|
||||||
}
|
}
|
||||||
QByteArray encoding;
|
QByteArray encoding;
|
||||||
encoding = unit->encoding();
|
encoding = unit->encoding();
|
||||||
editor = mEditorList->newEditor(fullPath, encoding, true, unit->isNew());
|
editor = mEditorList->newEditor(unit->fileName(), encoding, true, unit->isNew());
|
||||||
editor->setInProject(true);
|
if (editor) {
|
||||||
//unit->setEncoding(encoding);
|
editor->setInProject(true);
|
||||||
editor->activate();
|
//unit->setEncoding(encoding);
|
||||||
loadUnitLayout(editor,index);
|
editor->activate();
|
||||||
return editor;
|
loadUnitLayout(editor,index);
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Project::unitFullPath(const PProjectUnit &unit) const
|
|
||||||
{
|
|
||||||
QDir dir(directory());
|
|
||||||
return dir.absoluteFilePath(unit->fileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Project::unitFullPath(const ProjectUnit *unit) const
|
|
||||||
{
|
|
||||||
QDir dir(directory());
|
|
||||||
return dir.absoluteFilePath(unit->fileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
Editor *Project::unitEditor(const PProjectUnit &unit) const
|
Editor *Project::unitEditor(const PProjectUnit &unit) const
|
||||||
{
|
{
|
||||||
return mEditorList->getOpenedEditorByFilename(unitFullPath(unit));
|
return mEditorList->getOpenedEditorByFilename(unit->fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor *Project::unitEditor(const ProjectUnit *unit) const
|
Editor *Project::unitEditor(const ProjectUnit *unit) const
|
||||||
{
|
{
|
||||||
return mEditorList->getOpenedEditorByFilename(unitFullPath(unit));
|
return mEditorList->getOpenedEditorByFilename(unit->fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::rebuildNodes()
|
void Project::rebuildNodes()
|
||||||
|
@ -570,21 +559,23 @@ bool Project::saveUnits()
|
||||||
return false;
|
return false;
|
||||||
for (int idx = 0; idx < mUnits.count(); idx++) {
|
for (int idx = 0; idx < mUnits.count(); idx++) {
|
||||||
PProjectUnit unit = mUnits[idx];
|
PProjectUnit unit = mUnits[idx];
|
||||||
bool rd_only = false;
|
|
||||||
QByteArray groupName = toByteArray(QString("Unit%1").arg(count+1));
|
QByteArray groupName = toByteArray(QString("Unit%1").arg(count+1));
|
||||||
if (unit->modified() && fileExists(unit->fileName())
|
if (!unit->FileMissing()) {
|
||||||
&& isReadOnly(unit->fileName())) {
|
bool rd_only = false;
|
||||||
// file is read-only
|
if (unit->modified() && fileExists(unit->fileName())
|
||||||
QMessageBox::critical(nullptr,
|
&& isReadOnly(unit->fileName())) {
|
||||||
tr("Can't save file"),
|
// file is read-only
|
||||||
tr("Can't save file '%1'").arg(unit->fileName()),
|
QMessageBox::critical(nullptr,
|
||||||
QMessageBox::Ok
|
tr("Can't save file"),
|
||||||
);
|
tr("Can't save file '%1'").arg(unit->fileName()),
|
||||||
rd_only = true;
|
QMessageBox::Ok
|
||||||
}
|
);
|
||||||
if (!rd_only) {
|
rd_only = true;
|
||||||
if (!unit->save() && unit->isNew())
|
}
|
||||||
return false;
|
if (!rd_only) {
|
||||||
|
if (!unit->save() && unit->isNew())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// saved new file or an existing file add to project file
|
// saved new file or an existing file add to project file
|
||||||
|
@ -758,7 +749,7 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate, b
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor * editor = mEditorList->newEditor(
|
Editor * editor = mEditorList->newEditor(
|
||||||
unitFullPath(unit),
|
unit->fileName(),
|
||||||
unit->encoding(),
|
unit->encoding(),
|
||||||
true,
|
true,
|
||||||
true);
|
true);
|
||||||
|
@ -1458,7 +1449,8 @@ void Project::loadLayout()
|
||||||
}
|
}
|
||||||
if (topLeft>=0 && topLeft<mUnits.count()) {
|
if (topLeft>=0 && topLeft<mUnits.count()) {
|
||||||
Editor * editor = unitEditor(mUnits[topLeft]);
|
Editor * editor = unitEditor(mUnits[topLeft]);
|
||||||
editor->activate();
|
if (editor)
|
||||||
|
editor->activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1746,6 +1738,7 @@ ProjectUnit::ProjectUnit(Project* parent)
|
||||||
{
|
{
|
||||||
mNode = nullptr;
|
mNode = nullptr;
|
||||||
mParent = parent;
|
mParent = parent;
|
||||||
|
mFileMissing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Project *ProjectUnit::parent() const
|
Project *ProjectUnit::parent() const
|
||||||
|
@ -1929,6 +1922,16 @@ void ProjectUnit::setNode(const PProjectModelNode &newNode)
|
||||||
mNode = newNode;
|
mNode = newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProjectUnit::FileMissing() const
|
||||||
|
{
|
||||||
|
return mFileMissing;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectUnit::setFileMissing(bool newDontSave)
|
||||||
|
{
|
||||||
|
mFileMissing = newDontSave;
|
||||||
|
}
|
||||||
|
|
||||||
ProjectModel::ProjectModel(Project *project, QObject *parent):
|
ProjectModel::ProjectModel(Project *project, QObject *parent):
|
||||||
QAbstractItemModel(parent),
|
QAbstractItemModel(parent),
|
||||||
mProject(project)
|
mProject(project)
|
||||||
|
|
|
@ -83,6 +83,9 @@ public:
|
||||||
PProjectModelNode &node();
|
PProjectModelNode &node();
|
||||||
void setNode(const PProjectModelNode &newNode);
|
void setNode(const PProjectModelNode &newNode);
|
||||||
|
|
||||||
|
bool FileMissing() const;
|
||||||
|
void setFileMissing(bool newDontSave);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Project* mParent;
|
Project* mParent;
|
||||||
QString mFileName;
|
QString mFileName;
|
||||||
|
@ -96,6 +99,7 @@ private:
|
||||||
int mPriority;
|
int mPriority;
|
||||||
QByteArray mEncoding;
|
QByteArray mEncoding;
|
||||||
PProjectModelNode mNode;
|
PProjectModelNode mNode;
|
||||||
|
bool mFileMissing;
|
||||||
};
|
};
|
||||||
|
|
||||||
using PProjectUnit = std::shared_ptr<ProjectUnit>;
|
using PProjectUnit = std::shared_ptr<ProjectUnit>;
|
||||||
|
@ -183,8 +187,6 @@ public:
|
||||||
PProjectUnit newUnit(PProjectModelNode parentNode,
|
PProjectUnit newUnit(PProjectModelNode parentNode,
|
||||||
const QString& customFileName="");
|
const QString& customFileName="");
|
||||||
Editor* openUnit(int index);
|
Editor* openUnit(int index);
|
||||||
QString unitFullPath(const PProjectUnit& unit) const;
|
|
||||||
QString unitFullPath(const ProjectUnit* unit) const;
|
|
||||||
Editor* unitEditor(const PProjectUnit& unit) const;
|
Editor* unitEditor(const PProjectUnit& unit) const;
|
||||||
Editor* unitEditor(const ProjectUnit* unit) const;
|
Editor* unitEditor(const ProjectUnit* unit) const;
|
||||||
Editor* unitEditor(int index) const {
|
Editor* unitEditor(int index) const {
|
||||||
|
|
|
@ -3334,8 +3334,8 @@ void Settings::Executor::doLoad()
|
||||||
mCaseEditorFontName = stringValue("case_editor_font_name","Dejavu Sans Mono");
|
mCaseEditorFontName = stringValue("case_editor_font_name","Dejavu Sans Mono");
|
||||||
#endif
|
#endif
|
||||||
mCaseEditorFontSize = intValue("case_editor_font_size",12);
|
mCaseEditorFontSize = intValue("case_editor_font_size",12);
|
||||||
mCaseEditorFontOnlyMonospaced = boolValue("case_editor_font_only_monospaced",false);
|
mCaseEditorFontOnlyMonospaced = boolValue("case_editor_font_only_monospaced",true);
|
||||||
mCaseTimeout = intValue("case_timeout", 1);
|
mCaseTimeout = intValue("case_timeout", 3);
|
||||||
mEnableCaseTimeout = boolValue("enable_case_timeout", true);
|
mEnableCaseTimeout = boolValue("enable_case_timeout", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue