[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [digikam/frameworks] utilities/queuemanager/manager: silence Cannot open XML file to load Workflow i
From:       Alin Marin Elena <alinm.elena () gmail ! com>
Date:       2014-12-31 21:57:08
Message-ID: E1Y6RGO-0003f0-Le () scm ! kde ! org
[Download RAW message or body]

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 = 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 Workflow";
-        return false;
-    }
-
-    QDomDocument doc("queuelist");
-
-    if (!doc.setContent(&file))
-    {
-        qCDebug(DIGIKAM_GENERAL_LOG) << "Cannot load Workflow XML file";
-        return false;
-    }
-
-    QDomElement docElem = doc.documentElement();
-
-    if (docElem.tagName() != "queuelist")
-    {
-        qCDebug(DIGIKAM_GENERAL_LOG) << "Workflow XML file do not content Queue List \
                data";
-        return false;
-    }
-
-    for (QDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling())
-    {
-        QDomElement e = 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() != "queue")
+        QDomElement docElem = doc.documentElement();
+
+        if (docElem.tagName() != "queuelist")
         {
-            continue;
+            qCDebug(DIGIKAM_GENERAL_LOG) << "Workflow XML file do not content Queue \
List data"; +            return false;
         }
 
-        Workflow q;
-        bool     versionOk = true;
-
-        for (QDomNode n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling())
+        for (QDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling())
         {
-            QDomElement e2 = n2.toElement();
-            if (e2.isNull())
+            QDomElement e = n.toElement();
+
+            if (e.isNull())
             {
                 continue;
             }
 
-            QString name2 = e2.tagName();
-            QString val2  = e2.attribute(QString::fromLatin1("value"));
-            bool ok       = true;
-
-            if (name2 == "queuetitle")
-            {
-                q.title = val2;
-            }
-            else if (name2 == "queuedesc")
-            {
-                q.desc = val2;
-            }
-            else if (name2 == "renamingparser")
-            {
-                q.qSettings.renamingParser = val2;
-            }
-            else if (name2 == "useoriginalalbum")
-            {
-                q.qSettings.useOrgAlbum = (bool)val2.toUInt(&ok);
-            }
-            else if (name2 == "usemulticorecpu")
-            {
-                q.qSettings.useMultiCoreCPU = (bool)val2.toUInt(&ok);
-            }
-            else if (name2 == "workingurl")
-            {
-                q.qSettings.workingUrl = KUrl(val2);
-            }
-            else if (name2 == "conflictrule")
-            {
-                q.qSettings.conflictRule = \
                (QueueSettings::ConflictRule)val2.toUInt(&ok);
-            }
-            else if (name2 == "renamingrule")
-            {
-                q.qSettings.renamingRule = \
                (QueueSettings::RenamingRule)val2.toUInt(&ok);
-            }
-            else if (name2 == "rawloadingrule")
+            if (e.tagName() != "queue")
             {
-                q.qSettings.rawLoadingRule = \
                (QueueSettings::RawLoadingRule)val2.toUInt(&ok);
-            }
-            else if (name2 == "rawdecodingsettings")
-            {
-                DRawDecoding::decodingSettingsFromXml(e2, \
q.qSettings.rawDecodingSettings); +                continue;
             }
-            else if (name2 == "tool")
+
+            Workflow q;
+            bool     versionOk = true;
+
+            for (QDomNode n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling())
             {
-                BatchToolSet set;
+                QDomElement e2 = n2.toElement();
+                if (e2.isNull())
+                {
+                    continue;
+                }
+
+                QString name2 = e2.tagName();
+                QString val2  = e2.attribute(QString::fromLatin1("value"));
+                bool ok       = true;
 
-                for (QDomNode n3 = e2.firstChild(); !n3.isNull(); n3 = \
n3.nextSibling()) +                if (name2 == "queuetitle")
                 {
-                    QDomElement e3 = n3.toElement();
-                    if (e3.isNull())
+                    q.title = val2;
+                }
+                else if (name2 == "queuedesc")
+                {
+                    q.desc = val2;
+                }
+                else if (name2 == "renamingparser")
+                {
+                    q.qSettings.renamingParser = val2;
+                }
+                else if (name2 == "useoriginalalbum")
+                {
+                    q.qSettings.useOrgAlbum = (bool)val2.toUInt(&ok);
+                }
+                else if (name2 == "usemulticorecpu")
+                {
+                    q.qSettings.useMultiCoreCPU = (bool)val2.toUInt(&ok);
+                }
+                else if (name2 == "workingurl")
+                {
+                    q.qSettings.workingUrl = KUrl(val2);
+                }
+                else if (name2 == "conflictrule")
+                {
+                    q.qSettings.conflictRule = \
(QueueSettings::ConflictRule)val2.toUInt(&ok); +                }
+                else if (name2 == "renamingrule")
+                {
+                    q.qSettings.renamingRule = \
(QueueSettings::RenamingRule)val2.toUInt(&ok); +                }
+                else if (name2 == "rawloadingrule")
+                {
+                    q.qSettings.rawLoadingRule = \
(QueueSettings::RawLoadingRule)val2.toUInt(&ok); +                }
+                else if (name2 == "rawdecodingsettings")
+                {
+                    DRawDecoding::decodingSettingsFromXml(e2, \
q.qSettings.rawDecodingSettings); +                }
+                else if (name2 == "tool")
+                {
+                    BatchToolSet set;
+
+                    for (QDomNode n3 = e2.firstChild(); !n3.isNull(); n3 = \
n3.nextSibling())  {
-                        continue;
+                        QDomElement e3 = n3.toElement();
+                        if (e3.isNull())
+                        {
+                            continue;
+                        }
+
+                        QString name3  = e3.tagName();
+                        QString val3   = e3.attribute(QString::fromLatin1("value"));
+
+                        if (name3 == "toolname")
+                        {
+                            set.name = val3;
+                        }
+                        else if (name3 == "toolgroup")
+                        {
+                            set.group = (BatchTool::BatchToolGroup)val3.toInt(&ok);
+                        }
+                        else if (name3 == "index")
+                        {
+                            set.index = val3.toInt(&ok);
+                        }
+                        else if (name3 == "version")
+                        {
+                            set.version = val3.toInt(&ok);
+                        }
+                        else if (name3 == "parameter")
+                        {
+                            QString pname = \
e3.attribute(QString::fromLatin1("name")); +                            QString type  \
= e3.attribute(QString::fromLatin1("type")); +                            QVariant \
var(val3); +                            \
var.convert(QVariant::nameToType(type.toAscii().constData())); +    /*
+                            qCDebug(DIGIKAM_GENERAL_LOG) << "name=" << pname << " :: \
" << "type=" << type << " :: " << "value=" << val3 +                                  \
<< " :: " << "QVariant=" << var; +    */
+                            set.settings.insert(pname, var);
+                        }
                     }
 
-                    QString name3  = e3.tagName();
-                    QString val3   = e3.attribute(QString::fromLatin1("value"));
+                    BatchTool* const tool = \
BatchToolsManager::instance()->findTool(set.name, set.group);  
-                    if (name3 == "toolname")
-                    {
-                        set.name = val3;
-                    }
-                    else if (name3 == "toolgroup")
-                    {
-                        set.group = (BatchTool::BatchToolGroup)val3.toInt(&ok);
-                    }
-                    else if (name3 == "index")
+                    if (tool)
                     {
-                        set.index = val3.toInt(&ok);
+                        if (set.version == tool->toolVersion())
+                        {
+                            q.aTools.append(set);
+                        }
                     }
-                    else if (name3 == "version")
+                    else
                     {
-                        set.version = val3.toInt(&ok);
+                        versionOk   = false;
+                        d->modified = true;
                     }
-                    else if (name3 == "parameter")
-                    {
-                        QString pname = e3.attribute(QString::fromLatin1("name"));
-                        QString type  = e3.attribute(QString::fromLatin1("type"));
-                        QVariant var(val3);
-                        \
                var.convert(QVariant::nameToType(type.toAscii().constData()));
-/*
-                        qCDebug(DIGIKAM_GENERAL_LOG) << "name=" << pname << " :: " \
                << "type=" << type << " :: " << "value=" << val3
-                                 << " :: " << "QVariant=" << var;
-*/
-                        set.settings.insert(pname, var);
-                    }
-                }
-
-                BatchTool* const tool = \
                BatchToolsManager::instance()->findTool(set.name, set.group);
-
-                if (tool)
-                {
-                    if (set.version == tool->toolVersion())
-                    {
-                        q.aTools.append(set);
-                    }
-                }
-                else
-                {
-                    versionOk   = false;
-                    d->modified = 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 compatible
+                insertPrivate(q);
+            }
+            else
+            {
+                failed.append(QString("%1 [%2]").arg(q.title).arg(q.desc));
+            }
         }
+        return true;
+    } 
+    else
+    {
+        return false;
     }
-
-    return true;
 }
 
 }  // namespace Digikam


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic