summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-09-30 15:49:39 (UTC)
committer benmeyer <benmeyer>2002-09-30 15:49:39 (UTC)
commit4a090f5954bd5523d214685610c6582975b3d855 (patch) (unidiff)
tree3c9add7dad5df41cdd4e04d00e1d468389c331f4
parentd2a7ac3311bda821ee07ff070c24f17958657129 (diff)
downloadopie-4a090f5954bd5523d214685610c6582975b3d855.zip
opie-4a090f5954bd5523d214685610c6582975b3d855.tar.gz
opie-4a090f5954bd5523d214685610c6582975b3d855.tar.bz2
Profile Changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindow.ui89
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp56
-rw-r--r--noncore/net/networksetup/mainwindowimp.h1
-rw-r--r--noncore/settings/networksettings/mainwindow.ui89
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp56
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h1
6 files changed, 198 insertions, 94 deletions
diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui
index b8c0675..f7efe99 100644
--- a/noncore/net/networksetup/mainwindow.ui
+++ b/noncore/net/networksetup/mainwindow.ui
@@ -8,13 +8,13 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>222</width> 14 <width>218</width>
15 <height>289</height> 15 <height>289</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Network Setup</string> 20 <string>Network Setup</string>
@@ -191,23 +191,12 @@
191 <number>11</number> 191 <number>11</number>
192 </property> 192 </property>
193 <property stdset="1"> 193 <property stdset="1">
194 <name>spacing</name> 194 <name>spacing</name>
195 <number>6</number> 195 <number>6</number>
196 </property> 196 </property>
197 <widget row="1" column="0" rowspan="1" colspan="2" >
198 <class>QLabel</class>
199 <property stdset="1">
200 <name>name</name>
201 <cstring>TextLabel3</cstring>
202 </property>
203 <property stdset="1">
204 <name>text</name>
205 <string>Change Profile To</string>
206 </property>
207 </widget>
208 <widget row="0" column="0" rowspan="1" colspan="2" > 197 <widget row="0" column="0" rowspan="1" colspan="2" >
209 <class>QLabel</class> 198 <class>QLabel</class>
210 <property stdset="1"> 199 <property stdset="1">
211 <name>name</name> 200 <name>name</name>
212 <cstring>TextLabel1</cstring> 201 <cstring>TextLabel1</cstring>
213 </property> 202 </property>
@@ -217,13 +206,13 @@
217 </property> 206 </property>
218 </widget> 207 </widget>
219 <widget row="0" column="2" > 208 <widget row="0" column="2" >
220 <class>QLabel</class> 209 <class>QLabel</class>
221 <property stdset="1"> 210 <property stdset="1">
222 <name>name</name> 211 <name>name</name>
223 <cstring>TextLabel2</cstring> 212 <cstring>currentProfileLabel</cstring>
224 </property> 213 </property>
225 <property stdset="1"> 214 <property stdset="1">
226 <name>frameShape</name> 215 <name>frameShape</name>
227 <enum>Panel</enum> 216 <enum>Panel</enum>
228 </property> 217 </property>
229 <property stdset="1"> 218 <property stdset="1">
@@ -232,48 +221,24 @@
232 </property> 221 </property>
233 <property stdset="1"> 222 <property stdset="1">
234 <name>text</name> 223 <name>text</name>
235 <string>All</string> 224 <string>All</string>
236 </property> 225 </property>
237 </widget> 226 </widget>
238 <widget row="1" column="2" > 227 <widget row="1" column="0" >
239 <class>QComboBox</class> 228 <class>QLabel</class>
240 <item>
241 <property>
242 <name>text</name>
243 <string>All</string>
244 </property>
245 </item>
246 <property stdset="1">
247 <name>name</name>
248 <cstring>ComboBox10</cstring>
249 </property>
250 </widget>
251 <widget row="2" column="1" rowspan="1" colspan="2" >
252 <class>QPushButton</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>removeProfileButton</cstring>
256 </property>
257 <property stdset="1">
258 <name>text</name>
259 <string>&amp;Remove</string>
260 </property>
261 </widget>
262 <widget row="2" column="0" >
263 <class>QPushButton</class>
264 <property stdset="1"> 229 <property stdset="1">
265 <name>name</name> 230 <name>name</name>
266 <cstring>newProfileButton</cstring> 231 <cstring>TextLabel1_2</cstring>
267 </property> 232 </property>
268 <property stdset="1"> 233 <property stdset="1">
269 <name>text</name> 234 <name>text</name>
270 <string>&amp;New</string> 235 <string>Profiles</string>
271 </property> 236 </property>
272 </widget> 237 </widget>
273 <spacer row="3" column="2" > 238 <spacer row="5" column="2" >
274 <property> 239 <property>
275 <name>name</name> 240 <name>name</name>
276 <cstring>Spacer16</cstring> 241 <cstring>Spacer16</cstring>
277 </property> 242 </property>
278 <property stdset="1"> 243 <property stdset="1">
279 <name>orientation</name> 244 <name>orientation</name>
@@ -288,12 +253,52 @@
288 <size> 253 <size>
289 <width>20</width> 254 <width>20</width>
290 <height>20</height> 255 <height>20</height>
291 </size> 256 </size>
292 </property> 257 </property>
293 </spacer> 258 </spacer>
259 <widget row="2" column="0" rowspan="3" colspan="1" >
260 <class>QListBox</class>
261 <property stdset="1">
262 <name>name</name>
263 <cstring>profilesList</cstring>
264 </property>
265 </widget>
266 <widget row="4" column="1" rowspan="1" colspan="2" >
267 <class>QPushButton</class>
268 <property stdset="1">
269 <name>name</name>
270 <cstring>PushButton7</cstring>
271 </property>
272 <property stdset="1">
273 <name>text</name>
274 <string>Set Current</string>
275 </property>
276 </widget>
277 <widget row="3" column="1" rowspan="1" colspan="2" >
278 <class>QPushButton</class>
279 <property stdset="1">
280 <name>name</name>
281 <cstring>removeProfileButton</cstring>
282 </property>
283 <property stdset="1">
284 <name>text</name>
285 <string>&amp;Remove</string>
286 </property>
287 </widget>
288 <widget row="2" column="1" rowspan="1" colspan="2" >
289 <class>QPushButton</class>
290 <property stdset="1">
291 <name>name</name>
292 <cstring>newProfileButton</cstring>
293 </property>
294 <property stdset="1">
295 <name>text</name>
296 <string>&amp;New</string>
297 </property>
298 </widget>
294 </grid> 299 </grid>
295 </widget> 300 </widget>
296 </widget> 301 </widget>
297 </vbox> 302 </vbox>
298</widget> 303</widget>
299<customwidgets> 304<customwidgets>
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index ad9362f..2f821a9 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -4,26 +4,30 @@
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interface.h" 5#include "interface.h"
6#include "kprocess.h" 6#include "kprocess.h"
7#include "module.h" 7#include "module.h"
8 8
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qdir.h>
11#include <qtabwidget.h> 10#include <qtabwidget.h>
11#include <qlistbox.h>
12#include <qlistview.h>
13#include <qheader.h>
14#include <qlabel.h>
15
12#include <qmainwindow.h> 16#include <qmainwindow.h>
13#include <qmessagebox.h> 17#include <qmessagebox.h>
14#include <qlistbox.h> 18
15#include <qpe/config.h> 19#include <qpe/config.h>
16#include <qpe/qlibrary.h> 20#include <qpe/qlibrary.h>
17#include <qpe/resource.h> 21#include <qpe/resource.h>
18#include <qlist.h>
19 22
23#include <qlist.h>
24#include <qdir.h>
20#include <qfile.h> 25#include <qfile.h>
21#include <qtextstream.h> 26#include <qtextstream.h>
22#include <qlistview.h> 27
23#include <qheader.h>
24// For library loading. 28// For library loading.
25#include <dlfcn.h> 29#include <dlfcn.h>
26 30
27#define TEMP_ALL "/tmp/ifconfig-a" 31#define TEMP_ALL "/tmp/ifconfig-a"
28#define TEMP_UP "/tmp/ifconfig" 32#define TEMP_UP "/tmp/ifconfig"
29 33
@@ -34,12 +38,17 @@
34 38
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) { 39MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
36 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked())); 40 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 41 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 42 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 43 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
44
45 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
46 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
47 connect(profilesList, SIGNAL(highlighted(const QString&)), this, SLOT(changeProfile(const QString&)));
48
40 // Make sure we have a plugin directory to scan. 49 // Make sure we have a plugin directory to scan.
41 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 50 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
42 QDir pluginDir( DirStr ); 51 QDir pluginDir( DirStr );
43 pluginDir.mkdir( DirStr ); 52 pluginDir.mkdir( DirStr );
44 pluginDir.mkdir( ( DirStr + "plugins/" ) ); 53 pluginDir.mkdir( ( DirStr + "plugins/" ) );
45 QString path = DirStr + "plugins"; 54 QString path = DirStr + "plugins";
@@ -54,12 +63,14 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
54 getInterfaceList(); 63 getInterfaceList();
55 serviceList->header()->hide(); 64 serviceList->header()->hide();
56 65
57 66
58 Config cfg("NetworkSetup"); 67 Config cfg("NetworkSetup");
59 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 68 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
69 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
70 profilesList->insertItem((*it));
60} 71}
61 72
62/** 73/**
63 * Deconstructor. Unload libraries and save profile list. 74 * Deconstructor. Unload libraries and save profile list.
64 */ 75 */
65MainWindowImp::~MainWindowImp(){ 76MainWindowImp::~MainWindowImp(){
@@ -304,16 +315,51 @@ void MainWindowImp::updateInterface(Interface *i){
304 item->setPixmap(1, type); 315 item->setPixmap(1, type);
305 316
306 item->setText(2, i->getHardwareName()); 317 item->setText(2, i->getHardwareName());
307 318
308} 319}
309 320
321/**
322 * Adds a new profile to the list of profiles.
323 * Don't add profiles that already exists.
324 * Appends to the combo and QStringList
325 */
310void MainWindowImp::addProfile(){ 326void MainWindowImp::addProfile(){
327 QString newProfileName = "New";
328 if(profiles.grep(newProfileName).count() > 0){
329 QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
330 return;
331 }
332 profiles.append(newProfileName);
333 profilesList->insertItem(newProfileName);
311 334
312} 335}
313 336
337/**
338 * Removes the currently selected profile in the combo.
339 * Doesn't delete if there are less then 2 profiles.
340 */
314void MainWindowImp::removeProfile(){ 341void MainWindowImp::removeProfile(){
342 if(profilesList->count() <= 1){
343 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
344 return;
345 }
346 QString profileToRemove = profilesList->currentText();
347 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
348 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
349 profilesList->clear();
350 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
351 profilesList->insertItem((*it));
352 }
353
354}
315 355
356/**
357 * A new profile has been selected, change.
358 * @param newProfile the new profile.
359 */
360void MainWindowImp::changeProfile(const QString& newProfile){
361 currentProfileLabel->setText(newProfile);
316} 362}
317 363
318// mainwindowimp.cpp 364// mainwindowimp.cpp
319 365
diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h
index 0618dd2..8e300bf 100644
--- a/noncore/net/networksetup/mainwindowimp.h
+++ b/noncore/net/networksetup/mainwindowimp.h
@@ -25,12 +25,13 @@ private slots:
25 25
26 void jobDone(KProcess *process); 26 void jobDone(KProcess *process);
27 void getInterfaceList(); 27 void getInterfaceList();
28 28
29 void addProfile(); 29 void addProfile();
30 void removeProfile(); 30 void removeProfile();
31 void changeProfile(const QString&);
31 32
32 void updateInterface(Interface *i); 33 void updateInterface(Interface *i);
33 34
34private: 35private:
35 void loadModules(QString path); 36 void loadModules(QString path);
36 37
diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui
index b8c0675..f7efe99 100644
--- a/noncore/settings/networksettings/mainwindow.ui
+++ b/noncore/settings/networksettings/mainwindow.ui
@@ -8,13 +8,13 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>222</width> 14 <width>218</width>
15 <height>289</height> 15 <height>289</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Network Setup</string> 20 <string>Network Setup</string>
@@ -191,23 +191,12 @@
191 <number>11</number> 191 <number>11</number>
192 </property> 192 </property>
193 <property stdset="1"> 193 <property stdset="1">
194 <name>spacing</name> 194 <name>spacing</name>
195 <number>6</number> 195 <number>6</number>
196 </property> 196 </property>
197 <widget row="1" column="0" rowspan="1" colspan="2" >
198 <class>QLabel</class>
199 <property stdset="1">
200 <name>name</name>
201 <cstring>TextLabel3</cstring>
202 </property>
203 <property stdset="1">
204 <name>text</name>
205 <string>Change Profile To</string>
206 </property>
207 </widget>
208 <widget row="0" column="0" rowspan="1" colspan="2" > 197 <widget row="0" column="0" rowspan="1" colspan="2" >
209 <class>QLabel</class> 198 <class>QLabel</class>
210 <property stdset="1"> 199 <property stdset="1">
211 <name>name</name> 200 <name>name</name>
212 <cstring>TextLabel1</cstring> 201 <cstring>TextLabel1</cstring>
213 </property> 202 </property>
@@ -217,13 +206,13 @@
217 </property> 206 </property>
218 </widget> 207 </widget>
219 <widget row="0" column="2" > 208 <widget row="0" column="2" >
220 <class>QLabel</class> 209 <class>QLabel</class>
221 <property stdset="1"> 210 <property stdset="1">
222 <name>name</name> 211 <name>name</name>
223 <cstring>TextLabel2</cstring> 212 <cstring>currentProfileLabel</cstring>
224 </property> 213 </property>
225 <property stdset="1"> 214 <property stdset="1">
226 <name>frameShape</name> 215 <name>frameShape</name>
227 <enum>Panel</enum> 216 <enum>Panel</enum>
228 </property> 217 </property>
229 <property stdset="1"> 218 <property stdset="1">
@@ -232,48 +221,24 @@
232 </property> 221 </property>
233 <property stdset="1"> 222 <property stdset="1">
234 <name>text</name> 223 <name>text</name>
235 <string>All</string> 224 <string>All</string>
236 </property> 225 </property>
237 </widget> 226 </widget>
238 <widget row="1" column="2" > 227 <widget row="1" column="0" >
239 <class>QComboBox</class> 228 <class>QLabel</class>
240 <item>
241 <property>
242 <name>text</name>
243 <string>All</string>
244 </property>
245 </item>
246 <property stdset="1">
247 <name>name</name>
248 <cstring>ComboBox10</cstring>
249 </property>
250 </widget>
251 <widget row="2" column="1" rowspan="1" colspan="2" >
252 <class>QPushButton</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>removeProfileButton</cstring>
256 </property>
257 <property stdset="1">
258 <name>text</name>
259 <string>&amp;Remove</string>
260 </property>
261 </widget>
262 <widget row="2" column="0" >
263 <class>QPushButton</class>
264 <property stdset="1"> 229 <property stdset="1">
265 <name>name</name> 230 <name>name</name>
266 <cstring>newProfileButton</cstring> 231 <cstring>TextLabel1_2</cstring>
267 </property> 232 </property>
268 <property stdset="1"> 233 <property stdset="1">
269 <name>text</name> 234 <name>text</name>
270 <string>&amp;New</string> 235 <string>Profiles</string>
271 </property> 236 </property>
272 </widget> 237 </widget>
273 <spacer row="3" column="2" > 238 <spacer row="5" column="2" >
274 <property> 239 <property>
275 <name>name</name> 240 <name>name</name>
276 <cstring>Spacer16</cstring> 241 <cstring>Spacer16</cstring>
277 </property> 242 </property>
278 <property stdset="1"> 243 <property stdset="1">
279 <name>orientation</name> 244 <name>orientation</name>
@@ -288,12 +253,52 @@
288 <size> 253 <size>
289 <width>20</width> 254 <width>20</width>
290 <height>20</height> 255 <height>20</height>
291 </size> 256 </size>
292 </property> 257 </property>
293 </spacer> 258 </spacer>
259 <widget row="2" column="0" rowspan="3" colspan="1" >
260 <class>QListBox</class>
261 <property stdset="1">
262 <name>name</name>
263 <cstring>profilesList</cstring>
264 </property>
265 </widget>
266 <widget row="4" column="1" rowspan="1" colspan="2" >
267 <class>QPushButton</class>
268 <property stdset="1">
269 <name>name</name>
270 <cstring>PushButton7</cstring>
271 </property>
272 <property stdset="1">
273 <name>text</name>
274 <string>Set Current</string>
275 </property>
276 </widget>
277 <widget row="3" column="1" rowspan="1" colspan="2" >
278 <class>QPushButton</class>
279 <property stdset="1">
280 <name>name</name>
281 <cstring>removeProfileButton</cstring>
282 </property>
283 <property stdset="1">
284 <name>text</name>
285 <string>&amp;Remove</string>
286 </property>
287 </widget>
288 <widget row="2" column="1" rowspan="1" colspan="2" >
289 <class>QPushButton</class>
290 <property stdset="1">
291 <name>name</name>
292 <cstring>newProfileButton</cstring>
293 </property>
294 <property stdset="1">
295 <name>text</name>
296 <string>&amp;New</string>
297 </property>
298 </widget>
294 </grid> 299 </grid>
295 </widget> 300 </widget>
296 </widget> 301 </widget>
297 </vbox> 302 </vbox>
298</widget> 303</widget>
299<customwidgets> 304<customwidgets>
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index ad9362f..2f821a9 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -4,26 +4,30 @@
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interface.h" 5#include "interface.h"
6#include "kprocess.h" 6#include "kprocess.h"
7#include "module.h" 7#include "module.h"
8 8
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qdir.h>
11#include <qtabwidget.h> 10#include <qtabwidget.h>
11#include <qlistbox.h>
12#include <qlistview.h>
13#include <qheader.h>
14#include <qlabel.h>
15
12#include <qmainwindow.h> 16#include <qmainwindow.h>
13#include <qmessagebox.h> 17#include <qmessagebox.h>
14#include <qlistbox.h> 18
15#include <qpe/config.h> 19#include <qpe/config.h>
16#include <qpe/qlibrary.h> 20#include <qpe/qlibrary.h>
17#include <qpe/resource.h> 21#include <qpe/resource.h>
18#include <qlist.h>
19 22
23#include <qlist.h>
24#include <qdir.h>
20#include <qfile.h> 25#include <qfile.h>
21#include <qtextstream.h> 26#include <qtextstream.h>
22#include <qlistview.h> 27
23#include <qheader.h>
24// For library loading. 28// For library loading.
25#include <dlfcn.h> 29#include <dlfcn.h>
26 30
27#define TEMP_ALL "/tmp/ifconfig-a" 31#define TEMP_ALL "/tmp/ifconfig-a"
28#define TEMP_UP "/tmp/ifconfig" 32#define TEMP_UP "/tmp/ifconfig"
29 33
@@ -34,12 +38,17 @@
34 38
35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) { 39MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
36 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked())); 40 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
37 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 41 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
38 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 42 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
39 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 43 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
44
45 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
46 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
47 connect(profilesList, SIGNAL(highlighted(const QString&)), this, SLOT(changeProfile(const QString&)));
48
40 // Make sure we have a plugin directory to scan. 49 // Make sure we have a plugin directory to scan.
41 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 50 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
42 QDir pluginDir( DirStr ); 51 QDir pluginDir( DirStr );
43 pluginDir.mkdir( DirStr ); 52 pluginDir.mkdir( DirStr );
44 pluginDir.mkdir( ( DirStr + "plugins/" ) ); 53 pluginDir.mkdir( ( DirStr + "plugins/" ) );
45 QString path = DirStr + "plugins"; 54 QString path = DirStr + "plugins";
@@ -54,12 +63,14 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
54 getInterfaceList(); 63 getInterfaceList();
55 serviceList->header()->hide(); 64 serviceList->header()->hide();
56 65
57 66
58 Config cfg("NetworkSetup"); 67 Config cfg("NetworkSetup");
59 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 68 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
69 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
70 profilesList->insertItem((*it));
60} 71}
61 72
62/** 73/**
63 * Deconstructor. Unload libraries and save profile list. 74 * Deconstructor. Unload libraries and save profile list.
64 */ 75 */
65MainWindowImp::~MainWindowImp(){ 76MainWindowImp::~MainWindowImp(){
@@ -304,16 +315,51 @@ void MainWindowImp::updateInterface(Interface *i){
304 item->setPixmap(1, type); 315 item->setPixmap(1, type);
305 316
306 item->setText(2, i->getHardwareName()); 317 item->setText(2, i->getHardwareName());
307 318
308} 319}
309 320
321/**
322 * Adds a new profile to the list of profiles.
323 * Don't add profiles that already exists.
324 * Appends to the combo and QStringList
325 */
310void MainWindowImp::addProfile(){ 326void MainWindowImp::addProfile(){
327 QString newProfileName = "New";
328 if(profiles.grep(newProfileName).count() > 0){
329 QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
330 return;
331 }
332 profiles.append(newProfileName);
333 profilesList->insertItem(newProfileName);
311 334
312} 335}
313 336
337/**
338 * Removes the currently selected profile in the combo.
339 * Doesn't delete if there are less then 2 profiles.
340 */
314void MainWindowImp::removeProfile(){ 341void MainWindowImp::removeProfile(){
342 if(profilesList->count() <= 1){
343 QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
344 return;
345 }
346 QString profileToRemove = profilesList->currentText();
347 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
348 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
349 profilesList->clear();
350 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
351 profilesList->insertItem((*it));
352 }
353
354}
315 355
356/**
357 * A new profile has been selected, change.
358 * @param newProfile the new profile.
359 */
360void MainWindowImp::changeProfile(const QString& newProfile){
361 currentProfileLabel->setText(newProfile);
316} 362}
317 363
318// mainwindowimp.cpp 364// mainwindowimp.cpp
319 365
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 0618dd2..8e300bf 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -25,12 +25,13 @@ private slots:
25 25
26 void jobDone(KProcess *process); 26 void jobDone(KProcess *process);
27 void getInterfaceList(); 27 void getInterfaceList();
28 28
29 void addProfile(); 29 void addProfile();
30 void removeProfile(); 30 void removeProfile();
31 void changeProfile(const QString&);
31 32
32 void updateInterface(Interface *i); 33 void updateInterface(Interface *i);
33 34
34private: 35private:
35 void loadModules(QString path); 36 void loadModules(QString path);
36 37