From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- wifi/kwireless/propertytable.cpp | 151 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 wifi/kwireless/propertytable.cpp (limited to 'wifi/kwireless/propertytable.cpp') diff --git a/wifi/kwireless/propertytable.cpp b/wifi/kwireless/propertytable.cpp new file mode 100644 index 00000000..7011c691 --- /dev/null +++ b/wifi/kwireless/propertytable.cpp @@ -0,0 +1,151 @@ +/* + $ Author: Mirko Boehm $ + $ License: This code is licensed under the LGPL $ + $ Copyright: (C) 1996-2003, Mirko Boehm $ + $ Contact: Mirko Boehm + http://www.kde.org + http://www.hackerbuero.org $ +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "propertytable.h" +#include "kwirelesswidget.h" + +extern "C" { +#include +} + +PropertyTable::PropertyTable(QWidget *parent, const char* name) + : PropertyTableBase(parent, name) +{ +} + +PropertyTable::~PropertyTable() +{ +} + +PropertiesDialog::PropertiesDialog(QWidget *parent, const char *name) + : KDialogBase(parent, name, true, + i18n("Wireless Network Device Properties"), + KDialogBase::Ok, KDialogBase::Ok, true), + wait(false) +{ + table = new PropertyTable(this); + setMainWidget(table); + table->table->setLeftMargin(0); + table->table->setSorting(false); + table->table->setReadOnly(true); + adjustSize(); + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), SLOT(timeout())); + timer->start(3000, false); + connect(table->cbDeviceSelector, SIGNAL(activated(int)), + SLOT(selected(int))); +} + +void PropertiesDialog::update(QPtrList *_info) +{ + int selection = table->cbDeviceSelector->currentItem(); + + if(wait) return; + + info = _info; + DeviceInfo *device; + QPtrListIterator it(*info); + + table->cbDeviceSelector->clear(); + + while((device = it.current()) != 0) + { + ++it; + table->cbDeviceSelector->insertItem(device->device()); + } + + if(selection > 0 && selection < table->cbDeviceSelector->count()) + { + selected(selection); + } else { + if(table->cbDeviceSelector->count() == 0) + { + selected(-1); + } else { + selected(0); + } + } + + table->cbDeviceSelector->setEnabled(info->count()>1); + + wait = true; +} + +void PropertiesDialog::timeout() +{ + wait = false; +} + +void PropertiesDialog::selected(int index) +{ + DeviceInfo temp; + DeviceInfo *device; + int count; + + if(index < 0) + { + device = &temp; + } else { + device = info->at(index); + } + + QString fields[] = + { + i18n("Device:"), + i18n("ESSID (network name):"), + i18n("Link quality:"), + i18n("Signal strength:"), + i18n("Noise level:"), + i18n("Bit rate:"), + i18n("Encryption:") + }; + const int NoOfFields = sizeof(fields)/sizeof(fields[0]); + + QString values[] = + { + device->device(), + device->essid(), + device->qualityString(), + device->signalString(), + device->noiseString(), + device->bitrateString(), + device->encrString() + }; + const int NoOfValues = sizeof(values)/sizeof(values[0]); + + if(table->table->numRows() == 0) + { + table->table->insertRows(0, NoOfFields); + // HACK (make more rows visible than the default): + resize(size().width(), (int)(1.8*size().height())); + } + + for(count = 0; counttable->setText(count, 0, fields[count]); + } + + for(count = 0; counttable->setText(count, 1, values[count]); + } + + table->table->adjustColumn(0); + table->table->adjustColumn(1); + +} + +#include "propertytable.moc" -- cgit v1.2.1