• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kwallet

  • sources
  • kde-4.14
  • kdeutils
  • kwalletmanager
  • src
  • manager
connectedappmodel.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 Valentin Rusu <kde@rusu.info>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This program 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 GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; see the file COPYING. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "connectedappmodel.h"
21 
22 #include <kwallet.h>
23 #include <kdebug.h>
24 
25 
26 ConnectedAppModel::ConnectedAppModel(KWallet::Wallet* wallet):
27  QStandardItemModel(),
28  _wallet(wallet)
29 {
30  refresh();
31 }
32 
33 void ConnectedAppModel::refresh()
34 {
35  clear();
36  _connectedAppsIndexMap.clear();
37 
38  _connectedApps = KWallet::Wallet::users(_wallet->walletName());
39  int row =0;
40  Q_FOREACH(QString appName, _connectedApps ) {
41  // for un unknown reason, kwalletd returs empty strings so lets avoid inserting them
42  // FIXME: find out why kwalletd returns empty strings here
43  if (appName.length()>0) {
44  QStandardItem *item = new QStandardItem(appName);
45  item->setEditable(false);
46  setItem(row, 0, item);
47  // this item will be hidden by the disconnect button, see below setIndexWidget call
48  setItem(row, 1, new QStandardItem("dummy"));
49  _connectedAppsIndexMap.insert(appName, QPersistentModelIndex(index(row, 0)));
50  row++;
51  }
52  }
53 }
54 
55 void ConnectedAppModel::removeApp(QString appName)
56 {
57  if (_connectedAppsIndexMap.contains(appName)) {
58  QPersistentModelIndex idx = _connectedAppsIndexMap[appName];
59  if (idx.isValid()) {
60  if (!removeRow(idx.row())) {
61  kDebug() << "Remove row failed for app " << appName;
62  }
63  }
64  } else {
65  kDebug() << "Attempting to remove unknown application " << appName;
66  }
67 }
68 
69 
70 #include "connectedappmodel.moc"
QStandardItemModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
QStandardItemModel
QMap::contains
bool contains(const Key &key) const
QStandardItemModel::clear
void clear()
QAbstractItemModel::removeRow
bool removeRow(int row, const QModelIndex &parent)
connectedappmodel.h
QMap::clear
void clear()
ConnectedAppModel::ConnectedAppModel
ConnectedAppModel(KWallet::Wallet *wallet)
Definition: connectedappmodel.cpp:26
QPersistentModelIndex::isValid
bool isValid() const
QStandardItemModel::setItem
void setItem(int row, int column, QStandardItem *item)
QString
ConnectedAppModel::refresh
void refresh()
Definition: connectedappmodel.cpp:33
QStandardItemModel::item
QStandardItem * item(int row, int column) const
QPersistentModelIndex
ConnectedAppModel::removeApp
void removeApp(QString)
Definition: connectedappmodel.cpp:55
QString::length
int length() const
QMap::insert
iterator insert(const Key &key, const T &value)
QStandardItem
QStandardItem::setEditable
void setEditable(bool editable)
QPersistentModelIndex::row
int row() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kwallet

Skip menu "kwallet"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal