summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/settingsimpl.cpp
Unidiff
Diffstat (limited to 'noncore/settings/aqpkg/settingsimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp13
1 files changed, 7 insertions, 6 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
@@ -1,42 +1,43 @@
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>
19using namespace std; 20using 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
31#include "settingsimpl.h" 32#include "settingsimpl.h"
32 33
33#include "global.h" 34#include "global.h"
34 35
35SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) 36SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
36 : SettingsBase( parent, name, modal, fl ) 37 : SettingsBase( parent, name, modal, fl )
37{ 38{
38 dataMgr = dataManager; 39 dataMgr = dataManager;
39 40
40 setupData(); 41 setupData();
41 changed = false; 42 changed = false;
42 newserver = false; 43 newserver = false;
@@ -70,153 +71,153 @@ void SettingsImpl :: setupData()
70 continue; 71 continue;
71 72
72 servers->insertItem( it->getServerName() ); 73 servers->insertItem( it->getServerName() );
73 } 74 }
74 75
75 // add destinations 76 // add destinations
76 vector<Destination>::iterator it2; 77 vector<Destination>::iterator it2;
77 for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) 78 for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 )
78 destinations->insertItem( it2->getDestinationName() ); 79 destinations->insertItem( it2->getDestinationName() );
79 80
80#ifdef QWS 81#ifdef QWS
81 Config cfg( "aqpkg" ); 82 Config cfg( "aqpkg" );
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
91void SettingsImpl :: editServer( int sel ) 92void 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
101void SettingsImpl :: newServer() 102void 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
110void SettingsImpl :: removeServer() 111void 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
118void SettingsImpl :: changeServerDetails() 119void 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
138 // See if this server is the active server 139 // See if this server is the active server
139 // if ( dataMgr->getActiveServer() == serverName ) 140 // if ( dataMgr->getActiveServer() == serverName )
140 // dataMgr->setActiveServer( newName ); 141 // dataMgr->setActiveServer( newName );
141 142
142 // Update list box 143 // Update list box
143 servers->changeItem( newName, currentSelectedServer ); 144 servers->changeItem( newName, currentSelectedServer );
144 } 145 }
145 } 146 }
146 else 147 else
147 { 148 {
148 Server s( newName, serverurl->text() ); 149 Server s( newName, serverurl->text() );
149 dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); 150 dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) );
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
159void SettingsImpl :: editDestination( int sel ) 160void 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
169void SettingsImpl :: newDestination() 170void 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
178void SettingsImpl :: removeDestination() 179void 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
186void SettingsImpl :: changeDestinationDetails() 187void 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
211 destinations->changeItem( newName, currentSelectedDestination ); 212 destinations->changeItem( newName, currentSelectedDestination );
212 } 213 }
213#ifdef QWS 214#ifdef QWS
214 QString key = newName; 215 QString key = newName;
215 key += "_linkToRoot"; 216 key += "_linkToRoot";
216 int val = d->linkToRoot(); 217 int val = d->linkToRoot();
217 cfg.writeEntry( key, val ); 218 cfg.writeEntry( key, val );
218#endif 219#endif
219 } 220 }
220 else 221 else
221 { 222 {
222 dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); 223 dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) );