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()
35 QVariant currentValue = value();
41 QList<ConnectionManager::Connection> connections;
43 if(cm.scanConnections(connections, ConnectionManager::GPRS) &&
44 connections.size() > 0)
46 changeItem(gprsIndex_, connections.at(0).name, "gprs");
50 qDebug() << "Unable to scan network connections";
53 selectByValue(currentValue);
57 void ConnectionSelector::setVisible(bool visible)
59 if(visible && !loaded_)
64 ButtonSelector::setVisible(visible);
67 void ConnectionSelector::addItems()
71 addItem(tr("Use global setting"), "global");
72 addItem(tr("WLAN connection"), "wlan");
73 addItem(tr("GPRS connection"), "gprs");
74 addItem(tr("Any connection"), "any");