-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/confedit/opie-confedit.control | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 17a5058..fc403d2 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -1,212 +1,214 @@ | |||
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 | QWidget *mainWidget = new QWidget(this); | 41 | QWidget *mainWidget = new QWidget(this); |
42 | setCentralWidget( mainWidget); | 42 | setCentralWidget( mainWidget); |
43 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); | 43 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); |
44 | mainLayout->setSpacing( 3 ); | 44 | mainLayout->setSpacing( 3 ); |
45 | mainLayout->setMargin( 3 ); | 45 | mainLayout->setMargin( 3 ); |
46 | 46 | ||
47 | 47 | ||
48 | qDebug("settingList"); | 48 | qDebug("settingList"); |
49 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); | 49 | settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist"); |
50 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));//, sizePolicy().hasHeightForWidth() ) ); | 50 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));//, sizePolicy().hasHeightForWidth() ) ); |
51 | mainLayout->addWidget( settingList, 0, 0 ); | 51 | mainLayout->addWidget( settingList, 0, 0 ); |
52 | 52 | ||
53 | qDebug("editor"); | 53 | qDebug("editor"); |
54 | editor = new EditWidget(this); | 54 | editor = new EditWidget(this); |
55 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum));//, sizePolicy().hasHeightForWidth() ) ); | 55 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum));//, sizePolicy().hasHeightForWidth() ) ); |
56 | // editor->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3));//, sizePolicy().hasHeightForWidth() ) ); | 56 | // editor->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3));//, sizePolicy().hasHeightForWidth() ) ); |
57 | mainLayout->addWidget( editor, 1, 0 ); | 57 | mainLayout->addWidget( editor, 1, 0 ); |
58 | 58 | ||
59 | makeMenu(); | 59 | makeMenu(); |
60 | 60 | ||
61 | qDebug("connect"); | 61 | qDebug("connect"); |
62 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), | 62 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
63 | this, SLOT(setCurrent(QListViewItem*))); | 63 | this, SLOT(setCurrent(QListViewItem*))); |
64 | 64 | ||
65 | 65 | ||
66 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 66 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
67 | SLOT( groupChanged(const QString&) ) ); | 67 | SLOT( groupChanged(const QString&) ) ); |
68 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 68 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
69 | SLOT( keyChanged(const QString&) ) ); | 69 | SLOT( keyChanged(const QString&) ) ); |
70 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 70 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
71 | SLOT( valueChanged(const QString&) ) ); | 71 | SLOT( valueChanged(const QString&) ) ); |
72 | // qDebug("editor->hide()"); | 72 | // qDebug("editor->hide()"); |
73 | // editor->hide(); | 73 | // editor->hide(); |
74 | qDebug("connect"); | 74 | qDebug("connect"); |
75 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | 75 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), |
76 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 76 | this, SLOT( stopTimer( QListViewItem* ) ) ); |
77 | setCurrent(0); | ||
77 | } | 78 | } |
78 | 79 | ||
79 | void MainWindow::makeMenu() | 80 | void MainWindow::makeMenu() |
80 | { | 81 | { |
81 | qDebug("MainWindow::makeMenu()"); | 82 | qDebug("MainWindow::makeMenu()"); |
82 | 83 | ||
83 | popupTimer = new QTimer(this); | 84 | popupTimer = new QTimer(this); |
84 | popupMenuFile = new QPopupMenu(this); | 85 | popupMenuFile = new QPopupMenu(this); |
85 | popupMenuEntry = new QPopupMenu(this); | 86 | popupMenuEntry = new QPopupMenu(this); |
86 | 87 | ||
87 | qDebug("Save"); | 88 | qDebug("Save"); |
88 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); | 89 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); |
89 | popupActionSave->addTo( popupMenuFile ); | 90 | popupActionSave->addTo( popupMenuFile ); |
90 | // popupActionSave->addTo( popupMenuEntry ); | 91 | // popupActionSave->addTo( popupMenuEntry ); |
91 | connect( popupActionSave, SIGNAL( activated() ), | 92 | connect( popupActionSave, SIGNAL( activated() ), |
92 | this , SLOT( saveConfFile() ) ); | 93 | this , SLOT( saveConfFile() ) ); |
93 | 94 | ||
94 | qDebug("Revert"); | 95 | qDebug("Revert"); |
95 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); | 96 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); |
96 | popupActionRevert->addTo( popupMenuFile ); | 97 | popupActionRevert->addTo( popupMenuFile ); |
97 | popupActionRevert->addTo( popupMenuEntry ); | 98 | popupActionRevert->addTo( popupMenuEntry ); |
98 | connect( popupActionRevert, SIGNAL( activated() ), | 99 | connect( popupActionRevert, SIGNAL( activated() ), |
99 | this , SLOT( revertConfFile() ) ); | 100 | this , SLOT( revertConfFile() ) ); |
100 | 101 | ||
101 | qDebug("Delete"); | 102 | qDebug("Delete"); |
102 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); | 103 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); |
103 | popupActionDelete->addTo( popupMenuFile ); | 104 | popupActionDelete->addTo( popupMenuFile ); |
104 | popupActionDelete->addTo( popupMenuEntry ); | 105 | popupActionDelete->addTo( popupMenuEntry ); |
105 | connect( popupActionDelete, SIGNAL( activated() ), | 106 | connect( popupActionDelete, SIGNAL( activated() ), |
106 | this , SLOT( removeConfFile() ) ); | 107 | this , SLOT( removeConfFile() ) ); |
107 | 108 | ||
108 | qDebug("connect"); | 109 | qDebug("connect"); |
109 | connect( popupTimer, SIGNAL(timeout()), | 110 | connect( popupTimer, SIGNAL(timeout()), |
110 | this, SLOT(showPopup()) ); | 111 | this, SLOT(showPopup()) ); |
111 | qDebug("connect"); | 112 | qDebug("connect"); |
112 | } | 113 | } |
113 | 114 | ||
114 | MainWindow::~MainWindow() | 115 | MainWindow::~MainWindow() |
115 | { | 116 | { |
116 | } | 117 | } |
117 | 118 | ||
118 | 119 | ||
119 | 120 | ||
120 | void MainWindow::setCurrent(QListViewItem *item) | 121 | void MainWindow::setCurrent(QListViewItem *item) |
121 | { | 122 | { |
123 | editor->hide(); | ||
122 | if (!item) return; | 124 | if (!item) return; |
123 | _item = (ListViewItemConf*) item; | 125 | _item = (ListViewItemConf*) item; |
124 | if (!_item) return; | 126 | if (!_item) return; |
125 | popupTimer->start( 750, true ); | 127 | popupTimer->start( 750, true ); |
126 | if (_item->getType() == ListViewItemConf::File) | 128 | if (_item->getType() == ListViewItemConf::File) |
127 | { | 129 | { |
128 | editor->hide(); | ||
129 | updateGeometry(); | 130 | updateGeometry(); |
130 | _currentItem=0; | 131 | _currentItem=0; |
131 | _fileItem = (ListViewItemConfFile*)item; | 132 | _fileItem = (ListViewItemConfFile*)item; |
132 | return; | 133 | return; |
133 | }else editor->show(); | 134 | } |
135 | editor->show(); | ||
134 | _fileItem = 0; | 136 | _fileItem = 0; |
135 | _currentItem = (ListViewItemConfigEntry*)item; | 137 | _currentItem = (ListViewItemConfigEntry*)item; |
136 | if (!_currentItem) return; | 138 | if (!_currentItem) return; |
137 | QString file = _currentItem->getFile(); | 139 | QString file = _currentItem->getFile(); |
138 | QString group = _currentItem->getGroup(); | 140 | QString group = _currentItem->getGroup(); |
139 | QString key = _currentItem->getKey(); | 141 | QString key = _currentItem->getKey(); |
140 | QString val = _currentItem->getValue(); | 142 | QString val = _currentItem->getValue(); |
141 | editor->TextFileName->setText(file); | 143 | editor->TextFileName->setText(file); |
142 | editor->LineEditGroup->setText(group); | 144 | editor->LineEditGroup->setText(group); |
143 | if (!key.isEmpty()) | 145 | if (!key.isEmpty()) |
144 | { | 146 | { |
145 | editor->isKey(true); | 147 | editor->isKey(true); |
146 | editor->LineEditKey->setText(key); | 148 | editor->LineEditKey->setText(key); |
147 | editor->LineEditValue->setText(val); | 149 | editor->LineEditValue->setText(val); |
148 | }else{ | 150 | }else{ |
149 | editor->isKey(false); | 151 | editor->isKey(false); |
150 | } | 152 | } |
151 | updateGeometry(); | 153 | updateGeometry(); |
152 | editor->updateGeometry(); | 154 | editor->updateGeometry(); |
153 | settingList->updateGeometry(); | 155 | settingList->updateGeometry(); |
154 | } | 156 | } |
155 | 157 | ||
156 | 158 | ||
157 | void MainWindow::groupChanged(const QString &g) | 159 | void MainWindow::groupChanged(const QString &g) |
158 | { | 160 | { |
159 | if (!_currentItem) return; | 161 | if (!_currentItem) return; |
160 | _currentItem->setGroup(g); | 162 | _currentItem->setGroup(g); |
161 | } | 163 | } |
162 | 164 | ||
163 | void MainWindow::keyChanged(const QString &k) | 165 | void MainWindow::keyChanged(const QString &k) |
164 | { | 166 | { |
165 | if (!_currentItem) return; | 167 | if (!_currentItem) return; |
166 | _currentItem->keyChanged(k); | 168 | _currentItem->keyChanged(k); |
167 | } | 169 | } |
168 | 170 | ||
169 | void MainWindow::valueChanged(const QString &v) | 171 | void MainWindow::valueChanged(const QString &v) |
170 | { | 172 | { |
171 | if (!_currentItem) return; | 173 | if (!_currentItem) return; |
172 | _currentItem->valueChanged(v); | 174 | _currentItem->valueChanged(v); |
173 | } | 175 | } |
174 | 176 | ||
175 | 177 | ||
176 | void MainWindow::stopTimer( QListViewItem* ) | 178 | void MainWindow::stopTimer( QListViewItem* ) |
177 | { | 179 | { |
178 | popupTimer->stop(); | 180 | popupTimer->stop(); |
179 | } | 181 | } |
180 | 182 | ||
181 | void MainWindow::saveConfFile() | 183 | void MainWindow::saveConfFile() |
182 | { | 184 | { |
183 | if (!_fileItem) return; | 185 | if (!_fileItem) return; |
184 | _fileItem->save(); | 186 | _fileItem->save(); |
185 | } | 187 | } |
186 | 188 | ||
187 | void MainWindow::revertConfFile() | 189 | void MainWindow::revertConfFile() |
188 | { | 190 | { |
189 | if (!_item) return; | 191 | if (!_item) return; |
190 | _item->revert(); | 192 | _item->revert(); |
191 | } | 193 | } |
192 | 194 | ||
193 | void MainWindow::removeConfFile() | 195 | void MainWindow::removeConfFile() |
194 | { | 196 | { |
195 | if (!_item) return; | 197 | if (!_item) return; |
196 | _item->remove(); | 198 | _item->remove(); |
197 | } | 199 | } |
198 | void MainWindow::showPopup() | 200 | void MainWindow::showPopup() |
199 | { | 201 | { |
200 | qDebug("showPopup"); | 202 | qDebug("showPopup"); |
201 | if (!_item) return; | 203 | if (!_item) return; |
202 | popupActionRevert->setEnabled(_item->revertable()); | 204 | popupActionRevert->setEnabled(_item->revertable()); |
203 | popupActionSave->setEnabled(_item->isChanged()); | 205 | popupActionSave->setEnabled(_item->isChanged()); |
204 | if (_fileItem) | 206 | if (_fileItem) |
205 | { | 207 | { |
206 | popupActionSave->setEnabled(_fileItem->isChanged()); | 208 | popupActionSave->setEnabled(_fileItem->isChanged()); |
207 | popupMenuFile->popup( QCursor::pos() ); | 209 | popupMenuFile->popup( QCursor::pos() ); |
208 | }else if(_currentItem) | 210 | }else if(_currentItem) |
209 | { | 211 | { |
210 | popupMenuEntry->popup( QCursor::pos() ); | 212 | popupMenuEntry->popup( QCursor::pos() ); |
211 | } | 213 | } |
212 | } | 214 | } |
diff --git a/noncore/apps/confedit/opie-confedit.control b/noncore/apps/confedit/opie-confedit.control new file mode 100644 index 0000000..a5491f8 --- a/dev/null +++ b/noncore/apps/confedit/opie-confedit.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Packagename: opie-confeditor | ||
2 | Files: bin/confedit apps/Settings/confedit.desktop pics/confedit/confedit.png | ||
3 | Priority: optional | ||
4 | Section: opie/ | ||
5 | Maintainer: Patrick S. Vogt <tille@handhelds.org> | ||
6 | Architecture: arm | ||
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: opie-base ($QPE_VERSION) | ||
9 | Description: An enditor for the ~/Settings/*.conf files | ||
10 | |||