- reduce memory usage when deciding file types
- enhancement: refresh project view for git status won't redraw project structure - enhancement: auto save project options after the compilerset option for project resetted - enhancement: "." and ".." in paths of issues not correctly handled
This commit is contained in:
parent
0d45cca2a5
commit
6d2ce9035d
3
NEWS.md
3
NEWS.md
|
@ -14,6 +14,9 @@ Red Panda C++ Version 2.0
|
||||||
- enhancement: keep current position in the class browser after contents modified
|
- enhancement: keep current position in the class browser after contents modified
|
||||||
- fix: "." and ".." in included header paths not correctly handled
|
- fix: "." and ".." in included header paths not correctly handled
|
||||||
- reduce memory usage when deciding file types
|
- reduce memory usage when deciding file types
|
||||||
|
- enhancement: refresh project view for git status won't redraw project structure
|
||||||
|
- enhancement: auto save project options after the compilerset option for project resetted
|
||||||
|
- enhancement: "." and ".." in paths of issues not correctly handled
|
||||||
|
|
||||||
Red Panda C++ Version 1.5
|
Red Panda C++ Version 1.5
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,8 @@ QString Compiler::getFileNameFromOutputLine(QString &line) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return temp;
|
QFileInfo info(temp);
|
||||||
|
return info.isAbsolute()?cleanPath(temp):absolutePath(mDirectory,temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Compiler::getLineNumberFromOutputLine(QString &line)
|
int Compiler::getLineNumberFromOutputLine(QString &line)
|
||||||
|
|
|
@ -194,7 +194,7 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
|
||||||
|
|
||||||
// Mention progress in the logs
|
// Mention progress in the logs
|
||||||
if (!ObjResFile.isEmpty()) {
|
if (!ObjResFile.isEmpty()) {
|
||||||
log(tr("- Resource File: %1").arg(QDir(mProject->directory()).absoluteFilePath(ObjResFile)));
|
log(tr("- Resource File: %1").arg(absolutePath(mProject->directory(),ObjResFile)));
|
||||||
}
|
}
|
||||||
log("");
|
log("");
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ bool ProjectCompiler::prepareForRebuild()
|
||||||
QString ProjectCompiler::getFileNameFromOutputLine(QString &line)
|
QString ProjectCompiler::getFileNameFromOutputLine(QString &line)
|
||||||
{
|
{
|
||||||
QString temp=Compiler::getFileNameFromOutputLine(line);
|
QString temp=Compiler::getFileNameFromOutputLine(line);
|
||||||
return QDir(mDirectory).absoluteFilePath(temp);
|
return absolutePath(mDirectory,temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectCompiler::prepareForCompile()
|
bool ProjectCompiler::prepareForCompile()
|
||||||
|
|
|
@ -447,9 +447,8 @@ void Debugger::loadForProject(const QString &filename, const QString &projectFol
|
||||||
mProjectLastLoadtime = 0;
|
mProjectLastLoadtime = 0;
|
||||||
PDebugConfig pConfig = load(filename, forProject);
|
PDebugConfig pConfig = load(filename, forProject);
|
||||||
if (pConfig->timestamp>0) {
|
if (pConfig->timestamp>0) {
|
||||||
QDir dir(projectFolder);
|
|
||||||
foreach (const PBreakpoint& breakpoint, pConfig->breakpoints) {
|
foreach (const PBreakpoint& breakpoint, pConfig->breakpoints) {
|
||||||
breakpoint->filename = dir.absoluteFilePath(breakpoint->filename);
|
breakpoint->filename = absolutePath(projectFolder,breakpoint->filename);
|
||||||
}
|
}
|
||||||
mBreakpointModel->setBreakpoints(pConfig->breakpoints,forProject);
|
mBreakpointModel->setBreakpoints(pConfig->breakpoints,forProject);
|
||||||
mWatchModel->setWatchVars(pConfig->watchVars,forProject);
|
mWatchModel->setWatchVars(pConfig->watchVars,forProject);
|
||||||
|
@ -685,13 +684,12 @@ void Debugger::save(const QString &filename, const QString& projectFolder)
|
||||||
std::shared_ptr<DebugConfig> pConfig = load(filename, forProject);
|
std::shared_ptr<DebugConfig> pConfig = load(filename, forProject);
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
|
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||||
QDir folder(projectFolder);
|
|
||||||
foreach (const PBreakpoint& breakpoint, pConfig->breakpoints) {
|
foreach (const PBreakpoint& breakpoint, pConfig->breakpoints) {
|
||||||
QString key = QString("%1-%2").arg(breakpoint->filename).arg(breakpoint->line);
|
QString key = QString("%1-%2").arg(breakpoint->filename).arg(breakpoint->line);
|
||||||
if (!breakpointCompareSet.contains(key)) {
|
if (!breakpointCompareSet.contains(key)) {
|
||||||
breakpointCompareSet.insert(key);
|
breakpointCompareSet.insert(key);
|
||||||
if (forProject)
|
if (forProject)
|
||||||
breakpoint->filename=folder.absoluteFilePath(breakpoint->filename);
|
breakpoint->filename=absolutePath(projectFolder,breakpoint->filename);
|
||||||
mBreakpointModel->addBreakpoint(breakpoint,forProject);
|
mBreakpointModel->addBreakpoint(breakpoint,forProject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -944,8 +944,7 @@ void MainWindow::onFileSaved(const QString &path, bool inProject)
|
||||||
if (pSettings->vcs().gitOk()) {
|
if (pSettings->vcs().gitOk()) {
|
||||||
QString branch;
|
QString branch;
|
||||||
if (inProject && mProject && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
if (inProject && mProject && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcon(path);
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
QModelIndex index = mFileSystemModel.index(path);
|
QModelIndex index = mFileSystemModel.index(path);
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
|
@ -4663,6 +4662,7 @@ void MainWindow::updateProjectView()
|
||||||
|
|
||||||
void MainWindow::onFileChanged(const QString &path)
|
void MainWindow::onFileChanged(const QString &path)
|
||||||
{
|
{
|
||||||
|
qDebug()<<path<<"modified";
|
||||||
if (mFilesChangedNotifying.contains(path))
|
if (mFilesChangedNotifying.contains(path))
|
||||||
return;
|
return;
|
||||||
mFilesChangedNotifying.insert(path);
|
mFilesChangedNotifying.insert(path);
|
||||||
|
@ -6591,7 +6591,7 @@ void MainWindow::newProjectUnitFile()
|
||||||
if (newProjectUnitDialog.exec()!=QDialog::Accepted) {
|
if (newProjectUnitDialog.exec()!=QDialog::Accepted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
newFileName=QDir(newProjectUnitDialog.folder()).absoluteFilePath(newProjectUnitDialog.filename());
|
newFileName= absolutePath(newProjectUnitDialog.folder(),newProjectUnitDialog.filename());
|
||||||
if (newFileName.isEmpty())
|
if (newFileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -6610,7 +6610,7 @@ void MainWindow::newProjectUnitFile()
|
||||||
newFileName);
|
newFileName);
|
||||||
if (newFileName.isEmpty())
|
if (newFileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
newFileName = QDir(mProject->directory()).absoluteFilePath(newFileName);
|
newFileName = absolutePath(mProject->directory(),newFileName);
|
||||||
}
|
}
|
||||||
if (fileExists(newFileName)) {
|
if (fileExists(newFileName)) {
|
||||||
QMessageBox::critical(this,tr("File Already Exists!"),
|
QMessageBox::critical(this,tr("File Already Exists!"),
|
||||||
|
@ -6633,8 +6633,7 @@ void MainWindow::newProjectUnitFile()
|
||||||
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
||||||
QString output;
|
QString output;
|
||||||
mProject->model()->iconProvider()->VCSRepository()->add(newFileName,output);
|
mProject->model()->iconProvider()->VCSRepository()->add(newFileName,output);
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcon(newFileName);
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
updateProjectView();
|
updateProjectView();
|
||||||
}
|
}
|
||||||
|
@ -7928,8 +7927,7 @@ void MainWindow::on_actionGit_Create_Repository_triggered()
|
||||||
if (mProject && mProject->folder() == mFileSystemModel.rootPath()) {
|
if (mProject && mProject->folder() == mFileSystemModel.rootPath()) {
|
||||||
mProject->addUnit(includeTrailingPathDelimiter(mProject->folder())+".gitignore", mProject->rootNode());
|
mProject->addUnit(includeTrailingPathDelimiter(mProject->folder())+".gitignore", mProject->rootNode());
|
||||||
} else if (mProject && mFileSystemModel.index(mProject->folder()).isValid()) {
|
} else if (mProject && mFileSystemModel.index(mProject->folder()).isValid()) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcons();
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
} else if (ui->projectView->isVisible() && mProject) {
|
} else if (ui->projectView->isVisible() && mProject) {
|
||||||
GitManager vcsManager;
|
GitManager vcsManager;
|
||||||
|
@ -7988,13 +7986,10 @@ void MainWindow::on_actionGit_Add_Files_triggered()
|
||||||
QString output;
|
QString output;
|
||||||
vcsManager.add(info.absolutePath(),info.fileName(),output);
|
vcsManager.add(info.absolutePath(),info.fileName(),output);
|
||||||
}
|
}
|
||||||
|
mProject->model()->refreshIcon(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//update icons in project view
|
|
||||||
if (mProject) {
|
|
||||||
mProject->model()->beginUpdate();
|
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
|
||||||
//update icons in files view too
|
//update icons in files view too
|
||||||
mFileSystemModelIconProvider.update();
|
mFileSystemModelIconProvider.update();
|
||||||
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
||||||
|
@ -8046,8 +8041,7 @@ void MainWindow::on_actionGit_Commit_triggered()
|
||||||
if (vcsManager.commit(folder,message,true,output)) {
|
if (vcsManager.commit(folder,message,true,output)) {
|
||||||
//update project view
|
//update project view
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcons();
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
//update files view
|
//update files view
|
||||||
mFileSystemModelIconProvider.update();
|
mFileSystemModelIconProvider.update();
|
||||||
|
@ -8076,8 +8070,7 @@ void MainWindow::on_actionGit_Restore_triggered()
|
||||||
|
|
||||||
//update project view
|
//update project view
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcons();
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
//update files view
|
//update files view
|
||||||
mFileSystemModelIconProvider.update();
|
mFileSystemModelIconProvider.update();
|
||||||
|
@ -8114,8 +8107,7 @@ void MainWindow::on_actionGit_Branch_triggered()
|
||||||
if (dialog.exec()==QDialog::Accepted) {
|
if (dialog.exec()==QDialog::Accepted) {
|
||||||
//update project view
|
//update project view
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcons();
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
//update files view
|
//update files view
|
||||||
setFilesViewRoot(pSettings->environment().currentFolder());
|
setFilesViewRoot(pSettings->environment().currentFolder());
|
||||||
|
@ -8137,8 +8129,7 @@ void MainWindow::on_actionGit_Merge_triggered()
|
||||||
if (dialog.exec()==QDialog::Accepted) {
|
if (dialog.exec()==QDialog::Accepted) {
|
||||||
//update project view
|
//update project view
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcons();
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
//update files view
|
//update files view
|
||||||
setFilesViewRoot(pSettings->environment().currentFolder());
|
setFilesViewRoot(pSettings->environment().currentFolder());
|
||||||
|
@ -8160,8 +8151,7 @@ void MainWindow::on_actionGit_Log_triggered()
|
||||||
if (dialog.exec()==QDialog::Accepted) {
|
if (dialog.exec()==QDialog::Accepted) {
|
||||||
//update project view
|
//update project view
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->refreshIcons();
|
||||||
mProject->model()->endUpdate();
|
|
||||||
}
|
}
|
||||||
//update files view
|
//update files view
|
||||||
setFilesViewRoot(pSettings->environment().currentFolder());
|
setFilesViewRoot(pSettings->environment().currentFolder());
|
||||||
|
|
|
@ -401,7 +401,7 @@ QString getLocalHeaderFilename(const QString &relativeTo, const QString &fileNam
|
||||||
QDir dir = relativeFile.dir();
|
QDir dir = relativeFile.dir();
|
||||||
// Search local directory
|
// Search local directory
|
||||||
if (dir.exists(fileName)) {
|
if (dir.exists(fileName)) {
|
||||||
return QDir::cleanPath(dir.absoluteFilePath(fileName));
|
return cleanPath(dir.absoluteFilePath(fileName));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@ QString getSystemHeaderFilename(const QString &fileName, const QStringList& incl
|
||||||
for (const QString& path:includePaths) {
|
for (const QString& path:includePaths) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
if (dir.exists(fileName)) {
|
if (dir.exists(fileName)) {
|
||||||
return QDir::cleanPath(dir.absoluteFilePath(fileName));
|
return cleanPath(dir.absoluteFilePath(fileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//not found
|
//not found
|
||||||
|
|
|
@ -197,8 +197,8 @@ void Project::open()
|
||||||
PProjectUnit newUnit = std::make_shared<ProjectUnit>(this);
|
PProjectUnit newUnit = std::make_shared<ProjectUnit>(this);
|
||||||
QByteArray groupName = toByteArray(QString("Unit%1").arg(i+1));
|
QByteArray groupName = toByteArray(QString("Unit%1").arg(i+1));
|
||||||
newUnit->setFileName(
|
newUnit->setFileName(
|
||||||
dir.absoluteFilePath(
|
cleanPath(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"),
|
||||||
|
@ -328,10 +328,10 @@ PProjectUnit Project::newUnit(PProjectModelNode parentNode, const QString& custo
|
||||||
// Find unused 'new' filename
|
// Find unused 'new' filename
|
||||||
if (customFileName.isEmpty()) {
|
if (customFileName.isEmpty()) {
|
||||||
do {
|
do {
|
||||||
s = dir.absoluteFilePath(tr("untitled")+QString("%1").arg(getNewFileNumber()));
|
s = cleanPath(dir.absoluteFilePath(tr("untitled")+QString("%1").arg(getNewFileNumber())));
|
||||||
} while (fileExists(s));
|
} while (fileExists(s));
|
||||||
} else {
|
} else {
|
||||||
s = dir.absoluteFilePath(customFileName);
|
s = cleanPath(dir.absoluteFilePath(customFileName));
|
||||||
}
|
}
|
||||||
if (mOptions.modelType == ProjectModelType::FileSystem) {
|
if (mOptions.modelType == ProjectModelType::FileSystem) {
|
||||||
// in file system mode, parentNode is determined by file's path
|
// in file system mode, parentNode is determined by file's path
|
||||||
|
@ -896,9 +896,9 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate, b
|
||||||
|
|
||||||
// Copy icon to project directory
|
// Copy icon to project directory
|
||||||
if (!mOptions.icon.isEmpty()) {
|
if (!mOptions.icon.isEmpty()) {
|
||||||
QString originIcon = QFileInfo(aTemplate->fileName()).absoluteDir().absoluteFilePath(mOptions.icon);
|
QString originIcon = cleanPath(QFileInfo(aTemplate->fileName()).absoluteDir().absoluteFilePath(mOptions.icon));
|
||||||
if (fileExists(originIcon)) {
|
if (fileExists(originIcon)) {
|
||||||
QString destIcon = QFileInfo(mFilename).absoluteDir().absoluteFilePath("app.ico");
|
QString destIcon = cleanPath(QFileInfo(mFilename).absoluteDir().absoluteFilePath("app.ico"));
|
||||||
QFile::copy(originIcon,destIcon);
|
QFile::copy(originIcon,destIcon);
|
||||||
mOptions.icon = destIcon;
|
mOptions.icon = destIcon;
|
||||||
} else {
|
} else {
|
||||||
|
@ -917,7 +917,7 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate, b
|
||||||
if (!templateUnit->Target.isEmpty())
|
if (!templateUnit->Target.isEmpty())
|
||||||
target = templateUnit->Target;
|
target = templateUnit->Target;
|
||||||
QFile::copy(
|
QFile::copy(
|
||||||
dir.absoluteFilePath(templateUnit->Source),
|
cleanPath(dir.absoluteFilePath(templateUnit->Source)),
|
||||||
includeTrailingPathDelimiter(this->directory())+target);
|
includeTrailingPathDelimiter(this->directory())+target);
|
||||||
unit = newUnit(mRootNode, target);
|
unit = newUnit(mRootNode, target);
|
||||||
} else {
|
} else {
|
||||||
|
@ -937,7 +937,7 @@ bool Project::assignTemplate(const std::shared_ptr<ProjectTemplate> aTemplate, b
|
||||||
this,
|
this,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
QString s2 = dir.absoluteFilePath(s);
|
QString s2 = cleanPath(dir.absoluteFilePath(s));
|
||||||
if (fileExists(s2) && !s.isEmpty()) {
|
if (fileExists(s2) && !s.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
editor->loadFile(s2);
|
editor->loadFile(s2);
|
||||||
|
@ -973,7 +973,7 @@ bool Project::saveAsTemplate(const QString &templateFolder,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fileName = dir.absoluteFilePath(TEMPLATE_INFO_FILE);
|
QString fileName = cleanPath(dir.absoluteFilePath(TEMPLATE_INFO_FILE));
|
||||||
PSimpleIni ini = std::make_shared<SimpleIni>();
|
PSimpleIni ini = std::make_shared<SimpleIni>();
|
||||||
|
|
||||||
ini->SetLongValue("Template","Ver",3);
|
ini->SetLongValue("Template","Ver",3);
|
||||||
|
@ -983,7 +983,7 @@ bool Project::saveAsTemplate(const QString &templateFolder,
|
||||||
ini->SetValue("Template", "Description", description.toUtf8());
|
ini->SetValue("Template", "Description", description.toUtf8());
|
||||||
if (fileExists(mOptions.icon)) {
|
if (fileExists(mOptions.icon)) {
|
||||||
QString iconName = extractFileName(mOptions.icon);
|
QString iconName = extractFileName(mOptions.icon);
|
||||||
copyFile(mOptions.icon, dir.absoluteFilePath(iconName),true);
|
copyFile(mOptions.icon, cleanPath(dir.absoluteFilePath(iconName)),true);
|
||||||
if (dir.exists(iconName))
|
if (dir.exists(iconName))
|
||||||
ini->SetValue("Template", "Icon", iconName.toUtf8());
|
ini->SetValue("Template", "Icon", iconName.toUtf8());
|
||||||
}
|
}
|
||||||
|
@ -1033,10 +1033,10 @@ bool Project::saveAsTemplate(const QString &templateFolder,
|
||||||
foreach (const PProjectUnit &unit, mUnits) {
|
foreach (const PProjectUnit &unit, mUnits) {
|
||||||
QString unitName = extractFileName(unit->fileName());
|
QString unitName = extractFileName(unit->fileName());
|
||||||
QByteArray section = toByteArray(QString("Unit%1").arg(i));
|
QByteArray section = toByteArray(QString("Unit%1").arg(i));
|
||||||
if (!copyFile(unit->fileName(), dir.absoluteFilePath(unitName),true)) {
|
if (!copyFile(unit->fileName(), cleanPath(dir.absoluteFilePath(unitName)),true)) {
|
||||||
QMessageBox::warning(nullptr,
|
QMessageBox::warning(nullptr,
|
||||||
tr("Warning"),
|
tr("Warning"),
|
||||||
tr("Can't save file %1").arg(dir.absoluteFilePath(unitName)),
|
tr("Can't save file %1").arg(cleanPath(dir.absoluteFilePath(unitName))),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
switch(getFileType(unit->fileName())) {
|
switch(getFileType(unit->fileName())) {
|
||||||
|
@ -1429,7 +1429,7 @@ void Project::buildPrivateResource(bool forceSave)
|
||||||
contents.append("}");
|
contents.append("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
rcFile = QDir(directory()).absoluteFilePath(rcFile);
|
rcFile = absolutePath(directory(),rcFile);
|
||||||
if (contents.count() > 3) {
|
if (contents.count() > 3) {
|
||||||
stringsToFile(contents,rcFile);
|
stringsToFile(contents,rcFile);
|
||||||
mOptions.privateResource = extractRelativePath(directory(), rcFile);
|
mOptions.privateResource = extractRelativePath(directory(), rcFile);
|
||||||
|
@ -1864,7 +1864,7 @@ void Project::loadOptions(SimpleIni& ini)
|
||||||
if (icon.isEmpty()) {
|
if (icon.isEmpty()) {
|
||||||
mOptions.icon = "";
|
mOptions.icon = "";
|
||||||
} else {
|
} else {
|
||||||
mOptions.icon = QDir(directory()).absoluteFilePath(icon);
|
mOptions.icon = absolutePath(directory(),icon);
|
||||||
}
|
}
|
||||||
mOptions.version = ini.GetLongValue("Project", "Ver", 0);
|
mOptions.version = ini.GetLongValue("Project", "Ver", 0);
|
||||||
if (mOptions.version > 0) { // ver > 0 is at least a v5 project
|
if (mOptions.version > 0) { // ver > 0 is at least a v5 project
|
||||||
|
@ -1962,6 +1962,7 @@ void Project::loadOptions(SimpleIni& ini)
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
setCompilerSet(pSettings->compilerSets().defaultIndex());
|
setCompilerSet(pSettings->compilerSets().defaultIndex());
|
||||||
|
saveOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(mOptions.compilerSet);
|
Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(mOptions.compilerSet);
|
||||||
|
@ -2609,7 +2610,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
return false;
|
return false;
|
||||||
QString oldName = unit->fileName();
|
QString oldName = unit->fileName();
|
||||||
QString curDir = extractFilePath(oldName);
|
QString curDir = extractFilePath(oldName);
|
||||||
newName = QDir(curDir).absoluteFilePath(newName);
|
newName = absolutePath(curDir,newName);
|
||||||
// Only continue if the user says so...
|
// Only continue if the user says so...
|
||||||
if (fileExists(newName) && newName.compare(oldName, PATH_SENSITIVITY)!=0) {
|
if (fileExists(newName) && newName.compare(oldName, PATH_SENSITIVITY)!=0) {
|
||||||
// don't remove when changing case for example
|
// don't remove when changing case for example
|
||||||
|
@ -2684,6 +2685,42 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectModel::refreshIcon(const QModelIndex &index, bool update)
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
if (update)
|
||||||
|
mIconProvider->update();
|
||||||
|
QVector<int> roles;
|
||||||
|
roles.append(Qt::DecorationRole);
|
||||||
|
emit dataChanged(index,index, roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectModel::refreshIcon(const QString &filename)
|
||||||
|
{
|
||||||
|
PProjectUnit unit=mProject->findUnit(filename);
|
||||||
|
if (!unit)
|
||||||
|
return;
|
||||||
|
PProjectModelNode node=unit->node();
|
||||||
|
QModelIndex index = getNodeIndex(node.get());
|
||||||
|
refreshIcon(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectModel::refreshIcons()
|
||||||
|
{
|
||||||
|
mIconProvider->update();
|
||||||
|
mProject->rootNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectModel::refreshNodeIconRecursive(PProjectModelNode node)
|
||||||
|
{
|
||||||
|
QModelIndex index=getNodeIndex(node.get());
|
||||||
|
refreshIcon(index,false);
|
||||||
|
foreach( PProjectModelNode child, node->children) {
|
||||||
|
refreshNodeIconRecursive(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex ProjectModel::getNodeIndex(ProjectModelNode *node) const
|
QModelIndex ProjectModel::getNodeIndex(ProjectModelNode *node) const
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
|
|
|
@ -146,6 +146,10 @@ public:
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
|
void refreshIcon(const QModelIndex& index, bool update=true);
|
||||||
|
void refreshIcon(const QString& filename);
|
||||||
|
void refreshIcons();
|
||||||
|
void refreshNodeIconRecursive(PProjectModelNode node);
|
||||||
|
|
||||||
QModelIndex getNodeIndex(ProjectModelNode *node) const;
|
QModelIndex getNodeIndex(ProjectModelNode *node) const;
|
||||||
QModelIndex getParentIndex(ProjectModelNode * node) const;
|
QModelIndex getParentIndex(ProjectModelNode * node) const;
|
||||||
|
|
|
@ -112,7 +112,7 @@ void ProjectGeneralWidget::doSave()
|
||||||
#endif
|
#endif
|
||||||
project->options().icon = "";
|
project->options().icon = "";
|
||||||
} else {
|
} else {
|
||||||
QString iconPath = QFileInfo(project->filename()).absoluteDir().absoluteFilePath("app.ico");
|
QString iconPath = absolutePath(project->directory(),"app.ico");
|
||||||
if (iconPath!=mIconPath) {
|
if (iconPath!=mIconPath) {
|
||||||
if (QFile(iconPath).exists()) {
|
if (QFile(iconPath).exists()) {
|
||||||
if (!QFile::remove(iconPath)) {
|
if (!QFile::remove(iconPath)) {
|
||||||
|
|
|
@ -116,7 +116,7 @@ void GitRepository::convertFilesListToSet(const QStringList &filesList, QSet<QSt
|
||||||
set.clear();
|
set.clear();
|
||||||
QDir dir(mRealFolder);
|
QDir dir(mRealFolder);
|
||||||
foreach (const QString& s, filesList) {
|
foreach (const QString& s, filesList) {
|
||||||
set.insert(dir.absoluteFilePath(s));
|
set.insert(cleanPath(dir.absoluteFilePath(s)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ void BookmarkModel::save(const QString &filename, const QString& projectFolder)
|
||||||
beginInsertRows(QModelIndex(),count,count);
|
beginInsertRows(QModelIndex(),count,count);
|
||||||
}
|
}
|
||||||
if (forProject) {
|
if (forProject) {
|
||||||
bookmark->filename = dir.absoluteFilePath(bookmark->filename);
|
bookmark->filename = cleanPath(dir.absoluteFilePath(bookmark->filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
list.append(bookmark);
|
list.append(bookmark);
|
||||||
|
@ -332,7 +332,7 @@ void BookmarkModel::loadProjectBookmarks(const QString &filename, const QString&
|
||||||
mProjectBookmarks = load(filename,0,&t);
|
mProjectBookmarks = load(filename,0,&t);
|
||||||
QDir folder(projectFolder);
|
QDir folder(projectFolder);
|
||||||
foreach (PBookmark bookmark, mProjectBookmarks) {
|
foreach (PBookmark bookmark, mProjectBookmarks) {
|
||||||
bookmark->filename=folder.absoluteFilePath(bookmark->filename);
|
bookmark->filename=cleanPath(folder.absoluteFilePath(bookmark->filename));
|
||||||
}
|
}
|
||||||
if (mIsForProject)
|
if (mIsForProject)
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include "../utils.h"
|
||||||
|
|
||||||
HeaderCompletionPopup::HeaderCompletionPopup(QWidget* parent):QWidget(parent)
|
HeaderCompletionPopup::HeaderCompletionPopup(QWidget* parent):QWidget(parent)
|
||||||
{
|
{
|
||||||
|
@ -231,7 +232,7 @@ void HeaderCompletionPopup::addFile(const QDir& dir, const QFileInfo& fileInfo,
|
||||||
PHeaderCompletionListItem item = std::make_shared<HeaderCompletionListItem>();
|
PHeaderCompletionListItem item = std::make_shared<HeaderCompletionListItem>();
|
||||||
item->filename = fileName;
|
item->filename = fileName;
|
||||||
item->itemType = type;
|
item->itemType = type;
|
||||||
item->fullpath = dir.absoluteFilePath(fileName);
|
item->fullpath = cleanPath(dir.absoluteFilePath(fileName));
|
||||||
item->usageCount = mHeaderUsageCounts.value(item->fullpath,0);
|
item->usageCount = mHeaderUsageCounts.value(item->fullpath,0);
|
||||||
item->isFolder = fileInfo.isDir();
|
item->isFolder = fileInfo.isDir();
|
||||||
mFullCompletionList.insert(fileName,item);
|
mFullCompletionList.insert(fileName,item);
|
||||||
|
|
|
@ -145,7 +145,7 @@ void NewProjectDialog::readTemplateDir(const QString& folderPath)
|
||||||
} else if (fileInfo.isDir()) {
|
} else if (fileInfo.isDir()) {
|
||||||
QDir subDir(fileInfo.absoluteFilePath());
|
QDir subDir(fileInfo.absoluteFilePath());
|
||||||
if (subDir.exists(TEMPLATE_INFO_FILE)) {
|
if (subDir.exists(TEMPLATE_INFO_FILE)) {
|
||||||
addTemplate(subDir.absoluteFilePath(TEMPLATE_INFO_FILE));
|
addTemplate(cleanPath(subDir.absoluteFilePath(TEMPLATE_INFO_FILE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ void NewProjectDialog::updateView()
|
||||||
QString tabText = mTemplatesTabBar->tabText(index);
|
QString tabText = mTemplatesTabBar->tabText(index);
|
||||||
if (category == tabText) {
|
if (category == tabText) {
|
||||||
QListWidgetItem * item;
|
QListWidgetItem * item;
|
||||||
QString iconFilename = QFileInfo(t->fileName()).absoluteDir().absoluteFilePath(t->icon());
|
QString iconFilename = cleanPath(QFileInfo(t->fileName()).absoluteDir().absoluteFilePath(t->icon()));
|
||||||
QIcon icon=QIcon(iconFilename);
|
QIcon icon=QIcon(iconFilename);
|
||||||
if (icon.isNull()) {
|
if (icon.isNull()) {
|
||||||
//todo : use an default icon
|
//todo : use an default icon
|
||||||
|
|
|
@ -74,7 +74,7 @@ void NewTemplateDialog::readTemplateCategoriesInDir(const QString &folderPath, Q
|
||||||
readTemplateCategory(fileInfo.absoluteFilePath(),categories);
|
readTemplateCategory(fileInfo.absoluteFilePath(),categories);
|
||||||
} else if (fileInfo.isDir()) {
|
} else if (fileInfo.isDir()) {
|
||||||
QDir subDir(fileInfo.absoluteFilePath());
|
QDir subDir(fileInfo.absoluteFilePath());
|
||||||
readTemplateCategory(subDir.absoluteFilePath(TEMPLATE_INFO_FILE),categories);
|
readTemplateCategory(cleanPath(subDir.absoluteFilePath(TEMPLATE_INFO_FILE)),categories);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -679,3 +679,13 @@ void createFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
stringToFile("",fileName);
|
stringToFile("",fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString cleanPath(const QString &dirPath)
|
||||||
|
{
|
||||||
|
return QDir::cleanPath(dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString absolutePath(const QString &dirPath, const QString &relativePath)
|
||||||
|
{
|
||||||
|
return QDir::cleanPath(QDir(dirPath).absoluteFilePath(relativePath));
|
||||||
|
}
|
||||||
|
|
|
@ -128,6 +128,9 @@ QString extractFileName(const QString& fileName);
|
||||||
QString extractFileDir(const QString& fileName);
|
QString extractFileDir(const QString& fileName);
|
||||||
QString extractFilePath(const QString& filePath);
|
QString extractFilePath(const QString& filePath);
|
||||||
QString extractAbsoluteFilePath(const QString& filePath);
|
QString extractAbsoluteFilePath(const QString& filePath);
|
||||||
|
QString cleanPath(const QString& dirPath);
|
||||||
|
QString absolutePath(const QString& dirPath, const QString& relativePath);
|
||||||
|
|
||||||
|
|
||||||
bool isReadOnly(const QString& filename);
|
bool isReadOnly(const QString& filename);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue