author | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
commit | 16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (side-by-side diff) | |
tree | 0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/apps/confedit/listviewitemconffile.cpp | |
parent | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff) | |
download | opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2 |
convert to Opie Debugging Framework
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, 15 insertions, 9 deletions
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 1ff2c44..2958cf5 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp @@ -1,127 +1,133 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "listviewitemconffile.h" +#include "listviewitemconfigentry.h" + +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qmessagebox.h> #include <qtextstream.h> -#include "listviewitemconfigentry.h" #define tr QObject::tr ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) : ListViewItemConf(parent), _valid(false) { confFileInfo = file; -// parseFile(); + // parseFile(); displayText(); } ListViewItemConfFile::~ListViewItemConfFile() { } void ListViewItemConfFile::displayText() { setText(0,(_changed?"*":"")+confFileInfo->fileName()); } QString ListViewItemConfFile::fileName() { return confFileInfo->fileName(); } void ListViewItemConfFile::parseFile() { - //qDebug("ListViewItemConfFile::parseFile BEGIN"); - QFile confFile(confFileInfo->absFilePath()); + //odebug << "ListViewItemConfFile::parseFile BEGIN" << oendl; + QFile confFile(confFileInfo->absFilePath()); if(! confFile.open(IO_ReadOnly)) QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0); QTextStream t( &confFile ); QString s; QString group; ListViewItemConfigEntry *groupItem; ListViewItemConfigEntry *item; while ( !t.atEnd() ) { s = t.readLine().stripWhiteSpace(); - //qDebug( "line: >%s<\n", s.latin1() ); + //odebug << "line: >" << s.latin1() << "<\n" << oendl; if (s.contains("<?xml")) { _valid = false; break; }else if ( s[0] == '[' && s[s.length()-1] == ']' ) { - // qDebug("got group"+s); + // odebug << "got group"+s << oendl; group = s.mid(1,s.length()-2); if (!groupItem) groupItem = new ListViewItemConfigEntry(this, tr("no group") ); groupItem = new ListViewItemConfigEntry(this, group ); insertItem( groupItem ); } else if ( int pos = s.find('=') ) { -// qDebug("got key"+s); - if (!groupItem) qDebug("PANIK NO GROUP! >%s<",group.latin1()); +// odebug << "got key"+s << oendl; + if (!groupItem) odebug << "PANIK NO GROUP! >" << group.latin1() << "<" << oendl; item = new ListViewItemConfigEntry(this, group, s ); groupItem->insertItem( item ); } } confFile.close(); setExpandable( _valid ); -// qDebug("ListViewItemConfFile::parseFile END"); +// odebug << "ListViewItemConfFile::parseFile END" << oendl; } void ListViewItemConfFile::remove() { QFile::remove(confFileInfo->absFilePath()); QFile::remove(backupFileName()); delete this; } void ListViewItemConfFile::revert() { if (!_changed) { // 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]; while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); conf.close(); back.close(); if (!conf.open(IO_WriteOnly)) return; QTextStream *t = new QTextStream( &conf ); |