From cbb1662a1c3bca476294100ce5e0d0eeb3655639 Mon Sep 17 00:00:00 2001 From: tille Date: Sat, 29 Jun 2002 20:53:42 +0000 Subject: makes backups, but does not save the file yet --- (limited to 'noncore') diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp index b76e425..f466f06 100644 --- a/noncore/apps/confedit/listviewconfdir.cpp +++ b/noncore/apps/confedit/listviewconfdir.cpp @@ -36,7 +36,7 @@ void ListViewConfDir::readConfFiles() confDir.setFilter( QDir::Files | QDir::NoSymLinks ); confDir.setSorting( QDir::Name ); - + confDir.setNameFilter("*.conf"); const QFileInfoList *list = confDir.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 5457384..a8fd770 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp @@ -21,7 +21,6 @@ ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) { confFileInfo = file; parseFile(); - _changed = false; displayText(); } @@ -32,7 +31,7 @@ ListViewItemConfFile::~ListViewItemConfFile() void ListViewItemConfFile::displayText() { - setText(0,(_changed?"*":"*")+confFileInfo->fileName()); + setText(0,(_changed?"*":"")+confFileInfo->fileName()); } QString ListViewItemConfFile::fileName() @@ -42,10 +41,7 @@ QString ListViewItemConfFile::fileName() void ListViewItemConfFile::parseFile() { - qDebug( confFileInfo->absFilePath() ); QFile confFile(confFileInfo->absFilePath()); - qDebug( confFileInfo->absFilePath() ); - // QString fileName = confFileInfo->fileName(); 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 ); @@ -64,7 +60,7 @@ void ListViewItemConfFile::parseFile() }else if ( s[0] == '[' && s[s.length()-1] == ']' ) { - qDebug("got group"+s); + // qDebug("got group"+s); group = s.mid(1,s.length()-2); groupItem = new ListViewItemConfigEntry(this, group ); insertItem( groupItem ); @@ -82,7 +78,22 @@ void ListViewItemConfFile::parseFile() void ListViewItemConfFile::save() { - qDebug("ListViewItemConfFile::save()"); + if (!_changed) return; + QString backup = confFileInfo->absFilePath()+"~"; + qDebug("make backup to "+backup); + QFile conf(confFileInfo->absFilePath()); + QFile back(backup); + + if (!conf.open(IO_ReadOnly)) return; + if (!back.open(IO_WriteOnly)) return; + + #define SIZE 124 + char buf[SIZE]; + while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); + conf.close(); + back.close(); + + qDebug("no saveing yet..."); unchanged(); } diff --git a/noncore/apps/confedit/listviewitemconffile.h b/noncore/apps/confedit/listviewitemconffile.h index 9208918..d89b19c 100644 --- a/noncore/apps/confedit/listviewitemconffile.h +++ b/noncore/apps/confedit/listviewitemconffile.h @@ -25,7 +25,6 @@ public: void parseFile(); QString fileName(); virtual void displayText(); - /** No descriptions */ void save(); protected: private: diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 5eeeb90..30dfdf7 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp @@ -86,13 +86,12 @@ MainWindow::~MainWindow() void MainWindow::setCurrent(QListViewItem *item) { - qDebug("MainWindow::setCurrent("); if (!item) return; - qDebug("cast ListViewItemConf"); ListViewItemConf *i = (ListViewItemConf*) item; if (!i) return; if (i->getType() == ListViewItemConf::File) { + qDebug("start timer"); popupTimer->start( 750, true ); editor->hide(); updateGeometry(); @@ -100,7 +99,6 @@ void MainWindow::setCurrent(QListViewItem *item) _fileItem = (ListViewItemConfFile*)item; return; }else editor->show(); - qDebug("cast ListViewItemConfigEntry"); _fileItem = 0; _currentItem = (ListViewItemConfigEntry*)item; if (!_currentItem) return; @@ -165,31 +163,6 @@ void MainWindow::showPopup() connect( popupAction, SIGNAL( activated() ), this , SLOT( saveConfFile() ) ); -// if ( !activePackage->installed() ) -// { -// popupMenu->insertItem( tr("Install to"), destsMenu ); -// QStringList dests = settings->getDestinationNames(); -// QString ad = settings->getDestinationName(); -// for (uint i = 0; i < dests.count(); i++ ) -// { -// popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); -// popupAction->addTo( destsMenu ); -// if ( dests[i] == ad && activePackage->toInstall() ) -// { -// popupAction->setToggleAction( true ); -// popupAction->setOn(true); -// }; -// } -// connect( destsMenu, SIGNAL( activated( int ) ), -// this, SLOT( changePackageDest( int ) ) ); -// }else{ -// popupAction = new QAction( tr("Remove"),QString::null, 0, this, 0 ); -// popupAction->addTo( popupMenu ); -// connect( popupAction, SIGNAL( activated() ), -// this , SLOT( toggleProcess() ) ); -// popupAction = new QAction( tr("Reinstall"),QString::null, 0, this, 0 ); -// popupAction->addTo( popupMenu ); -// popupAction->setEnabled( false ); -// } + popupMenu->popup( QCursor::pos() ); } -- cgit v0.9.0.2