summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp211
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h38
2 files changed, 141 insertions, 108 deletions
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index d9a67f3..6805863 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -1,643 +1,654 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7 .>+-= 7 .>+-=
8_;:, .> :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12- . .-<_> .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14 .%`+i> _;_. 14 .%`+i> _;_.
15 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22: = ...= . :.=- 22: = ...= . :.=-
23-. .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "oipkgconfigdlg.h" 32#include "oipkgconfigdlg.h"
33 33
34#include <opie2/ofiledialog.h> 34#include <opie2/ofiledialog.h>
35 35
36#include <qpe/qpeapplication.h>
36#include <qpe/resource.h> 37#include <qpe/resource.h>
37 38
38#include <qcheckbox.h> 39#include <qcheckbox.h>
39#include <qcombobox.h> 40#include <qcombobox.h>
40#include <qgroupbox.h> 41#include <qgroupbox.h>
41#include <qlabel.h> 42#include <qlabel.h>
42#include <qlineedit.h> 43#include <qlineedit.h>
43#include <qlistbox.h> 44#include <qlistbox.h>
44#include <qpushbutton.h> 45#include <qpushbutton.h>
45#include <qscrollview.h> 46#include <qscrollview.h>
46#include <qwhatsthis.h> 47#include <qwhatsthis.h>
47 48
48OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 49OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
49 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 50 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
50 , m_ipkg( ipkg ) 51 , m_ipkg( ipkg )
51 , m_configs( 0x0 ) 52 , m_configs( 0l )
52 , m_installOptions( installOptions ) 53 , m_installOptions( installOptions )
53 , m_serverNew( false ) 54 , m_serverNew( false )
54 , m_serverCurrent( -1 ) 55 , m_serverCurrent( -1 )
55 , m_destNew( false ) 56 , m_destNew( false )
56 , m_destCurrent( -1 ) 57 , m_destCurrent( -1 )
57 , m_layout( this, 2, 4 ) 58 , m_layout( this, 2, 4 )
58 , m_tabWidget( this ) 59 , m_tabWidget( this )
59{ 60{
60 setCaption( tr( "Configuration" ) ); 61 setCaption( tr( "Configuration" ) );
61 62
62 // Initialize configuration widgets 63 // Initialize configuration widgets
63 if ( !installOptions ) 64 if ( !installOptions )
64 { 65 {
65 initServerWidget(); 66 initServerWidget();
66 initDestinationWidget(); 67 initDestinationWidget();
67 initProxyWidget(); 68 initProxyWidget();
68 } 69 }
69 initOptionsWidget(); 70 initOptionsWidget();
70 71
71 // Load configuration information 72 // Load configuration information
72 initData(); 73 initData();
73 74
74 // Setup tabs for all info 75 // Setup tabs for all info
75 m_layout.addWidget( &m_tabWidget ); 76 m_layout.addWidget( &m_tabWidget );
76 if ( !m_installOptions ) 77 if ( !m_installOptions )
77 { 78 {
78 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); 79 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
79 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); 80 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
80 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); 81 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
81 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 82 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
82 m_tabWidget.setCurrentTab( tr( "Servers" ) ); 83 m_tabWidget.setCurrentTab( tr( "Servers" ) );
83 } 84 }
84 else 85 else
85 { 86 {
86 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 87 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
87 } 88 }
88} 89}
89 90
90void OIpkgConfigDlg::accept() 91void OIpkgConfigDlg::accept()
91{ 92{
92 // Save server, destination and proxy configuration 93 // Save server, destination and proxy configuration
93 if ( !m_installOptions ) 94 if ( !m_installOptions )
94 { 95 {
95 // Update proxy information before saving settings 96 // Update proxy information before saving settings
96 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" ); 97 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" );
97 if ( confItem ) 98 if ( confItem )
98 { 99 {
99 confItem->setValue( m_proxyHttpServer->text() ); 100 confItem->setValue( m_proxyHttpServer->text() );
100 confItem->setActive( m_proxyHttpActive->isChecked() ); 101 confItem->setActive( m_proxyHttpActive->isChecked() );
101 } 102 }
102 else 103 else
103 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", 104 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy",
104 m_proxyHttpServer->text(), QString::null, 105 m_proxyHttpServer->text(), QString::null,
105 m_proxyHttpActive->isChecked() ) ); 106 m_proxyHttpActive->isChecked() ) );
106 107
107 confItem = findConfItem( OConfItem::Option, "ftp_proxy" ); 108 confItem = findConfItem( OConfItem::Option, "ftp_proxy" );
108 if ( confItem ) 109 if ( confItem )
109 { 110 {
110 confItem->setValue( m_proxyFtpServer->text() ); 111 confItem->setValue( m_proxyFtpServer->text() );
111 confItem->setActive( m_proxyFtpActive->isChecked() ); 112 confItem->setActive( m_proxyFtpActive->isChecked() );
112 } 113 }
113 else 114 else
114 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", 115 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy",
115 m_proxyFtpServer->text(), QString::null, 116 m_proxyFtpServer->text(), QString::null,
116 m_proxyFtpActive->isChecked() ) ); 117 m_proxyFtpActive->isChecked() ) );
117 118
118 confItem = findConfItem( OConfItem::Option, "proxy_username" ); 119 confItem = findConfItem( OConfItem::Option, "proxy_username" );
119 if ( confItem ) 120 if ( confItem )
120 confItem->setValue( m_proxyUsername->text() ); 121 confItem->setValue( m_proxyUsername->text() );
121 else 122 else
122 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", 123 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username",
123 m_proxyUsername->text() ) ); 124 m_proxyUsername->text() ) );
124 125
125 confItem = findConfItem( OConfItem::Option, "proxy_password" ); 126 confItem = findConfItem( OConfItem::Option, "proxy_password" );
126 if ( confItem ) 127 if ( confItem )
127 confItem->setValue( m_proxyPassword->text() ); 128 confItem->setValue( m_proxyPassword->text() );
128 else 129 else
129 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", 130 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password",
130 m_proxyPassword->text() ) ); 131 m_proxyPassword->text() ) );
131 132
132 m_ipkg->setConfigItems( m_configs ); 133 m_ipkg->setConfigItems( m_configs );
133 } 134 }
134 135
135 // Save options configuration 136 // Save options configuration
136 int options = 0; 137 int options = 0;
137 if ( m_optForceDepends->isChecked() ) 138 if ( m_optForceDepends->isChecked() )
138 options |= FORCE_DEPENDS; 139 options |= FORCE_DEPENDS;
139 if ( m_optForceReinstall->isChecked() ) 140 if ( m_optForceReinstall->isChecked() )
140 options |= FORCE_REINSTALL; 141 options |= FORCE_REINSTALL;
141 if ( m_optForceRemove->isChecked() ) 142 if ( m_optForceRemove->isChecked() )
142 options |= FORCE_REMOVE; 143 options |= FORCE_REMOVE;
143 if ( m_optForceOverwrite->isChecked() ) 144 if ( m_optForceOverwrite->isChecked() )
144 options |= FORCE_OVERWRITE; 145 options |= FORCE_OVERWRITE;
145 m_ipkg->setIpkgExecOptions( options ); 146 m_ipkg->setIpkgExecOptions( options );
146 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); 147 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
147 148
148 QDialog::accept(); 149 QDialog::accept();
149} 150}
150 151
151void OIpkgConfigDlg::reject() 152void OIpkgConfigDlg::reject()
152{ 153{
153 if ( m_configs ) 154 if ( m_configs )
154 delete m_configs; 155 delete m_configs;
155} 156}
156 157
157void OIpkgConfigDlg::initServerWidget() 158void OIpkgConfigDlg::initServerWidget()
158{ 159{
159 m_serverWidget = new QWidget( this ); 160 m_serverWidget = new QWidget( this );
160 161
161 // Initialize UI 162 // Initialize UI
162 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); 163 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
163 QScrollView *sv = new QScrollView( m_serverWidget ); 164 QScrollView *sv = new QScrollView( m_serverWidget );
164 vb->addWidget( sv, 0, 0 ); 165 vb->addWidget( sv, 0, 0 );
165 sv->setResizePolicy( QScrollView::AutoOneFit ); 166 sv->setResizePolicy( QScrollView::AutoOneFit );
166 sv->setFrameStyle( QFrame::NoFrame ); 167 sv->setFrameStyle( QFrame::NoFrame );
167 QWidget *container = new QWidget( sv->viewport() ); 168 QWidget *container = new QWidget( sv->viewport() );
168 sv->addChild( container ); 169 sv->addChild( container );
169 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 170 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
170 171
171 m_serverList = new QListBox( container ); 172 m_serverList = new QListBox( container );
172 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); 173 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) );
173 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 174 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
174 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); 175 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
175 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 176 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
176 177
177 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 178 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
178 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 179 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
179 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); 180 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
180 layout->addWidget( btn, 1, 0 ); 181 layout->addWidget( btn, 1, 0 );
181 182
182 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 183 m_serverEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container );
183 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 184 m_serverEditBtn->setEnabled( false );
184 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 185 QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) );
185 layout->addWidget( btn, 1, 1 ); 186 connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) );
186 187 layout->addWidget( m_serverEditBtn, 1, 1 );
187 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 188
188 grpbox->layout()->setSpacing( 2 ); 189 m_serverDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
189 grpbox->layout()->setMargin( 4 ); 190 m_serverDeleteBtn->setEnabled( false );
190 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 191 QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
191 192 connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
192 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 193 layout->addWidget( m_serverDeleteBtn, 1, 2 );
193
194 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
195 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
196 grplayout->addWidget( label, 0, 0 );
197 m_serverName = new QLineEdit( grpbox );
198 QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) );
199 grplayout->addWidget( m_serverName, 0, 1 );
200
201 label = new QLabel( tr( "Address:" ), grpbox );
202 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
203 grplayout->addWidget( label, 1, 0 );
204 m_serverLocation = new QLineEdit( grpbox );
205 QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) );
206 grplayout->addWidget( m_serverLocation, 1, 1 );
207
208 m_serverActive = new QCheckBox( tr( "Active" ), grpbox );
209 QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) );
210 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
211
212 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
213 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
214 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
215 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
216} 194}
217 195
218void OIpkgConfigDlg::initDestinationWidget() 196void OIpkgConfigDlg::initDestinationWidget()
219{ 197{
220 m_destWidget = new QWidget( this ); 198 m_destWidget = new QWidget( this );
221 199
222 // Initialize UI 200 // Initialize UI
223 QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); 201 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
224 QScrollView *sv = new QScrollView( m_destWidget ); 202 QScrollView *sv = new QScrollView( m_destWidget );
225 vb->addWidget( sv, 0, 0 ); 203 vb->addWidget( sv, 0, 0 );
226 sv->setResizePolicy( QScrollView::AutoOneFit ); 204 sv->setResizePolicy( QScrollView::AutoOneFit );
227 sv->setFrameStyle( QFrame::NoFrame ); 205 sv->setFrameStyle( QFrame::NoFrame );
228 QWidget *container = new QWidget( sv->viewport() ); 206 QWidget *container = new QWidget( sv->viewport() );
229 sv->addChild( container ); 207 sv->addChild( container );
230 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 208 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
231 209
232 m_destList = new QListBox( container ); 210 m_destList = new QListBox( container );
233 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); 211 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) );
234 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 212 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
235 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); 213 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) );
236 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); 214 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 );
237 215
238 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 216 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
239 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 217 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
240 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); 218 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
241 layout->addWidget( btn, 1, 0 ); 219 layout->addWidget( btn, 1, 0 );
242 220
243 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 221 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
244 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 222 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) );
245 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); 223 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
246 layout->addWidget( btn, 1, 1 ); 224 layout->addWidget( btn, 1, 1 );
247 225
248 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); 226 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container );
249 grpbox->layout()->setSpacing( 2 ); 227 grpbox->layout()->setSpacing( 2 );
250 grpbox->layout()->setMargin( 4 ); 228 grpbox->layout()->setMargin( 4 );
251 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 229 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
252 230
253 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 231 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
254 232
255 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 233 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
256 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); 234 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
257 grplayout->addWidget( label, 0, 0 ); 235 grplayout->addWidget( label, 0, 0 );
258 m_destName = new QLineEdit( grpbox ); 236 m_destName = new QLineEdit( grpbox );
259 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) ); 237 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) );
260 grplayout->addMultiCellWidget( m_destName, 0, 0, 1, 2 ); 238 grplayout->addMultiCellWidget( m_destName, 0, 0, 1, 2 );
261 239
262 label = new QLabel( tr( "Location:" ), grpbox ); 240 label = new QLabel( tr( "Location:" ), grpbox );
263 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) ); 241 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
264 grplayout->addWidget( label, 1, 0 ); 242 grplayout->addWidget( label, 1, 0 );
265 m_destLocation = new QLineEdit( grpbox ); 243 m_destLocation = new QLineEdit( grpbox );
266 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) ); 244 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) );
267 grplayout->addWidget( m_destLocation, 1, 1 ); 245 grplayout->addWidget( m_destLocation, 1, 1 );
268 btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, grpbox ); 246 btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, grpbox );
269 btn->setMaximumWidth( btn->height() ); 247 btn->setMaximumWidth( btn->height() );
270 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) ); 248 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
271 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestSelectPath()) ); 249 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestSelectPath()) );
272 grplayout->addWidget( btn, 1, 2 ); 250 grplayout->addWidget( btn, 1, 2 );
273 251
274 m_destActive = new QCheckBox( tr( "Active" ), grpbox ); 252 m_destActive = new QCheckBox( tr( "Active" ), grpbox );
275 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) ); 253 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) );
276 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 2 ); 254 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 2 );
277 255
278 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 256 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
279 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) ); 257 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
280 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) ); 258 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) );
281 grplayout->addMultiCellWidget( btn, 3, 3, 0, 2 ); 259 grplayout->addMultiCellWidget( btn, 3, 3, 0, 2 );
282} 260}
283 261
284void OIpkgConfigDlg::initProxyWidget() 262void OIpkgConfigDlg::initProxyWidget()
285{ 263{
286 m_proxyWidget = new QWidget( this ); 264 m_proxyWidget = new QWidget( this );
287 265
288 // Initialize UI 266 // Initialize UI
289 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); 267 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
290 QScrollView *sv = new QScrollView( m_proxyWidget ); 268 QScrollView *sv = new QScrollView( m_proxyWidget );
291 vb->addWidget( sv, 0, 0 ); 269 vb->addWidget( sv, 0, 0 );
292 sv->setResizePolicy( QScrollView::AutoOneFit ); 270 sv->setResizePolicy( QScrollView::AutoOneFit );
293 sv->setFrameStyle( QFrame::NoFrame ); 271 sv->setFrameStyle( QFrame::NoFrame );
294 QWidget *container = new QWidget( sv->viewport() ); 272 QWidget *container = new QWidget( sv->viewport() );
295 sv->addChild( container ); 273 sv->addChild( container );
296 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); 274 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 );
297 275
298 // HTTP proxy server configuration 276 // HTTP proxy server configuration
299 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); 277 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
300 grpbox->layout()->setSpacing( 2 ); 278 grpbox->layout()->setSpacing( 2 );
301 grpbox->layout()->setMargin( 4 ); 279 grpbox->layout()->setMargin( 4 );
302 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); 280 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
303 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 281 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
304 m_proxyHttpServer = new QLineEdit( grpbox ); 282 m_proxyHttpServer = new QLineEdit( grpbox );
305 QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); 283 QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) );
306 grplayout->addWidget( m_proxyHttpServer ); 284 grplayout->addWidget( m_proxyHttpServer );
307 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 285 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox );
308 QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); 286 QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) );
309 grplayout->addWidget( m_proxyHttpActive ); 287 grplayout->addWidget( m_proxyHttpActive );
310 288
311 // FTP proxy server configuration 289 // FTP proxy server configuration
312 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); 290 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
313 grpbox->layout()->setSpacing( 2 ); 291 grpbox->layout()->setSpacing( 2 );
314 grpbox->layout()->setMargin( 4 ); 292 grpbox->layout()->setMargin( 4 );
315 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); 293 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
316 grplayout = new QVBoxLayout( grpbox->layout() ); 294 grplayout = new QVBoxLayout( grpbox->layout() );
317 m_proxyFtpServer = new QLineEdit( grpbox ); 295 m_proxyFtpServer = new QLineEdit( grpbox );
318 QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) ); 296 QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) );
319 grplayout->addWidget( m_proxyFtpServer ); 297 grplayout->addWidget( m_proxyFtpServer );
320 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 298 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox );
321 QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); 299 QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) );
322 grplayout->addWidget( m_proxyFtpActive ); 300 grplayout->addWidget( m_proxyFtpActive );
323 301
324 // Proxy server username and password configuration 302 // Proxy server username and password configuration
325 QLabel *label = new QLabel( tr( "Username:" ), container ); 303 QLabel *label = new QLabel( tr( "Username:" ), container );
326 QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); 304 QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) );
327 layout->addWidget( label, 2, 0 ); 305 layout->addWidget( label, 2, 0 );
328 m_proxyUsername = new QLineEdit( container ); 306 m_proxyUsername = new QLineEdit( container );
329 QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); 307 QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) );
330 layout->addWidget( m_proxyUsername, 2, 1 ); 308 layout->addWidget( m_proxyUsername, 2, 1 );
331 309
332 label = new QLabel( tr( "Password:" ), container ); 310 label = new QLabel( tr( "Password:" ), container );
333 QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); 311 QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) );
334 layout->addWidget( label, 3, 0 ); 312 layout->addWidget( label, 3, 0 );
335 m_proxyPassword = new QLineEdit( container ); 313 m_proxyPassword = new QLineEdit( container );
336 QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); 314 QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) );
337 layout->addWidget( m_proxyPassword, 3, 1 ); 315 layout->addWidget( m_proxyPassword, 3, 1 );
338} 316}
339 317
340void OIpkgConfigDlg::initOptionsWidget() 318void OIpkgConfigDlg::initOptionsWidget()
341{ 319{
342 m_optionsWidget = new QWidget( this ); 320 m_optionsWidget = new QWidget( this );
343 321
344 // Initialize UI 322 // Initialize UI
345 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); 323 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget );
346 QScrollView *sv = new QScrollView( m_optionsWidget ); 324 QScrollView *sv = new QScrollView( m_optionsWidget );
347 vb->addWidget( sv, 0, 0 ); 325 vb->addWidget( sv, 0, 0 );
348 sv->setResizePolicy( QScrollView::AutoOneFit ); 326 sv->setResizePolicy( QScrollView::AutoOneFit );
349 sv->setFrameStyle( QFrame::NoFrame ); 327 sv->setFrameStyle( QFrame::NoFrame );
350 QWidget *container = new QWidget( sv->viewport() ); 328 QWidget *container = new QWidget( sv->viewport() );
351 sv->addChild( container ); 329 sv->addChild( container );
352 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 ); 330 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 );
353 331
354 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); 332 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
355 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); 333 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) );
356 layout->addWidget( m_optForceDepends ); 334 layout->addWidget( m_optForceDepends );
357 335
358 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); 336 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
359 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); 337 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) );
360 layout->addWidget( m_optForceReinstall ); 338 layout->addWidget( m_optForceReinstall );
361 339
362 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); 340 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
363 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); 341 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) );
364 layout->addWidget( m_optForceRemove ); 342 layout->addWidget( m_optForceRemove );
365 343
366 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); 344 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
367 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); 345 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) );
368 layout->addWidget( m_optForceOverwrite ); 346 layout->addWidget( m_optForceOverwrite );
369 347
370 QLabel *l = new QLabel( tr( "Information Level" ), container ); 348 QLabel *l = new QLabel( tr( "Information Level" ), container );
371 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); 349 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) );
372 layout->addWidget( l ); 350 layout->addWidget( l );
373 351
374 m_optVerboseIpkg = new QComboBox( container ); 352 m_optVerboseIpkg = new QComboBox( container );
375 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); 353 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) );
376 m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); 354 m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
377 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); 355 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
378 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); 356 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
379 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); 357 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
380 layout->addWidget( m_optVerboseIpkg ); 358 layout->addWidget( m_optVerboseIpkg );
381 359
382 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 360 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
383} 361}
384 362
385void OIpkgConfigDlg::initData() 363void OIpkgConfigDlg::initData()
386{ 364{
387 // Read ipkg configuration (server/destination/proxy) information 365 // Read ipkg configuration (server/destination/proxy) information
388 if ( m_ipkg && !m_installOptions ) 366 if ( m_ipkg && !m_installOptions )
389 { 367 {
390 m_configs = m_ipkg->configItems(); 368 m_configs = m_ipkg->configItems();
391 if ( m_configs ) 369 if ( m_configs )
392 { 370 {
393 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) 371 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
394 { 372 {
395 OConfItem *config = configIt.current(); 373 OConfItem *config = configIt.current();
396 374
397 // Add configuration item to the appropriate dialog controls 375 // Add configuration item to the appropriate dialog controls
398 if ( config ) 376 if ( config )
399 { 377 {
400 if ( config->type() == OConfItem::Source ) 378 if ( config->type() == OConfItem::Source )
401 { 379 {
402 m_serverList->insertItem( config->name() ); 380 m_serverList->insertItem( config->name() );
403 } 381 }
404 else if ( config->type() == OConfItem::Destination ) 382 else if ( config->type() == OConfItem::Destination )
405 { 383 {
406 m_destList->insertItem( config->name() ); 384 m_destList->insertItem( config->name() );
407 } 385 }
408 else if ( config->type() == OConfItem::Option ) 386 else if ( config->type() == OConfItem::Option )
409 { 387 {
410 if ( config->name() == "http_proxy" ) 388 if ( config->name() == "http_proxy" )
411 { 389 {
412 m_proxyHttpServer->setText( config->value() ); 390 m_proxyHttpServer->setText( config->value() );
413 m_proxyHttpActive->setChecked( config->active() ); 391 m_proxyHttpActive->setChecked( config->active() );
414 } 392 }
415 else if ( config->name() == "ftp_proxy" ) 393 else if ( config->name() == "ftp_proxy" )
416 { 394 {
417 m_proxyFtpServer->setText( config->value() ); 395 m_proxyFtpServer->setText( config->value() );
418 m_proxyFtpActive->setChecked( config->active() ); 396 m_proxyFtpActive->setChecked( config->active() );
419 } 397 }
420 else if ( config->name() == "proxy_username" ) 398 else if ( config->name() == "proxy_username" )
421 { 399 {
422 m_proxyUsername->setText( config->value() ); 400 m_proxyUsername->setText( config->value() );
423 } 401 }
424 else if ( config->name() == "proxy_password" ) 402 else if ( config->name() == "proxy_password" )
425 { 403 {
426 m_proxyPassword->setText( config->value() ); 404 m_proxyPassword->setText( config->value() );
427 } 405 }
428 } 406 }
429 } 407 }
430 } 408 }
431 } 409 }
432 } 410 }
433 411
434 // Get Ipkg execution options 412 // Get Ipkg execution options
435 int options = m_ipkg->ipkgExecOptions(); 413 int options = m_ipkg->ipkgExecOptions();
436 if ( options & FORCE_DEPENDS ) 414 if ( options & FORCE_DEPENDS )
437 m_optForceDepends->setChecked( true ); 415 m_optForceDepends->setChecked( true );
438 if ( options & FORCE_REINSTALL ) 416 if ( options & FORCE_REINSTALL )
439 m_optForceReinstall->setChecked( true ); 417 m_optForceReinstall->setChecked( true );
440 if ( options & FORCE_REMOVE ) 418 if ( options & FORCE_REMOVE )
441 m_optForceRemove->setChecked( true ); 419 m_optForceRemove->setChecked( true );
442 if ( options & FORCE_OVERWRITE ) 420 if ( options & FORCE_OVERWRITE )
443 m_optForceOverwrite->setChecked( true ); 421 m_optForceOverwrite->setChecked( true );
444 422
445 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); 423 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
446} 424}
447 425
448OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name ) 426OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name )
449{ 427{
450 // Find selected server in list 428 // Find selected server in list
451 OConfItemListIterator configIt( *m_configs ); 429 OConfItemListIterator configIt( *m_configs );
452 OConfItem *config = 0x0; 430 OConfItem *config = 0l;
453 for ( ; configIt.current(); ++configIt ) 431 for ( ; configIt.current(); ++configIt )
454 { 432 {
455 config = configIt.current(); 433 config = configIt.current();
456 if ( config->type() == type && config->name() == name ) 434 if ( config->type() == type && config->name() == name )
457 break; 435 break;
458 } 436 }
459 437
460 if ( config && config->type() == type && config->name() == name ) 438 if ( config && config->type() == type && config->name() == name )
461 return config; 439 return config;
462 440
463 return 0x0; 441 return 0l;
464} 442}
465 443
466void OIpkgConfigDlg::slotServerEdit( int index ) 444void OIpkgConfigDlg::slotServerSelected( int index )
467{ 445{
468 m_serverNew = false;
469 m_serverCurrent = index; 446 m_serverCurrent = index;
470 447
471 // Find selected server in list 448 // Enable Edit and Delete buttons
472 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 449 m_serverEditBtn->setEnabled( true );
473 450 m_serverDeleteBtn->setEnabled( true );
474 // Display server details
475 if ( server )
476 {
477 m_serverCurrName = server->name();
478 m_serverName->setText( server->name() );
479 m_serverLocation->setText( server->value() );
480 m_serverActive->setChecked( server->active() );
481 m_serverName->setFocus();
482 }
483} 451}
484 452
485void OIpkgConfigDlg::slotServerNew() 453void OIpkgConfigDlg::slotServerNew()
486{ 454{
487 m_serverNew = true; 455 OConfItem *server = new OConfItem( OConfItem::Source );
456
457 OIpkgServerDlg dlg( server, this );
458 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
459 {
460 // Add to configuration option list
461 m_configs->append( server );
462 m_configs->sort();
488 463
489 m_serverName->setText( QString::null ); 464 // Add to server list
490 m_serverLocation->setText( QString::null ); 465 m_serverList->insertItem( server->name() );
491 m_serverActive->setChecked( true ); 466 m_serverList->setCurrentItem( m_serverList->count() );
492 m_serverName->setFocus(); 467 }
468 else
469 delete server;
493} 470}
494 471
495void OIpkgConfigDlg::slotServerDelete() 472void OIpkgConfigDlg::slotServerEdit()
496{ 473{
497 // Find selected server in list 474 // Find selected server in list
498 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 475 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
499 476
500 // Delete server 477 // Delete server
501 if ( server ) 478 if ( server )
502 { 479 {
503 m_configs->removeRef( server ); 480 QString origName = server->name();
504 m_serverList->removeItem( m_serverCurrent ); 481 OIpkgServerDlg dlg( server, this );
482 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
483 {
484 // Check to see if name has changed, if so update the server list
485 if ( server->name() != origName )
486 m_serverList->changeItem( server->name(), m_serverCurrent );
487 }
505 } 488 }
506} 489}
507 490
508void OIpkgConfigDlg::slotServerUpdate() 491void OIpkgConfigDlg::slotServerDelete()
509{ 492{
510 QString newName = m_serverName->text(); 493 // Find selected server in list
511 494 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
512 // Convert any spaces to underscores
513 newName.replace( QRegExp( " " ), "_" );
514
515 if ( !m_serverNew )
516 {
517 // Find selected server in list
518 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName );
519
520 // Delete server
521 if ( server )
522 {
523 // Update url
524 server->setValue( m_serverLocation->text() );
525 server->setActive( m_serverActive->isChecked() );
526
527 // Check if server name has changed, if it has then we need to replace the key in the map
528 if ( m_serverCurrName != newName )
529 {
530 // Update server name
531 server->setName( newName );
532 495
533 // Update list box 496 // Delete server
534 m_serverList->changeItem( newName, m_serverCurrent ); 497 if ( server )
535 }
536 }
537 }
538 else
539 { 498 {
540 // Add new server to configuration list 499 m_configs->removeRef( server );
541 // TODO - support src/gz 500 m_serverList->removeItem( m_serverCurrent );
542 m_configs->append( new OConfItem( OConfItem::Source, newName, m_serverLocation->text(),
543 QString::null, m_serverActive->isChecked() ) );
544 m_configs->sort();
545
546 m_serverList->insertItem( newName );
547 m_serverList->setCurrentItem( m_serverList->count() );
548 m_serverNew = false;
549 } 501 }
550} 502}
551 503
552void OIpkgConfigDlg::slotDestEdit( int index ) 504void OIpkgConfigDlg::slotDestEdit( int index )
553{ 505{
554 m_destNew = false; 506 m_destNew = false;
555 m_destCurrent = index; 507 m_destCurrent = index;
556 508
557 // Find selected destination in list 509 // Find selected destination in list
558 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 510 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
559 511
560 // Display destination details 512 // Display destination details
561 if ( destination ) 513 if ( destination )
562 { 514 {
563 m_destCurrName = destination->name(); 515 m_destCurrName = destination->name();
564 m_destName->setText( destination->name() ); 516 m_destName->setText( destination->name() );
565 m_destLocation->setText( destination->value() ); 517 m_destLocation->setText( destination->value() );
566 m_destActive->setChecked( destination->active() ); 518 m_destActive->setChecked( destination->active() );
567 m_destName->setFocus(); 519 m_destName->setFocus();
568 } 520 }
569} 521}
570 522
571void OIpkgConfigDlg::slotDestNew() 523void OIpkgConfigDlg::slotDestNew()
572{ 524{
573 m_destNew = true; 525 m_destNew = true;
574 526
575 m_destName->setText( QString::null ); 527 m_destName->setText( QString::null );
576 m_destLocation->setText( QString::null ); 528 m_destLocation->setText( QString::null );
577 m_destActive->setChecked( true ); 529 m_destActive->setChecked( true );
578 m_destName->setFocus(); 530 m_destName->setFocus();
579} 531}
580 532
581void OIpkgConfigDlg::slotDestDelete() 533void OIpkgConfigDlg::slotDestDelete()
582{ 534{
583 // Find selected destination in list 535 // Find selected destination in list
584 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 536 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
585 537
586 // Delete destination 538 // Delete destination
587 if ( destination ) 539 if ( destination )
588 { 540 {
589 m_configs->removeRef( destination ); 541 m_configs->removeRef( destination );
590 m_destList->removeItem( m_destCurrent ); 542 m_destList->removeItem( m_destCurrent );
591 } 543 }
592} 544}
593 545
594void OIpkgConfigDlg::slotDestSelectPath() 546void OIpkgConfigDlg::slotDestSelectPath()
595{ 547{
596 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_destLocation->text() ); 548 QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_destLocation->text() );
597 if ( path.at( path.length() - 1 ) == '/' ) 549 if ( path.at( path.length() - 1 ) == '/' )
598 path.truncate( path.length() - 1 ); 550 path.truncate( path.length() - 1 );
599 m_destLocation->setText( path ); 551 m_destLocation->setText( path );
600} 552}
601 553
602void OIpkgConfigDlg::slotDestUpdate() 554void OIpkgConfigDlg::slotDestUpdate()
603{ 555{
604 QString newName = m_destName->text(); 556 QString newName = m_destName->text();
605 557
606 // Convert any spaces to underscores 558 // Convert any spaces to underscores
607 newName.replace( QRegExp( " " ), "_" ); 559 newName.replace( QRegExp( " " ), "_" );
608 560
609 if ( !m_destNew ) 561 if ( !m_destNew )
610 { 562 {
611 // Find selected destination in list 563 // Find selected destination in list
612 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName ); 564 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName );
613 565
614 // Display destination details 566 // Display destination details
615 if ( destination ) 567 if ( destination )
616 { 568 {
617 // Update url 569 // Update url
618 destination->setValue( m_destLocation->text() ); 570 destination->setValue( m_destLocation->text() );
619 destination->setActive( m_destActive->isChecked() ); 571 destination->setActive( m_destActive->isChecked() );
620 572
621 // Check if destination name has changed, if it has then we need to replace the key in the map 573 // Check if destination name has changed, if it has then we need to replace the key in the map
622 if ( m_destCurrName != newName ) 574 if ( m_destCurrName != newName )
623 { 575 {
624 // Update destination name 576 // Update destination name
625 destination->setName( newName ); 577 destination->setName( newName );
626 578
627 // Update list box 579 // Update list box
628 m_destList->changeItem( newName, m_destCurrent ); 580 m_destList->changeItem( newName, m_destCurrent );
629 } 581 }
630 } 582 }
631 } 583 }
632 else 584 else
633 { 585 {
634 // Add new destination to configuration list 586 // Add new destination to configuration list
635 m_configs->append( new OConfItem( OConfItem::Destination, newName, 587 m_configs->append( new OConfItem( OConfItem::Destination, newName,
636 m_destLocation->text(), QString::null, m_destActive->isChecked() ) ); 588 m_destLocation->text(), QString::null, m_destActive->isChecked() ) );
637 m_configs->sort(); 589 m_configs->sort();
638 590
639 m_destList->insertItem( newName ); 591 m_destList->insertItem( newName );
640 m_destList->setCurrentItem( m_destList->count() ); 592 m_destList->setCurrentItem( m_destList->count() );
641 m_destNew = false; 593 m_destNew = false;
642 } 594 }
643} 595}
596
597OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
598 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
599 , m_server( server )
600{
601 setCaption( tr( "Edit server" ) );
602
603 // Initialize UI
604 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
605
606 m_active = new QCheckBox( tr( "Active" ), this );
607 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
608 layout->addWidget( m_active );
609
610 layout->addStretch();
611
612 QLabel *label = new QLabel( tr( "Name:" ), this );
613 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
614 layout->addWidget( label );
615 m_name = new QLineEdit( this );
616 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
617 layout->addWidget( m_name );
618
619 layout->addStretch();
620
621 label = new QLabel( tr( "Address:" ), this );
622 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
623 layout->addWidget( label );
624 m_location = new QLineEdit( this );
625 QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) );
626 layout->addWidget( m_location );
627
628 layout->addStretch();
629
630 m_compressed = new QCheckBox( tr( "Compressed server feed" ), this );
631 QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) );
632 layout->addWidget( m_compressed );
633
634 // Populate initial information
635 if ( m_server )
636 {
637 m_name->setText( m_server->name() );
638 m_location->setText( m_server->value() );
639 m_compressed->setChecked( m_server->features().contains( "Compressed" ) );
640 m_active->setChecked( m_server->active() );
641 }
642}
643
644void OIpkgServerDlg::accept()
645{
646 // Save information entered
647 m_server->setName( m_name->text() );
648 m_server->setValue( m_location->text() );
649 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" )
650 : m_server->setFeatures( QString::null );
651 m_server->setActive( m_active->isChecked() );
652
653 QDialog::accept();
654}
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
index a4e4f82..076a181 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.h
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -1,132 +1,154 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7 .>+-= 7 .>+-=
8_;:, .> :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12- . .-<_> .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14 .%`+i> _;_. 14 .%`+i> _;_.
15 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22: = ...= . :.=- 22: = ...= . :.=-
23-. .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32 32
33#ifndef OIPKGCONFIGDLG_H 33#ifndef OIPKGCONFIGDLG_H
34#define OIPKGCONFIGDLG_H 34#define OIPKGCONFIGDLG_H
35 35
36#include <opie2/otabwidget.h> 36#include <opie2/otabwidget.h>
37 37
38#include <qdialog.h> 38#include <qdialog.h>
39#include <qlayout.h> 39#include <qlayout.h>
40 40
41#include "oipkg.h" 41#include "oipkg.h"
42 42
43class QCheckBox; 43class QCheckBox;
44class QComboBox; 44class QComboBox;
45class QLineEdit; 45class QLineEdit;
46class QListBox; 46class QListBox;
47class QPushButton;
47 48
48class OIpkgConfigDlg : public QDialog 49class OIpkgConfigDlg : public QDialog
49{ 50{
50 Q_OBJECT 51 Q_OBJECT
51 52
52public: 53public:
53 OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 ); 54 OIpkgConfigDlg( OIpkg *ipkg = 0l, bool installOptions = false, QWidget *parent = 0l );
54 55
55protected slots: 56protected slots:
56 void accept(); 57 void accept();
57 void reject(); 58 void reject();
58 59
59private: 60private:
60 OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options 61 OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options
61 OConfItemList *m_configs; // Local list of configuration items 62 OConfItemList *m_configs; // Local list of configuration items
62 63
63 bool m_installOptions; // If true, will only display the Options tab 64 bool m_installOptions; // If true, will only display the Options tab
64 65
65 // Server cached information 66 // Server cached information
66 bool m_serverNew; // Indicates if server information is for a new server 67 bool m_serverNew; // Indicates if server information is for a new server
67 int m_serverCurrent; // Index of currently selected server in m_serverList 68 int m_serverCurrent; // Index of currently selected server in m_serverList
68 QString m_serverCurrName; // Name of currently selected server in m_serverList 69 QString m_serverCurrName; // Name of currently selected server in m_serverList
69 70
70 // Destination cached information 71 // Destination cached information
71 bool m_destNew; // Indicates if destination information is for a new destination 72 bool m_destNew; // Indicates if destination information is for a new destination
72 int m_destCurrent; // Index of currently selected destination in m_destList 73 int m_destCurrent; // Index of currently selected destination in m_destList
73 QString m_destCurrName; // Name of currently selected destination in m_destList 74 QString m_destCurrName; // Name of currently selected destination in m_destList
74 75
75 // UI controls 76 // UI controls
76 QVBoxLayout m_layout; // Main dialog layout control 77 QVBoxLayout m_layout; // Main dialog layout control
77 Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control 78 Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control
78 QWidget *m_serverWidget; // Widget containing server configuration controls 79 QWidget *m_serverWidget; // Widget containing server configuration controls
79 QWidget *m_destWidget; // Widget containing destination configuration controls 80 QWidget *m_destWidget; // Widget containing destination configuration controls
80 QWidget *m_proxyWidget; // Widget containing proxy configuration controls 81 QWidget *m_proxyWidget; // Widget containing proxy configuration controls
81 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls 82 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls
82 83
83 // Server configuration UI controls 84 // Server configuration UI controls
84 QListBox *m_serverList; // Server list selection 85 QListBox *m_serverList; // Server list selection
85 QLineEdit *m_serverName; // Server name edit box 86 QPushButton *m_serverEditBtn; // Server edit button
86 QLineEdit *m_serverLocation; // Server location URL edit box 87 QPushButton *m_serverDeleteBtn; // Server edit button
87 QCheckBox *m_serverActive; // Activate server check box
88 88
89 // Destination configuration UI controls 89 // Destination configuration UI controls
90 QListBox *m_destList; // Destination list selection 90 QListBox *m_destList; // Destination list selection
91 QLineEdit *m_destName; // Destination name edit box 91 QLineEdit *m_destName; // Destination name edit box
92 QLineEdit *m_destLocation; // Destination location URL edit box 92 QLineEdit *m_destLocation; // Destination location URL edit box
93 QCheckBox *m_destActive; // Activate destination check box 93 QCheckBox *m_destActive; // Activate destination check box
94 94
95 // Proxy server configuration UI controls 95 // Proxy server configuration UI controls
96 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box 96 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box
97 QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box 97 QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box
98 QLineEdit *m_proxyFtpServer; // FTP proxy server edit box 98 QLineEdit *m_proxyFtpServer; // FTP proxy server edit box
99 QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box 99 QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box
100 QLineEdit *m_proxyUsername; // Proxy server username edit box 100 QLineEdit *m_proxyUsername; // Proxy server username edit box
101 QLineEdit *m_proxyPassword; // Proxy server password edit box 101 QLineEdit *m_proxyPassword; // Proxy server password edit box
102 102
103 // Options configuration UI controls 103 // Options configuration UI controls
104 QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox 104 QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox
105 QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox 105 QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox
106 QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox 106 QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox
107 QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox 107 QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox
108 QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection 108 QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection
109 109
110 void initServerWidget(); 110 void initServerWidget();
111 void initDestinationWidget(); 111 void initDestinationWidget();
112 void initProxyWidget(); 112 void initProxyWidget();
113 void initOptionsWidget(); 113 void initOptionsWidget();
114 114
115 void initData(); 115 void initData();
116 116
117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 ); 117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
118 const QString &name = QString::null );
118 119
119private slots: 120private slots:
120 void slotServerEdit( int index ); 121 void slotServerSelected( int index );
121 void slotServerNew(); 122 void slotServerNew();
123 void slotServerEdit();
122 void slotServerDelete(); 124 void slotServerDelete();
123 void slotServerUpdate(); 125// void slotServerUpdate();
124 126
125 void slotDestEdit( int index ); 127 void slotDestEdit( int index );
126 void slotDestNew(); 128 void slotDestNew();
127 void slotDestDelete(); 129 void slotDestDelete();
128 void slotDestSelectPath(); 130 void slotDestSelectPath();
129 void slotDestUpdate(); 131 void slotDestUpdate();
130}; 132};
131 133
134class OIpkgServerDlg : public QDialog
135{
136 Q_OBJECT
137
138public:
139 OIpkgServerDlg( OConfItem *server = 0l, QWidget *parent = 0l );
140
141protected slots:
142 void accept();
143
144private:
145 OConfItem *m_server;
146
147 // UI controls
148 QLineEdit *m_name; // Server name edit box
149 QLineEdit *m_location; // Server location URL edit box
150 QCheckBox *m_compressed; // Indicates whether the server is a 'src/gz' feed
151 QCheckBox *m_active; // Indicates whether the server is activated
152};
153
132#endif 154#endif