summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp15
-rw-r--r--noncore/apps/confedit/mainwindow.cpp1
2 files changed, 13 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()
QFile::remove(backupFileName());
delete this;
}
void ListViewItemConfFile::revert()
{
- if (_changed)
+ if (!_changed)
{
- parseFile();
- }else{
+ // read the backup file
QFile conf(confFileInfo->absFilePath());
QFile back(backupFileName());
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();
}
+ parseFile();
+ expand();
}
void ListViewItemConfFile::save()
{
if (!_changed) return;
QFile conf(confFileInfo->absFilePath());
@@ -144,8 +145,16 @@ QString ListViewItemConfFile::backupFileName()
return confFileInfo->absFilePath()+"~";
}
void ListViewItemConfFile::expand()
{
+ QListViewItem *subItem = firstChild();
+ QListViewItem *toDel;
+ while(subItem)
+ {
+ toDel = subItem;
+ subItem = subItem->nextSibling();
+ delete toDel;
+ }
parseFile();
}
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index 6de8741..c91c846 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -70,12 +70,13 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
SLOT( keyChanged(const QString&) ) );
connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
SLOT( valueChanged(const QString&) ) );
setCurrent(0);
+ editor->layoutType(EditWidget::File);
}
void MainWindow::makeMenu()
{
popupTimer = new QTimer(this);
popupMenuFile = new QPopupMenu(this);