~ubuntu-branches/ubuntu/precise/networkmanagement/precise

« back to all changes in this revision

Viewing changes to libs/ui/scanwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-10-23 14:00:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20111023140013-e38hdzybcg6zndrk
Tags: 0.9~svngit.nm09.20111023.ff842e-0ubuntu1
* New upstream snapshot.
* Drop all patches, merged upstream.
* Add kubuntu_add_subdirectory_po.diff to build the translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    setupUi(this);
35
35
 
36
36
    //populate the interfaces combobox
37
 
    foreach (Solid::Control::NetworkInterfaceNm09 * iface, Solid::Control::NetworkManagerNm09::networkInterfaces()) {
 
37
    foreach (const Solid::Control::NetworkInterfaceNm09 * iface, Solid::Control::NetworkManagerNm09::networkInterfaces()) {
38
38
        if (iface->type() == Solid::Control::NetworkInterfaceNm09::Wifi) {
39
39
 
40
 
            Solid::Control::WirelessNetworkInterfaceNm09 * wiface = static_cast<Solid::Control::WirelessNetworkInterfaceNm09*>(iface);
 
40
            const Solid::Control::WirelessNetworkInterfaceNm09 * wiface = static_cast<const Solid::Control::WirelessNetworkInterfaceNm09*>(iface);
41
41
            m_interface->addItem(UiUtils::interfaceNameLabel(iface->uni()), wiface->uni());
42
42
        }
43
43
    }
58
58
    m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
59
59
    m_scanProxySelectionModel = new QItemSelectionModel(m_proxyModel);
60
60
    m_detailsView = new QTreeView(this);
 
61
    m_detailsView->sortByColumn(0, Qt::AscendingOrder);
61
62
    m_detailsView->setSelectionBehavior(QAbstractItemView::SelectRows);
62
63
    m_detailsView->setAllColumnsShowFocus(true);
63
64
    m_detailsView->setRootIsDecorated(false);
109
110
            break;
110
111
        case true:
111
112
        default:
112
 
            accessPoint.second = m_scanModel->data(m_scanModel->index(index.row(),3)).toString();
 
113
            accessPoint.second = m_scanModel->data(m_scanModel->index(index.row(),5)).toString();
113
114
            break;
114
115
    }
115
116
 
116
117
    return accessPoint;
117
118
}
118
119
 
 
120
QPair<Solid::Control::WirelessNetworkInterfaceNm09 *, Solid::Control::AccessPointNm09 *> ScanWidget::currentAccessPointUni()
 
121
{
 
122
    QPair<Solid::Control::WirelessNetworkInterfaceNm09 *, Solid::Control::AccessPointNm09 *> pair(0, 0);
 
123
    QModelIndex index;
 
124
 
 
125
    switch (m_stack->currentIndex())
 
126
    {
 
127
        case Details:
 
128
            index = m_proxyModel->mapToSource(m_scanProxySelectionModel->currentIndex());
 
129
            break;
 
130
        case Map:
 
131
        default:
 
132
            index = m_scanSelectionModel->currentIndex();
 
133
            break;
 
134
    }
 
135
 
 
136
    if (!index.isValid()) {
 
137
        return pair;
 
138
    }
 
139
 
 
140
    QString apMac = m_scanModel->data(m_scanModel->index(index.row(),5)).toString();
 
141
    if (apMac.isEmpty()) {
 
142
        return pair;
 
143
    }
 
144
 
 
145
    Solid::Control::WirelessNetworkInterfaceNm09 * wiface = qobject_cast<Solid::Control::WirelessNetworkInterfaceNm09 *>(Solid::Control::NetworkManagerNm09::findNetworkInterface(m_interface->itemData(m_interface->currentIndex()).toString()));
 
146
    if (wiface) {
 
147
        foreach(const QString & uni, wiface->accessPoints()) {
 
148
            Solid::Control::AccessPointNm09 * ap = wiface->findAccessPoint(uni);
 
149
            if (ap->hardwareAddress() == apMac) {
 
150
                pair.first = wiface;
 
151
                pair.second = ap;
 
152
                break;
 
153
            }
 
154
        }
 
155
    }
 
156
 
 
157
    return pair;
 
158
}
 
159
 
119
160
void ScanWidget::onInterfaceChanged(int index)
120
161
{
121
162
    m_scanModel->setNetworkInterface(m_interface->itemData(index).toString());