author | tille <tille> | 2002-07-08 14:12:26 (UTC) |
---|---|---|
committer | tille <tille> | 2002-07-08 14:12:26 (UTC) |
commit | c92049007eaf6615a059425073b03a827d11831e (patch) (side-by-side diff) | |
tree | 6d4d0b05a597d46eb6969cd728174fa6345a1099 /noncore | |
parent | 0d6ff4c6b10524943b43240489182138694f2759 (diff) | |
download | opie-c92049007eaf6615a059425073b03a827d11831e.zip opie-c92049007eaf6615a059425073b03a827d11831e.tar.gz opie-c92049007eaf6615a059425073b03a827d11831e.tar.bz2 |
parse files when needed
an other oipkg test ;)
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 1 |
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 @@ -81,40 +81,41 @@ void ListViewItemConfFile::parseFile() } void ListViewItemConfFile::remove() { QFile::remove(confFileInfo->absFilePath()); 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()); QFile back(backupFileName()); if (!conf.open(IO_ReadOnly)) return; if (!back.open(IO_WriteOnly)) return; char buf[SIZE]; @@ -138,14 +139,22 @@ bool ListViewItemConfFile::revertable() { return _changed || QFile(backupFileName()).exists(); } 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 @@ -64,24 +64,25 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : this, SLOT(setCurrent(QListViewItem*))); connect( settingList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( stopTimer( QListViewItem* ) ) ); connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), SLOT( groupChanged(const QString&) ) ); 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); popupMenuEntry = new QPopupMenu(this); popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); popupActionSave->addTo( popupMenuFile ); // popupActionSave->addTo( popupMenuEntry ); connect( popupActionSave, SIGNAL( activated() ), |