summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/listviewconfdir.cpp2
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp25
-rw-r--r--noncore/apps/confedit/listviewitemconffile.h1
-rw-r--r--noncore/apps/confedit/mainwindow.cpp31
4 files changed, 21 insertions, 38 deletions
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()
36 36
37 confDir.setFilter( QDir::Files | QDir::NoSymLinks ); 37 confDir.setFilter( QDir::Files | QDir::NoSymLinks );
38 confDir.setSorting( QDir::Name ); 38 confDir.setSorting( QDir::Name );
39 39 confDir.setNameFilter("*.conf");
40 const QFileInfoList *list = confDir.entryInfoList(); 40 const QFileInfoList *list = confDir.entryInfoList();
41 QFileInfoListIterator it( *list ); 41 QFileInfoListIterator it( *list );
42 QFileInfo *fi; 42 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)
21{ 21{
22 confFileInfo = file; 22 confFileInfo = file;
23 parseFile(); 23 parseFile();
24 _changed = false;
25 displayText(); 24 displayText();
26} 25}
27 26
@@ -32,7 +31,7 @@ ListViewItemConfFile::~ListViewItemConfFile()
32 31
33void ListViewItemConfFile::displayText() 32void ListViewItemConfFile::displayText()
34{ 33{
35 setText(0,(_changed?"*":"*")+confFileInfo->fileName()); 34 setText(0,(_changed?"*":"")+confFileInfo->fileName());
36} 35}
37 36
38QString ListViewItemConfFile::fileName() 37QString ListViewItemConfFile::fileName()
@@ -42,10 +41,7 @@ QString ListViewItemConfFile::fileName()
42 41
43void ListViewItemConfFile::parseFile() 42void ListViewItemConfFile::parseFile()
44{ 43{
45 qDebug( confFileInfo->absFilePath() );
46 QFile confFile(confFileInfo->absFilePath()); 44 QFile confFile(confFileInfo->absFilePath());
47 qDebug( confFileInfo->absFilePath() );
48 // QString fileName = confFileInfo->fileName();
49 if(! confFile.open(IO_ReadOnly)) 45 if(! confFile.open(IO_ReadOnly))
50 QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0); 46 QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0);
51 QTextStream t( &confFile ); 47 QTextStream t( &confFile );
@@ -64,7 +60,7 @@ void ListViewItemConfFile::parseFile()
64 }else 60 }else
65 if ( s[0] == '[' && s[s.length()-1] == ']' ) 61 if ( s[0] == '[' && s[s.length()-1] == ']' )
66 { 62 {
67 qDebug("got group"+s); 63 // qDebug("got group"+s);
68 group = s.mid(1,s.length()-2); 64 group = s.mid(1,s.length()-2);
69 groupItem = new ListViewItemConfigEntry(this, group ); 65 groupItem = new ListViewItemConfigEntry(this, group );
70 insertItem( groupItem ); 66 insertItem( groupItem );
@@ -82,7 +78,22 @@ void ListViewItemConfFile::parseFile()
82 78
83void ListViewItemConfFile::save() 79void ListViewItemConfFile::save()
84{ 80{
85 qDebug("ListViewItemConfFile::save()"); 81 if (!_changed) return;
82 QString backup = confFileInfo->absFilePath()+"~";
83 qDebug("make backup to "+backup);
84 QFile conf(confFileInfo->absFilePath());
85 QFile back(backup);
86
87 if (!conf.open(IO_ReadOnly)) return;
88 if (!back.open(IO_WriteOnly)) return;
89
90 #define SIZE 124
91 char buf[SIZE];
92 while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c);
93 conf.close();
94 back.close();
95
96
86 qDebug("no saveing yet..."); 97 qDebug("no saveing yet...");
87 unchanged(); 98 unchanged();
88} 99}
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:
25 void parseFile(); 25 void parseFile();
26 QString fileName(); 26 QString fileName();
27 virtual void displayText(); 27 virtual void displayText();
28 /** No descriptions */
29 void save(); 28 void save();
30protected: 29protected:
31private: 30private:
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()
86 86
87void MainWindow::setCurrent(QListViewItem *item) 87void MainWindow::setCurrent(QListViewItem *item)
88{ 88{
89 qDebug("MainWindow::setCurrent(");
90 if (!item) return; 89 if (!item) return;
91 qDebug("cast ListViewItemConf");
92 ListViewItemConf *i = (ListViewItemConf*) item; 90 ListViewItemConf *i = (ListViewItemConf*) item;
93 if (!i) return; 91 if (!i) return;
94 if (i->getType() == ListViewItemConf::File) 92 if (i->getType() == ListViewItemConf::File)
95 { 93 {
94 qDebug("start timer");
96 popupTimer->start( 750, true ); 95 popupTimer->start( 750, true );
97 editor->hide(); 96 editor->hide();
98 updateGeometry(); 97 updateGeometry();
@@ -100,7 +99,6 @@ void MainWindow::setCurrent(QListViewItem *item)
100 _fileItem = (ListViewItemConfFile*)item; 99 _fileItem = (ListViewItemConfFile*)item;
101 return; 100 return;
102 }else editor->show(); 101 }else editor->show();
103 qDebug("cast ListViewItemConfigEntry");
104 _fileItem = 0; 102 _fileItem = 0;
105 _currentItem = (ListViewItemConfigEntry*)item; 103 _currentItem = (ListViewItemConfigEntry*)item;
106 if (!_currentItem) return; 104 if (!_currentItem) return;
@@ -165,31 +163,6 @@ void MainWindow::showPopup()
165 connect( popupAction, SIGNAL( activated() ), 163 connect( popupAction, SIGNAL( activated() ),
166 this , SLOT( saveConfFile() ) ); 164 this , SLOT( saveConfFile() ) );
167 165
168// if ( !activePackage->installed() ) 166
169// {
170 // popupMenu->insertItem( tr("Install to"), destsMenu );
171 // QStringList dests = settings->getDestinationNames();
172 // QString ad = settings->getDestinationName();
173 // for (uint i = 0; i < dests.count(); i++ )
174 // {
175 // popupAction = new QAction( dests[i], QString::null, 0, this, 0 );
176 // popupAction->addTo( destsMenu );
177 // if ( dests[i] == ad && activePackage->toInstall() )
178 // {
179// popupAction->setToggleAction( true );
180 // popupAction->setOn(true);
181 // };
182 // }
183 // connect( destsMenu, SIGNAL( activated( int ) ),
184 // this, SLOT( changePackageDest( int ) ) );
185// }else{
186 // popupAction = new QAction( tr("Remove"),QString::null, 0, this, 0 );
187 // popupAction->addTo( popupMenu );
188 // connect( popupAction, SIGNAL( activated() ),
189 // this , SLOT( toggleProcess() ) );
190 // popupAction = new QAction( tr("Reinstall"),QString::null, 0, this, 0 );
191 // popupAction->addTo( popupMenu );
192 // popupAction->setEnabled( false );
193// }
194 popupMenu->popup( QCursor::pos() ); 167 popupMenu->popup( QCursor::pos() );
195} 168}