2 * This file is part of Jenirok.
4 * Jenirok is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Jenirok is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Jenirok. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtCore/QList>
20 #include <QtCore/QVariant>
21 #include <QtCore/QDebug>
22 #include "connectionselector.h"
23 #include "connectionmanager.h"
25 ConnectionSelector::ConnectionSelector(QString const& text, QWidget* parent):
26 ButtonSelector(text, parent), loaded_(false), gprsIndex_(0)
31 void ConnectionSelector::updateConnections()
33 QVariant currentValue = value();
39 QList<ConnectionManager::Connection> connections;
41 if(cm.scanConnections(connections, ConnectionManager::GPRS) &&
42 connections.size() > 0)
44 changeItem(gprsIndex_, connections.at(0).name, "gprs");
48 qDebug() << "Unable to scan network connections";
51 selectByValue(currentValue);
55 void ConnectionSelector::setVisible(bool visible)
57 if(visible && !loaded_)
62 ButtonSelector::setVisible(visible);
65 void ConnectionSelector::addItems()
69 addItem(tr("Use global setting"), "global");
70 addItem(tr("WLAN connection"), "wlan");
71 addItem(tr("GPRS connection"), "gprs");
72 addItem(tr("Any connection"), "any");