Diffstat (limited to 'noncore/apps/confedit/listviewitemconffile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 1f85095..ce6504c 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp | |||
@@ -87,28 +87,29 @@ void ListViewItemConfFile::remove() | |||
87 | QFile::remove(backupFileName()); | 87 | QFile::remove(backupFileName()); |
88 | delete this; | 88 | delete this; |
89 | } | 89 | } |
90 | 90 | ||
91 | void ListViewItemConfFile::revert() | 91 | void ListViewItemConfFile::revert() |
92 | { | 92 | { |
93 | if (_changed) | 93 | if (!_changed) |
94 | { | 94 | { |
95 | parseFile(); | 95 | // read the backup file |
96 | }else{ | ||
97 | QFile conf(confFileInfo->absFilePath()); | 96 | QFile conf(confFileInfo->absFilePath()); |
98 | QFile back(backupFileName()); | 97 | QFile back(backupFileName()); |
99 | 98 | ||
100 | if (!back.open(IO_ReadOnly)) return; | 99 | if (!back.open(IO_ReadOnly)) return; |
101 | if (!conf.open(IO_WriteOnly)) return; | 100 | if (!conf.open(IO_WriteOnly)) return; |
102 | 101 | ||
103 | #define SIZE 124 | 102 | #define SIZE 124 |
104 | char buf[SIZE]; | 103 | char buf[SIZE]; |
105 | while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c); | 104 | while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c); |
106 | conf.close(); | 105 | conf.close(); |
107 | back.close(); | 106 | back.close(); |
108 | } | 107 | } |
108 | parseFile(); | ||
109 | expand(); | ||
109 | } | 110 | } |
110 | 111 | ||
111 | void ListViewItemConfFile::save() | 112 | void ListViewItemConfFile::save() |
112 | { | 113 | { |
113 | if (!_changed) return; | 114 | if (!_changed) return; |
114 | QFile conf(confFileInfo->absFilePath()); | 115 | QFile conf(confFileInfo->absFilePath()); |
@@ -144,8 +145,16 @@ QString ListViewItemConfFile::backupFileName() | |||
144 | return confFileInfo->absFilePath()+"~"; | 145 | return confFileInfo->absFilePath()+"~"; |
145 | } | 146 | } |
146 | 147 | ||
147 | 148 | ||
148 | void ListViewItemConfFile::expand() | 149 | void ListViewItemConfFile::expand() |
149 | { | 150 | { |
151 | QListViewItem *subItem = firstChild(); | ||
152 | QListViewItem *toDel; | ||
153 | while(subItem) | ||
154 | { | ||
155 | toDel = subItem; | ||
156 | subItem = subItem->nextSibling(); | ||
157 | delete toDel; | ||
158 | } | ||
150 | parseFile(); | 159 | parseFile(); |
151 | } | 160 | } |