Add Default Search Paths via musredit preferences if previously no search paths were present
So far it was not possible to add Default Search Paths to musrfit via musredit if somebody delete all the predefined search paths. This bug is now fixed.
This commit is contained in:
parent
2c65609f84
commit
64fc455831
@ -302,6 +302,17 @@ void PChangeDefaultPathsDialog::saveDefaultPathList()
|
|||||||
}
|
}
|
||||||
fileIn.close();
|
fileIn.close();
|
||||||
|
|
||||||
|
// check if there is any data_path is present in the musrfit_startup.xml
|
||||||
|
bool dataPathPresent = false;
|
||||||
|
QString str;
|
||||||
|
for (int i=0; i<fileContent.count(); i++) {
|
||||||
|
str = fileContent[i];
|
||||||
|
if (str.trimmed().startsWith("<data_path>")) {
|
||||||
|
dataPathPresent = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// write the new musrfit_startup.xml
|
// write the new musrfit_startup.xml
|
||||||
QFile fileOut(fDefaultPath->getPrefPathName());
|
QFile fileOut(fDefaultPath->getPrefPathName());
|
||||||
if (!fileOut.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!fileOut.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
@ -309,11 +320,15 @@ void PChangeDefaultPathsDialog::saveDefaultPathList()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTextStream out(&fileOut);
|
QTextStream out(&fileOut);
|
||||||
QString str;
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (int i=0; i<fileContent.count(); i++) {
|
for (int i=0; i<fileContent.count(); i++) {
|
||||||
str = fileContent[i];
|
str = fileContent[i];
|
||||||
if (!str.trimmed().startsWith("<data_path>")) {
|
if (!str.trimmed().startsWith("<data_path>")) {
|
||||||
|
// if not data_path was present, add the new data_paths just before the end of the musrfit_start.xml close tag
|
||||||
|
if ((dataPathPresent == false) && (str.trimmed().startsWith("</musrfit>"))) {
|
||||||
|
for (int j=0; j<fSearchPath_listWidget->count(); j++)
|
||||||
|
out << " <data_path>" << fSearchPath_listWidget->item(j)->text() << "</data_path>" << endl;
|
||||||
|
}
|
||||||
out << fileContent[i] << endl;
|
out << fileContent[i] << endl;
|
||||||
} else {
|
} else {
|
||||||
if (first) {
|
if (first) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user