Diffstat (limited to 'noncore/settings/aqpkg/settingsimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index a18a178..9dd2206 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -7,24 +7,25 @@ | |||
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 | using namespace std; | 20 | using namespace std; |
20 | 21 | ||
21 | #include <qlistbox.h> | 22 | #include <qlistbox.h> |
22 | #include <qlineedit.h> | 23 | #include <qlineedit.h> |
23 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
24 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
25 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
26 | 27 | ||
27 | #ifdef QWS | 28 | #ifdef QWS |
28 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
29 | #endif | 30 | #endif |
30 | 31 | ||
@@ -82,56 +83,56 @@ void SettingsImpl :: setupData() | |||
82 | cfg.setGroup( "settings" ); | 83 | cfg.setGroup( "settings" ); |
83 | jumpTo->setChecked( cfg.readBoolEntry( "showJumpTo", "true" ) ); | 84 | jumpTo->setChecked( cfg.readBoolEntry( "showJumpTo", "true" ) ); |
84 | #else | 85 | #else |
85 | jumpTo->setChecked( true ); | 86 | jumpTo->setChecked( true ); |
86 | #endif | 87 | #endif |
87 | } | 88 | } |
88 | 89 | ||
89 | //------------------ Servers tab ---------------------- | 90 | //------------------ Servers tab ---------------------- |
90 | 91 | ||
91 | void SettingsImpl :: editServer( int sel ) | 92 | void SettingsImpl :: editServer( int sel ) |
92 | { | 93 | { |
93 | currentSelectedServer = sel; | 94 | currentSelectedServer = sel; |
94 | Server *s = dataMgr->getServer( servers->currentText() ); | 95 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); |
95 | serverName = s->getServerName(); | 96 | serverName = s->getServerName(); |
96 | servername->setText( s->getServerName() ); | 97 | servername->setText( s->getServerName() ); |
97 | serverurl->setText( s->getServerUrl() ); | 98 | serverurl->setText( s->getServerUrl() ); |
98 | active->setChecked( s->isServerActive() ); | 99 | active->setChecked( s->isServerActive() ); |
99 | } | 100 | } |
100 | 101 | ||
101 | void SettingsImpl :: newServer() | 102 | void SettingsImpl :: newServer() |
102 | { | 103 | { |
103 | newserver = true; | 104 | newserver = true; |
104 | servername->setText( "" ); | 105 | servername->setText( "" ); |
105 | serverurl->setText( "" ); | 106 | serverurl->setText( "" ); |
106 | servername->setFocus(); | 107 | servername->setFocus(); |
107 | active->setChecked( true ); | 108 | active->setChecked( true ); |
108 | } | 109 | } |
109 | 110 | ||
110 | void SettingsImpl :: removeServer() | 111 | void SettingsImpl :: removeServer() |
111 | { | 112 | { |
112 | changed = true; | 113 | changed = true; |
113 | Server *s = dataMgr->getServer( servers->currentText() ); | 114 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); |
114 | dataMgr->getServerList().erase( s ); | 115 | dataMgr->getServerList().erase( s ); |
115 | servers->removeItem( currentSelectedServer ); | 116 | servers->removeItem( currentSelectedServer ); |
116 | } | 117 | } |
117 | 118 | ||
118 | void SettingsImpl :: changeServerDetails() | 119 | void SettingsImpl :: changeServerDetails() |
119 | { | 120 | { |
120 | changed = true; | 121 | changed = true; |
121 | 122 | ||
122 | QString newName = servername->text(); | 123 | QString newName = servername->text(); |
123 | if ( !newserver ) | 124 | if ( !newserver ) |
124 | { | 125 | { |
125 | Server *s = dataMgr->getServer( serverName ); | 126 | vector<Server>::iterator s = dataMgr->getServer( servers->currentText() ); |
126 | 127 | ||
127 | // Update url | 128 | // Update url |
128 | s->setServerUrl( serverurl->text() ); | 129 | s->setServerUrl( serverurl->text() ); |
129 | s->setActive( active->isChecked() ); | 130 | s->setActive( active->isChecked() ); |
130 | 131 | ||
131 | 132 | ||
132 | // Check if server name has changed, if it has then we need to replace the key in the map | 133 | // Check if server name has changed, if it has then we need to replace the key in the map |
133 | if ( serverName != newName ) | 134 | if ( serverName != newName ) |
134 | { | 135 | { |
135 | // Update server name | 136 | // Update server name |
136 | s->setServerName( newName ); | 137 | s->setServerName( newName ); |
137 | 138 | ||
@@ -150,61 +151,61 @@ void SettingsImpl :: changeServerDetails() | |||
150 | dataMgr->getServerList().end()->setActive( active->isChecked() ); | 151 | dataMgr->getServerList().end()->setActive( active->isChecked() ); |
151 | servers->insertItem( newName ); | 152 | servers->insertItem( newName ); |
152 | servers->setCurrentItem( servers->count() ); | 153 | servers->setCurrentItem( servers->count() ); |
153 | newserver = false; | 154 | newserver = false; |
154 | } | 155 | } |
155 | } | 156 | } |
156 | 157 | ||
157 | //------------------ Destinations tab ---------------------- | 158 | //------------------ Destinations tab ---------------------- |
158 | 159 | ||
159 | void SettingsImpl :: editDestination( int sel ) | 160 | void SettingsImpl :: editDestination( int sel ) |
160 | { | 161 | { |
161 | currentSelectedDestination = sel; | 162 | currentSelectedDestination = sel; |
162 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 163 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); |
163 | destinationName = d->getDestinationName(); | 164 | destinationName = d->getDestinationName(); |
164 | destinationname->setText( d->getDestinationName() ); | 165 | destinationname->setText( d->getDestinationName() ); |
165 | destinationurl->setText( d->getDestinationPath() ); | 166 | destinationurl->setText( d->getDestinationPath() ); |
166 | linkToRoot->setChecked( d->linkToRoot() ); | 167 | linkToRoot->setChecked( d->linkToRoot() ); |
167 | } | 168 | } |
168 | 169 | ||
169 | void SettingsImpl :: newDestination() | 170 | void SettingsImpl :: newDestination() |
170 | { | 171 | { |
171 | newdestination = true; | 172 | newdestination = true; |
172 | destinationname->setText( "" ); | 173 | destinationname->setText( "" ); |
173 | destinationurl->setText( "" ); | 174 | destinationurl->setText( "" ); |
174 | destinationname->setFocus(); | 175 | destinationname->setFocus(); |
175 | linkToRoot->setChecked( true ); | 176 | linkToRoot->setChecked( true ); |
176 | } | 177 | } |
177 | 178 | ||
178 | void SettingsImpl :: removeDestination() | 179 | void SettingsImpl :: removeDestination() |
179 | { | 180 | { |
180 | changed = true; | 181 | changed = true; |
181 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 182 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); |
182 | dataMgr->getDestinationList().erase( d ); | 183 | dataMgr->getDestinationList().erase( d ); |
183 | destinations->removeItem( currentSelectedDestination ); | 184 | destinations->removeItem( currentSelectedDestination ); |
184 | } | 185 | } |
185 | 186 | ||
186 | void SettingsImpl :: changeDestinationDetails() | 187 | void SettingsImpl :: changeDestinationDetails() |
187 | { | 188 | { |
188 | changed = true; | 189 | changed = true; |
189 | 190 | ||
190 | #ifdef QWS | 191 | #ifdef QWS |
191 | Config cfg( "aqpkg" ); | 192 | Config cfg( "aqpkg" ); |
192 | cfg.setGroup( "destinations" ); | 193 | cfg.setGroup( "destinations" ); |
193 | #endif | 194 | #endif |
194 | 195 | ||
195 | QString newName = destinationname->text(); | 196 | QString newName = destinationname->text(); |
196 | if ( !newdestination ) | 197 | if ( !newdestination ) |
197 | { | 198 | { |
198 | Destination *d = dataMgr->getDestination( destinationName ); | 199 | vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() ); |
199 | 200 | ||
200 | // Update url | 201 | // Update url |
201 | d->setDestinationPath( destinationurl->text() ); | 202 | d->setDestinationPath( destinationurl->text() ); |
202 | d->linkToRoot( linkToRoot->isChecked() ); | 203 | d->linkToRoot( linkToRoot->isChecked() ); |
203 | 204 | ||
204 | // Check if server name has changed, if it has then we need to replace the key in the map | 205 | // Check if server name has changed, if it has then we need to replace the key in the map |
205 | if ( destinationName != newName ) | 206 | if ( destinationName != newName ) |
206 | { | 207 | { |
207 | // Update server name | 208 | // Update server name |
208 | d->setDestinationName( newName ); | 209 | d->setDestinationName( newName ); |
209 | 210 | ||
210 | // Update list box | 211 | // Update list box |