summaryrefslogtreecommitdiff
Unidiff
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 @@
1 DESTDIR = $(OPIEDIR)/bin
2 TEMPLATE= app
3 #CONFIG = qt warn_on release
4 CONFIG = qt warn_on debug
5 HEADERS = mainwindow.h listviewconfdir.h listviewitemconffile.h listviewitemconfigentry.h editwidget.h listviewitemconf.h
6 SOURCES = main.cpp mainwindow.cpp listviewconfdir.cpp listviewitemconffile.cpp listviewitemconfigentry.cpp editwidget.cpp listviewitemconf.cpp
7INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/ioclude
9LIBS += -lqpe
10 INTERFACES=
11 TARGET = confedit
12
13TRANSLATIONS = ../../../i18n/de/confedit.ts \
14 ../../../i18n/en/confedit.ts \
15 ../../../i18n/es/confedit.ts \
16 ../../../i18n/fr/confedit.ts \
17 ../../../i18n/hu/confedit.ts \
18 ../../../i18n/ja/confedit.ts \
19 ../../../i18n/ko/confedit.ts \
20 ../../../i18n/no/confedit.ts \
21 ../../../i18n/pl/confedit.ts \
22 ../../../i18n/pt/confedit.ts \
23 ../../../i18n/pt_BR/confedit.ts \
24 ../../../i18n/sl/confedit.ts \
25 ../../../i18n/zh_CN/confedit.ts \
26 ../../../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 @@
1#include "editwidget.h"
2
3#include <qlabel.h>
4#include <qlineedit.h>
5#include <qpushbutton.h>
6#include <qlayout.h>
7#include <qvariant.h>
8#include <qtooltip.h>
9#include <qwhatsthis.h>
10#include <qtimer.h>
11#include <qpopupmenu.h>
12#include <qaction.h>
13#include "listviewitemconfigentry.h"
14
15EditWidget::EditWidget( QWidget* parent, const char* name, WFlags fl )
16 : QWidget( parent, name, fl )
17{
18
19 EditWidgetLayout = new QGridLayout( this );
20 EditWidgetLayout->setSpacing( 3 );
21 EditWidgetLayout->setMargin( 3 );
22
23 QLabel *TextLabelFileName = new QLabel( this, "TextLabelFileName" );
24 TextLabelFileName->setText( tr( "File Name:" ) );
25 EditWidgetLayout->addWidget( TextLabelFileName, 0, 0 );
26 TextFileName = new QLabel( this, "TextFileName" );
27 EditWidgetLayout->addWidget( TextFileName, 0, 1 );
28
29 QLabel *TextLabelGroup = new QLabel( this, "TextLabelGroup" );
30 TextLabelGroup->setText( tr( "Group:" ) );
31 EditWidgetLayout->addWidget( TextLabelGroup, 1, 0 );
32 LineEditGroup = new QLineEdit( this, "LineEditGroup" );
33 EditWidgetLayout->addWidget( LineEditGroup, 1, 1 );
34
35 TextLabelKey = new QLabel( this, "TextLabelKey" );
36 TextLabelKey->setText( tr( "Key:" ) );
37 EditWidgetLayout->addWidget( TextLabelKey, 2, 0 );
38 LineEditKey = new QLineEdit( this, "LineEditKey" );
39 EditWidgetLayout->addWidget( LineEditKey, 2, 1 );
40
41 TextLabelValue = new QLabel( this, "TextLabelValue" );
42 TextLabelValue->setText( tr( "Value:" ) );
43 EditWidgetLayout->addWidget( TextLabelValue, 3, 0 );
44 LineEditValue = new QLineEdit( this, "LineEditValue" );
45 EditWidgetLayout->addWidget( LineEditValue, 3, 1 );
46
47}
48
49
50EditWidget::~EditWidget()
51{
52}
53
54
55void EditWidget::isKey(bool h)
56{
57 if (h)
58 {
59 LineEditGroup->setEnabled(false);
60 TextLabelKey->show();
61 LineEditKey->show();
62 TextLabelValue->show();
63 LineEditValue->show();
64 }else{
65 LineEditGroup->setEnabled(true);
66 TextLabelKey->hide();
67 LineEditKey->hide();
68 TextLabelValue->hide();
69 LineEditValue->hide();
70 }
71 update();
72}
73
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 @@
1#ifndef EDITWIDGET_H
2#define EDITWIDGET_H
3
4#include <qvariant.h>
5#include <qwidget.h>
6class QVBoxLayout;
7class QHBoxLayout;
8class QGridLayout;
9class QLabel;
10class QLineEdit;
11class QListViewItem;
12class ListViewItemConfigEntry;
13class QTimer;
14class QPopupMenu;
15
16class EditWidget : public QWidget
17{
18 Q_OBJECT
19
20public:
21 EditWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
22 ~EditWidget();
23
24 QLabel *TextLabelKey;
25 QLabel *TextLabelValue;
26 QLabel *TextFileName;
27 QLineEdit *LineEditGroup;
28 QLineEdit *LineEditKey;
29 QLineEdit *LineEditValue;
30 void isKey(bool h);
31protected:
32 QGridLayout* EditWidgetLayout;
33
34private:
35};
36
37#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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
10
11#include "listviewconfdir.h"
12
13#include <qmessagebox.h>
14
15#include "listviewitemconffile.h"
16
17ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name )
18 : QListView(parent,name), confDir(settingsPath)
19{
20
21 setRootIsDecorated( true );
22 addColumn(tr("Files"));
23
24 if (!confDir.isReadable())
25 QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0);
26 readConfFiles();
27}
28
29
30ListViewConfDir::~ListViewConfDir()
31{
32}
33
34void ListViewConfDir::readConfFiles()
35{
36
37 confDir.setFilter( QDir::Files | QDir::NoSymLinks );
38 confDir.setSorting( QDir::Name );
39
40 const QFileInfoList *list = confDir.entryInfoList();
41 QFileInfoListIterator it( *list );
42 QFileInfo *fi;
43
44 ListViewItemConfFile *fileEntry;
45
46 while ( (fi=it.current()) )
47 {
48 qDebug( "opening: >%s<", fi->fileName().data() );
49 fileEntry = new ListViewItemConfFile( fi, this );
50
51 ++it;
52 }
53} \ 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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
11
12#ifndef LISTVIEWCONFDIR_H
13#define LISTVIEWCONFDIR_H
14
15#include <qwidget.h>
16#include <qlistview.h>
17#include <qdir.h>
18
19class QDir;
20
21class ListViewConfDir : public QListView {
22 Q_OBJECT
23public:
24 ListViewConfDir(QString settingsPath, QWidget *parent=0, const char *name=0);
25 ~ListViewConfDir();
26
27private:
28 QDir confDir;
29
30 void readConfFiles();
31};
32
33#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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10#include "listviewitemconf.h"
11
12ListViewItemConf::ListViewItemConf(ListViewItemConf *parent)
13 : QListViewItem(parent), _changed(false)
14{
15}
16
17ListViewItemConf::ListViewItemConf(QListView *parent)
18 : QListViewItem(parent), _changed(false)
19{
20 _type = File;
21}
22
23ListViewItemConf::~ListViewItemConf()
24{
25}
26
27int ListViewItemConf::getType()
28{
29 return _type;
30}
31
32void ListViewItemConf::changed()
33{
34 _changed=true;
35 displayText();
36}
37
38void ListViewItemConf::unchanged()
39{
40 _changed=false;
41 for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling())
42 {
43 ((ListViewItemConf*)it)->unchanged();
44 }
45 displayText();
46} \ 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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10#ifndef LISTVIEWITEMCONF_H
11#define LISTVIEWITEMCONF_H
12
13#include <qlistview.h>
14
15
16class ListViewItemConf : public QListViewItem
17{
18public:
19 enum {File, Group, Key};
20
21 ListViewItemConf(ListViewItemConf *parent);
22 ListViewItemConf(QListView *parent);
23 ~ListViewItemConf();
24
25 int getType();
26 virtual void displayText() = 0;
27 virtual void changed();
28 virtual void unchanged();
29
30protected:
31 int _type;
32 bool _changed;
33};
34
35#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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10
11#include "listviewitemconffile.h"
12#include <qmessagebox.h>
13#include <qtextstream.h>
14#include <qstring.h>
15#include "listviewitemconfigentry.h"
16
17#define tr QObject::tr
18
19ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent)
20 : ListViewItemConf(parent), _valid(false)
21{
22 confFileInfo = file;
23 parseFile();
24 _changed = false;
25 displayText();
26}
27
28ListViewItemConfFile::~ListViewItemConfFile()
29{
30}
31
32
33void ListViewItemConfFile::displayText()
34{
35 setText(0,(_changed?"*":"*")+confFileInfo->fileName());
36}
37
38QString ListViewItemConfFile::fileName()
39{
40 return confFileInfo->fileName();
41}
42
43void ListViewItemConfFile::parseFile()
44{
45 qDebug( confFileInfo->absFilePath() );
46 QFile confFile(confFileInfo->absFilePath());
47 qDebug( confFileInfo->absFilePath() );
48 // QString fileName = confFileInfo->fileName();
49 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);
51 QTextStream t( &confFile );
52 QString s;
53 QString group;
54 ListViewItemConfigEntry *groupItem;
55 ListViewItemConfigEntry *item;
56 while ( !t.atEnd() )
57 {
58 s = t.readLine().stripWhiteSpace();
59 //qDebug( "line: >%s<\n", s.latin1() );
60 if (s.contains("<?xml"))
61 {
62 _valid = false;
63 break;
64 }else
65 if ( s[0] == '[' && s[s.length()-1] == ']' )
66 {
67 qDebug("got group"+s);
68 group = s.mid(1,s.length()-2);
69 groupItem = new ListViewItemConfigEntry(this, group );
70 insertItem( groupItem );
71 } else
72 if ( int pos = s.find('=') )
73 {
74 // qDebug("got key"+s);
75 item = new ListViewItemConfigEntry(this, group, s );
76 groupItem->insertItem( item );
77 }
78 }
79 confFile.close();
80 setExpandable( _valid );
81}
82
83void ListViewItemConfFile::save()
84{
85 qDebug("ListViewItemConfFile::save()");
86 qDebug("no saveing yet...");
87 unchanged();
88}
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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9 // (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10
11#ifndef LISTVIEWITEMCONFFILE_H
12#define LISTVIEWITEMCONFFILE_H
13
14#include <qwidget.h>
15#include <qlistview.h>
16#include <qfile.h>
17#include <qfileinfo.h>
18#include "listviewitemconf.h"
19
20
21class ListViewItemConfFile : public ListViewItemConf {
22public:
23 ListViewItemConfFile(QFileInfo *file, QListView *parent=0);
24 ~ListViewItemConfFile();
25 void parseFile();
26 QString fileName();
27 virtual void displayText();
28 /** No descriptions */
29 void save();
30protected:
31private:
32 bool _valid;
33 QFileInfo *confFileInfo;
34};
35
36#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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
10
11#include "listviewitemconfigentry.h"
12#include "listviewitemconffile.h"
13
14ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key)
15 : ListViewItemConf(parent)
16{
17 _fileItem = parent;
18 _file = parent->fileName();
19 _group = group;
20 setKey(key);
21 _fileItem->unchanged();
22}
23
24ListViewItemConfigEntry::~ListViewItemConfigEntry()
25{
26}
27
28bool ListViewItemConfigEntry::isGroup()
29{
30 return _key.isEmpty();
31}
32
33bool ListViewItemConfigEntry::isKey()
34{
35 return !_key.isEmpty();
36}
37
38QString ListViewItemConfigEntry::getFile()
39{
40 return _file;
41}
42
43void ListViewItemConfigEntry::setGroup(QString g)
44{
45 if (g==_group) return;
46 _group = g;
47 changed();
48}
49
50QString ListViewItemConfigEntry::getGroup()
51{
52 return _group;
53}
54
55void ListViewItemConfigEntry::setKey(QString key)
56{
57 int pos = key.find("=");
58 _key = key.left(pos).stripWhiteSpace();
59 _value = key.right(key.length() - pos - 1).stripWhiteSpace();
60 displayText();
61}
62
63QString ListViewItemConfigEntry::getKey()
64{
65 return _key;
66}
67
68QString ListViewItemConfigEntry::getValue()
69{
70 return _value;
71}
72
73void ListViewItemConfigEntry::keyChanged(QString k)
74{
75 if (k==_key) return;
76 _key = k;
77 changed();
78}
79
80void ListViewItemConfigEntry::valueChanged(QString v)
81{
82 if (v==_value) return;
83 _value = v;
84 changed();
85}
86
87void ListViewItemConfigEntry::displayText()
88{
89 QString s;
90 if (_changed) s="*";
91 if (isGroup())
92 {
93 s += "["+_group+"]";
94 _type = Group;
95 }else{
96 s += _key+" = "+_value;
97 _type = Key;
98 }
99 setText(0,s);
100}
101
102void ListViewItemConfigEntry::changed()
103{
104 _changed=true;
105 displayText();
106 _fileItem->changed();
107} \ 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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
10
11#ifndef LISTVIEWITEMCONFIGENTRY_H
12#define LISTVIEWITEMCONFIGENTRY_H
13
14#include <qwidget.h>
15#include <qlistview.h>
16#include "listviewitemconffile.h"
17#include "listviewitemconf.h"
18
19class ListViewItemConfigEntry : public ListViewItemConf {
20public:
21 ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key="");
22 ~ListViewItemConfigEntry();
23 bool isGroup();
24 bool isKey();
25 QString getFile();
26 void setGroup(QString);
27 QString getGroup();
28 void setKey(QString);
29 QString getKey();
30 QString getValue();
31 void keyChanged(QString);
32 void valueChanged(QString);
33 virtual void displayText();
34 virtual void changed();
35private:
36 QString _file;
37 QString _group;
38 QString _key;
39 QString _value;
40 ListViewItemConfFile *_fileItem;
41};
42
43#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 @@
1
2#include "mainwindow.h"
3
4#include <qpe/qpeapplication.h>
5#include <stdio.h>
6int main( int argc, char ** argv )
7{
8 printf("This is confedit\n");
9 printf("$Id$\n");
10
11 QPEApplication a( argc, argv );
12 MainWindow mw;
13 a.showMainDocumentWidget( &mw );
14 return a.exec();
15}
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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11
12
13#include "mainwindow.h"
14
15#include <qpe/qpemenubar.h>
16#include <qpe/qpemessagebox.h>
17#include <qpe/resource.h>
18#include <qpe/config.h>
19#include <qpe/qpetoolbar.h>
20#include <qaction.h>
21#include <qmessagebox.h>
22#include <qpopupmenu.h>
23#include <qtoolbutton.h>
24#include <qstring.h>
25#include <qlabel.h>
26#include <qfile.h>
27#include <qpushbutton.h>
28#include <qlayout.h>
29#include <qlineedit.h>
30
31#include "listviewconfdir.h"
32#include "listviewitemconf.h"
33#include "listviewitemconfigentry.h"
34
35
36MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
37 QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0)
38 {
39 setCaption( tr("Conf File Editor") );
40
41 popupTimer = new QTimer(this);
42 popupMenu = new QPopupMenu(this);
43
44 QWidget *mainWidget = new QWidget(this);
45 setCentralWidget( mainWidget);
46
47 QGridLayout *mainLayout = new QGridLayout( mainWidget );
48 mainLayout->setSpacing( 3 );
49 mainLayout->setMargin( 3 );
50
51
52 settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist");
53 mainLayout->addWidget( settingList, 0, 0 );
54
55 editor = new EditWidget(this);
56 mainLayout->addWidget( editor, 1, 0 );
57
58 connect (settingList, SIGNAL( currentChanged(QListViewItem*) ),
59 this, SLOT(setCurrent(QListViewItem*)));
60
61 connect( popupTimer, SIGNAL(timeout()),
62 this, SLOT(showPopup()) );
63 connect( this, SIGNAL( clicked( QListViewItem* ) ),
64 this, SLOT( stopTimer( QListViewItem* ) ) );
65
66 connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ),
67 SLOT( groupChanged(const QString&) ) );
68 connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
69 SLOT( keyChanged(const QString&) ) );
70 connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
71 SLOT( valueChanged(const QString&) ) );
72 makeMenu();
73}
74
75void MainWindow::makeMenu()
76{
77
78
79}
80
81MainWindow::~MainWindow()
82{
83}
84
85
86
87void MainWindow::setCurrent(QListViewItem *item)
88{
89 qDebug("MainWindow::setCurrent(");
90 if (!item) return;
91 qDebug("cast ListViewItemConf");
92 ListViewItemConf *i = (ListViewItemConf*) item;
93 if (!i) return;
94 if (i->getType() == ListViewItemConf::File)
95 {
96 popupTimer->start( 750, true );
97 editor->hide();
98 updateGeometry();
99 _currentItem=0;
100 _fileItem = (ListViewItemConfFile*)item;
101 return;
102 }else editor->show();
103 qDebug("cast ListViewItemConfigEntry");
104 _fileItem = 0;
105 _currentItem = (ListViewItemConfigEntry*)item;
106 if (!_currentItem) return;
107 QString file = _currentItem->getFile();
108 QString group = _currentItem->getGroup();
109 QString key = _currentItem->getKey();
110 QString val = _currentItem->getValue();
111 editor->TextFileName->setText(file);
112 editor->LineEditGroup->setText(group);
113 if (!key.isEmpty())
114 {
115 editor->isKey(true);
116 editor->LineEditKey->setText(key);
117 editor->LineEditValue->setText(val);
118 }else{
119 editor->isKey(false);
120 }
121 updateGeometry();
122}
123
124
125void MainWindow::groupChanged(const QString &g)
126{
127 if (!_currentItem) return;
128 _currentItem->setGroup(g);
129}
130
131void MainWindow::keyChanged(const QString &k)
132{
133 if (!_currentItem) return;
134 _currentItem->keyChanged(k);
135}
136
137void MainWindow::valueChanged(const QString &v)
138{
139 if (!_currentItem) return;
140 _currentItem->valueChanged(v);
141}
142
143
144void MainWindow::stopTimer( QListViewItem* )
145{
146 qDebug("stopTimer");
147 popupTimer->stop();
148}
149
150void MainWindow::saveConfFile()
151{
152 if (!_fileItem) return;
153 _fileItem->save();
154}
155
156void MainWindow::showPopup()
157{
158 qDebug("showPopup");
159 if (!_fileItem) return;
160 popupMenu->clear();
161
162 QAction *popupAction;
163 popupAction = new QAction( tr("Save"),QString::null, 0, this, 0 );
164 popupAction->addTo( popupMenu );
165 connect( popupAction, SIGNAL( activated() ),
166 this , SLOT( saveConfFile() ) );
167
168// if ( !activePackage->installed() )
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() );
195}
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 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11
12#ifndef MAINWINDOW_H
13#define MAINWINDOW_H
14
15#include <qmainwindow.h>
16#include <qaction.h>
17#include <qtimer.h>
18#include <qpopupmenu.h>
19#include "editwidget.h"
20
21class QPEToolBar;
22class ListViewItemConfFile;
23class ListViewConfDir;
24
25
26class MainWindow : public QMainWindow
27{
28 Q_OBJECT
29
30
31public:
32 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
33 ~MainWindow();
34
35
36public slots:
37 void setCurrent(QListViewItem*);
38 void groupChanged(const QString&);
39 void keyChanged(const QString&);
40 void valueChanged(const QString&);
41 void showPopup();
42 void stopTimer( QListViewItem* );
43 void saveConfFile();
44
45private:
46 ListViewConfDir *settingList;
47 EditWidget *editor;
48 ListViewItemConfigEntry *_currentItem;
49 ListViewItemConfFile *_fileItem;
50 QTimer *popupTimer;
51 QPopupMenu *popupMenu;
52
53 void makeMenu();
54};
55
56#endif