Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 726adae5 authored by Martin Kacej's avatar Martin Kacej

added model option mode displaying

parent c25b8460
......@@ -36,6 +36,14 @@ MobileProxyModel::~MobileProxyModel()
{
}
void MobileProxyModel::setShowSavedMode(bool mode){
_showSavedMode = mode;
}
bool MobileProxyModel::showSavedMode() const{
return _showSavedMode;
}
bool MobileProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
const QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
......@@ -48,13 +56,15 @@ bool MobileProxyModel::filterAcceptsRow(int source_row, const QModelIndex& sourc
}
const NetworkManager::ConnectionSettings::ConnectionType type = (NetworkManager::ConnectionSettings::ConnectionType) sourceModel()->data(index, NetworkModel::TypeRole).toUInt();
if (type != NetworkManager::ConnectionSettings::Wireless) {
return false;
if (type == NetworkManager::ConnectionSettings::Wireless) {
NetworkModelItem::ItemType itemType = (NetworkModelItem::ItemType)sourceModel()->data(index, NetworkModel::ItemTypeRole).toUInt();
if (showSavedMode()) {
return itemType == NetworkModelItem::UnavailableConnection;
} else {
return itemType >= NetworkModelItem::AvailableConnection;
}
}
// TODO add an option to show already configured connections
NetworkModelItem::ItemType itemType = (NetworkModelItem::ItemType)sourceModel()->data(index, NetworkModel::ItemTypeRole).toUInt();
return itemType > NetworkModelItem::UnavailableConnection;
return false;
}
bool MobileProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
......
/*
* Mobile applet proxy model - model for displaying netwoks in mobile kcm
* Mobile proxy model - model for displaying netwoks in mobile kcm
* Copyright 2017 Martin Kacej <m.kacej@atlas.sk>
*
* This program is free software; you can redistribute it and/or
......@@ -29,14 +29,18 @@ class Q_DECL_EXPORT MobileProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(QAbstractItemModel * sourceModel READ sourceModel WRITE setSourceModel)
Q_PROPERTY(bool showSavedMode READ showSavedMode WRITE setShowSavedMode)//NOTIFY showSavedModeChanged)
public:
explicit MobileProxyModel(QObject* parent = 0);
virtual ~MobileProxyModel();
void setShowSavedMode(bool mode);
bool showSavedMode() const;
protected:
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const Q_DECL_OVERRIDE;
bool lessThan(const QModelIndex& left, const QModelIndex& right) const Q_DECL_OVERRIDE;
private:
bool _showSavedMode;
};
#endif // PLASMA_NM_MOBILE_PROXY_MODEL_H
......@@ -54,6 +54,7 @@ Kirigami.ApplicationItem {
PlasmaNM.MobileProxyModel {
id: mobileProxyModel
sourceModel: connectionModel
showSavedMode: false
}
NetworkListView{
......
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