summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/confedit.pro26
-rw-r--r--noncore/apps/confedit/editwidget.cpp73
-rw-r--r--noncore/apps/confedit/editwidget.h37
-rw-r--r--noncore/apps/confedit/listviewconfdir.cpp53
-rw-r--r--noncore/apps/confedit/listviewconfdir.h33
-rw-r--r--noncore/apps/confedit/listviewitemconf.cpp46
-rw-r--r--noncore/apps/confedit/listviewitemconf.h35
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp88
-rw-r--r--noncore/apps/confedit/listviewitemconffile.h36
-rw-r--r--noncore/apps/confedit/listviewitemconfigentry.cpp107
-rw-r--r--noncore/apps/confedit/listviewitemconfigentry.h43
-rw-r--r--noncore/apps/confedit/main.cpp15
-rw-r--r--noncore/apps/confedit/mainwindow.cpp195
-rw-r--r--noncore/apps/confedit/mainwindow.h56
14 files changed, 843 insertions, 0 deletions
diff --git a/noncore/apps/confedit/confedit.pro b/noncore/apps/confedit/confedit.pro
new file mode 100644
index 0000000..2dc2edf
--- a/dev/null
+++ b/noncore/apps/confedit/confedit.pro
@@ -0,0 +1,26 @@
+DESTDIR = $(OPIEDIR)/bin
+TEMPLATE = app
+#CONFIG = qt warn_on release
+CONFIG = qt warn_on debug
+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)/ioclude
+LIBS += -lqpe
+INTERFACES =
+TARGET = confedit
+
+TRANSLATIONS = ../../../i18n/de/confedit.ts \
+ ../../../i18n/en/confedit.ts \
+ ../../../i18n/es/confedit.ts \
+ ../../../i18n/fr/confedit.ts \
+ ../../../i18n/hu/confedit.ts \
+ ../../../i18n/ja/confedit.ts \
+ ../../../i18n/ko/confedit.ts \
+ ../../../i18n/no/confedit.ts \
+ ../../../i18n/pl/confedit.ts \
+ ../../../i18n/pt/confedit.ts \
+ ../../../i18n/pt_BR/confedit.ts \
+ ../../../i18n/sl/confedit.ts \
+ ../../../i18n/zh_CN/confedit.ts \
+ ../../../i18n/zh_TW/confedit.ts
diff --git a/noncore/apps/confedit/editwidget.cpp b/noncore/apps/confedit/editwidget.cpp
new file mode 100644
index 0000000..64f968a
--- a/dev/null
+++ b/noncore/apps/confedit/editwidget.cpp
@@ -0,0 +1,73 @@
+#include "editwidget.h"
+
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qtimer.h>
+#include <qpopupmenu.h>
+#include <qaction.h>
+#include "listviewitemconfigentry.h"
+
+EditWidget::EditWidget( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+
+ EditWidgetLayout = new QGridLayout( this );
+ EditWidgetLayout->setSpacing( 3 );
+ EditWidgetLayout->setMargin( 3 );
+
+ QLabel *TextLabelFileName = new QLabel( this, "TextLabelFileName" );
+ TextLabelFileName->setText( tr( "File Name:" ) );
+ EditWidgetLayout->addWidget( TextLabelFileName, 0, 0 );
+ TextFileName = new QLabel( this, "TextFileName" );
+ EditWidgetLayout->addWidget( TextFileName, 0, 1 );
+
+ QLabel *TextLabelGroup = new QLabel( this, "TextLabelGroup" );
+ TextLabelGroup->setText( tr( "Group:" ) );
+ EditWidgetLayout->addWidget( TextLabelGroup, 1, 0 );
+ LineEditGroup = new QLineEdit( this, "LineEditGroup" );
+ EditWidgetLayout->addWidget( LineEditGroup, 1, 1 );
+
+ TextLabelKey = new QLabel( this, "TextLabelKey" );
+ TextLabelKey->setText( tr( "Key:" ) );
+ EditWidgetLayout->addWidget( TextLabelKey, 2, 0 );
+ LineEditKey = new QLineEdit( this, "LineEditKey" );
+ EditWidgetLayout->addWidget( LineEditKey, 2, 1 );
+
+ TextLabelValue = new QLabel( this, "TextLabelValue" );
+ TextLabelValue->setText( tr( "Value:" ) );
+ EditWidgetLayout->addWidget( TextLabelValue, 3, 0 );
+ LineEditValue = new QLineEdit( this, "LineEditValue" );
+ EditWidgetLayout->addWidget( LineEditValue, 3, 1 );
+
+}
+
+
+EditWidget::~EditWidget()
+{
+}
+
+
+void EditWidget::isKey(bool h)
+{
+ if (h)
+ {
+ LineEditGroup->setEnabled(false);
+ TextLabelKey->show();
+ LineEditKey->show();
+ TextLabelValue->show();
+ LineEditValue->show();
+ }else{
+ LineEditGroup->setEnabled(true);
+ TextLabelKey->hide();
+ LineEditKey->hide();
+ TextLabelValue->hide();
+ LineEditValue->hide();
+ }
+ update();
+}
+
diff --git a/noncore/apps/confedit/editwidget.h b/noncore/apps/confedit/editwidget.h
new file mode 100644
index 0000000..673166f
--- a/dev/null
+++ b/noncore/apps/confedit/editwidget.h
@@ -0,0 +1,37 @@
+#ifndef EDITWIDGET_H
+#define EDITWIDGET_H
+
+#include <qvariant.h>
+#include <qwidget.h>
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QLabel;
+class QLineEdit;
+class QListViewItem;
+class ListViewItemConfigEntry;
+class QTimer;
+class QPopupMenu;
+
+class EditWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ EditWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~EditWidget();
+
+ QLabel *TextLabelKey;
+ QLabel *TextLabelValue;
+ QLabel *TextFileName;
+ QLineEdit *LineEditGroup;
+ QLineEdit *LineEditKey;
+ QLineEdit *LineEditValue;
+ void isKey(bool h);
+protected:
+ QGridLayout* EditWidgetLayout;
+
+private:
+};
+
+#endif // EDITWIDGET_H
diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp
new file mode 100644
index 0000000..b76e425
--- a/dev/null
+++ b/noncore/apps/confedit/listviewconfdir.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * *
+ * 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 <qmessagebox.h>
+
+#include "listviewitemconffile.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();
+}
+
+
+ListViewConfDir::~ListViewConfDir()
+{
+}
+
+void ListViewConfDir::readConfFiles()
+{
+
+ confDir.setFilter( QDir::Files | QDir::NoSymLinks );
+ confDir.setSorting( QDir::Name );
+
+ const QFileInfoList *list = confDir.entryInfoList();
+ QFileInfoListIterator it( *list );
+ QFileInfo *fi;
+
+ ListViewItemConfFile *fileEntry;
+
+ while ( (fi=it.current()) )
+ {
+ qDebug( "opening: >%s<", fi->fileName().data() );
+ fileEntry = new ListViewItemConfFile( fi, this );
+
+ ++it;
+ }
+} \ No newline at end of file
diff --git a/noncore/apps/confedit/listviewconfdir.h b/noncore/apps/confedit/listviewconfdir.h
new file mode 100644
index 0000000..3131972
--- a/dev/null
+++ b/noncore/apps/confedit/listviewconfdir.h
@@ -0,0 +1,33 @@
+/***************************************************************************
+ * *
+ * 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>
+
+#ifndef LISTVIEWCONFDIR_H
+#define LISTVIEWCONFDIR_H
+
+#include <qwidget.h>
+#include <qlistview.h>
+#include <qdir.h>
+
+class QDir;
+
+class ListViewConfDir : public QListView {
+ Q_OBJECT
+public:
+ ListViewConfDir(QString settingsPath, QWidget *parent=0, const char *name=0);
+ ~ListViewConfDir();
+
+private:
+ QDir confDir;
+
+ void readConfFiles();
+};
+
+#endif
diff --git a/noncore/apps/confedit/listviewitemconf.cpp b/noncore/apps/confedit/listviewitemconf.cpp
new file mode 100644
index 0000000..55f8422
--- a/dev/null
+++ b/noncore/apps/confedit/listviewitemconf.cpp
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "listviewitemconf.h"
+
+ListViewItemConf::ListViewItemConf(ListViewItemConf *parent)
+ : QListViewItem(parent), _changed(false)
+{
+}
+
+ListViewItemConf::ListViewItemConf(QListView *parent)
+ : QListViewItem(parent), _changed(false)
+{
+ _type = File;
+}
+
+ListViewItemConf::~ListViewItemConf()
+{
+}
+
+int ListViewItemConf::getType()
+{
+ return _type;
+}
+
+void ListViewItemConf::changed()
+{
+ _changed=true;
+ displayText();
+}
+
+void ListViewItemConf::unchanged()
+{
+ _changed=false;
+ for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling())
+ {
+ ((ListViewItemConf*)it)->unchanged();
+ }
+ displayText();
+} \ No newline at end of file
diff --git a/noncore/apps/confedit/listviewitemconf.h b/noncore/apps/confedit/listviewitemconf.h
new file mode 100644
index 0000000..5837625
--- a/dev/null
+++ b/noncore/apps/confedit/listviewitemconf.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef LISTVIEWITEMCONF_H
+#define LISTVIEWITEMCONF_H
+
+#include <qlistview.h>
+
+
+class ListViewItemConf : public QListViewItem
+{
+public:
+ enum {File, Group, Key};
+
+ ListViewItemConf(ListViewItemConf *parent);
+ ListViewItemConf(QListView *parent);
+ ~ListViewItemConf();
+
+ int getType();
+ virtual void displayText() = 0;
+ virtual void changed();
+ virtual void unchanged();
+
+protected:
+ int _type;
+ bool _changed;
+};
+
+#endif
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp
new file mode 100644
index 0000000..5457384
--- a/dev/null
+++ b/noncore/apps/confedit/listviewitemconffile.cpp
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * *
+ * 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 <qmessagebox.h>
+#include <qtextstream.h>
+#include <qstring.h>
+#include "listviewitemconfigentry.h"
+
+#define tr QObject::tr
+
+ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent)
+ : ListViewItemConf(parent), _valid(false)
+{
+ confFileInfo = file;
+ parseFile();
+ _changed = false;
+ displayText();
+}
+
+ListViewItemConfFile::~ListViewItemConfFile()
+{
+}
+
+
+void ListViewItemConfFile::displayText()
+{
+ setText(0,(_changed?"*":"*")+confFileInfo->fileName());
+}
+
+QString ListViewItemConfFile::fileName()
+{
+ return confFileInfo->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 );
+ QString s;
+ QString group;
+ ListViewItemConfigEntry *groupItem;
+ ListViewItemConfigEntry *item;
+ while ( !t.atEnd() )
+ {
+ s = t.readLine().stripWhiteSpace();
+ // qDebug( "line: >%s<\n", s.latin1() );
+ if (s.contains("<?xml"))
+ {
+ _valid = false;
+ break;
+ }else
+ if ( s[0] == '[' && s[s.length()-1] == ']' )
+ {
+ qDebug("got group"+s);
+ group = s.mid(1,s.length()-2);
+ groupItem = new ListViewItemConfigEntry(this, group );
+ insertItem( groupItem );
+ } else
+ if ( int pos = s.find('=') )
+ {
+ // qDebug("got key"+s);
+ item = new ListViewItemConfigEntry(this, group, s );
+ groupItem->insertItem( item );
+ }
+ }
+ confFile.close();
+ setExpandable( _valid );
+}
+
+void ListViewItemConfFile::save()
+{
+ qDebug("ListViewItemConfFile::save()");
+ qDebug("no saveing yet...");
+ unchanged();
+}
diff --git a/noncore/apps/confedit/listviewitemconffile.h b/noncore/apps/confedit/listviewitemconffile.h
new file mode 100644
index 0000000..9208918
--- a/dev/null
+++ b/noncore/apps/confedit/listviewitemconffile.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * *
+ * 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>
+
+#ifndef LISTVIEWITEMCONFFILE_H
+#define LISTVIEWITEMCONFFILE_H
+
+#include <qwidget.h>
+#include <qlistview.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include "listviewitemconf.h"
+
+
+class ListViewItemConfFile : public ListViewItemConf {
+public:
+ ListViewItemConfFile(QFileInfo *file, QListView *parent=0);
+ ~ListViewItemConfFile();
+ void parseFile();
+ QString fileName();
+ virtual void displayText();
+ /** No descriptions */
+ void save();
+protected:
+private:
+ bool _valid;
+ QFileInfo *confFileInfo;
+};
+
+#endif
diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp
new file mode 100644
index 0000000..16be46e
--- a/dev/null
+++ b/noncore/apps/confedit/listviewitemconfigentry.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * *
+ * 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 "listviewitemconfigentry.h"
+#include "listviewitemconffile.h"
+
+ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key)
+ : ListViewItemConf(parent)
+{
+ _fileItem = parent;
+ _file = parent->fileName();
+ _group = group;
+ setKey(key);
+ _fileItem->unchanged();
+}
+
+ListViewItemConfigEntry::~ListViewItemConfigEntry()
+{
+}
+
+bool ListViewItemConfigEntry::isGroup()
+{
+ return _key.isEmpty();
+}
+
+bool ListViewItemConfigEntry::isKey()
+{
+ return !_key.isEmpty();
+}
+
+QString ListViewItemConfigEntry::getFile()
+{
+ return _file;
+}
+
+void ListViewItemConfigEntry::setGroup(QString g)
+{
+ if (g==_group) return;
+ _group = g;
+ changed();
+}
+
+QString ListViewItemConfigEntry::getGroup()
+{
+ return _group;
+}
+
+void ListViewItemConfigEntry::setKey(QString key)
+{
+ int pos = key.find("=");
+ _key = key.left(pos).stripWhiteSpace();
+ _value = key.right(key.length() - pos - 1).stripWhiteSpace();
+ displayText();
+}
+
+QString ListViewItemConfigEntry::getKey()
+{
+ return _key;
+}
+
+QString ListViewItemConfigEntry::getValue()
+{
+ return _value;
+}
+
+void ListViewItemConfigEntry::keyChanged(QString k)
+{
+ if (k==_key) return;
+ _key = k;
+ changed();
+}
+
+void ListViewItemConfigEntry::valueChanged(QString v)
+{
+ if (v==_value) return;
+ _value = v;
+ changed();
+}
+
+void ListViewItemConfigEntry::displayText()
+{
+ QString s;
+ if (_changed) s="*";
+ if (isGroup())
+ {
+ s += "["+_group+"]";
+ _type = Group;
+ }else{
+ s += _key+" = "+_value;
+ _type = Key;
+ }
+ setText(0,s);
+}
+
+void ListViewItemConfigEntry::changed()
+{
+ _changed=true;
+ displayText();
+ _fileItem->changed();
+} \ No newline at end of file
diff --git a/noncore/apps/confedit/listviewitemconfigentry.h b/noncore/apps/confedit/listviewitemconfigentry.h
new file mode 100644
index 0000000..d2b331f
--- a/dev/null
+++ b/noncore/apps/confedit/listviewitemconfigentry.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * *
+ * 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>
+
+#ifndef LISTVIEWITEMCONFIGENTRY_H
+#define LISTVIEWITEMCONFIGENTRY_H
+
+#include <qwidget.h>
+#include <qlistview.h>
+#include "listviewitemconffile.h"
+#include "listviewitemconf.h"
+
+class ListViewItemConfigEntry : public ListViewItemConf {
+public:
+ ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key="");
+ ~ListViewItemConfigEntry();
+ bool isGroup();
+ bool isKey();
+ QString getFile();
+ void setGroup(QString);
+ QString getGroup();
+ void setKey(QString);
+ QString getKey();
+ QString getValue();
+ void keyChanged(QString);
+ void valueChanged(QString);
+ virtual void displayText();
+ virtual void changed();
+private:
+ QString _file;
+ QString _group;
+ QString _key;
+ QString _value;
+ ListViewItemConfFile *_fileItem;
+};
+
+#endif
diff --git a/noncore/apps/confedit/main.cpp b/noncore/apps/confedit/main.cpp
new file mode 100644
index 0000000..58a79ce
--- a/dev/null
+++ b/noncore/apps/confedit/main.cpp
@@ -0,0 +1,15 @@
+
+#include "mainwindow.h"
+
+#include <qpe/qpeapplication.h>
+#include <stdio.h>
+int main( int argc, char ** argv )
+{
+ printf("This is confedit\n");
+ printf("$Id$\n");
+
+ QPEApplication a( argc, argv );
+ MainWindow mw;
+ a.showMainDocumentWidget( &mw );
+ return a.exec();
+}
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
new file mode 100644
index 0000000..5eeeb90
--- a/dev/null
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -0,0 +1,195 @@
+/***************************************************************************
+ * *
+ * 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 <qpe/qpemenubar.h>
+#include <qpe/qpemessagebox.h>
+#include <qpe/resource.h>
+#include <qpe/config.h>
+#include <qpe/qpetoolbar.h>
+#include <qaction.h>
+#include <qmessagebox.h>
+#include <qpopupmenu.h>
+#include <qtoolbutton.h>
+#include <qstring.h>
+#include <qlabel.h>
+#include <qfile.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+
+#include "listviewconfdir.h"
+#include "listviewitemconf.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") );
+
+ popupTimer = new QTimer(this);
+ popupMenu = new QPopupMenu(this);
+
+ QWidget *mainWidget = new QWidget(this);
+ setCentralWidget( mainWidget);
+
+ QGridLayout *mainLayout = new QGridLayout( mainWidget );
+ mainLayout->setSpacing( 3 );
+ mainLayout->setMargin( 3 );
+
+
+ settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist");
+ mainLayout->addWidget( settingList, 0, 0 );
+
+ editor = new EditWidget(this);
+ mainLayout->addWidget( editor, 1, 0 );
+
+ connect (settingList, SIGNAL( currentChanged(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&) ) );
+ makeMenu();
+}
+
+void MainWindow::makeMenu()
+{
+
+
+}
+
+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)
+ {
+ popupTimer->start( 750, true );
+ editor->hide();
+ updateGeometry();
+ _currentItem=0;
+ _fileItem = (ListViewItemConfFile*)item;
+ return;
+ }else editor->show();
+ qDebug("cast ListViewItemConfigEntry");
+ _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->isKey(true);
+ editor->LineEditKey->setText(key);
+ editor->LineEditValue->setText(val);
+ }else{
+ editor->isKey(false);
+ }
+ updateGeometry();
+}
+
+
+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* )
+{
+ qDebug("stopTimer");
+ popupTimer->stop();
+}
+
+void MainWindow::saveConfFile()
+{
+ if (!_fileItem) return;
+ _fileItem->save();
+}
+
+void MainWindow::showPopup()
+{
+ qDebug("showPopup");
+ if (!_fileItem) return;
+ popupMenu->clear();
+
+ QAction *popupAction;
+ popupAction = new QAction( tr("Save"),QString::null, 0, this, 0 );
+ popupAction->addTo( popupMenu );
+ 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() );
+}
diff --git a/noncore/apps/confedit/mainwindow.h b/noncore/apps/confedit/mainwindow.h
new file mode 100644
index 0000000..b015dac
--- a/dev/null
+++ b/noncore/apps/confedit/mainwindow.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * *
+ * 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>
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <qmainwindow.h>
+#include <qaction.h>
+#include <qtimer.h>
+#include <qpopupmenu.h>
+#include "editwidget.h"
+
+class QPEToolBar;
+class ListViewItemConfFile;
+class ListViewConfDir;
+
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+
+public:
+ MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
+ ~MainWindow();
+
+
+public slots:
+ void setCurrent(QListViewItem*);
+ void groupChanged(const QString&);
+ void keyChanged(const QString&);
+ void valueChanged(const QString&);
+ void showPopup();
+ void stopTimer( QListViewItem* );
+ void saveConfFile();
+
+private:
+ ListViewConfDir *settingList;
+ EditWidget *editor;
+ ListViewItemConfigEntry *_currentItem;
+ ListViewItemConfFile *_fileItem;
+ QTimer *popupTimer;
+ QPopupMenu *popupMenu;
+
+ void makeMenu();
+};
+
+#endif