From eb02223de534d315bfdcb0d521719c2d2e9a7235 Mon Sep 17 00:00:00 2001 From: tille Date: Sat, 29 Jun 2002 22:44:44 +0000 Subject: saving --- (limited to 'noncore/apps') diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index a8fd770..858726d 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp @@ -92,8 +92,15 @@ void ListViewItemConfFile::save() 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 ); + for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) + { + ((ListViewItemConfigEntry*)it)->save(t); + } + conf.close(); qDebug("no saveing yet..."); unchanged(); } diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp index 16be46e..77ce17d 100644 --- a/noncore/apps/confedit/listviewitemconfigentry.cpp +++ b/noncore/apps/confedit/listviewitemconfigentry.cpp @@ -10,6 +10,7 @@ #include "listviewitemconfigentry.h" #include "listviewitemconffile.h" +#include ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key) : ListViewItemConf(parent) @@ -104,4 +105,24 @@ void ListViewItemConfigEntry::changed() _changed=true; displayText(); _fileItem->changed(); +} + +void ListViewItemConfigEntry::save(QTextStream *t) +{ + QString s; + if (isGroup()) + { + s += "["+_group+"]"; + _type = Group; + }else{ + s += _key+" = "+_value; + _type = Key; + } + s += "\n"; + (*t) << s; + _changed = false; + for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) + { + ((ListViewItemConfigEntry*)it)->save(t); + } } \ No newline at end of file diff --git a/noncore/apps/confedit/listviewitemconfigentry.h b/noncore/apps/confedit/listviewitemconfigentry.h index d2b331f..1ff0491 100644 --- a/noncore/apps/confedit/listviewitemconfigentry.h +++ b/noncore/apps/confedit/listviewitemconfigentry.h @@ -16,6 +16,8 @@ #include "listviewitemconffile.h" #include "listviewitemconf.h" +class QTextStream; + class ListViewItemConfigEntry : public ListViewItemConf { public: ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key=""); @@ -32,6 +34,7 @@ public: void valueChanged(QString); virtual void displayText(); virtual void changed(); + void save(QTextStream*); private: QString _file; QString _group; diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 30dfdf7..47d9518 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp @@ -55,20 +55,20 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : editor = new EditWidget(this); mainLayout->addWidget( editor, 1, 0 ); - connect (settingList, SIGNAL( currentChanged(QListViewItem*) ), + connect(settingList, SIGNAL( pressed(QListViewItem*) ), this, SLOT(setCurrent(QListViewItem*))); - connect( popupTimer, SIGNAL(timeout()), - this, SLOT(showPopup()) ); - connect( this, 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&) ) ); + connect( popupTimer, SIGNAL(timeout()), + this, SLOT(showPopup()) ); + 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&) ) ); makeMenu(); } -- cgit v0.9.0.2