• 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
allyourbase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003-2005 George Staikos <staikos@kde.org>
3  Copyright (C) 2005 Isaac Clerencia <isaac@warp.es>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef ALLYOURBASE_H
22 #define ALLYOURBASE_H
23 
24 #include <kwallet.h>
25 #include <kiconloader.h>
26 #include <kicontheme.h>
27 #include <klistwidget.h>
28 #include <QPixmap>
29 #include <QDropEvent>
30 #include <QDragEnterEvent>
31 #include <QMouseEvent>
32 #include <QTreeWidget>
33 
34 #define KWALLETENTRYMAGIC ((quint32) 0x6B776C65)
35 #define KWALLETFOLDERMAGIC ((quint32) 0x6B776C66)
36 
37 
38 enum KWalletListItemClasses {
39  KWalletFolderItemClass = QTreeWidgetItem::UserType,
40  KWalletContainerItemClass,
41  KWalletEntryItemClass,
42  KWalletUnknownClass
43 };
44 
45 class KWalletEntryItem : public QTreeWidgetItem {
46  public:
47  KWalletEntryItem(KWallet::Wallet *w, QTreeWidgetItem* parent, const QString& ename);
48  virtual ~KWalletEntryItem();
49 
50  const QString& name() const { return m_name; }
51  void setName(const QString& n);
52  // Cancel renaming
53  void restoreName();
54 
55  public:
56  KWallet::Wallet *_wallet;
57 
58  private:
59  void setText(int, const QString&) {} // forbidden
60  QString m_name;
61 };
62 
63 class KWalletContainerItem : public QTreeWidgetItem {
64  public:
65  KWalletContainerItem(QTreeWidgetItem* parent, const QString& name, KWallet::Wallet::EntryType entryType);
66  virtual ~KWalletContainerItem();
67 
68  public:
69  KWallet::Wallet::EntryType entryType();
70  bool contains(const QString& itemKey);
71  QTreeWidgetItem* getItem(const QString& itemKey);
72 
73  private:
74  KWallet::Wallet::EntryType _type;
75 };
76 
77 class KWalletFolderItem : public QTreeWidgetItem {
78  public:
79  KWalletFolderItem(KWallet::Wallet *w, QTreeWidget* parent, const QString& name, int entries);
80  virtual ~KWalletFolderItem();
81 
82  virtual bool acceptDrop(const QMimeSource *mime) const;
83 
84  QString name() const;
85  void refresh();
86  KWalletContainerItem* getContainer(KWallet::Wallet::EntryType type);
87  QPixmap getFolderIcon(KIconLoader::Group group);
88  bool contains(const QString& itemKey);
89  QTreeWidgetItem* getItem(const QString& itemKey);
90  void refreshItemsCount();
91 
92  public:
93  KWallet::Wallet *_wallet;
94 
95  private:
96  QString _name;
97  int _entries;
98 };
99 
100 class KWalletEntryList : public QTreeWidget {
101  Q_OBJECT
102 
103  public:
104  explicit KWalletEntryList(QWidget *parent, const char *name = 0L);
105  virtual ~KWalletEntryList();
106 
107  bool existsFolder(const QString& name);
108  KWalletFolderItem* getFolder(const QString& name);
109  void setWallet(KWallet::Wallet *w);
110 
111  protected:
112  virtual void dragEnterEvent(QDragEnterEvent *e);
113  virtual void dragMoveEvent(QDragMoveEvent *e);
114  virtual void dropEvent(QDropEvent *e);
115  virtual void mousePressEvent(QMouseEvent *e);
116  virtual void mouseMoveEvent(QMouseEvent *e);
117 
118  void itemDropped(QDropEvent *e, QTreeWidgetItem *item);
119 
120  private:
121  static KWalletFolderItem *getItemFolder(QTreeWidgetItem *item);
122  QMimeData *itemMimeData(const QTreeWidgetItem *i) const;
123 
124  public:
125  KWallet::Wallet *_wallet;
126  QPoint _mousePos;
127 
128  public Q_SLOTS:
129  void selectFirstVisible();
130  void refreshItemsCount();
131 };
132 
133 class KWalletItem : public QListWidgetItem {
134  public:
135  KWalletItem(QListWidget *parent, const QString& walletName);
136  virtual ~KWalletItem();
137 
138  void setOpen(bool state);
139 
140  void processDropEvent(QDropEvent *e);
141 
142  private:
143  bool _open;
144 };
145 
146 inline QDataStream& operator<<(QDataStream& str, const KWalletEntryItem& w) {
147  QString name = w.text(0);
148  str << name;
149  KWallet::Wallet::EntryType et = w._wallet->entryType(name);
150  str << qint64(et);
151  QByteArray a;
152  w._wallet->readEntry(name, a);
153  str << a;
154  return str;
155 }
156 
157 inline QDataStream& operator<<(QDataStream& str, const KWalletFolderItem& w) {
158  QString oldFolder = w._wallet->currentFolder();
159  str << w.name();
160  w._wallet->setFolder(w.name());
161  QStringList entries = w._wallet->entryList();
162  foreach (const QString &entry, entries) {
163  str << entry;
164  KWallet::Wallet::EntryType et = w._wallet->entryType(entry);
165  str << (qint32)et;
166  QByteArray a;
167  w._wallet->readEntry(entry, a);
168  str << a;
169  }
170  w._wallet->setFolder(oldFolder);
171  return str;
172 }
173 
174 #endif
KWalletFolderItem::refreshItemsCount
void refreshItemsCount()
Definition: allyourbase.cpp:71
QWidget
KWalletEntryList::~KWalletEntryList
virtual ~KWalletEntryList()
Definition: allyourbase.cpp:355
KWalletItem::KWalletItem
KWalletItem(QListWidget *parent, const QString &walletName)
Definition: allyourbase.cpp:186
KWalletFolderItem::acceptDrop
virtual bool acceptDrop(const QMimeSource *mime) const
Definition: allyourbase.cpp:118
KWalletItem
Definition: allyourbase.h:133
KWalletEntryList::_mousePos
QPoint _mousePos
Definition: allyourbase.h:126
QByteArray
KWalletListItemClasses
KWalletListItemClasses
Definition: allyourbase.h:38
QDragMoveEvent
QDataStream
KWalletContainerItem
Definition: allyourbase.h:63
KWalletEntryItem::~KWalletEntryItem
virtual ~KWalletEntryItem()
Definition: allyourbase.cpp:168
KWalletEntryList::getFolder
KWalletFolderItem * getFolder(const QString &name)
Definition: allyourbase.cpp:600
KWalletEntryList::dragEnterEvent
virtual void dragEnterEvent(QDragEnterEvent *e)
Definition: allyourbase.cpp:580
QListWidgetItem
KWalletFolderItem::getFolderIcon
QPixmap getFolderIcon(KIconLoader::Group group)
Definition: allyourbase.cpp:51
KWalletFolderItem
Definition: allyourbase.h:77
KWalletFolderItem::getContainer
KWalletContainerItem * getContainer(KWallet::Wallet::EntryType type)
Definition: allyourbase.cpp:87
KWalletEntryList
Definition: allyourbase.h:100
QPoint
QMouseEvent
KWalletContainerItem::getItem
QTreeWidgetItem * getItem(const QString &itemKey)
Definition: allyourbase.cpp:150
KWalletFolderItemClass
Definition: allyourbase.h:39
QListWidget
QMimeData
KWalletFolderItem::name
QString name() const
Definition: allyourbase.cpp:123
KWalletEntryItemClass
Definition: allyourbase.h:41
KWalletEntryList::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *e)
Definition: allyourbase.cpp:556
QTreeWidget
QObject::name
const char * name() const
KWalletEntryList::itemDropped
void itemDropped(QDropEvent *e, QTreeWidgetItem *item)
Definition: allyourbase.cpp:359
KWalletFolderItem::~KWalletFolderItem
virtual ~KWalletFolderItem()
Definition: allyourbase.cpp:127
KWalletEntryItem::KWalletEntryItem
KWalletEntryItem(KWallet::Wallet *w, QTreeWidgetItem *parent, const QString &ename)
Definition: allyourbase.cpp:163
KWalletEntryItem::restoreName
void restoreName()
Definition: allyourbase.cpp:177
KWalletEntryList::dropEvent
virtual void dropEvent(QDropEvent *e)
Definition: allyourbase.cpp:575
QDropEvent
KWalletEntryList::setWallet
void setWallet(KWallet::Wallet *w)
Definition: allyourbase.cpp:492
KWalletContainerItemClass
Definition: allyourbase.h:40
QString
KWalletFolderItem::refresh
void refresh()
Definition: allyourbase.cpp:64
KWalletEntryItem::name
const QString & name() const
Definition: allyourbase.h:50
QStringList
KWalletFolderItem::getItem
QTreeWidgetItem * getItem(const QString &itemKey)
Definition: allyourbase.cpp:104
KWalletEntryList::KWalletEntryList
KWalletEntryList(QWidget *parent, const char *name=0L)
Definition: allyourbase.cpp:342
QPixmap
KWalletUnknownClass
Definition: allyourbase.h:42
KWalletContainerItem::KWalletContainerItem
KWalletContainerItem(QTreeWidgetItem *parent, const QString &name, KWallet::Wallet::EntryType entryType)
Definition: allyourbase.cpp:134
QTreeWidgetItem::parent
QTreeWidgetItem * parent() const
KWalletEntryItem
Definition: allyourbase.h:45
KWalletFolderItem::_wallet
KWallet::Wallet * _wallet
Definition: allyourbase.h:93
KWalletEntryList::dragMoveEvent
virtual void dragMoveEvent(QDragMoveEvent *e)
Definition: allyourbase.cpp:584
KWalletEntryList::_wallet
KWallet::Wallet * _wallet
Definition: allyourbase.h:125
QDragEnterEvent
KWalletContainerItem::entryType
KWallet::Wallet::EntryType entryType()
Definition: allyourbase.cpp:142
KWalletItem::setOpen
void setOpen(bool state)
Definition: allyourbase.cpp:194
QTreeWidgetItem
KWalletEntryList::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
Definition: allyourbase.cpp:550
KWalletFolderItem::contains
bool contains(const QString &itemKey)
Definition: allyourbase.cpp:100
KWalletItem::~KWalletItem
virtual ~KWalletItem()
Definition: allyourbase.cpp:191
KWalletContainerItem::contains
bool contains(const QString &itemKey)
Definition: allyourbase.cpp:146
KWalletEntryList::existsFolder
bool existsFolder(const QString &name)
Definition: allyourbase.cpp:496
operator<<
QDataStream & operator<<(QDataStream &str, const KWalletEntryItem &w)
Definition: allyourbase.h:146
KWalletEntryItem::setName
void setName(const QString &n)
Definition: allyourbase.cpp:171
QTreeWidgetItem::type
int type() const
KWalletContainerItem::~KWalletContainerItem
virtual ~KWalletContainerItem()
Definition: allyourbase.cpp:139
QObject::parent
QObject * parent() const
KWalletFolderItem::KWalletFolderItem
KWalletFolderItem(KWallet::Wallet *w, QTreeWidget *parent, const QString &name, int entries)
Definition: allyourbase.cpp:44
KWalletEntryList::selectFirstVisible
void selectFirstVisible()
Definition: allyourbase.cpp:625
QTreeWidgetItem::text
QString text(int column) const
KWalletEntryItem::_wallet
KWallet::Wallet * _wallet
Definition: allyourbase.h:56
KWalletEntryList::refreshItemsCount
void refreshItemsCount()
Definition: allyourbase.cpp:641
QMimeSource
KWalletItem::processDropEvent
void processDropEvent(QDropEvent *e)
Definition: allyourbase.cpp:267
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