author | tille <tille> | 2002-06-29 23:23:09 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-29 23:23:09 (UTC) |
commit | 0f179c0cc471b659b30dec4762c9c36678063f31 (patch) (side-by-side diff) | |
tree | 5350dc3b1c05991953011d01ad19cb12414abc1a /noncore/apps/confedit/listviewitemconffile.cpp | |
parent | eb02223de534d315bfdcb0d521719c2d2e9a7235 (diff) | |
download | opie-0f179c0cc471b659b30dec4762c9c36678063f31.zip opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.gz opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.bz2 |
revert
Diffstat (limited to 'noncore/apps/confedit/listviewitemconffile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 858726d..b075063 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp @@ -74,7 +74,30 @@ void ListViewItemConfFile::parseFile() } confFile.close(); + unchanged(); setExpandable( _valid ); } + +void ListViewItemConfFile::revert() +{ + if (_changed) + { + parseFile(); + }else{ + QString backup = confFileInfo->absFilePath()+"~"; + QFile conf(confFileInfo->absFilePath()); + QFile back(backup); + + if (!back.open(IO_ReadOnly)) return; + if (!conf.open(IO_WriteOnly)) return; + + #define SIZE 124 + char buf[SIZE]; + while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c); + conf.close(); + back.close(); + } +} + void ListViewItemConfFile::save() { @@ -102,5 +125,10 @@ void ListViewItemConfFile::save() } conf.close(); - qDebug("no saveing yet..."); unchanged(); } + + +bool ListViewItemConfFile::revertable() +{ + return _changed || QFile(confFileInfo->absFilePath()+"~").exists(); +}
\ No newline at end of file |