summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index 592de3e..74e7137 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -1,190 +1,227 @@
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 <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qgroupbox.h> 36#include <qgroupbox.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qlineedit.h> 38#include <qlineedit.h>
39#include <qlistbox.h> 39#include <qlistbox.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qscrollview.h> 41#include <qscrollview.h>
42 42
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44 44
45using namespace Opie::Ui; 45using namespace Opie::Ui;
46OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 46OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
47 : QDialog( parent, QString::null, true ) 47 : QDialog( parent, QString::null, true )
48 , m_ipkg( ipkg ) 48 , m_ipkg( ipkg )
49 , m_configs( 0x0 ) 49 , m_configs( 0x0 )
50 , m_installOptions( installOptions ) 50 , m_installOptions( installOptions )
51 , m_serverNew( false ) 51 , m_serverNew( false )
52 , m_serverCurrent( -1 ) 52 , m_serverCurrent( -1 )
53 , m_destNew( false ) 53 , m_destNew( false )
54 , m_destCurrent( -1 ) 54 , m_destCurrent( -1 )
55 , m_layout( this, 2, 4 ) 55 , m_layout( this, 2, 4 )
56 , m_tabWidget( this ) 56 , m_tabWidget( this )
57{ 57{
58 setCaption( tr( "Configuration" ) ); 58 setCaption( tr( "Configuration" ) );
59 59
60 // Initialize configuration widgets 60 // Initialize configuration widgets
61 if ( !installOptions ) 61 if ( !installOptions )
62 { 62 {
63 initServerWidget(); 63 initServerWidget();
64 initDestinationWidget(); 64 initDestinationWidget();
65 initProxyWidget(); 65 initProxyWidget();
66 } 66 }
67 initOptionsWidget(); 67 initOptionsWidget();
68 68
69 // Load configuration information 69 // Load configuration information
70 initData(); 70 initData();
71 71
72 // Setup tabs for all info 72 // Setup tabs for all info
73 m_layout.addWidget( &m_tabWidget ); 73 m_layout.addWidget( &m_tabWidget );
74 if ( !m_installOptions ) 74 if ( !m_installOptions )
75 { 75 {
76 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); 76 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
77 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); 77 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
78 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); 78 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
79 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 79 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
80 m_tabWidget.setCurrentTab( tr( "Servers" ) ); 80 m_tabWidget.setCurrentTab( tr( "Servers" ) );
81 } 81 }
82 else 82 else
83 { 83 {
84 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 84 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
85 } 85 }
86 86
87 //showMaximized(); 87 //showMaximized();
88} 88}
89 89
90void OIpkgConfigDlg::accept() 90void OIpkgConfigDlg::accept()
91{ 91{
92 // Save server, destination and proxy configuration 92 // Save server, destination and proxy configuration
93 if ( !m_installOptions ) 93 if ( !m_installOptions )
94 {
95 // Update proxy information before saving settings
96 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" );
97 if ( confItem )
98 {
99 confItem->setValue( m_proxyHttpServer->text() );
100 confItem->setActive( m_proxyHttpActive->isChecked() );
101 }
102 else
103 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "http_proxy",
104 m_proxyHttpServer->text(), m_proxyHttpActive->isChecked() ) );
105
106 confItem = findConfItem( OConfItem::Option, "ftp_proxy" );
107 if ( confItem )
108 {
109 confItem->setValue( m_proxyFtpServer->text() );
110 confItem->setActive( m_proxyFtpActive->isChecked() );
111 }
112 else
113 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "ftp_proxy",
114 m_proxyFtpServer->text(), m_proxyFtpActive->isChecked() ) );
115
116 confItem = findConfItem( OConfItem::Option, "proxy_username" );
117 if ( confItem )
118 confItem->setValue( m_proxyUsername->text() );
119 else
120 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_username",
121 m_proxyUsername->text() ) );
122
123 confItem = findConfItem( OConfItem::Option, "proxy_password" );
124 if ( confItem )
125 confItem->setValue( m_proxyPassword->text() );
126 else
127 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_password",
128 m_proxyPassword->text() ) );
129
94 m_ipkg->setConfigItems( m_configs ); 130 m_ipkg->setConfigItems( m_configs );
131 }
95 132
96 // Save options configuration 133 // Save options configuration
97 int options = 0; 134 int options = 0;
98 if ( m_optForceDepends->isChecked() ) 135 if ( m_optForceDepends->isChecked() )
99 options |= FORCE_DEPENDS; 136 options |= FORCE_DEPENDS;
100 if ( m_optForceReinstall->isChecked() ) 137 if ( m_optForceReinstall->isChecked() )
101 options |= FORCE_REINSTALL; 138 options |= FORCE_REINSTALL;
102 if ( m_optForceRemove->isChecked() ) 139 if ( m_optForceRemove->isChecked() )
103 options |= FORCE_REMOVE; 140 options |= FORCE_REMOVE;
104 if ( m_optForceOverwrite->isChecked() ) 141 if ( m_optForceOverwrite->isChecked() )
105 options |= FORCE_OVERWRITE; 142 options |= FORCE_OVERWRITE;
106 m_ipkg->setIpkgExecOptions( options ); 143 m_ipkg->setIpkgExecOptions( options );
107 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); 144 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
108 145
109 QDialog::accept(); 146 QDialog::accept();
110} 147}
111 148
112void OIpkgConfigDlg::reject() 149void OIpkgConfigDlg::reject()
113{ 150{
114 if ( m_configs ) 151 if ( m_configs )
115 delete m_configs; 152 delete m_configs;
116} 153}
117 154
118void OIpkgConfigDlg::initServerWidget() 155void OIpkgConfigDlg::initServerWidget()
119{ 156{
120 m_serverWidget = new QWidget( this ); 157 m_serverWidget = new QWidget( this );
121 158
122 // Initialize UI 159 // Initialize UI
123 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); 160 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
124 QScrollView *sv = new QScrollView( m_serverWidget ); 161 QScrollView *sv = new QScrollView( m_serverWidget );
125 vb->addWidget( sv, 0, 0 ); 162 vb->addWidget( sv, 0, 0 );
126 sv->setResizePolicy( QScrollView::AutoOneFit ); 163 sv->setResizePolicy( QScrollView::AutoOneFit );
127 sv->setFrameStyle( QFrame::NoFrame ); 164 sv->setFrameStyle( QFrame::NoFrame );
128 QWidget *container = new QWidget( sv->viewport() ); 165 QWidget *container = new QWidget( sv->viewport() );
129 sv->addChild( container ); 166 sv->addChild( container );
130 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 167 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
131 168
132 m_serverList = new QListBox( container ); 169 m_serverList = new QListBox( container );
133 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 170 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
134 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); 171 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) );
135 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 172 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
136 173
137 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 174 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
138 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); 175 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
139 layout->addWidget( btn, 1, 0 ); 176 layout->addWidget( btn, 1, 0 );
140 177
141 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 178 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
142 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 179 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
143 layout->addWidget( btn, 1, 1 ); 180 layout->addWidget( btn, 1, 1 );
144 181
145 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 182 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
146 grpbox->layout()->setSpacing( 2 ); 183 grpbox->layout()->setSpacing( 2 );
147 grpbox->layout()->setMargin( 4 ); 184 grpbox->layout()->setMargin( 4 );
148 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 185 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
149 186
150 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 187 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
151 188
152 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 189 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
153 grplayout->addWidget( label, 0, 0 ); 190 grplayout->addWidget( label, 0, 0 );
154 m_serverName = new QLineEdit( grpbox ); 191 m_serverName = new QLineEdit( grpbox );
155 grplayout->addWidget( m_serverName, 0, 1 ); 192 grplayout->addWidget( m_serverName, 0, 1 );
156 193
157 label = new QLabel( tr( "Address:" ), grpbox ); 194 label = new QLabel( tr( "Address:" ), grpbox );
158 grplayout->addWidget( label, 1, 0 ); 195 grplayout->addWidget( label, 1, 0 );
159 m_serverLocation = new QLineEdit( grpbox ); 196 m_serverLocation = new QLineEdit( grpbox );
160 grplayout->addWidget( m_serverLocation, 1, 1 ); 197 grplayout->addWidget( m_serverLocation, 1, 1 );
161 198
162 m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox ); 199 m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox );
163 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 ); 200 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
164 201
165 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 202 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
166 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) ); 203 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
167 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 204 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
168} 205}
169 206
170void OIpkgConfigDlg::initDestinationWidget() 207void OIpkgConfigDlg::initDestinationWidget()
171{ 208{
172 m_destWidget = new QWidget( this ); 209 m_destWidget = new QWidget( this );
173 210
174 // Initialize UI 211 // Initialize UI
175 QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); 212 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
176 QScrollView *sv = new QScrollView( m_destWidget ); 213 QScrollView *sv = new QScrollView( m_destWidget );
177 vb->addWidget( sv, 0, 0 ); 214 vb->addWidget( sv, 0, 0 );
178 sv->setResizePolicy( QScrollView::AutoOneFit ); 215 sv->setResizePolicy( QScrollView::AutoOneFit );
179 sv->setFrameStyle( QFrame::NoFrame ); 216 sv->setFrameStyle( QFrame::NoFrame );
180 QWidget *container = new QWidget( sv->viewport() ); 217 QWidget *container = new QWidget( sv->viewport() );
181 sv->addChild( container ); 218 sv->addChild( container );
182 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 219 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
183 220
184 m_destList = new QListBox( container ); 221 m_destList = new QListBox( container );
185 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 222 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
186 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); 223 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) );
187 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); 224 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 );
188 225
189 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 226 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
190 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); 227 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );