Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Unmaintained
Network Management
Commits
4276442b
Commit
4276442b
authored
Aug 27, 2011
by
Ilia Kats
Browse files
Show band and channel in ScanWidget/details.
BUG: 259284 FIXED-IN: nm09
parent
ab72548f
Changes
12
Hide whitespace changes
Inline
Side-by-side
libs/internals/uiutils.cpp
View file @
4276442b
...
...
@@ -20,9 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Own
#include
"uiutils.h"
#include
"uiutils_p.h"
#include
"paths.h"
#include
"settings/802-11-wireless.h"
// KDE
#include
<KDebug>
#include
<KIconLoader>
...
...
@@ -37,6 +40,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Qt
#include
<QSizeF>
K_GLOBAL_STATIC
(
UiUtilsPrivate
,
s_UiUtilsPrivate
)
QString
UiUtils
::
interfaceTypeLabel
(
const
Solid
::
Control
::
NetworkInterfaceNm09
::
Type
type
,
const
Solid
::
Control
::
NetworkInterfaceNm09
*
iface
)
{
QString
deviceText
;
...
...
@@ -410,4 +415,55 @@ QByteArray UiUtils::macAddressFromString( const QString & s)
return
ba
;
}
QPair
<
int
,
int
>
UiUtils
::
findBandAndChannel
(
int
freq
)
{
UiUtilsPrivate
*
priv
=
s_UiUtilsPrivate
;
QPair
<
int
,
int
>
pair
;
if
(
freq
<
2500
)
{
pair
.
first
=
Knm
::
WirelessSetting
::
EnumBand
::
bg
;
pair
.
second
=
0
;
int
i
=
0
;
QList
<
QPair
<
int
,
int
>
>
bFreqs
=
priv
->
getBFreqs
();
while
(
i
<
bFreqs
.
size
())
{
if
(
bFreqs
.
at
(
i
).
second
<=
freq
)
{
pair
.
second
=
bFreqs
.
at
(
i
).
first
;
}
else
{
break
;
}
i
++
;
}
return
pair
;
}
pair
.
second
=
0
;
int
i
=
0
;
QList
<
QPair
<
int
,
int
>
>
aFreqs
=
priv
->
getAFreqs
();
while
(
i
<
aFreqs
.
size
())
{
if
(
aFreqs
.
at
(
i
).
second
<=
freq
)
{
pair
.
second
=
aFreqs
.
at
(
i
).
first
;
}
else
{
break
;
}
i
++
;
}
pair
.
first
=
Knm
::
WirelessSetting
::
EnumBand
::
a
;
return
pair
;
}
QString
UiUtils
::
wirelessBandToString
(
int
band
)
{
switch
(
band
)
{
case
Knm
::
WirelessSetting
::
EnumBand
::
a
:
return
QLatin1String
(
"a"
);
break
;
case
Knm
::
WirelessSetting
::
EnumBand
::
bg
:
return
QLatin1String
(
"b/g"
);
break
;
}
return
QString
();
}
// vim: sw=4 sts=4 et tw=100
libs/internals/uiutils.h
View file @
4276442b
...
...
@@ -125,5 +125,18 @@ public:
*/
static
QByteArray
macAddressFromString
(
const
QString
&
s
);
/**
* @param freq frequency of a wireless network
* @return The frequency translated into band (first element of the QPair) and channel. The band value is
* corresponding to the type enum in Knm::WirelessSetting::EnumBand
*/
static
QPair
<
int
,
int
>
findBandAndChannel
(
int
freq
);
/**
* @param band The band of a wireless network. The value corresponds to the type enum in Knm::WirelessSetting::EnumBand
* @return A string representation
*/
static
QString
wirelessBandToString
(
int
band
);
};
#endif // UIUTILS_H
libs/ui/802_11_wirelesswidget.cpp
View file @
4276442b
...
...
@@ -222,7 +222,7 @@ void Wireless80211Widget::setAccessPointData(const Solid::Control::WirelessNetwo
}
Q_D
(
const
Wireless80211Widget
);
QPair
<
int
,
int
>
bandAndChannel
=
d
->
ui
.
channel
->
findBandAndChannel
((
int
)
ap
->
frequency
());
QPair
<
int
,
int
>
bandAndChannel
=
UiUtils
::
findBandAndChannel
((
int
)
ap
->
frequency
());
switch
(
bandAndChannel
.
first
)
{
...
...
@@ -371,84 +371,6 @@ Wireless80211WidgetBand::Wireless80211WidgetBand(QWidget * parent)
channels
<<
channels_a
<<
channels_b
;
setBand
(
Wireless80211WidgetPrivate
::
AIndex
);
freqs_bgn
<<
2412
<<
2417
<<
2422
<<
2427
<<
2432
<<
2437
<<
2442
<<
2447
<<
2452
<<
2457
<<
2462
<<
2467
<<
2472
<<
2484
;
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
183
,
4915
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
184
,
4920
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
185
,
4925
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
187
,
4935
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
188
,
4940
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
189
,
4945
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
192
,
4960
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
196
,
4980
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
7
,
5035
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
8
,
5040
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
9
,
5045
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
11
,
5055
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
12
,
5060
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
16
,
5080
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
34
,
5170
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
36
,
5180
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
38
,
5190
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
40
,
5200
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
42
,
5210
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
44
,
5220
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
46
,
5230
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
48
,
5240
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
52
,
5260
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
56
,
5280
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
60
,
5300
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
64
,
5320
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
100
,
5500
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
104
,
5520
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
108
,
5540
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
112
,
5560
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
116
,
5580
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
120
,
5600
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
124
,
5620
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
128
,
5640
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
132
,
5660
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
136
,
5680
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
140
,
5700
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
149
,
5745
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
153
,
5765
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
157
,
5785
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
161
,
5805
));
freqs_ahjn
.
append
(
QPair
<
int
,
int
>
(
165
,
5825
));
}
QPair
<
int
,
int
>
Wireless80211WidgetBand
::
findBandAndChannel
(
int
freq
)
{
QPair
<
int
,
int
>
pair
;
pair
.
second
=
0
;
foreach
(
const
int
f
,
freqs_bgn
)
{
if
(
f
<=
freq
)
{
pair
.
second
++
;
}
else
{
break
;
}
}
if
(
freq
<
2500
)
{
pair
.
first
=
Knm
::
WirelessSetting
::
EnumBand
::
bg
;
return
pair
;
}
pair
.
second
=
0
;
int
i
=
0
;
while
(
i
<
freqs_ahjn
.
size
())
{
if
(
freqs_ahjn
.
at
(
i
).
second
<=
freq
)
{
pair
.
second
=
freqs_ahjn
.
at
(
i
).
first
;
}
else
{
break
;
}
i
++
;
}
pair
.
first
=
Knm
::
WirelessSetting
::
EnumBand
::
a
;
return
pair
;
}
QString
Wireless80211WidgetBand
::
textFromValue
(
int
value
)
const
...
...
libs/ui/802_11_wirelesswidget.h
View file @
4276442b
...
...
@@ -74,8 +74,6 @@ public Q_SLOTS:
private:
enum
ChannelsFor
{
a
=
0
,
bg
=
1
};
QList
<
QList
<
int
>
>
channels
;
QList
<
int
>
freqs_bgn
;
QList
<
QPair
<
int
,
int
>
>
freqs_ahjn
;
int
selectedBand
;
};
...
...
libs/ui/apitemdelegate.cpp
View file @
4276442b
...
...
@@ -35,19 +35,20 @@ ApItemDelegate::~ApItemDelegate()
void
ApItemDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
KIcon
encryptedIcon
(
index
.
data
(
Ap
ItemModel
::
EncryptionRole
).
value
<
QIcon
>
());
KIcon
encryptedIcon
(
index
.
data
(
Network
ItemModel
::
EncryptionRole
).
value
<
QIcon
>
());
encryptedIcon
.
paint
(
painter
,
QRect
(
option
.
rect
.
topLeft
(),
option
.
decorationSize
));
QSize
iconSize
=
encryptedIcon
.
actualSize
(
option
.
decorationSize
);
QStyleOptionViewItem
delegateOption
=
option
;
delegateOption
.
rect
.
translate
(
iconSize
.
width
(),
0
);
delegateOption
.
rect
.
setWidth
(
option
.
rect
.
width
()
-
iconSize
.
width
());
delegateOption
.
decorationSize
=
QSize
(
-
1
,
-
1
);
QItemDelegate
::
paint
(
painter
,
delegateOption
,
index
);
}
QSize
ApItemDelegate
::
sizeHint
(
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
KIcon
encryptedIcon
=
KIcon
(
index
.
data
(
Ap
ItemModel
::
EncryptionRole
).
toString
());
KIcon
encryptedIcon
=
KIcon
(
index
.
data
(
Network
ItemModel
::
EncryptionRole
).
toString
());
QSize
rect
=
encryptedIcon
.
actualSize
(
option
.
decorationSize
);
return
rect
;
...
...
libs/ui/apitemdelegate.h
View file @
4276442b
...
...
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef APITEMDELEGATE_H
#define APITEMDELEGATE_H
#include
"
ap
itemmodel.h"
#include
"
network
itemmodel.h"
#include
"accesspoint.h"
#include
<QItemDelegate>
...
...
libs/ui/apitemview.cpp
View file @
4276442b
...
...
@@ -156,7 +156,7 @@ void ApItemView::layoutItems()
int
numRows
=
m_model
->
rowCount
();
for
(
int
ctr
=
0
;
ctr
<
numRows
;
ctr
++
)
{
QModelIndex
index
=
m_model
->
index
(
ctr
,
0
);
int
strength
=
m_model
->
data
(
index
,
Ap
ItemModel
::
SignalStrength
).
toInt
();
int
strength
=
m_model
->
data
(
index
,
Network
ItemModel
::
SignalStrength
).
toInt
();
int
x
=
(
geometry
().
width
()
-
m_itemWidth
)
-
(
geometry
().
width
()
-
m_itemWidth
-
computerHeight
)
*
strength
/
100
;
QPoint
topLeft
=
QPoint
(
x
,
0
);
m_apLayout
[
index
]
=
QRect
(
topLeft
,
QSize
(
m_itemWidth
,
m_itemHeight
));
...
...
libs/ui/apitemview.h
View file @
4276442b
...
...
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef APITEMVIEW_H
#define APITEMVIEW_H
#include
"
ap
itemmodel.h"
#include
"
network
itemmodel.h"
#include
<QWidget>
#include
<QPoint>
...
...
libs/ui/networkitemmodel.cpp
View file @
4276442b
...
...
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include
<KLocale>
#include
"wirelesssecurityidentifier.h"
#include
<uiutils.h>
NetworkItemModel
::
NetworkItemModel
(
const
QString
&
uni
,
QObject
*
parent
)
:
QAbstractItemModel
(
parent
),
...
...
@@ -116,6 +117,22 @@ QVariant NetworkItemModel::data(const QModelIndex &index, int role) const
}
else
{
return
QVariant
();
}
case
Band
:
ap
=
m_networkInterface
->
findAccessPoint
(
network
->
referenceAccessPoint
());
if
(
ap
)
{
int
freq
=
ap
->
frequency
();
return
UiUtils
::
findBandAndChannel
(
freq
).
first
;
}
else
{
return
QVariant
();
}
case
Channel
:
ap
=
m_networkInterface
->
findAccessPoint
(
network
->
referenceAccessPoint
());
if
(
ap
)
{
int
freq
=
ap
->
frequency
();
return
UiUtils
::
findBandAndChannel
(
freq
).
second
;
}
else
{
return
QVariant
();
}
default:
return
QVariant
();
}
...
...
@@ -138,6 +155,18 @@ QVariant NetworkItemModel::data(const QModelIndex &index, int role) const
else
return
QVariant
();
case
3
:
if
(
role
==
Qt
::
DisplayRole
)
{
ap
=
m_networkInterface
->
findAccessPoint
(
network
->
referenceAccessPoint
());
int
freq
=
ap
->
frequency
();
return
UiUtils
::
wirelessBandToString
(
UiUtils
::
findBandAndChannel
(
freq
).
first
);
}
case
4
:
if
(
role
==
Qt
::
DisplayRole
)
{
ap
=
m_networkInterface
->
findAccessPoint
(
network
->
referenceAccessPoint
());
int
freq
=
ap
->
frequency
();
return
QString
(
"%1 (%2 MHz)"
).
arg
(
UiUtils
::
findBandAndChannel
(
freq
).
second
).
arg
(
freq
);
}
case
5
:
if
(
role
==
Qt
::
DisplayRole
)
return
m_networkInterface
->
findAccessPoint
(
network
->
referenceAccessPoint
())
->
hardwareAddress
();
else
...
...
@@ -165,6 +194,10 @@ QVariant NetworkItemModel::headerData(int section, Qt::Orientation orientation,
case
2
:
return
QVariant
(
i18nc
(
"@item:intable wireless encryption type"
,
"Encryption"
));
case
3
:
return
QVariant
(
i18nc
(
"@item:intable wireless band"
,
"Band"
));
case
4
:
return
QVariant
(
i18nc
(
"@item:intable wireless channel"
,
"Channel"
));
case
5
:
return
QVariant
(
i18nc
(
"@item:intable wireless access point hardware address"
,
"MAC Address"
));
default:
return
QVariant
();
...
...
libs/ui/networkitemmodel.h
View file @
4276442b
...
...
@@ -41,7 +41,7 @@ class NetworkItemModel : public QAbstractItemModel
Q_OBJECT
public:
enum
UserRoles
{
SignalStrength
=
Qt
::
UserRole
,
MacAddress
,
ConnectionType
,
EncryptionRole
};
enum
UserRoles
{
SignalStrength
=
Qt
::
UserRole
,
MacAddress
,
Band
,
Channel
,
ConnectionType
,
EncryptionRole
};
NetworkItemModel
(
const
QString
&
uni
,
QObject
*
parent
=
0
);
~
NetworkItemModel
();
...
...
@@ -65,7 +65,7 @@ class NetworkItemModel : public QAbstractItemModel
Solid
::
Control
::
WirelessNetworkInterfaceNm09
*
m_networkInterface
;
Solid
::
Control
::
WirelessNetworkInterfaceEnvironment
*
m_environment
;
static
const
int
s_numColumns
=
4
;
static
const
int
s_numColumns
=
6
;
};
#endif
...
...
libs/ui/scanwidget.cpp
View file @
4276442b
...
...
@@ -58,6 +58,7 @@ ScanWidget::ScanWidget(QWidget *parent)
m_proxyModel
->
setSortCaseSensitivity
(
Qt
::
CaseInsensitive
);
m_scanProxySelectionModel
=
new
QItemSelectionModel
(
m_proxyModel
);
m_detailsView
=
new
QTreeView
(
this
);
m_detailsView
->
sortByColumn
(
0
,
Qt
::
AscendingOrder
);
m_detailsView
->
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
m_detailsView
->
setAllColumnsShowFocus
(
true
);
m_detailsView
->
setRootIsDecorated
(
false
);
...
...
@@ -109,7 +110,7 @@ QPair<QString,QString> ScanWidget::currentAccessPoint() const
break
;
case
true
:
default:
accessPoint
.
second
=
m_scanModel
->
data
(
m_scanModel
->
index
(
index
.
row
(),
3
)).
toString
();
accessPoint
.
second
=
m_scanModel
->
data
(
m_scanModel
->
index
(
index
.
row
(),
5
)).
toString
();
break
;
}
...
...
@@ -136,7 +137,7 @@ QPair<Solid::Control::WirelessNetworkInterfaceNm09 *, Solid::Control::AccessPoin
return
pair
;
}
QString
apMac
=
m_scanModel
->
data
(
m_scanModel
->
index
(
index
.
row
(),
3
)).
toString
();
QString
apMac
=
m_scanModel
->
data
(
m_scanModel
->
index
(
index
.
row
(),
5
)).
toString
();
if
(
apMac
.
isEmpty
())
{
return
pair
;
}
...
...
plasma_nm_version.h
View file @
4276442b
#ifndef PLASMA_NM_VERSION_H
#define PLASMA_NM_VERSION_H
static
const
char
*
plasmaNmVersion
=
"nm09-2011082
6
"
;
static
const
char
*
plasmaNmVersion
=
"nm09-2011082
7
"
;
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment