Git commit e4d45f361767a59029761345e4514b886cb01ae7 by Alin Marin Elena. Committed on 31/12/2014 at 12:01. Pushed by elena into branch 'frameworks'. silence Cannot open XML file to load Workflow if the file does not exits in= the first place M +139 -135 utilities/queuemanager/manager/workflowmanager.cpp http://commits.kde.org/digikam/e4d45f361767a59029761345e4514b886cb01ae7 diff --git a/utilities/queuemanager/manager/workflowmanager.cpp b/utilities= /queuemanager/manager/workflowmanager.cpp index e4ba43e..647dd19 100644 --- a/utilities/queuemanager/manager/workflowmanager.cpp +++ b/utilities/queuemanager/manager/workflowmanager.cpp @@ -313,172 +313,176 @@ bool WorkflowManager::load(QStringList& failed) d->modified =3D false; = QFile file(d->file); + if (file.exists()){ + if (!file.open(QIODevice::ReadOnly)) + { + qCDebug(DIGIKAM_GENERAL_LOG) << "Cannot open XML file to load = Workflow"; + return false; + } = - if (!file.open(QIODevice::ReadOnly)) - { - qCDebug(DIGIKAM_GENERAL_LOG) << "Cannot open XML file to load Work= flow"; - return false; - } - - QDomDocument doc("queuelist"); - - if (!doc.setContent(&file)) - { - qCDebug(DIGIKAM_GENERAL_LOG) << "Cannot load Workflow XML file"; - return false; - } - - QDomElement docElem =3D doc.documentElement(); - - if (docElem.tagName() !=3D "queuelist") - { - qCDebug(DIGIKAM_GENERAL_LOG) << "Workflow XML file do not content = Queue List data"; - return false; - } - - for (QDomNode n =3D docElem.firstChild(); !n.isNull(); n =3D n.nextSib= ling()) - { - QDomElement e =3D n.toElement(); + QDomDocument doc("queuelist"); = - if (e.isNull()) + if (!doc.setContent(&file)) { - continue; + qCDebug(DIGIKAM_GENERAL_LOG) << "Cannot load Workflow XML file= "; + return false; } = - if (e.tagName() !=3D "queue") + QDomElement docElem =3D doc.documentElement(); + + if (docElem.tagName() !=3D "queuelist") { - continue; + qCDebug(DIGIKAM_GENERAL_LOG) << "Workflow XML file do not cont= ent Queue List data"; + return false; } = - Workflow q; - bool versionOk =3D true; - - for (QDomNode n2 =3D e.firstChild(); !n2.isNull(); n2 =3D n2.nextS= ibling()) + for (QDomNode n =3D docElem.firstChild(); !n.isNull(); n =3D n.nex= tSibling()) { - QDomElement e2 =3D n2.toElement(); - if (e2.isNull()) + QDomElement e =3D n.toElement(); + + if (e.isNull()) { continue; } = - QString name2 =3D e2.tagName(); - QString val2 =3D e2.attribute(QString::fromLatin1("value")); - bool ok =3D true; - - if (name2 =3D=3D "queuetitle") - { - q.title =3D val2; - } - else if (name2 =3D=3D "queuedesc") - { - q.desc =3D val2; - } - else if (name2 =3D=3D "renamingparser") - { - q.qSettings.renamingParser =3D val2; - } - else if (name2 =3D=3D "useoriginalalbum") - { - q.qSettings.useOrgAlbum =3D (bool)val2.toUInt(&ok); - } - else if (name2 =3D=3D "usemulticorecpu") - { - q.qSettings.useMultiCoreCPU =3D (bool)val2.toUInt(&ok); - } - else if (name2 =3D=3D "workingurl") - { - q.qSettings.workingUrl =3D KUrl(val2); - } - else if (name2 =3D=3D "conflictrule") - { - q.qSettings.conflictRule =3D (QueueSettings::ConflictRule)= val2.toUInt(&ok); - } - else if (name2 =3D=3D "renamingrule") - { - q.qSettings.renamingRule =3D (QueueSettings::RenamingRule)= val2.toUInt(&ok); - } - else if (name2 =3D=3D "rawloadingrule") + if (e.tagName() !=3D "queue") { - q.qSettings.rawLoadingRule =3D (QueueSettings::RawLoadingR= ule)val2.toUInt(&ok); - } - else if (name2 =3D=3D "rawdecodingsettings") - { - DRawDecoding::decodingSettingsFromXml(e2, q.qSettings.rawD= ecodingSettings); + continue; } - else if (name2 =3D=3D "tool") + + Workflow q; + bool versionOk =3D true; + + for (QDomNode n2 =3D e.firstChild(); !n2.isNull(); n2 =3D n2.n= extSibling()) { - BatchToolSet set; + QDomElement e2 =3D n2.toElement(); + if (e2.isNull()) + { + continue; + } + + QString name2 =3D e2.tagName(); + QString val2 =3D e2.attribute(QString::fromLatin1("value"= )); + bool ok =3D true; = - for (QDomNode n3 =3D e2.firstChild(); !n3.isNull(); n3 =3D= n3.nextSibling()) + if (name2 =3D=3D "queuetitle") { - QDomElement e3 =3D n3.toElement(); - if (e3.isNull()) + q.title =3D val2; + } + else if (name2 =3D=3D "queuedesc") + { + q.desc =3D val2; + } + else if (name2 =3D=3D "renamingparser") + { + q.qSettings.renamingParser =3D val2; + } + else if (name2 =3D=3D "useoriginalalbum") + { + q.qSettings.useOrgAlbum =3D (bool)val2.toUInt(&ok); + } + else if (name2 =3D=3D "usemulticorecpu") + { + q.qSettings.useMultiCoreCPU =3D (bool)val2.toUInt(&ok); + } + else if (name2 =3D=3D "workingurl") + { + q.qSettings.workingUrl =3D KUrl(val2); + } + else if (name2 =3D=3D "conflictrule") + { + q.qSettings.conflictRule =3D (QueueSettings::ConflictR= ule)val2.toUInt(&ok); + } + else if (name2 =3D=3D "renamingrule") + { + q.qSettings.renamingRule =3D (QueueSettings::RenamingR= ule)val2.toUInt(&ok); + } + else if (name2 =3D=3D "rawloadingrule") + { + q.qSettings.rawLoadingRule =3D (QueueSettings::RawLoad= ingRule)val2.toUInt(&ok); + } + else if (name2 =3D=3D "rawdecodingsettings") + { + DRawDecoding::decodingSettingsFromXml(e2, q.qSettings.= rawDecodingSettings); + } + else if (name2 =3D=3D "tool") + { + BatchToolSet set; + + for (QDomNode n3 =3D e2.firstChild(); !n3.isNull(); n3= =3D n3.nextSibling()) { - continue; + QDomElement e3 =3D n3.toElement(); + if (e3.isNull()) + { + continue; + } + + QString name3 =3D e3.tagName(); + QString val3 =3D e3.attribute(QString::fromLatin= 1("value")); + + if (name3 =3D=3D "toolname") + { + set.name =3D val3; + } + else if (name3 =3D=3D "toolgroup") + { + set.group =3D (BatchTool::BatchToolGroup)val3.= toInt(&ok); + } + else if (name3 =3D=3D "index") + { + set.index =3D val3.toInt(&ok); + } + else if (name3 =3D=3D "version") + { + set.version =3D val3.toInt(&ok); + } + else if (name3 =3D=3D "parameter") + { + QString pname =3D e3.attribute(QString::fromLa= tin1("name")); + QString type =3D e3.attribute(QString::fromLa= tin1("type")); + QVariant var(val3); + var.convert(QVariant::nameToType(type.toAscii(= ).constData())); + /* + qCDebug(DIGIKAM_GENERAL_LOG) << "name=3D" << p= name << " :: " << "type=3D" << type << " :: " << "value=3D" << val3 + << " :: " << "QVariant=3D" << var; + */ + set.settings.insert(pname, var); + } } = - QString name3 =3D e3.tagName(); - QString val3 =3D e3.attribute(QString::fromLatin1("v= alue")); + BatchTool* const tool =3D BatchToolsManager::instance(= )->findTool(set.name, set.group); = - if (name3 =3D=3D "toolname") - { - set.name =3D val3; - } - else if (name3 =3D=3D "toolgroup") - { - set.group =3D (BatchTool::BatchToolGroup)val3.toIn= t(&ok); - } - else if (name3 =3D=3D "index") + if (tool) { - set.index =3D val3.toInt(&ok); + if (set.version =3D=3D tool->toolVersion()) + { + q.aTools.append(set); + } } - else if (name3 =3D=3D "version") + else { - set.version =3D val3.toInt(&ok); + versionOk =3D false; + d->modified =3D true; } - else if (name3 =3D=3D "parameter") - { - QString pname =3D e3.attribute(QString::fromLatin1= ("name")); - QString type =3D e3.attribute(QString::fromLatin1= ("type")); - QVariant var(val3); - var.convert(QVariant::nameToType(type.toAscii().co= nstData())); -/* - qCDebug(DIGIKAM_GENERAL_LOG) << "name=3D" << pname= << " :: " << "type=3D" << type << " :: " << "value=3D" << val3 - << " :: " << "QVariant=3D" << var; -*/ - set.settings.insert(pname, var); - } - } - - BatchTool* const tool =3D BatchToolsManager::instance()->f= indTool(set.name, set.group); - - if (tool) - { - if (set.version =3D=3D tool->toolVersion()) - { - q.aTools.append(set); - } - } - else - { - versionOk =3D false; - d->modified =3D true; } } - } = - if (versionOk) - { - // We only instert workflow if all tools version are compatible - insertPrivate(q); - } - else - { - failed.append(QString("%1 [%2]").arg(q.title).arg(q.desc)); + if (versionOk) + { + // We only instert workflow if all tools version are compa= tible + insertPrivate(q); + } + else + { + failed.append(QString("%1 [%2]").arg(q.title).arg(q.desc)); + } } + return true; + } = + else + { + return false; } - - return true; } = } // namespace Digikam