- 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
|
||||
- enhancement: timeout for problem case test
|
||||
- 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
|
||||
- fix: only convert project icon file when it's filename doesn't end with ".ico"
|
||||
|
|
|
@ -53,6 +53,8 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
|
|||
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER_VCS_NOCHANGE);
|
||||
} else
|
||||
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER);
|
||||
} else if (!info.exists()) {
|
||||
icon = pIconsManager->getIcon(IconsManager::ACTION_MISC_CROSS);
|
||||
} else if (isHFile(info.fileName())) {
|
||||
if (mVCSRepository->isFileInRepository(info)) {
|
||||
if (mVCSRepository->isFileConflicting(info))
|
||||
|
|
|
@ -160,14 +160,15 @@ void Project::open()
|
|||
newUnit->setFileName(
|
||||
dir.absoluteFilePath(
|
||||
fromByteArray(ini.GetValue(groupName,"FileName",""))));
|
||||
if (!QFileInfo(newUnit->fileName()).exists()) {
|
||||
QMessageBox::critical(nullptr,
|
||||
tr("File Not Found"),
|
||||
tr("Project file '%1' can't be found!")
|
||||
.arg(newUnit->fileName()),
|
||||
QMessageBox::Ok);
|
||||
newUnit->setModified(true);
|
||||
} else {
|
||||
// if (!QFileInfo(newUnit->fileName()).exists()) {
|
||||
// QMessageBox::critical(nullptr,
|
||||
// tr("File Not Found"),
|
||||
// tr("Project file '%1' can't be found!")
|
||||
// .arg(newUnit->fileName()),
|
||||
// QMessageBox::Ok);
|
||||
// newUnit->setModified(true);
|
||||
// } else {
|
||||
newUnit->setFileMissing(!QFileInfo(newUnit->fileName()).exists());
|
||||
newUnit->setFolder(fromByteArray(ini.GetValue(groupName,"Folder","")));
|
||||
newUnit->setCompile(ini.GetBoolValue(groupName,"Compile", true));
|
||||
newUnit->setCompileCpp(
|
||||
|
@ -191,7 +192,6 @@ void Project::open()
|
|||
newUnit->node()->unitIndex = mUnits.count();
|
||||
mUnits.append(newUnit);
|
||||
}
|
||||
}
|
||||
rebuildNodes();
|
||||
}
|
||||
|
||||
|
@ -296,9 +296,8 @@ Editor *Project::openUnit(int index)
|
|||
|
||||
PProjectUnit unit = mUnits[index];
|
||||
|
||||
if (!unit->fileName().isEmpty()) {
|
||||
QString fullPath = unitFullPath(unit);
|
||||
Editor * editor = mEditorList->getOpenedEditorByFilename(fullPath);
|
||||
if (!unit->fileName().isEmpty() && fileExists(unit->fileName())) {
|
||||
Editor * editor = mEditorList->getOpenedEditorByFilename(unit->fileName());
|
||||
if (editor) {//already opened in the editors
|
||||
editor->setInProject(true);
|
||||
editor->activate();
|
||||
|
@ -306,36 +305,26 @@ Editor *Project::openUnit(int index)
|
|||
}
|
||||
QByteArray encoding;
|
||||
encoding = unit->encoding();
|
||||
editor = mEditorList->newEditor(fullPath, encoding, true, unit->isNew());
|
||||
editor = mEditorList->newEditor(unit->fileName(), encoding, true, unit->isNew());
|
||||
if (editor) {
|
||||
editor->setInProject(true);
|
||||
//unit->setEncoding(encoding);
|
||||
editor->activate();
|
||||
loadUnitLayout(editor,index);
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
return mEditorList->getOpenedEditorByFilename(unitFullPath(unit));
|
||||
return mEditorList->getOpenedEditorByFilename(unit->fileName());
|
||||
}
|
||||
|
||||
Editor *Project::unitEditor(const ProjectUnit *unit) const
|
||||
{
|
||||
return mEditorList->getOpenedEditorByFilename(unitFullPath(unit));
|
||||
return mEditorList->getOpenedEditorByFilename(unit->fileName());
|
||||
}
|
||||
|
||||
void Project::rebuildNodes()
|
||||
|
@ -570,8 +559,9 @@ bool Project::saveUnits()
|
|||
return false;
|
||||
for (int idx = 0; idx < mUnits.count(); idx++) {
|
||||
PProjectUnit unit = mUnits[idx];
|
||||
bool rd_only = false;
|
||||
QByteArray groupName = toByteArray(QString("Unit%1").arg(count+1));
|
||||
if (!unit->FileMissing()) {
|
||||
bool rd_only = false;
|
||||
if (unit->modified() && fileExists(unit->fileName())
|
||||
&& isReadOnly(unit->fileName())) {
|
||||
// file is read-only
|
||||
|
@ -586,6 +576,7 @@ bool Project::saveUnits()
|
|||
if (!unit->save() && unit->isNew())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// saved new file or an existing file add to project file
|
||||
ini.SetValue(
|
||||
|
@ -758,7 +749,7 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate, b
|
|||
}
|
||||
|
||||
Editor * editor = mEditorList->newEditor(
|
||||
unitFullPath(unit),
|
||||
unit->fileName(),
|
||||
unit->encoding(),
|
||||
true,
|
||||
true);
|
||||
|
@ -1458,6 +1449,7 @@ void Project::loadLayout()
|
|||
}
|
||||
if (topLeft>=0 && topLeft<mUnits.count()) {
|
||||
Editor * editor = unitEditor(mUnits[topLeft]);
|
||||
if (editor)
|
||||
editor->activate();
|
||||
}
|
||||
}
|
||||
|
@ -1746,6 +1738,7 @@ ProjectUnit::ProjectUnit(Project* parent)
|
|||
{
|
||||
mNode = nullptr;
|
||||
mParent = parent;
|
||||
mFileMissing = false;
|
||||
}
|
||||
|
||||
Project *ProjectUnit::parent() const
|
||||
|
@ -1929,6 +1922,16 @@ void ProjectUnit::setNode(const PProjectModelNode &newNode)
|
|||
mNode = newNode;
|
||||
}
|
||||
|
||||
bool ProjectUnit::FileMissing() const
|
||||
{
|
||||
return mFileMissing;
|
||||
}
|
||||
|
||||
void ProjectUnit::setFileMissing(bool newDontSave)
|
||||
{
|
||||
mFileMissing = newDontSave;
|
||||
}
|
||||
|
||||
ProjectModel::ProjectModel(Project *project, QObject *parent):
|
||||
QAbstractItemModel(parent),
|
||||
mProject(project)
|
||||
|
|
|
@ -83,6 +83,9 @@ public:
|
|||
PProjectModelNode &node();
|
||||
void setNode(const PProjectModelNode &newNode);
|
||||
|
||||
bool FileMissing() const;
|
||||
void setFileMissing(bool newDontSave);
|
||||
|
||||
private:
|
||||
Project* mParent;
|
||||
QString mFileName;
|
||||
|
@ -96,6 +99,7 @@ private:
|
|||
int mPriority;
|
||||
QByteArray mEncoding;
|
||||
PProjectModelNode mNode;
|
||||
bool mFileMissing;
|
||||
};
|
||||
|
||||
using PProjectUnit = std::shared_ptr<ProjectUnit>;
|
||||
|
@ -183,8 +187,6 @@ public:
|
|||
PProjectUnit newUnit(PProjectModelNode parentNode,
|
||||
const QString& customFileName="");
|
||||
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 ProjectUnit* unit) const;
|
||||
Editor* unitEditor(int index) const {
|
||||
|
|
|
@ -3334,8 +3334,8 @@ void Settings::Executor::doLoad()
|
|||
mCaseEditorFontName = stringValue("case_editor_font_name","Dejavu Sans Mono");
|
||||
#endif
|
||||
mCaseEditorFontSize = intValue("case_editor_font_size",12);
|
||||
mCaseEditorFontOnlyMonospaced = boolValue("case_editor_font_only_monospaced",false);
|
||||
mCaseTimeout = intValue("case_timeout", 1);
|
||||
mCaseEditorFontOnlyMonospaced = boolValue("case_editor_font_only_monospaced",true);
|
||||
mCaseTimeout = intValue("case_timeout", 3);
|
||||
mEnableCaseTimeout = boolValue("enable_case_timeout", true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue