-rw-r--r-- | noncore/apps/confedit/confedit.pro | 24 | ||||
-rw-r--r-- | noncore/apps/confedit/config.in | 2 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewconfdir.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 24 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 19 |
5 files changed, 41 insertions, 40 deletions
diff --git a/noncore/apps/confedit/confedit.pro b/noncore/apps/confedit/confedit.pro index 5a71680..785c588 100644 --- a/noncore/apps/confedit/confedit.pro +++ b/noncore/apps/confedit/confedit.pro @@ -1,21 +1,9 @@ -CONFIG = qt warn_on quick-app -HEADERS = mainwindow.h listviewconfdir.h listviewitemconffile.h listviewitemconfigentry.h editwidget.h listviewitemconf.h -SOURCES = main.cpp mainwindow.cpp listviewconfdir.cpp listviewitemconffile.cpp listviewitemconfigentry.cpp editwidget.cpp listviewitemconf.cpp -INCLUDEPATH += $(OPIEDIR)/include +CONFIG = qt warn_on quick-app +HEADERS = mainwindow.h listviewconfdir.h listviewitemconffile.h listviewitemconfigentry.h editwidget.h listviewitemconf.h +SOURCES = main.cpp mainwindow.cpp listviewconfdir.cpp listviewitemconffile.cpp listviewitemconfigentry.cpp editwidget.cpp listviewitemconf.cpp +INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -INTERFACES = -LIBS += -lopiecore2 +LIBS += -lqpe -lopiecore2 TARGET = confedit -!contains( platform, x11 ) { - - include ( $(OPIEDIR)/include.pro ) - LIBS += -lqpe -} - -contains( platform, x11 ) { - LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib -} - - - +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/confedit/config.in b/noncore/apps/confedit/config.in index e377307..d7682dc 100644 --- a/noncore/apps/confedit/config.in +++ b/noncore/apps/confedit/config.in @@ -1,4 +1,4 @@ config CONFEDIT - boolean "opie-confeditor (generic editor for all Opie settings)" + boolean "opie-confedit (generic editor for all Opie settings)" default "y" depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp index 0c2feeb..33bffe1 100644 --- a/noncore/apps/confedit/listviewconfdir.cpp +++ b/noncore/apps/confedit/listviewconfdir.cpp @@ -1,61 +1,65 @@ /*************************************************************************** * * * 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. Vogtp <tille@handhelds.org> #include "listviewconfdir.h" +#include "listviewitemconffile.h" -#include <qmessagebox.h> +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; -#include "listviewitemconffile.h" +/* QT */ +#include <qmessagebox.h> ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name ) : QListView(parent,name), confDir(settingsPath) { setRootIsDecorated( true ); addColumn(tr("Files")); if (!confDir.isReadable()) QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0); readConfFiles(); connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); } ListViewConfDir::~ListViewConfDir() { } void ListViewConfDir::readConfFiles() { - confDir.setFilter( QDir::Files | QDir::NoSymLinks ); + confDir.setFilter( QDir::Files | QDir::NoSymLinks ); confDir.setSorting( QDir::Name ); confDir.setNameFilter("*.conf"); const QFileInfoList *list = confDir.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; ListViewItemConfFile *fileEntry; while ( (fi=it.current()) ) { - qDebug( "opening: >%s<", fi->fileName().data() ); + odebug << "opening: >" << fi->fileName().data() << "<" << oendl; fileEntry = new ListViewItemConfFile( fi, this ); QListViewItem *dummy = new QListViewItem(fileEntry, "dummy"); ++it; } } void ListViewConfDir::expand(QListViewItem *item) { ((ListViewItemConf*)item)->expand(); } 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,159 +1,165 @@ /*************************************************************************** * * * 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 ); for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) { ((ListViewItemConfigEntry*)it)->save(t); } conf.close(); unchanged(); } 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 6ef1043..4b04c97 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp @@ -1,189 +1,192 @@ /*************************************************************************** * * * 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 "mainwindow.h" +#include "listviewconfdir.h" +#include "listviewitemconfigentry.h" +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> -#include "listviewconfdir.h" -#include "listviewitemconfigentry.h" - - MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) { setCaption( tr("Conf File Editor") ); // setBaseSize( qApp->globalStrut() ); setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); mainLayout = new QVBoxLayout( this ); mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 ); - qDebug("creating settingList"); + odebug << "creating settingList" << oendl; settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); mainLayout->addWidget( settingList, 0); - qDebug("creating editor"); + odebug << "creating editor" << oendl; editor = new EditWidget(this); editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); mainLayout->addWidget( editor, 1 ); editor->layoutType( ListViewItemConf::File ); makeMenu(); connect(settingList, SIGNAL( pressed(QListViewItem*) ), 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() ), this , SLOT( saveConfFile() ) ); popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); popupActionRevert->addTo( popupMenuFile ); popupActionRevert->addTo( popupMenuEntry ); connect( popupActionRevert, SIGNAL( activated() ), this , SLOT( revertConfFile() ) ); popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); popupActionDelete->addTo( popupMenuFile ); popupActionDelete->addTo( popupMenuEntry ); connect( popupActionDelete, SIGNAL( activated() ), this , SLOT( removeConfFile() ) ); connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) ); } MainWindow::~MainWindow() { } void MainWindow::setCurrent(QListViewItem *item) { -// qDebug("MainWindow::setCurrent"); +// odebug << "MainWindow::setCurrent" << oendl; if (!item) return; _item = (ListViewItemConf*) item; if (!_item) return; popupTimer->start( 750, true ); if (_item->getType() == ListViewItemConf::File) { editor->layoutType(EditWidget::File); _currentItem=0; _fileItem = (ListViewItemConfFile*)item; return; } _fileItem = 0; _currentItem = (ListViewItemConfigEntry*)item; if (!_currentItem) return; QString file = _currentItem->getFile(); QString group = _currentItem->getGroup(); QString key = _currentItem->getKey(); QString val = _currentItem->getValue(); editor->TextFileName->setText(file); editor->LineEditGroup->setText(group); if (!key.isEmpty()) { editor->layoutType(EditWidget::Entry); editor->LineEditKey->setText(key); editor->LineEditValue->setText(val); }else{ editor->layoutType(EditWidget::Group); } } void MainWindow::groupChanged(const QString &g) { if (!_currentItem) return; _currentItem->setGroup(g); } void MainWindow::keyChanged(const QString &k) { if (!_currentItem) return; _currentItem->keyChanged(k); } void MainWindow::valueChanged(const QString &v) { if (!_currentItem) return; _currentItem->valueChanged(v); } void MainWindow::stopTimer( QListViewItem* ) { popupTimer->stop(); } void MainWindow::saveConfFile() { if (!_fileItem) return; _fileItem->save(); } void MainWindow::revertConfFile() { if (!_item) return; _item->revert(); } void MainWindow::removeConfFile() { if (!_item) return; _item->remove(); } void MainWindow::showPopup() { -qDebug("showPopup"); +odebug << "showPopup" << oendl; if (!_item) return; popupActionRevert->setEnabled(_item->revertable()); popupActionSave->setEnabled(_item->isChanged()); if (_fileItem) { popupActionSave->setEnabled(_fileItem->isChanged()); popupMenuFile->popup( QCursor::pos() ); }else if(_currentItem) { popupMenuEntry->popup( QCursor::pos() ); } } |