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