1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/*
Copyright (C) 2003-2005 George Staikos <staikos@kde.org>
Copyright (C) 2005 Isaac Clerencia <isaac@warp.es>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef ALLYOURBASE_H
#define ALLYOURBASE_H
#include <kiconview.h>
#include <klistview.h>
#include <kwallet.h>
#include <kiconloader.h>
#include <kicontheme.h>
#define KWALLETENTRYMAGIC ((Q_UINT32) 0x6B776C65)
#define KWALLETFOLDERMAGIC ((Q_UINT32) 0x6B776C66)
enum KWalletListItemClasses {
KWalletFolderItemClass = 1000,
KWalletContainerItemClass,
KWalletEntryItemClass,
KWalletUnknownClass = 2000
};
class KWalletEntryItem : public KListViewItem {
public:
KWalletEntryItem(KWallet::Wallet *w, QListViewItem* parent, const QString& ename);
virtual ~KWalletEntryItem();
const QString& oldName() { return _oldName; }
QString currentName() { return text(0); }
void clearOldName() { _oldName = text(0); }
virtual int rtti() const;
public:
KWallet::Wallet *_wallet;
private:
QString _oldName;
};
class KWalletContainerItem : public KListViewItem {
public:
KWalletContainerItem(QListViewItem* parent, const QString& name,
KWallet::Wallet::EntryType type);
virtual ~KWalletContainerItem();
public:
virtual int rtti() const;
KWallet::Wallet::EntryType type();
bool contains(const QString& itemKey);
QListViewItem* getItem(const QString& itemKey);
private:
KWallet::Wallet::EntryType _type;
};
class KWalletFolderItem : public KListViewItem {
public:
KWalletFolderItem(KWallet::Wallet *w, QListView* parent,
const QString& name, int entries);
virtual ~KWalletFolderItem();
virtual bool acceptDrop(const QMimeSource *mime) const;
virtual int rtti() const;
QString name() const;
void refresh();
KWalletContainerItem* getContainer(KWallet::Wallet::EntryType type);
QPixmap getFolderIcon(KIcon::Group group);
bool contains(const QString& itemKey);
QListViewItem* getItem(const QString& itemKey);
public:
KWallet::Wallet *_wallet;
private:
QString _name;
int _entries;
};
class KWalletEntryList : public KListView {
Q_OBJECT
public:
KWalletEntryList(QWidget *parent, const char *name = 0L);
virtual ~KWalletEntryList();
bool existsFolder(const QString& name);
KWalletFolderItem* getFolder(const QString& name);
void contentsDropEvent(QDropEvent *e);
void contentsDragEnterEvent(QDragEnterEvent *e);
void setWallet(KWallet::Wallet *w);
protected:
void itemDropped(QDropEvent *e, QListViewItem *item);
virtual QDragObject *dragObject();
virtual bool acceptDrag (QDropEvent* event) const;
private:
static KWalletFolderItem *getItemFolder(QListViewItem *item);
public:
KWallet::Wallet *_wallet;
};
class KWalletItem : public QIconViewItem {
public:
KWalletItem(QIconView *parent, const QString& walletName);
virtual ~KWalletItem();
virtual bool acceptDrop(const QMimeSource *mime) const;
protected:
virtual void dropped(QDropEvent *e, const QValueList<QIconDragItem>& lst);
};
class KWalletIconView : public KIconView {
Q_OBJECT
public:
KWalletIconView(QWidget *parent, const char *name = 0L);
virtual ~KWalletIconView();
protected slots:
virtual void slotDropped(QDropEvent *e, const QValueList<QIconDragItem>& lst);
protected:
virtual QDragObject *dragObject();
virtual void contentsMousePressEvent(QMouseEvent *e);
QPoint _mousePos;
};
inline QDataStream& operator<<(QDataStream& str, const KWalletEntryItem& w) {
QString name = w.text(0);
str << name;
KWallet::Wallet::EntryType et = w._wallet->entryType(name);
str << long(et);
QByteArray a;
w._wallet->readEntry(name, a);
str << a;
return str;
}
inline QDataStream& operator<<(QDataStream& str, const KWalletFolderItem& w) {
QString oldFolder = w._wallet->currentFolder();
str << w.name();
w._wallet->setFolder(w.name());
QStringList entries = w._wallet->entryList();
for (QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
str << *it;
KWallet::Wallet::EntryType et = w._wallet->entryType(*it);
str << long(et);
QByteArray a;
w._wallet->readEntry(*it, a);
str << a;
}
w._wallet->setFolder(oldFolder);
return str;
}
#endif
|