author | tille <tille> | 2002-06-30 01:05:42 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-30 01:05:42 (UTC) |
commit | 064b3d7b91a526a64c22facba228e3c2fec8fdc8 (patch) (side-by-side diff) | |
tree | 98221da79a27bc13b8214b92c8c936c529312e24 /noncore/apps/confedit/listviewitemconffile.cpp | |
parent | 1f9e13bb2d287a2495e2cbb0f8be0f53c883eae2 (diff) | |
download | opie-064b3d7b91a526a64c22facba228e3c2fec8fdc8.zip opie-064b3d7b91a526a64c22facba228e3c2fec8fdc8.tar.gz opie-064b3d7b91a526a64c22facba228e3c2fec8fdc8.tar.bz2 |
late night
Diffstat (limited to 'noncore/apps/confedit/listviewitemconffile.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 22 |
1 files changed, 15 insertions, 7 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 @@ -78,15 +78,21 @@ void ListViewItemConfFile::parseFile() } +void ListViewItemConfFile::remove() +{ + QFile::remove(confFileInfo->absFilePath()); + QFile::remove(backupFileName()); + delete this; +} + void ListViewItemConfFile::revert() { if (_changed) { parseFile(); }else{ - QString backup = confFileInfo->absFilePath()+"~"; QFile conf(confFileInfo->absFilePath()); - QFile back(backup); + QFile back(backupFileName()); if (!back.open(IO_ReadOnly)) return; if (!conf.open(IO_WriteOnly)) return; @@ -102,15 +108,12 @@ void ListViewItemConfFile::revert() 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); conf.close(); @@ -130,5 +133,10 @@ void ListViewItemConfFile::save() bool ListViewItemConfFile::revertable() { - return _changed || QFile(confFileInfo->absFilePath()+"~").exists(); + return _changed || QFile(backupFileName()).exists(); +} + +QString ListViewItemConfFile::backupFileName() +{ + return confFileInfo->absFilePath()+"~"; }
\ No newline at end of file |