summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp56
1 files changed, 51 insertions, 5 deletions
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
@@ -7,20 +7,24 @@
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
@@ -37,6 +41,11 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
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 );
@@ -57,6 +66,8 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
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/**
@@ -307,13 +318,48 @@ void MainWindowImp::updateInterface(Interface *i){
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 }
315 353
316} 354}
317 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);
362}
363
318// mainwindowimp.cpp 364// mainwindowimp.cpp
319 365