author | tille <tille> | 2002-06-29 23:23:09 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-29 23:23:09 (UTC) |
commit | 0f179c0cc471b659b30dec4762c9c36678063f31 (patch) (unidiff) | |
tree | 5350dc3b1c05991953011d01ad19cb12414abc1a | |
parent | eb02223de534d315bfdcb0d521719c2d2e9a7235 (diff) | |
download | opie-0f179c0cc471b659b30dec4762c9c36678063f31.zip opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.gz opie-0f179c0cc471b659b30dec4762c9c36678063f31.tar.bz2 |
revert
-rw-r--r-- | noncore/apps/confedit/listviewitemconf.h | 1 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 30 | ||||
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.h | 2 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 47 | ||||
-rw-r--r-- | noncore/apps/confedit/mainwindow.h | 10 |
5 files changed, 71 insertions, 19 deletions
diff --git a/noncore/apps/confedit/listviewitemconf.h b/noncore/apps/confedit/listviewitemconf.h index 5837625..c6e60ba 100644 --- a/noncore/apps/confedit/listviewitemconf.h +++ b/noncore/apps/confedit/listviewitemconf.h | |||
@@ -1,35 +1,36 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | #ifndef LISTVIEWITEMCONF_H | 10 | #ifndef LISTVIEWITEMCONF_H |
11 | #define LISTVIEWITEMCONF_H | 11 | #define LISTVIEWITEMCONF_H |
12 | 12 | ||
13 | #include <qlistview.h> | 13 | #include <qlistview.h> |
14 | 14 | ||
15 | 15 | ||
16 | class ListViewItemConf : public QListViewItem | 16 | class ListViewItemConf : public QListViewItem |
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | enum {File, Group, Key}; | 19 | enum {File, Group, Key}; |
20 | 20 | ||
21 | ListViewItemConf(ListViewItemConf *parent); | 21 | ListViewItemConf(ListViewItemConf *parent); |
22 | ListViewItemConf(QListView *parent); | 22 | ListViewItemConf(QListView *parent); |
23 | ~ListViewItemConf(); | 23 | ~ListViewItemConf(); |
24 | 24 | ||
25 | int getType(); | 25 | int getType(); |
26 | virtual void displayText() = 0; | 26 | virtual void displayText() = 0; |
27 | virtual void changed(); | 27 | virtual void changed(); |
28 | bool isChanged() {return _changed;}; | ||
28 | virtual void unchanged(); | 29 | virtual void unchanged(); |
29 | 30 | ||
30 | protected: | 31 | protected: |
31 | int _type; | 32 | int _type; |
32 | bool _changed; | 33 | bool _changed; |
33 | }; | 34 | }; |
34 | 35 | ||
35 | #endif | 36 | #endif |
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 858726d..b075063 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp | |||
@@ -1,106 +1,134 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
10 | 10 | ||
11 | #include "listviewitemconffile.h" | 11 | #include "listviewitemconffile.h" |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qtextstream.h> | 13 | #include <qtextstream.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include "listviewitemconfigentry.h" | 15 | #include "listviewitemconfigentry.h" |
16 | 16 | ||
17 | #define tr QObject::tr | 17 | #define tr QObject::tr |
18 | 18 | ||
19 | ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) | 19 | ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) |
20 | : ListViewItemConf(parent), _valid(false) | 20 | : ListViewItemConf(parent), _valid(false) |
21 | { | 21 | { |
22 | confFileInfo = file; | 22 | confFileInfo = file; |
23 | parseFile(); | 23 | parseFile(); |
24 | displayText(); | 24 | displayText(); |
25 | } | 25 | } |
26 | 26 | ||
27 | ListViewItemConfFile::~ListViewItemConfFile() | 27 | ListViewItemConfFile::~ListViewItemConfFile() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | 31 | ||
32 | void ListViewItemConfFile::displayText() | 32 | void ListViewItemConfFile::displayText() |
33 | { | 33 | { |
34 | setText(0,(_changed?"*":"")+confFileInfo->fileName()); | 34 | setText(0,(_changed?"*":"")+confFileInfo->fileName()); |
35 | } | 35 | } |
36 | 36 | ||
37 | QString ListViewItemConfFile::fileName() | 37 | QString ListViewItemConfFile::fileName() |
38 | { | 38 | { |
39 | return confFileInfo->fileName(); | 39 | return confFileInfo->fileName(); |
40 | } | 40 | } |
41 | 41 | ||
42 | void ListViewItemConfFile::parseFile() | 42 | void ListViewItemConfFile::parseFile() |
43 | { | 43 | { |
44 | QFile confFile(confFileInfo->absFilePath()); | 44 | QFile confFile(confFileInfo->absFilePath()); |
45 | if(! confFile.open(IO_ReadOnly)) | 45 | if(! confFile.open(IO_ReadOnly)) |
46 | 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); |
47 | QTextStream t( &confFile ); | 47 | QTextStream t( &confFile ); |
48 | QString s; | 48 | QString s; |
49 | QString group; | 49 | QString group; |
50 | ListViewItemConfigEntry *groupItem; | 50 | ListViewItemConfigEntry *groupItem; |
51 | ListViewItemConfigEntry *item; | 51 | ListViewItemConfigEntry *item; |
52 | while ( !t.atEnd() ) | 52 | while ( !t.atEnd() ) |
53 | { | 53 | { |
54 | s = t.readLine().stripWhiteSpace(); | 54 | s = t.readLine().stripWhiteSpace(); |
55 | //qDebug( "line: >%s<\n", s.latin1() ); | 55 | //qDebug( "line: >%s<\n", s.latin1() ); |
56 | if (s.contains("<?xml")) | 56 | if (s.contains("<?xml")) |
57 | { | 57 | { |
58 | _valid = false; | 58 | _valid = false; |
59 | break; | 59 | break; |
60 | }else | 60 | }else |
61 | if ( s[0] == '[' && s[s.length()-1] == ']' ) | 61 | if ( s[0] == '[' && s[s.length()-1] == ']' ) |
62 | { | 62 | { |
63 | // qDebug("got group"+s); | 63 | // qDebug("got group"+s); |
64 | group = s.mid(1,s.length()-2); | 64 | group = s.mid(1,s.length()-2); |
65 | groupItem = new ListViewItemConfigEntry(this, group ); | 65 | groupItem = new ListViewItemConfigEntry(this, group ); |
66 | insertItem( groupItem ); | 66 | insertItem( groupItem ); |
67 | } else | 67 | } else |
68 | if ( int pos = s.find('=') ) | 68 | if ( int pos = s.find('=') ) |
69 | { | 69 | { |
70 | // qDebug("got key"+s); | 70 | // qDebug("got key"+s); |
71 | item = new ListViewItemConfigEntry(this, group, s ); | 71 | item = new ListViewItemConfigEntry(this, group, s ); |
72 | groupItem->insertItem( item ); | 72 | groupItem->insertItem( item ); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | confFile.close(); | 75 | confFile.close(); |
76 | unchanged(); | ||
76 | setExpandable( _valid ); | 77 | setExpandable( _valid ); |
77 | } | 78 | } |
78 | 79 | ||
80 | |||
81 | void ListViewItemConfFile::revert() | ||
82 | { | ||
83 | if (_changed) | ||
84 | { | ||
85 | parseFile(); | ||
86 | }else{ | ||
87 | QString backup = confFileInfo->absFilePath()+"~"; | ||
88 | QFile conf(confFileInfo->absFilePath()); | ||
89 | QFile back(backup); | ||
90 | |||
91 | if (!back.open(IO_ReadOnly)) return; | ||
92 | if (!conf.open(IO_WriteOnly)) return; | ||
93 | |||
94 | #define SIZE 124 | ||
95 | char buf[SIZE]; | ||
96 | while (int c = back.readBlock(buf, SIZE) ) conf.writeBlock(buf,c); | ||
97 | conf.close(); | ||
98 | back.close(); | ||
99 | } | ||
100 | } | ||
101 | |||
79 | void ListViewItemConfFile::save() | 102 | void ListViewItemConfFile::save() |
80 | { | 103 | { |
81 | if (!_changed) return; | 104 | if (!_changed) return; |
82 | QString backup = confFileInfo->absFilePath()+"~"; | 105 | QString backup = confFileInfo->absFilePath()+"~"; |
83 | qDebug("make backup to "+backup); | 106 | qDebug("make backup to "+backup); |
84 | QFile conf(confFileInfo->absFilePath()); | 107 | QFile conf(confFileInfo->absFilePath()); |
85 | QFile back(backup); | 108 | QFile back(backup); |
86 | 109 | ||
87 | if (!conf.open(IO_ReadOnly)) return; | 110 | if (!conf.open(IO_ReadOnly)) return; |
88 | if (!back.open(IO_WriteOnly)) return; | 111 | if (!back.open(IO_WriteOnly)) return; |
89 | 112 | ||
90 | #define SIZE 124 | 113 | #define SIZE 124 |
91 | char buf[SIZE]; | 114 | char buf[SIZE]; |
92 | while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); | 115 | while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); |
93 | conf.close(); | 116 | conf.close(); |
94 | back.close(); | 117 | back.close(); |
95 | 118 | ||
96 | 119 | ||
97 | if (!conf.open(IO_WriteOnly)) return; | 120 | if (!conf.open(IO_WriteOnly)) return; |
98 | QTextStream *t = new QTextStream( &conf ); | 121 | QTextStream *t = new QTextStream( &conf ); |
99 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) | 122 | for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling()) |
100 | { | 123 | { |
101 | ((ListViewItemConfigEntry*)it)->save(t); | 124 | ((ListViewItemConfigEntry*)it)->save(t); |
102 | } | 125 | } |
103 | conf.close(); | 126 | conf.close(); |
104 | qDebug("no saveing yet..."); | ||
105 | unchanged(); | 127 | unchanged(); |
106 | } | 128 | } |
129 | |||
130 | |||
131 | bool ListViewItemConfFile::revertable() | ||
132 | { | ||
133 | return _changed || QFile(confFileInfo->absFilePath()+"~").exists(); | ||
134 | } \ No newline at end of file | ||
diff --git a/noncore/apps/confedit/listviewitemconffile.h b/noncore/apps/confedit/listviewitemconffile.h index d89b19c..ae23eab 100644 --- a/noncore/apps/confedit/listviewitemconffile.h +++ b/noncore/apps/confedit/listviewitemconffile.h | |||
@@ -1,35 +1,37 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 9 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
10 | 10 | ||
11 | #ifndef LISTVIEWITEMCONFFILE_H | 11 | #ifndef LISTVIEWITEMCONFFILE_H |
12 | #define LISTVIEWITEMCONFFILE_H | 12 | #define LISTVIEWITEMCONFFILE_H |
13 | 13 | ||
14 | #include <qwidget.h> | 14 | #include <qwidget.h> |
15 | #include <qlistview.h> | 15 | #include <qlistview.h> |
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qfileinfo.h> | 17 | #include <qfileinfo.h> |
18 | #include "listviewitemconf.h" | 18 | #include "listviewitemconf.h" |
19 | 19 | ||
20 | 20 | ||
21 | class ListViewItemConfFile : public ListViewItemConf { | 21 | class ListViewItemConfFile : public ListViewItemConf { |
22 | public: | 22 | public: |
23 | ListViewItemConfFile(QFileInfo *file, QListView *parent=0); | 23 | ListViewItemConfFile(QFileInfo *file, QListView *parent=0); |
24 | ~ListViewItemConfFile(); | 24 | ~ListViewItemConfFile(); |
25 | void parseFile(); | 25 | void parseFile(); |
26 | QString fileName(); | 26 | QString fileName(); |
27 | virtual void displayText(); | 27 | virtual void displayText(); |
28 | bool revertable(); | ||
28 | void save(); | 29 | void save(); |
30 | void revert(); | ||
29 | protected: | 31 | protected: |
30 | private: | 32 | private: |
31 | bool _valid; | 33 | bool _valid; |
32 | QFileInfo *confFileInfo; | 34 | QFileInfo *confFileInfo; |
33 | }; | 35 | }; |
34 | 36 | ||
35 | #endif | 37 | #endif |
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 47d9518..77b91f6 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -1,168 +1,181 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | 12 | ||
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | 14 | ||
15 | #include <qpe/qpemenubar.h> | 15 | #include <qpe/qpemenubar.h> |
16 | #include <qpe/qpemessagebox.h> | 16 | #include <qpe/qpemessagebox.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/qpetoolbar.h> | 19 | #include <qpe/qpetoolbar.h> |
20 | #include <qaction.h> | 20 | #include <qaction.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
23 | #include <qtoolbutton.h> | 23 | #include <qtoolbutton.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | 30 | ||
31 | #include "listviewconfdir.h" | 31 | #include "listviewconfdir.h" |
32 | #include "listviewitemconf.h" | 32 | #include "listviewitemconf.h" |
33 | #include "listviewitemconfigentry.h" | 33 | #include "listviewitemconfigentry.h" |
34 | 34 | ||
35 | 35 | ||
36 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 36 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
37 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) | 37 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) |
38 | { | 38 | { |
39 | setCaption( tr("Conf File Editor") ); | 39 | setCaption( tr("Conf File Editor") ); |
40 | 40 | ||
41 | popupTimer = new QTimer(this); | ||
42 | popupMenu = new QPopupMenu(this); | ||
43 | |||
44 | QWidget *mainWidget = new QWidget(this); | 41 | QWidget *mainWidget = new QWidget(this); |
45 | setCentralWidget( mainWidget); | 42 | setCentralWidget( mainWidget); |
46 | 43 | ||
47 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); | 44 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); |
48 | mainLayout->setSpacing( 3 ); | 45 | mainLayout->setSpacing( 3 ); |
49 | mainLayout->setMargin( 3 ); | 46 | mainLayout->setMargin( 3 ); |
50 | 47 | ||
51 | 48 | ||
52 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); | 49 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); |
53 | mainLayout->addWidget( settingList, 0, 0 ); | 50 | mainLayout->addWidget( settingList, 0, 0 ); |
54 | 51 | ||
55 | editor = new EditWidget(this); | 52 | editor = new EditWidget(this); |
56 | mainLayout->addWidget( editor, 1, 0 ); | 53 | mainLayout->addWidget( editor, 1, 0 ); |
57 | 54 | ||
58 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), | 55 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
59 | this, SLOT(setCurrent(QListViewItem*))); | 56 | this, SLOT(setCurrent(QListViewItem*))); |
60 | 57 | ||
61 | connect( popupTimer, SIGNAL(timeout()), | ||
62 | this, SLOT(showPopup()) ); | ||
63 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | ||
64 | this, SLOT( stopTimer( QListViewItem* ) ) ); | ||
65 | 58 | ||
66 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 59 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
67 | SLOT( groupChanged(const QString&) ) ); | 60 | SLOT( groupChanged(const QString&) ) ); |
68 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 61 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
69 | SLOT( keyChanged(const QString&) ) ); | 62 | SLOT( keyChanged(const QString&) ) ); |
70 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 63 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
71 | SLOT( valueChanged(const QString&) ) ); | 64 | SLOT( valueChanged(const QString&) ) ); |
72 | makeMenu(); | 65 | makeMenu(); |
73 | } | 66 | } |
74 | 67 | ||
75 | void MainWindow::makeMenu() | 68 | void MainWindow::makeMenu() |
76 | { | 69 | { |
77 | 70 | ||
78 | 71 | ||
72 | popupTimer = new QTimer(this); | ||
73 | popupMenuFile = new QPopupMenu(this); | ||
74 | |||
75 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); | ||
76 | popupActionSave->addTo( popupMenuFile ); | ||
77 | connect( popupActionSave, SIGNAL( activated() ), | ||
78 | this , SLOT( saveConfFile() ) ); | ||
79 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); | ||
80 | popupActionRevert->addTo( popupMenuFile ); | ||
81 | connect( popupActionRevert, SIGNAL( activated() ), | ||
82 | this , SLOT( revertConfFile() ) ); | ||
83 | |||
84 | connect( popupTimer, SIGNAL(timeout()), | ||
85 | this, SLOT(showPopup()) ); | ||
86 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | ||
87 | this, SLOT( stopTimer( QListViewItem* ) ) ); | ||
79 | } | 88 | } |
80 | 89 | ||
81 | MainWindow::~MainWindow() | 90 | MainWindow::~MainWindow() |
82 | { | 91 | { |
83 | } | 92 | } |
84 | 93 | ||
85 | 94 | ||
86 | 95 | ||
87 | void MainWindow::setCurrent(QListViewItem *item) | 96 | void MainWindow::setCurrent(QListViewItem *item) |
88 | { | 97 | { |
89 | if (!item) return; | 98 | if (!item) return; |
90 | ListViewItemConf *i = (ListViewItemConf*) item; | 99 | ListViewItemConf *i = (ListViewItemConf*) item; |
91 | if (!i) return; | 100 | if (!i) return; |
92 | if (i->getType() == ListViewItemConf::File) | 101 | if (i->getType() == ListViewItemConf::File) |
93 | { | 102 | { |
94 | qDebug("start timer"); | 103 | qDebug("start timer"); |
95 | popupTimer->start( 750, true ); | 104 | popupTimer->start( 750, true ); |
96 | editor->hide(); | 105 | editor->hide(); |
97 | updateGeometry(); | 106 | updateGeometry(); |
98 | _currentItem=0; | 107 | _currentItem=0; |
99 | _fileItem = (ListViewItemConfFile*)item; | 108 | _fileItem = (ListViewItemConfFile*)item; |
100 | return; | 109 | return; |
101 | }else editor->show(); | 110 | }else editor->show(); |
102 | _fileItem = 0; | 111 | _fileItem = 0; |
103 | _currentItem = (ListViewItemConfigEntry*)item; | 112 | _currentItem = (ListViewItemConfigEntry*)item; |
104 | if (!_currentItem) return; | 113 | if (!_currentItem) return; |
105 | QString file = _currentItem->getFile(); | 114 | QString file = _currentItem->getFile(); |
106 | QString group = _currentItem->getGroup(); | 115 | QString group = _currentItem->getGroup(); |
107 | QString key = _currentItem->getKey(); | 116 | QString key = _currentItem->getKey(); |
108 | QString val = _currentItem->getValue(); | 117 | QString val = _currentItem->getValue(); |
109 | editor->TextFileName->setText(file); | 118 | editor->TextFileName->setText(file); |
110 | editor->LineEditGroup->setText(group); | 119 | editor->LineEditGroup->setText(group); |
111 | if (!key.isEmpty()) | 120 | if (!key.isEmpty()) |
112 | { | 121 | { |
113 | editor->isKey(true); | 122 | editor->isKey(true); |
114 | editor->LineEditKey->setText(key); | 123 | editor->LineEditKey->setText(key); |
115 | editor->LineEditValue->setText(val); | 124 | editor->LineEditValue->setText(val); |
116 | }else{ | 125 | }else{ |
117 | editor->isKey(false); | 126 | editor->isKey(false); |
118 | } | 127 | } |
119 | updateGeometry(); | 128 | updateGeometry(); |
120 | } | 129 | } |
121 | 130 | ||
122 | 131 | ||
123 | void MainWindow::groupChanged(const QString &g) | 132 | void MainWindow::groupChanged(const QString &g) |
124 | { | 133 | { |
125 | if (!_currentItem) return; | 134 | if (!_currentItem) return; |
126 | _currentItem->setGroup(g); | 135 | _currentItem->setGroup(g); |
127 | } | 136 | } |
128 | 137 | ||
129 | void MainWindow::keyChanged(const QString &k) | 138 | void MainWindow::keyChanged(const QString &k) |
130 | { | 139 | { |
131 | if (!_currentItem) return; | 140 | if (!_currentItem) return; |
132 | _currentItem->keyChanged(k); | 141 | _currentItem->keyChanged(k); |
133 | } | 142 | } |
134 | 143 | ||
135 | void MainWindow::valueChanged(const QString &v) | 144 | void MainWindow::valueChanged(const QString &v) |
136 | { | 145 | { |
137 | if (!_currentItem) return; | 146 | if (!_currentItem) return; |
138 | _currentItem->valueChanged(v); | 147 | _currentItem->valueChanged(v); |
139 | } | 148 | } |
140 | 149 | ||
141 | 150 | ||
142 | void MainWindow::stopTimer( QListViewItem* ) | 151 | void MainWindow::stopTimer( QListViewItem* ) |
143 | { | 152 | { |
144 | qDebug("stopTimer"); | 153 | qDebug("stopTimer"); |
145 | popupTimer->stop(); | 154 | popupTimer->stop(); |
146 | } | 155 | } |
147 | 156 | ||
148 | void MainWindow::saveConfFile() | 157 | void MainWindow::saveConfFile() |
149 | { | 158 | { |
150 | if (!_fileItem) return; | 159 | if (!_fileItem) return; |
151 | _fileItem->save(); | 160 | _fileItem->save(); |
152 | } | 161 | } |
153 | 162 | ||
163 | void MainWindow::revertConfFile() | ||
164 | { | ||
165 | if (!_fileItem) return; | ||
166 | _fileItem->revert(); | ||
167 | } | ||
168 | |||
154 | void MainWindow::showPopup() | 169 | void MainWindow::showPopup() |
155 | { | 170 | { |
156 | qDebug("showPopup"); | 171 | qDebug("showPopup"); |
157 | if (!_fileItem) return; | 172 | if (_fileItem) |
158 | popupMenu->clear(); | 173 | { |
159 | 174 | popupActionSave->setEnabled(_fileItem->isChanged()); | |
160 | QAction *popupAction; | 175 | popupActionRevert->setEnabled(_fileItem->revertable()); |
161 | popupAction = new QAction( tr("Save"),QString::null, 0, this, 0 ); | 176 | popupMenuFile->popup( QCursor::pos() ); |
162 | popupAction->addTo( popupMenu ); | 177 | }else if(_currentItem->isChanged()) |
163 | connect( popupAction, SIGNAL( activated() ), | 178 | { |
164 | this , SLOT( saveConfFile() ) ); | ||
165 | |||
166 | 179 | ||
167 | popupMenu->popup( QCursor::pos() ); | 180 | } |
168 | } | 181 | } |
diff --git a/noncore/apps/confedit/mainwindow.h b/noncore/apps/confedit/mainwindow.h index b015dac..e0dc0b0 100644 --- a/noncore/apps/confedit/mainwindow.h +++ b/noncore/apps/confedit/mainwindow.h | |||
@@ -1,56 +1,64 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 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 * | 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 * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | #ifndef MAINWINDOW_H | 12 | #ifndef MAINWINDOW_H |
13 | #define MAINWINDOW_H | 13 | #define MAINWINDOW_H |
14 | 14 | ||
15 | #include <qmainwindow.h> | 15 | #include <qmainwindow.h> |
16 | #include <qaction.h> | 16 | #include <qaction.h> |
17 | #include <qtimer.h> | 17 | #include <qtimer.h> |
18 | #include <qpopupmenu.h> | 18 | #include <qpopupmenu.h> |
19 | #include "editwidget.h" | 19 | #include "editwidget.h" |
20 | 20 | ||
21 | class QPEToolBar; | 21 | class QPEToolBar; |
22 | class ListViewItemConfFile; | 22 | class ListViewItemConfFile; |
23 | class ListViewConfDir; | 23 | class ListViewConfDir; |
24 | 24 | ||
25 | 25 | ||
26 | class MainWindow : public QMainWindow | 26 | class MainWindow : public QMainWindow |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | 30 | ||
31 | public: | 31 | public: |
32 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 32 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
33 | ~MainWindow(); | 33 | ~MainWindow(); |
34 | 34 | ||
35 | 35 | ||
36 | public slots: | 36 | public slots: |
37 | void setCurrent(QListViewItem*); | 37 | void setCurrent(QListViewItem*); |
38 | void groupChanged(const QString&); | 38 | void groupChanged(const QString&); |
39 | void keyChanged(const QString&); | 39 | void keyChanged(const QString&); |
40 | void valueChanged(const QString&); | 40 | void valueChanged(const QString&); |
41 | void showPopup(); | 41 | void showPopup(); |
42 | void stopTimer( QListViewItem* ); | 42 | void stopTimer( QListViewItem* ); |
43 | void saveConfFile(); | 43 | void saveConfFile(); |
44 | void revertConfFile(); | ||
44 | 45 | ||
45 | private: | 46 | private: |
46 | ListViewConfDir *settingList; | 47 | ListViewConfDir *settingList; |
47 | EditWidget *editor; | 48 | EditWidget *editor; |
48 | ListViewItemConfigEntry *_currentItem; | 49 | ListViewItemConfigEntry *_currentItem; |
49 | ListViewItemConfFile *_fileItem; | 50 | ListViewItemConfFile *_fileItem; |
50 | QTimer *popupTimer; | 51 | QTimer *popupTimer; |
51 | QPopupMenu *popupMenu; | 52 | QPopupMenu *popupMenuFile; |
53 | QPopupMenu *popupMenuEntry; | ||
54 | QAction *popupActionSave; | ||
55 | QAction *popupActionRevert; | ||
56 | QAction *popupActionDelete; | ||
57 | QAction *popupActionNew; | ||
58 | //QAction *popupAction; | ||
59 | //QAction *popupAction; | ||
52 | 60 | ||
53 | void makeMenu(); | 61 | void makeMenu(); |
54 | }; | 62 | }; |
55 | 63 | ||
56 | #endif | 64 | #endif |