Commit 3944b0bc authored by Jan Grulich's avatar Jan Grulich

Merge branch 'Plasma/5.11'

parents 1fd29822 9f863798
......@@ -3,7 +3,6 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasmanetworkmanagement-libs\")
set(plasmanm_internal_SRCS
models/appletproxymodel.cpp
models/creatableconnectionsmodel.cpp
models/editoridentitymodel.cpp
models/editorproxymodel.cpp
models/kcmidentitymodel.cpp
models/networkitemslist.cpp
......
/*
Copyright 2014 Jan Grulich <jgrulich@redhat.com>
Copyright 2014 Lukáš Tinkl <ltinkl@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "editoridentitymodel.h"
#include "networkmodel.h"
#include "networkmodelitem.h"
#include "uiutils.h"
#include <NetworkManagerQt/Settings>
#include <QIcon>
#include <QFont>
#include <KLocalizedString>
EditorIdentityModel::EditorIdentityModel(QObject* parent)
: QIdentityProxyModel(parent)
{
NetworkModel * baseModel = new NetworkModel(this);
setSourceModel(baseModel);
}
EditorIdentityModel::~EditorIdentityModel()
{
}
Qt::ItemFlags EditorIdentityModel::flags(const QModelIndex& index) const
{
const QModelIndex mappedProxyIndex = index.sibling(index.row(), 0);
return QIdentityProxyModel::flags(mappedProxyIndex) | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
int EditorIdentityModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return 3;
}
QVariant EditorIdentityModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch (section) {
case 0:
return i18n("Connection name");
case 1:
return i18n("Connection type");
case 2:
return i18n("Last used");
}
}
return QIdentityProxyModel::headerData(section, orientation, role);
}
QVariant EditorIdentityModel::data(const QModelIndex& index, int role) const
{
const QModelIndex sourceIndex = sourceModel()->index(index.row(), 0);
const QString connectionName = sourceModel()->data(sourceIndex, NetworkModel::NameRole).toString();
const QString lastUsed = sourceModel()->data(sourceIndex, NetworkModel::LastUsedDateOnlyRole).toString();
const bool isActivated = (NetworkManager::ActiveConnection::State) sourceModel()->data(sourceIndex, NetworkModel::ConnectionStateRole).toInt()
== NetworkManager::ActiveConnection::Activated;
const bool isActivating = (NetworkManager::ActiveConnection::State) sourceModel()->data(sourceIndex, NetworkModel::ConnectionStateRole).toInt()
== NetworkManager::ActiveConnection::Activating;
NetworkManager::ConnectionSettings::ConnectionType type = static_cast<NetworkManager::ConnectionSettings::ConnectionType>(sourceModel()->data(sourceIndex, NetworkModel::TypeRole).toInt());
NetworkManager::ConnectionSettings::Ptr settings;
NetworkManager::VpnSetting::Ptr vpnSetting ;
if (type == NetworkManager::ConnectionSettings::Vpn) {
settings = NetworkManager::findConnection(sourceModel()->data(sourceIndex, NetworkModel::ConnectionPathRole).toString())->settings();
if (settings) {
vpnSetting = settings->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
}
}
QString tooltip;
const QString iconName = UiUtils::iconAndTitleForConnectionSettingsType(type, tooltip);
const int column = index.column();
if (role == Qt::DisplayRole) {
switch (column) {
case 0:
if (type == NetworkManager::ConnectionSettings::Infiniband ||
type == NetworkManager::ConnectionSettings::Bond ||
type == NetworkManager::ConnectionSettings::Bridge ||
#if NM_CHECK_VERSION(0, 9, 10)
type == NetworkManager::ConnectionSettings::Team ||
#endif
type == NetworkManager::ConnectionSettings::Vlan) {
return QString(connectionName + " (" + NetworkManager::ConnectionSettings::typeAsString(type) + ")");
}
return connectionName;
case 1:
if (type == NetworkManager::ConnectionSettings::Vpn && vpnSetting) {
return QString("%1 (%2)").arg(tooltip).arg(vpnSetting->serviceType().section('.', -1));
}
return tooltip;
case 2:
return lastUsed;
}
} else if (role == Qt::DecorationRole) {
if (column == 0) {
return QIcon::fromTheme(iconName);
}
} else if (role == Qt::ToolTipRole) {
if (column == 0)
return tooltip;
} else if (role == Qt::FontRole) {
if (column == 0 && isActivated) {
QFont f;
f.setBold(true);
return f;
} else if (column == 0 && isActivating) {
QFont f;
f.setItalic(true);
return f;
}
} else {
return sourceModel()->data(index, role);
}
return QVariant();
}
QModelIndex EditorIdentityModel::index(int row, int column, const QModelIndex& parent) const
{
Q_UNUSED(parent);
return createIndex(row, column);
}
QModelIndex EditorIdentityModel::mapToSource(const QModelIndex& proxyIndex) const
{
if (proxyIndex.column() > 0) {
return QModelIndex();
}
return QIdentityProxyModel::mapToSource(proxyIndex);
}
/*
Copyright 2014 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_NM_EDITOR_IDENTITY_MODEL_H
#define PLASMA_NM_EDITOR_IDENTITY_MODEL_H
#include <QIdentityProxyModel>
#include <QModelIndex>
class Q_DECL_EXPORT EditorIdentityModel : public QIdentityProxyModel
{
Q_OBJECT
public:
explicit EditorIdentityModel(QObject* parent = 0);
virtual ~EditorIdentityModel();
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QModelIndex mapToSource(const QModelIndex &proxyIndex) const Q_DECL_OVERRIDE;
};
#endif // PLASMA_NM_EDITOR_IDENTITY_MODEL_H
......@@ -263,9 +263,7 @@ NetworkModelItem::ItemType NetworkModelItem::itemType() const
#if NM_CHECK_VERSION(0, 9, 10)
m_type == NetworkManager::ConnectionSettings::Team ||
#endif
((NetworkManager::status() == NetworkManager::Connected ||
NetworkManager::status() == NetworkManager::ConnectedLinkLocal ||
NetworkManager::status() == NetworkManager::ConnectedSiteOnly) && m_type == NetworkManager::ConnectionSettings::Vpn)) {
(NetworkManager::status() == NetworkManager::Connected && m_type == NetworkManager::ConnectionSettings::Vpn)) {
if (m_connectionPath.isEmpty() && m_type == NetworkManager::ConnectionSettings::Wireless) {
return NetworkModelItem::AvailableAccessPoint;
} else if (m_connectionPath.isEmpty() && m_type == NetworkManager::ConnectionSettings::Wimax) {
......
......@@ -59,6 +59,6 @@ Comment[sr@latin]=Virtuelne privatne mreže preko Fortinetovog SSL VPN‑a
Comment[sv]=Fortinet SSLVPN virtuella privata nätverk
Comment[uk]=Віртуальні приватні мережі SSLVPN Fortinet
Comment[x-test]=xxFortinet SSLVPN virtual private networksxx
Comment[zh_CN]=Fortinet SSLVPN 虚拟专网
Comment[zh_CN]=Fortinet SSLVPN 虛拟私人网络
Comment[zh_TW]=Fortinet SSLVPN 虛擬私人網路
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment