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

List:       kde-commits
Subject:    [plasmate/terietor/kconfigxt] editors/kconfigxt: Don't hang when the user modifies the value of an e
From:       Giorgos Tsiapaliokas <terietor () gmail ! com>
Date:       2012-08-09 9:16:35
Message-ID: 20120809091635.A1853A6094 () git ! kde ! org
[Download RAW message or body]

Git commit a15375852ccc116c23399c3ba53d6b9c66966921 by Giorgos Tsiapaliokas.
Committed on 09/08/2012 at 11:15.
Pushed by tsiapaliwkas into branch 'terietor/kconfigxt'.

Don't hang when the user modifies the value of an entry and
make the code more human readable

M  +10   -7    editors/kconfigxt/kconfigxteditor.cpp

http://commits.kde.org/plasmate/a15375852ccc116c23399c3ba53d6b9c66966921

diff --git a/editors/kconfigxt/kconfigxteditor.cpp b/editors/kconfigxt/kconfigxteditor.cpp
index 2431c20..dff4f7e 100644
--- a/editors/kconfigxt/kconfigxteditor.cpp
+++ b/editors/kconfigxt/kconfigxteditor.cpp
@@ -353,14 +353,12 @@ void KConfigXtEditor::modifyEntry(QTreeWidgetItem* item, int column)
             QString line = xmlFile.readLine();
             if (line.contains(oldEntry)) {
                 while (!line.contains("</entry>")) {
-                    //we took this from the xml spec
-                    QString startsWith = "<default>";
-                    QString endsWith = "</default>";
-                    if (line.startsWith(startsWith)
-                        && line.endsWith(endsWith)) {
-                            line.replace(oldEntry, startsWith
-                            + item->text(2) + endsWith);
+                    QString oldValue = stringToDefault(m_lastEntryItem["value"]);
+                    if (line.contains(oldValue)) {
+                        line.replace(oldValue, stringToDefault(item->text(2)));
                     }
+                    text.append(line);
+                    line = xmlFile.readLine();
                }
             }
             text.append(line);
@@ -475,6 +473,11 @@ QString KConfigXtEditor::stringToDescription(const QString& descriptionType, con
     return QString("<%1>%2</%1>").arg(descriptionType).arg(descriptionValue);
 }
 
+QString KConfigXtEditor::stringToDefault(const QString& value) const
+{
+    return QString("<default>%1</default>").arg(value);
+}
+
 void KConfigXtEditor::replaceItemsInXml(const QString& oldItem, const QString& newItem)
 {
     //take the xml file
[prev in list] [next in list] [prev in thread] [next in thread] 

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