author | andyq <andyq> | 2003-02-10 18:20:16 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-02-10 18:20:16 (UTC) |
commit | 2bc5aaa5c480c2b8924593f1010c7efd3bd50693 (patch) (unidiff) | |
tree | 1009b6d88a7773a59d4742a1376cafe1a4729b02 | |
parent | ee2434f70b0dbc88072748a52b353ab226669a47 (diff) | |
download | opie-2bc5aaa5c480c2b8924593f1010c7efd3bd50693.zip opie-2bc5aaa5c480c2b8924593f1010c7efd3bd50693.tar.gz opie-2bc5aaa5c480c2b8924593f1010c7efd3bd50693.tar.bz2 |
Fixed bug where feed names could have spaces in them
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 7541f0b..9f611da 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -1,440 +1,451 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | settingsimpl.cpp - description | 2 | settingsimpl.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Thu Aug 29 2002 | 4 | begin : Thu Aug 29 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <fstream> | 18 | #include <fstream> |
19 | #include <algorithm> | 19 | #include <algorithm> |
20 | using namespace std; | 20 | using namespace std; |
21 | 21 | ||
22 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
23 | #include <qgroupbox.h> | 23 | #include <qgroupbox.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qlistbox.h> | 27 | #include <qlistbox.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | 29 | ||
30 | #include <opie/otabwidget.h> | 30 | #include <opie/otabwidget.h> |
31 | 31 | ||
32 | #ifdef QWS | 32 | #ifdef QWS |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include "settingsimpl.h" | 37 | #include "settingsimpl.h" |
38 | 38 | ||
39 | #include "global.h" | 39 | #include "global.h" |
40 | 40 | ||
41 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 41 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
42 | : QDialog( parent, name, modal, fl ) | 42 | : QDialog( parent, name, modal, fl ) |
43 | { | 43 | { |
44 | setCaption( tr( "Configuration" ) ); | 44 | setCaption( tr( "Configuration" ) ); |
45 | 45 | ||
46 | // Setup layout to make everything pretty | 46 | // Setup layout to make everything pretty |
47 | QVBoxLayout *layout = new QVBoxLayout( this ); | 47 | QVBoxLayout *layout = new QVBoxLayout( this ); |
48 | layout->setMargin( 2 ); | 48 | layout->setMargin( 2 ); |
49 | layout->setSpacing( 4 ); | 49 | layout->setSpacing( 4 ); |
50 | 50 | ||
51 | // Setup tabs for all info | 51 | // Setup tabs for all info |
52 | OTabWidget *tabwidget = new OTabWidget( this ); | 52 | OTabWidget *tabwidget = new OTabWidget( this ); |
53 | layout->addWidget( tabwidget ); | 53 | layout->addWidget( tabwidget ); |
54 | 54 | ||
55 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); | 55 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); |
56 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); | 56 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); |
57 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); | 57 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); |
58 | tabwidget->setCurrentTab( tr( "Servers" ) ); | 58 | tabwidget->setCurrentTab( tr( "Servers" ) ); |
59 | 59 | ||
60 | dataMgr = dataManager; | 60 | dataMgr = dataManager; |
61 | setupData(); | 61 | setupData(); |
62 | changed = false; | 62 | changed = false; |
63 | newserver = false; | 63 | newserver = false; |
64 | newdestination = false; | 64 | newdestination = false; |
65 | } | 65 | } |
66 | 66 | ||
67 | SettingsImpl :: ~SettingsImpl() | 67 | SettingsImpl :: ~SettingsImpl() |
68 | { | 68 | { |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | bool SettingsImpl :: showDlg() | 72 | bool SettingsImpl :: showDlg() |
73 | { | 73 | { |
74 | showMaximized(); | 74 | showMaximized(); |
75 | exec(); | 75 | exec(); |
76 | 76 | ||
77 | if ( changed ) | 77 | if ( changed ) |
78 | dataMgr->writeOutIpkgConf(); | 78 | dataMgr->writeOutIpkgConf(); |
79 | 79 | ||
80 | return changed; | 80 | return changed; |
81 | } | 81 | } |
82 | 82 | ||
83 | QWidget *SettingsImpl :: initServerTab() | 83 | QWidget *SettingsImpl :: initServerTab() |
84 | { | 84 | { |
85 | QWidget *control = new QWidget( this ); | 85 | QWidget *control = new QWidget( this ); |
86 | 86 | ||
87 | QVBoxLayout *vb = new QVBoxLayout( control ); | 87 | QVBoxLayout *vb = new QVBoxLayout( control ); |
88 | 88 | ||
89 | QScrollView *sv = new QScrollView( control ); | 89 | QScrollView *sv = new QScrollView( control ); |
90 | vb->addWidget( sv, 0, 0 ); | 90 | vb->addWidget( sv, 0, 0 ); |
91 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 91 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
92 | sv->setFrameStyle( QFrame::NoFrame ); | 92 | sv->setFrameStyle( QFrame::NoFrame ); |
93 | 93 | ||
94 | QWidget *container = new QWidget( sv->viewport() ); | 94 | QWidget *container = new QWidget( sv->viewport() ); |
95 | sv->addChild( container ); | 95 | sv->addChild( container ); |
96 | 96 | ||
97 | QGridLayout *layout = new QGridLayout( container ); | 97 | QGridLayout *layout = new QGridLayout( container ); |
98 | layout->setSpacing( 2 ); | 98 | layout->setSpacing( 2 ); |
99 | layout->setMargin( 4 ); | 99 | layout->setMargin( 4 ); |
100 | 100 | ||
101 | servers = new QListBox( container ); | 101 | servers = new QListBox( container ); |
102 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 102 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
103 | connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); | 103 | connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); |
104 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); | 104 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); |
105 | 105 | ||
106 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 106 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
107 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); | 107 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); |
108 | layout->addWidget( btn, 1, 0 ); | 108 | layout->addWidget( btn, 1, 0 ); |
109 | 109 | ||
110 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 110 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
111 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); | 111 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); |
112 | layout->addWidget( btn, 1, 1 ); | 112 | layout->addWidget( btn, 1, 1 ); |
113 | 113 | ||
114 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 114 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
115 | grpbox->layout()->setSpacing( 2 ); | 115 | grpbox->layout()->setSpacing( 2 ); |
116 | grpbox->layout()->setMargin( 4 ); | 116 | grpbox->layout()->setMargin( 4 ); |
117 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 117 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
118 | 118 | ||
119 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 119 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
120 | 120 | ||
121 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 121 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
122 | grplayout->addWidget( label, 0, 0 ); | 122 | grplayout->addWidget( label, 0, 0 ); |
123 | servername = new QLineEdit( grpbox ); | 123 | servername = new QLineEdit( grpbox ); |
124 | grplayout->addWidget( servername, 0, 1 ); | 124 | grplayout->addWidget( servername, 0, 1 ); |
125 | 125 | ||
126 | label = new QLabel( tr( "Address:" ), grpbox ); | 126 | label = new QLabel( tr( "Address:" ), grpbox ); |
127 | grplayout->addWidget( label, 1, 0 ); | 127 | grplayout->addWidget( label, 1, 0 ); |
128 | serverurl = new QLineEdit( grpbox ); | 128 | serverurl = new QLineEdit( grpbox ); |
129 | grplayout->addWidget( serverurl, 1, 1 ); | 129 | grplayout->addWidget( serverurl, 1, 1 ); |
130 | 130 | ||
131 | active = new QCheckBox( tr( "Active Server" ), grpbox ); | 131 | active = new QCheckBox( tr( "Active Server" ), grpbox ); |
132 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); | 132 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); |
133 | 133 | ||
134 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 134 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
135 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); | 135 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); |
136 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 136 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
137 | 137 | ||
138 | return control; | 138 | return control; |
139 | } | 139 | } |
140 | 140 | ||
141 | QWidget *SettingsImpl :: initDestinationTab() | 141 | QWidget *SettingsImpl :: initDestinationTab() |
142 | { | 142 | { |
143 | QWidget *control = new QWidget( this ); | 143 | QWidget *control = new QWidget( this ); |
144 | 144 | ||
145 | QVBoxLayout *vb = new QVBoxLayout( control ); | 145 | QVBoxLayout *vb = new QVBoxLayout( control ); |
146 | 146 | ||
147 | QScrollView *sv = new QScrollView( control ); | 147 | QScrollView *sv = new QScrollView( control ); |
148 | vb->addWidget( sv, 0, 0 ); | 148 | vb->addWidget( sv, 0, 0 ); |
149 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 149 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
150 | sv->setFrameStyle( QFrame::NoFrame ); | 150 | sv->setFrameStyle( QFrame::NoFrame ); |
151 | 151 | ||
152 | QWidget *container = new QWidget( sv->viewport() ); | 152 | QWidget *container = new QWidget( sv->viewport() ); |
153 | sv->addChild( container ); | 153 | sv->addChild( container ); |
154 | 154 | ||
155 | QGridLayout *layout = new QGridLayout( container ); | 155 | QGridLayout *layout = new QGridLayout( container ); |
156 | layout->setSpacing( 2 ); | 156 | layout->setSpacing( 2 ); |
157 | layout->setMargin( 4 ); | 157 | layout->setMargin( 4 ); |
158 | 158 | ||
159 | destinations = new QListBox( container ); | 159 | destinations = new QListBox( container ); |
160 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 160 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
161 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); | 161 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); |
162 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); | 162 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); |
163 | 163 | ||
164 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 164 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
165 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); | 165 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); |
166 | layout->addWidget( btn, 1, 0 ); | 166 | layout->addWidget( btn, 1, 0 ); |
167 | 167 | ||
168 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 168 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
169 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); | 169 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); |
170 | layout->addWidget( btn, 1, 1 ); | 170 | layout->addWidget( btn, 1, 1 ); |
171 | 171 | ||
172 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 172 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
173 | grpbox->layout()->setSpacing( 2 ); | 173 | grpbox->layout()->setSpacing( 2 ); |
174 | grpbox->layout()->setMargin( 4 ); | 174 | grpbox->layout()->setMargin( 4 ); |
175 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 175 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
176 | 176 | ||
177 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 177 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
178 | 178 | ||
179 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 179 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
180 | grplayout->addWidget( label, 0, 0 ); | 180 | grplayout->addWidget( label, 0, 0 ); |
181 | destinationname = new QLineEdit( grpbox ); | 181 | destinationname = new QLineEdit( grpbox ); |
182 | grplayout->addWidget( destinationname, 0, 1 ); | 182 | grplayout->addWidget( destinationname, 0, 1 ); |
183 | 183 | ||
184 | label = new QLabel( tr( "Location:" ), grpbox ); | 184 | label = new QLabel( tr( "Location:" ), grpbox ); |
185 | grplayout->addWidget( label, 1, 0 ); | 185 | grplayout->addWidget( label, 1, 0 ); |
186 | destinationurl = new QLineEdit( grpbox ); | 186 | destinationurl = new QLineEdit( grpbox ); |
187 | grplayout->addWidget( destinationurl, 1, 1 ); | 187 | grplayout->addWidget( destinationurl, 1, 1 ); |
188 | 188 | ||
189 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); | 189 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); |
190 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 190 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
191 | 191 | ||
192 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 192 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
193 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); | 193 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); |
194 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 194 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
195 | 195 | ||
196 | return control; | 196 | return control; |
197 | } | 197 | } |
198 | 198 | ||
199 | QWidget *SettingsImpl :: initProxyTab() | 199 | QWidget *SettingsImpl :: initProxyTab() |
200 | { | 200 | { |
201 | QWidget *control = new QWidget( this ); | 201 | QWidget *control = new QWidget( this ); |
202 | 202 | ||
203 | QVBoxLayout *vb = new QVBoxLayout( control ); | 203 | QVBoxLayout *vb = new QVBoxLayout( control ); |
204 | 204 | ||
205 | QScrollView *sv = new QScrollView( control ); | 205 | QScrollView *sv = new QScrollView( control ); |
206 | vb->addWidget( sv, 0, 0 ); | 206 | vb->addWidget( sv, 0, 0 ); |
207 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 207 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
208 | sv->setFrameStyle( QFrame::NoFrame ); | 208 | sv->setFrameStyle( QFrame::NoFrame ); |
209 | 209 | ||
210 | QWidget *container = new QWidget( sv->viewport() ); | 210 | QWidget *container = new QWidget( sv->viewport() ); |
211 | sv->addChild( container ); | 211 | sv->addChild( container ); |
212 | 212 | ||
213 | QGridLayout *layout = new QGridLayout( container ); | 213 | QGridLayout *layout = new QGridLayout( container ); |
214 | layout->setSpacing( 2 ); | 214 | layout->setSpacing( 2 ); |
215 | layout->setMargin( 4 ); | 215 | layout->setMargin( 4 ); |
216 | 216 | ||
217 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 217 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
218 | grpbox->layout()->setSpacing( 2 ); | 218 | grpbox->layout()->setSpacing( 2 ); |
219 | grpbox->layout()->setMargin( 4 ); | 219 | grpbox->layout()->setMargin( 4 ); |
220 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 220 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
221 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 221 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
222 | txtHttpProxy = new QLineEdit( grpbox ); | 222 | txtHttpProxy = new QLineEdit( grpbox ); |
223 | grplayout->addWidget( txtHttpProxy ); | 223 | grplayout->addWidget( txtHttpProxy ); |
224 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 224 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
225 | grplayout->addWidget( chkHttpProxyEnabled ); | 225 | grplayout->addWidget( chkHttpProxyEnabled ); |
226 | 226 | ||
227 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 227 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
228 | grpbox->layout()->setSpacing( 2 ); | 228 | grpbox->layout()->setSpacing( 2 ); |
229 | grpbox->layout()->setMargin( 4 ); | 229 | grpbox->layout()->setMargin( 4 ); |
230 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 230 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
231 | grplayout = new QVBoxLayout( grpbox->layout() ); | 231 | grplayout = new QVBoxLayout( grpbox->layout() ); |
232 | txtFtpProxy = new QLineEdit( grpbox ); | 232 | txtFtpProxy = new QLineEdit( grpbox ); |
233 | grplayout->addWidget( txtFtpProxy ); | 233 | grplayout->addWidget( txtFtpProxy ); |
234 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 234 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
235 | grplayout->addWidget( chkFtpProxyEnabled ); | 235 | grplayout->addWidget( chkFtpProxyEnabled ); |
236 | 236 | ||
237 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 237 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
238 | layout->addWidget( label, 2, 0 ); | 238 | layout->addWidget( label, 2, 0 ); |
239 | txtUsername = new QLineEdit( container ); | 239 | txtUsername = new QLineEdit( container ); |
240 | layout->addWidget( txtUsername, 2, 1 ); | 240 | layout->addWidget( txtUsername, 2, 1 ); |
241 | 241 | ||
242 | label = new QLabel( tr( "Password:" ), container ); | 242 | label = new QLabel( tr( "Password:" ), container ); |
243 | layout->addWidget( label, 3, 0 ); | 243 | layout->addWidget( label, 3, 0 ); |
244 | txtPassword = new QLineEdit( container ); | 244 | txtPassword = new QLineEdit( container ); |
245 | layout->addWidget( txtPassword, 3, 1 ); | 245 | layout->addWidget( txtPassword, 3, 1 ); |
246 | 246 | ||
247 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 247 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); |
248 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); | 248 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); |
249 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 249 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
250 | 250 | ||
251 | return control; | 251 | return control; |
252 | } | 252 | } |
253 | 253 | ||
254 | void SettingsImpl :: setupData() | 254 | void SettingsImpl :: setupData() |
255 | { | 255 | { |
256 | // add servers | 256 | // add servers |
257 | QString serverName; | 257 | QString serverName; |
258 | QListIterator<Server> it( dataMgr->getServerList() ); | 258 | QListIterator<Server> it( dataMgr->getServerList() ); |
259 | for ( ; it.current(); ++it ) | 259 | for ( ; it.current(); ++it ) |
260 | { | 260 | { |
261 | serverName = it.current()->getServerName(); | 261 | serverName = it.current()->getServerName(); |
262 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) | 262 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) |
263 | continue; | 263 | continue; |
264 | 264 | ||
265 | servers->insertItem( serverName ); | 265 | servers->insertItem( serverName ); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | // add destinations | 269 | // add destinations |
270 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); | 270 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); |
271 | for ( ; it2.current(); ++it2 ) | 271 | for ( ; it2.current(); ++it2 ) |
272 | destinations->insertItem( it2.current()->getDestinationName() ); | 272 | destinations->insertItem( it2.current()->getDestinationName() ); |
273 | 273 | ||
274 | // setup proxy tab | 274 | // setup proxy tab |
275 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); | 275 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); |
276 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); | 276 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); |
277 | txtUsername->setText( dataMgr->getProxyUsername() ); | 277 | txtUsername->setText( dataMgr->getProxyUsername() ); |
278 | txtPassword->setText( dataMgr->getProxyPassword() ); | 278 | txtPassword->setText( dataMgr->getProxyPassword() ); |
279 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); | 279 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); |
280 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); | 280 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); |
281 | } | 281 | } |
282 | 282 | ||
283 | //------------------ Servers tab ---------------------- | 283 | //------------------ Servers tab ---------------------- |
284 | 284 | ||
285 | void SettingsImpl :: editServer( int sel ) | 285 | void SettingsImpl :: editServer( int sel ) |
286 | { | 286 | { |
287 | currentSelectedServer = sel; | 287 | currentSelectedServer = sel; |
288 | Server *s = dataMgr->getServer( servers->currentText() ); | 288 | Server *s = dataMgr->getServer( servers->currentText() ); |
289 | serverName = s->getServerName(); | 289 | serverName = s->getServerName(); |
290 | servername->setText( s->getServerName() ); | 290 | servername->setText( s->getServerName() ); |
291 | serverurl->setText( s->getServerUrl() ); | 291 | serverurl->setText( s->getServerUrl() ); |
292 | active->setChecked( s->isServerActive() ); | 292 | active->setChecked( s->isServerActive() ); |
293 | } | 293 | } |
294 | 294 | ||
295 | void SettingsImpl :: newServer() | 295 | void SettingsImpl :: newServer() |
296 | { | 296 | { |
297 | newserver = true; | 297 | newserver = true; |
298 | servername->setText( "" ); | 298 | servername->setText( "" ); |
299 | serverurl->setText( "" ); | 299 | serverurl->setText( "" ); |
300 | servername->setFocus(); | 300 | servername->setFocus(); |
301 | active->setChecked( true ); | 301 | active->setChecked( true ); |
302 | } | 302 | } |
303 | 303 | ||
304 | void SettingsImpl :: removeServer() | 304 | void SettingsImpl :: removeServer() |
305 | { | 305 | { |
306 | changed = true; | 306 | changed = true; |
307 | Server *s = dataMgr->getServer( servers->currentText() ); | 307 | Server *s = dataMgr->getServer( servers->currentText() ); |
308 | dataMgr->getServerList().removeRef( s ); | 308 | dataMgr->getServerList().removeRef( s ); |
309 | servers->removeItem( currentSelectedServer ); | 309 | servers->removeItem( currentSelectedServer ); |
310 | } | 310 | } |
311 | 311 | ||
312 | void SettingsImpl :: changeServerDetails() | 312 | void SettingsImpl :: changeServerDetails() |
313 | { | 313 | { |
314 | changed = true; | 314 | changed = true; |
315 | 315 | ||
316 | QString newName = servername->text(); | 316 | QString newName = servername->text(); |
317 | |||
318 | // Convert any spaces to underscores | ||
319 | char *tmpStr = new char[newName.length() + 1]; | ||
320 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) | ||
321 | { | ||
322 | if ( newName[i] == ' ' ) | ||
323 | tmpStr[i] = '_'; | ||
324 | else | ||
325 | tmpStr[i] = newName[i].latin1(); | ||
326 | } | ||
327 | tmpStr[newName.length()] = '\0'; | ||
328 | |||
329 | newName = tmpStr; | ||
330 | delete tmpStr; | ||
331 | |||
317 | if ( !newserver ) | 332 | if ( !newserver ) |
318 | { | 333 | { |
319 | Server *s = dataMgr->getServer( servers->currentText() ); | 334 | Server *s = dataMgr->getServer( servers->currentText() ); |
320 | 335 | ||
321 | // Update url | 336 | // Update url |
322 | s->setServerUrl( serverurl->text() ); | 337 | s->setServerUrl( serverurl->text() ); |
323 | s->setActive( active->isChecked() ); | 338 | s->setActive( active->isChecked() ); |
324 | 339 | ||
325 | 340 | ||
326 | // Check if server name has changed, if it has then we need to replace the key in the map | 341 | // Check if server name has changed, if it has then we need to replace the key in the map |
327 | if ( serverName != newName ) | 342 | if ( serverName != newName ) |
328 | { | 343 | { |
329 | // Update server name | 344 | // Update server name |
330 | s->setServerName( newName ); | 345 | s->setServerName( newName ); |
331 | |||
332 | // See if this server is the active server | ||
333 | // if ( dataMgr->getActiveServer() == serverName ) | ||
334 | // dataMgr->setActiveServer( newName ); | ||
335 | |||
336 | // Update list box | ||
337 | servers->changeItem( newName, currentSelectedServer ); | ||
338 | } | 346 | } |
347 | |||
348 | // Update list box | ||
349 | servers->changeItem( newName, currentSelectedServer ); | ||
339 | } | 350 | } |
340 | else | 351 | else |
341 | { | 352 | { |
342 | Server s( newName, serverurl->text() ); | 353 | Server s( newName, serverurl->text() ); |
343 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); | 354 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); |
344 | dataMgr->getServerList().last()->setActive( active->isChecked() ); | 355 | dataMgr->getServerList().last()->setActive( active->isChecked() ); |
345 | servers->insertItem( newName ); | 356 | servers->insertItem( newName ); |
346 | servers->setCurrentItem( servers->count() ); | 357 | servers->setCurrentItem( servers->count() ); |
347 | newserver = false; | 358 | newserver = false; |
348 | } | 359 | } |
349 | } | 360 | } |
350 | 361 | ||
351 | //------------------ Destinations tab ---------------------- | 362 | //------------------ Destinations tab ---------------------- |
352 | 363 | ||
353 | void SettingsImpl :: editDestination( int sel ) | 364 | void SettingsImpl :: editDestination( int sel ) |
354 | { | 365 | { |
355 | currentSelectedDestination = sel; | 366 | currentSelectedDestination = sel; |
356 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 367 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
357 | destinationName = d->getDestinationName(); | 368 | destinationName = d->getDestinationName(); |
358 | destinationname->setText( d->getDestinationName() ); | 369 | destinationname->setText( d->getDestinationName() ); |
359 | destinationurl->setText( d->getDestinationPath() ); | 370 | destinationurl->setText( d->getDestinationPath() ); |
360 | linkToRoot->setChecked( d->linkToRoot() ); | 371 | linkToRoot->setChecked( d->linkToRoot() ); |
361 | } | 372 | } |
362 | 373 | ||
363 | void SettingsImpl :: newDestination() | 374 | void SettingsImpl :: newDestination() |
364 | { | 375 | { |
365 | newdestination = true; | 376 | newdestination = true; |
366 | destinationname->setText( "" ); | 377 | destinationname->setText( "" ); |
367 | destinationurl->setText( "" ); | 378 | destinationurl->setText( "" ); |
368 | destinationname->setFocus(); | 379 | destinationname->setFocus(); |
369 | linkToRoot->setChecked( true ); | 380 | linkToRoot->setChecked( true ); |
370 | } | 381 | } |
371 | 382 | ||
372 | void SettingsImpl :: removeDestination() | 383 | void SettingsImpl :: removeDestination() |
373 | { | 384 | { |
374 | changed = true; | 385 | changed = true; |
375 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 386 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
376 | dataMgr->getDestinationList().removeRef( d ); | 387 | dataMgr->getDestinationList().removeRef( d ); |
377 | destinations->removeItem( currentSelectedDestination ); | 388 | destinations->removeItem( currentSelectedDestination ); |
378 | } | 389 | } |
379 | 390 | ||
380 | void SettingsImpl :: changeDestinationDetails() | 391 | void SettingsImpl :: changeDestinationDetails() |
381 | { | 392 | { |
382 | changed = true; | 393 | changed = true; |
383 | 394 | ||
384 | #ifdef QWS | 395 | #ifdef QWS |
385 | Config cfg( "aqpkg" ); | 396 | Config cfg( "aqpkg" ); |
386 | cfg.setGroup( "destinations" ); | 397 | cfg.setGroup( "destinations" ); |
387 | #endif | 398 | #endif |
388 | 399 | ||
389 | QString newName = destinationname->text(); | 400 | QString newName = destinationname->text(); |
390 | if ( !newdestination ) | 401 | if ( !newdestination ) |
391 | { | 402 | { |
392 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 403 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
393 | 404 | ||
394 | // Update url | 405 | // Update url |
395 | d->setDestinationPath( destinationurl->text() ); | 406 | d->setDestinationPath( destinationurl->text() ); |
396 | d->linkToRoot( linkToRoot->isChecked() ); | 407 | d->linkToRoot( linkToRoot->isChecked() ); |
397 | 408 | ||
398 | // Check if server name has changed, if it has then we need to replace the key in the map | 409 | // Check if server name has changed, if it has then we need to replace the key in the map |
399 | if ( destinationName != newName ) | 410 | if ( destinationName != newName ) |
400 | { | 411 | { |
401 | // Update server name | 412 | // Update server name |
402 | d->setDestinationName( newName ); | 413 | d->setDestinationName( newName ); |
403 | 414 | ||
404 | // Update list box | 415 | // Update list box |
405 | destinations->changeItem( newName, currentSelectedDestination ); | 416 | destinations->changeItem( newName, currentSelectedDestination ); |
406 | } | 417 | } |
407 | #ifdef QWS | 418 | #ifdef QWS |
408 | QString key = newName; | 419 | QString key = newName; |
409 | key += "_linkToRoot"; | 420 | key += "_linkToRoot"; |
410 | int val = d->linkToRoot(); | 421 | int val = d->linkToRoot(); |
411 | cfg.writeEntry( key, val ); | 422 | cfg.writeEntry( key, val ); |
412 | #endif | 423 | #endif |
413 | } | 424 | } |
414 | else | 425 | else |
415 | { | 426 | { |
416 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); | 427 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); |
417 | destinations->insertItem( newName ); | 428 | destinations->insertItem( newName ); |
418 | destinations->setCurrentItem( destinations->count() ); | 429 | destinations->setCurrentItem( destinations->count() ); |
419 | newdestination = false; | 430 | newdestination = false; |
420 | 431 | ||
421 | #ifdef QWS | 432 | #ifdef QWS |
422 | QString key = newName; | 433 | QString key = newName; |
423 | key += "_linkToRoot"; | 434 | key += "_linkToRoot"; |
424 | cfg.writeEntry( key, true ); | 435 | cfg.writeEntry( key, true ); |
425 | #endif | 436 | #endif |
426 | } | 437 | } |
427 | } | 438 | } |
428 | 439 | ||
429 | //------------------ Proxy tab ---------------------- | 440 | //------------------ Proxy tab ---------------------- |
430 | void SettingsImpl :: proxyApplyChanges() | 441 | void SettingsImpl :: proxyApplyChanges() |
431 | { | 442 | { |
432 | changed = true; | 443 | changed = true; |
433 | dataMgr->setHttpProxy( txtHttpProxy->text() ); | 444 | dataMgr->setHttpProxy( txtHttpProxy->text() ); |
434 | dataMgr->setFtpProxy( txtFtpProxy->text() ); | 445 | dataMgr->setFtpProxy( txtFtpProxy->text() ); |
435 | dataMgr->setProxyUsername( txtUsername->text() ); | 446 | dataMgr->setProxyUsername( txtUsername->text() ); |
436 | dataMgr->setProxyPassword( txtPassword->text() ); | 447 | dataMgr->setProxyPassword( txtPassword->text() ); |
437 | 448 | ||
438 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); | 449 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); |
439 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); | 450 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); |
440 | } | 451 | } |