Diffstat (limited to 'noncore/apps/confedit/listviewitemconffile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index b075063..228421b 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp @@ -79,4 +79,11 @@ void ListViewItemConfFile::parseFile() +void ListViewItemConfFile::remove() +{ + QFile::remove(confFileInfo->absFilePath()); + QFile::remove(backupFileName()); + delete this; +} + void ListViewItemConfFile::revert() { @@ -85,7 +92,6 @@ void ListViewItemConfFile::revert() parseFile(); }else{ - QString backup = confFileInfo->absFilePath()+"~"; QFile conf(confFileInfo->absFilePath()); - QFile back(backup); + QFile back(backupFileName()); if (!back.open(IO_ReadOnly)) return; @@ -103,13 +109,10 @@ void ListViewItemConfFile::save() { if (!_changed) return; - QString backup = confFileInfo->absFilePath()+"~"; - qDebug("make backup to "+backup); QFile conf(confFileInfo->absFilePath()); - QFile back(backup); + QFile back(backupFileName()); if (!conf.open(IO_ReadOnly)) return; if (!back.open(IO_WriteOnly)) return; - #define SIZE 124 char buf[SIZE]; while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); @@ -131,4 +134,9 @@ void ListViewItemConfFile::save() bool ListViewItemConfFile::revertable() { - return _changed || QFile(confFileInfo->absFilePath()+"~").exists(); -}
\ No newline at end of file + return _changed || QFile(backupFileName()).exists(); +} + +QString ListViewItemConfFile::backupFileName() +{ + return confFileInfo->absFilePath()+"~"; +} |