summaryrefslogtreecommitdiffabout
path: root/pwmanager
Unidiff
Diffstat (limited to 'pwmanager') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/commentbox.cpp4
-rw-r--r--pwmanager/pwmanager/pwm.cpp41
2 files changed, 29 insertions, 16 deletions
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp
index 4a76f36..e2d2d2b 100644
--- a/pwmanager/pwmanager/commentbox.cpp
+++ b/pwmanager/pwmanager/commentbox.cpp
@@ -1,281 +1,281 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "commentbox.h" 20#include "commentbox.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "htmlgen.h" 22#include "htmlgen.h"
23 23
24#include <klocale.h> 24#include <klocale.h>
25 25
26#ifndef PWM_EMBEDDED 26#ifndef PWM_EMBEDDED
27#include <khtml_part.h> 27#include <khtml_part.h>
28#include <khtmlview.h> 28#include <khtmlview.h>
29#include <qtextedit.h> 29#include <qtextedit.h>
30#else 30#else
31#include <qmultilineedit.h> 31#include <qmultilineedit.h>
32#endif 32#endif
33 33
34 34
35 35
36#ifndef PWM_EMBEDDED 36#ifndef PWM_EMBEDDED
37CommentBox::CommentBox(QWidget *_parentWidget) 37CommentBox::CommentBox(QWidget *_parentWidget)
38{ 38{
39 PWM_ASSERT(_parentWidget); 39 PWM_ASSERT(_parentWidget);
40 parentWidget = _parentWidget; 40 parentWidget = _parentWidget;
41 textDta = 0; 41 textDta = 0;
42 htmlDta = 0; 42 htmlDta = 0;
43 mode = mode_notSet; 43 mode = mode_notSet;
44} 44}
45 45
46CommentBox::~CommentBox() 46CommentBox::~CommentBox()
47{ 47{
48 clearText(); 48 clearText();
49 clearHtml(); 49 clearHtml();
50} 50}
51 51
52void CommentBox::clear() 52void CommentBox::clear()
53{ 53{
54 clearText(); 54 clearText();
55 clearHtml(); 55 clearHtml();
56 mode = mode_notSet; 56 mode = mode_notSet;
57 this->hide(); 57 this->hide();
58} 58}
59 59
60void CommentBox::clearText() 60void CommentBox::clearText()
61{ 61{
62 delete_ifnot_null(textDta); 62 delete_ifnot_null(textDta);
63} 63}
64 64
65void CommentBox::clearHtml() 65void CommentBox::clearHtml()
66{ 66{
67 delete_ifnot_null(htmlDta); 67 delete_ifnot_null(htmlDta);
68} 68}
69 69
70void CommentBox::setText(const QString &text) 70void CommentBox::setText(const QString &text)
71{ 71{
72 switchTo(mode_text); 72 switchTo(mode_text);
73 PWM_ASSERT(textDta); 73 PWM_ASSERT(textDta);
74 textDta->setText(i18n("Comment") + ": " + text); 74 textDta->setText( text);
75 if (!textDta->isVisible()) 75 if (!textDta->isVisible())
76 textDta->show(); 76 textDta->show();
77} 77}
78 78
79bool CommentBox::getText(QString *text) 79bool CommentBox::getText(QString *text)
80{ 80{
81 if (mode != mode_text) 81 if (mode != mode_text)
82 return false; 82 return false;
83 PWM_ASSERT(text); 83 PWM_ASSERT(text);
84 if (!textDta) { 84 if (!textDta) {
85 *text = ""; 85 *text = "";
86 return true; 86 return true;
87 } 87 }
88 *text = textDta->text(); 88 *text = textDta->text();
89 return true; 89 return true;
90} 90}
91 91
92void CommentBox::setHtml(QString code) 92void CommentBox::setHtml(QString code)
93{ 93{
94 switchTo(mode_html); 94 switchTo(mode_html);
95 PWM_ASSERT(htmlDta); 95 PWM_ASSERT(htmlDta);
96 if (!HtmlGen::replaceSSDummy(&code)) 96 if (!HtmlGen::replaceSSDummy(&code))
97 printWarn("CommentBox::setHtml(): replaceSSDummy() failed!"); 97 printWarn("CommentBox::setHtml(): replaceSSDummy() failed!");
98 htmlDta->begin(); 98 htmlDta->begin();
99 htmlDta->write(code); 99 htmlDta->write(code);
100 htmlDta->end(); 100 htmlDta->end();
101 htmlDta->show(); 101 htmlDta->show();
102} 102}
103 103
104void CommentBox::setContent(const QString &dta) 104void CommentBox::setContent(const QString &dta)
105{ 105{
106 // if there's no data, hide the comment-box 106 // if there's no data, hide the comment-box
107 if (dta.isEmpty()) { 107 if (dta.isEmpty()) {
108 clear(); 108 clear();
109 return; 109 return;
110 } 110 }
111 if (HtmlGen::isHtml(dta)) { 111 if (HtmlGen::isHtml(dta)) {
112 setHtml(dta); 112 setHtml(dta);
113 return; 113 return;
114 } 114 }
115 // we assume it's plain text 115 // we assume it's plain text
116 setText(dta); 116 setText(dta);
117} 117}
118 118
119void CommentBox::switchTo(commentBoxMode newMode) 119void CommentBox::switchTo(commentBoxMode newMode)
120{ 120{
121 if (newMode == mode) 121 if (newMode == mode)
122 return; 122 return;
123 123
124 // cleanup old mode 124 // cleanup old mode
125 switch (mode) { 125 switch (mode) {
126 case mode_text: 126 case mode_text:
127 clearText(); 127 clearText();
128 break; 128 break;
129 case mode_html: 129 case mode_html:
130 clearHtml(); 130 clearHtml();
131 break; 131 break;
132 default: 132 default:
133 break; 133 break;
134 } 134 }
135 135
136 // setup new mode 136 // setup new mode
137 switch (newMode) { 137 switch (newMode) {
138 case mode_text: 138 case mode_text:
139 textDta = new QTextEdit(parentWidget); 139 textDta = new QTextEdit(parentWidget);
140 textDta->setTextFormat(Qt::PlainText); 140 textDta->setTextFormat(Qt::PlainText);
141 textDta->setReadOnly(true); 141 textDta->setReadOnly(true);
142 textDta->show(); 142 textDta->show();
143 break; 143 break;
144 case mode_html: 144 case mode_html:
145 htmlDta = new KHTMLPart(parentWidget, 0, 145 htmlDta = new KHTMLPart(parentWidget, 0,
146 parentWidget); 146 parentWidget);
147 htmlDta->show(); 147 htmlDta->show();
148 break; 148 break;
149 default: 149 default:
150 BUG(); 150 BUG();
151 break; 151 break;
152 } 152 }
153 153
154 mode = newMode; 154 mode = newMode;
155} 155}
156 156
157void CommentBox::show() 157void CommentBox::show()
158{ 158{
159 switch (mode) { 159 switch (mode) {
160 case mode_text: 160 case mode_text:
161 PWM_ASSERT(textDta); 161 PWM_ASSERT(textDta);
162 textDta->show(); 162 textDta->show();
163 break; 163 break;
164 case mode_html: 164 case mode_html:
165 PWM_ASSERT(htmlDta); 165 PWM_ASSERT(htmlDta);
166 htmlDta->show(); 166 htmlDta->show();
167 break; 167 break;
168 default: 168 default:
169 break; 169 break;
170 } 170 }
171 171
172} 172}
173 173
174void CommentBox::hide() 174void CommentBox::hide()
175{ 175{
176 switch (mode) { 176 switch (mode) {
177 case mode_text: 177 case mode_text:
178 PWM_ASSERT(textDta); 178 PWM_ASSERT(textDta);
179 textDta->hide(); 179 textDta->hide();
180 break; 180 break;
181 case mode_html: 181 case mode_html:
182 PWM_ASSERT(htmlDta); 182 PWM_ASSERT(htmlDta);
183 htmlDta->hide(); 183 htmlDta->hide();
184 break; 184 break;
185 default: 185 default:
186 break; 186 break;
187 } 187 }
188} 188}
189 189
190void CommentBox::resize(const QSize &size) 190void CommentBox::resize(const QSize &size)
191{ 191{
192 switch (mode) { 192 switch (mode) {
193 case mode_text: 193 case mode_text:
194 PWM_ASSERT(textDta); 194 PWM_ASSERT(textDta);
195 textDta->resize(size); 195 textDta->resize(size);
196 break; 196 break;
197 case mode_html: 197 case mode_html:
198 PWM_ASSERT(htmlDta); 198 PWM_ASSERT(htmlDta);
199 htmlDta->view()->resize(size); 199 htmlDta->view()->resize(size);
200 break; 200 break;
201 default: 201 default:
202 break; 202 break;
203 } 203 }
204 204
205} 205}
206 206
207QSize CommentBox::size() 207QSize CommentBox::size()
208{ 208{
209 switch (mode) { 209 switch (mode) {
210 case mode_text: 210 case mode_text:
211 PWM_ASSERT(textDta); 211 PWM_ASSERT(textDta);
212 return textDta->size(); 212 return textDta->size();
213 break; 213 break;
214 case mode_html: 214 case mode_html:
215 PWM_ASSERT(htmlDta); 215 PWM_ASSERT(htmlDta);
216 return htmlDta->view()->size(); 216 return htmlDta->view()->size();
217 break; 217 break;
218 default: 218 default:
219 break; 219 break;
220 } 220 }
221 221
222 return QSize(); 222 return QSize();
223} 223}
224 224
225 225
226//////////////////////////////////////////////////////////////////////// 226////////////////////////////////////////////////////////////////////////
227 227
228#else 228#else
229 229
230CommentBox::CommentBox(QWidget *_parentWidget) 230CommentBox::CommentBox(QWidget *_parentWidget)
231 : QMultiLineEdit(_parentWidget) 231 : QMultiLineEdit(_parentWidget)
232 232
233{ 233{
234 this->setReadOnly(true); 234 this->setReadOnly(true);
235} 235}
236 236
237CommentBox::~CommentBox() 237CommentBox::~CommentBox()
238{ 238{
239} 239}
240 240
241void CommentBox::clear() 241void CommentBox::clear()
242{ 242{
243 this->hide(); 243 this->hide();
244} 244}
245 245
246 246
247void CommentBox::setText(const QString &text) 247void CommentBox::setText(const QString &text)
248{ 248{
249 QMultiLineEdit::setText(i18n("Comment") + ": " + text); 249 QMultiLineEdit::setText( text);
250 if (!this->isVisible()) 250 if (!this->isVisible())
251 this->show(); 251 this->show();
252} 252}
253 253
254bool CommentBox::getText(QString *text) 254bool CommentBox::getText(QString *text)
255{ 255{
256 *text = this->text(); 256 *text = this->text();
257 return true; 257 return true;
258} 258}
259 259
260void CommentBox::setContent(const QString &dta) 260void CommentBox::setContent(const QString &dta)
261{ 261{
262 // if there's no data, hide the comment-box 262 // if there's no data, hide the comment-box
263 if (dta.isEmpty()) { 263 if (dta.isEmpty()) {
264 clear(); 264 clear();
265 return; 265 return;
266 } 266 }
267 267
268 // we assume it's plain text 268 // we assume it's plain text
269 setText(dta); 269 setText(dta);
270} 270}
271 271
272#endif 272#endif
273 273
274 274
275 275
276 276
277 277
278 278
279 279
280 280
281 281
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 48257ef..fc6837f 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -156,676 +156,689 @@ enum {
156enum { 156enum {
157 BUTTON_TOOL_NEW = 0, 157 BUTTON_TOOL_NEW = 0,
158 BUTTON_TOOL_OPEN, 158 BUTTON_TOOL_OPEN,
159 BUTTON_TOOL_SAVE, 159 BUTTON_TOOL_SAVE,
160 BUTTON_TOOL_SAVEAS, 160 BUTTON_TOOL_SAVEAS,
161 BUTTON_TOOL_PRINT, 161 BUTTON_TOOL_PRINT,
162 BUTTON_TOOL_ADD, 162 BUTTON_TOOL_ADD,
163 BUTTON_TOOL_EDIT, 163 BUTTON_TOOL_EDIT,
164 BUTTON_TOOL_DEL, 164 BUTTON_TOOL_DEL,
165 BUTTON_TOOL_FIND, 165 BUTTON_TOOL_FIND,
166 BUTTON_TOOL_LOCK, 166 BUTTON_TOOL_LOCK,
167 BUTTON_TOOL_DEEPLOCK, 167 BUTTON_TOOL_DEEPLOCK,
168 BUTTON_TOOL_UNLOCK 168 BUTTON_TOOL_UNLOCK
169}; 169};
170 170
171 171
172PwM::PwM(PwMInit *_init, PwMDoc *doc, 172PwM::PwM(PwMInit *_init, PwMDoc *doc,
173 bool virginity, 173 bool virginity,
174 QWidget *parent, const char *name) 174 QWidget *parent, const char *name)
175 : KMainWindow(parent, "HALLO") 175 : KMainWindow(parent, "HALLO")
176 , forceQuit (false) 176 , forceQuit (false)
177 , forceMinimizeToTray (false) 177 , forceMinimizeToTray (false)
178{ 178{
179 syncManager = 0; 179 syncManager = 0;
180 virgin = !virginity; 180 virgin = !virginity;
181 init = _init; 181 init = _init;
182 connect(doc, SIGNAL(docClosed(PwMDoc *)), 182 connect(doc, SIGNAL(docClosed(PwMDoc *)),
183 this, SLOT(docClosed(PwMDoc *))); 183 this, SLOT(docClosed(PwMDoc *)));
184 initMenubar(); 184 initMenubar();
185 initToolbar(); 185 initToolbar();
186 initMetrics(); 186 initMetrics();
187 setVirgin(virginity); 187 setVirgin(virginity);
188 setFocusPolicy(QWidget::WheelFocus); 188 setFocusPolicy(QWidget::WheelFocus);
189#ifndef PWM_EMBEDDED 189#ifndef PWM_EMBEDDED
190 statusBar()->show(); 190 statusBar()->show();
191#endif 191#endif
192 view = makeNewListView(doc); 192 view = makeNewListView(doc);
193 setCentralWidget(view); 193 setCentralWidget(view);
194 updateCaption(); 194 updateCaption();
195 showStatMsg(i18n("Ready.")); 195 showStatMsg(i18n("Ready."));
196} 196}
197 197
198PwM::~PwM() 198PwM::~PwM()
199{ 199{
200 //qDebug("PwM::~PwM() %x", this); 200 //qDebug("PwM::~PwM() %x", this);
201 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), 201 disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)),
202 this, SLOT(docClosed(PwMDoc *))); 202 this, SLOT(docClosed(PwMDoc *)));
203 conf()->confWndMainWndSize(size()); 203 conf()->confWndMainWndSize(size());
204 //LR closing of windows changed 204 //LR closing of windows changed
205 //needed for fastload option on PDA 205 //needed for fastload option on PDA
206 //emit closed(this); 206 //emit closed(this);
207 //qDebug("PwM::~PwM() emited closed(this)"); 207 //qDebug("PwM::~PwM() emited closed(this)");
208 delete view; 208 delete view;
209 delete syncManager; 209 delete syncManager;
210} 210}
211 211
212void PwM::initMenubar() 212void PwM::initMenubar()
213{ 213{
214 KIconLoader* picons; 214 KIconLoader* picons;
215#ifndef PWM_EMBEDDED 215#ifndef PWM_EMBEDDED
216 KIconLoader icons; 216 KIconLoader icons;
217 picons = &icons; 217 picons = &icons;
218#else 218#else
219 picons = KGlobal::iconLoader(); 219 picons = KGlobal::iconLoader();
220 220
221 221
222 syncPopup = new KPopupMenu(this); 222 syncPopup = new KPopupMenu(this);
223 223
224 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); 224 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup);
225 syncManager->setBlockSave(false); 225 syncManager->setBlockSave(false);
226 226
227 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 227 connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
228 syncManager->fillSyncMenu(); 228 syncManager->fillSyncMenu();
229 229
230#endif 230#endif
231 filePopup = new KPopupMenu(this); 231 filePopup = new KPopupMenu(this);
232 importPopup = new KPopupMenu(filePopup); 232 importPopup = new KPopupMenu(filePopup);
233 exportPopup = new KPopupMenu(filePopup); 233 exportPopup = new KPopupMenu(filePopup);
234 managePopup = new KPopupMenu(this); 234 managePopup = new KPopupMenu(this);
235#ifdef CONFIG_KEYCARD 235#ifdef CONFIG_KEYCARD
236 chipcardPopup = new KPopupMenu(this); 236 chipcardPopup = new KPopupMenu(this);
237#endif // CONFIG_KEYCARD 237#endif // CONFIG_KEYCARD
238 viewPopup = new KPopupMenu(this); 238 viewPopup = new KPopupMenu(this);
239 optionsPopup = new KPopupMenu(this); 239 optionsPopup = new KPopupMenu(this);
240 240
241// "file" popup menu 241// "file" popup menu
242 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 242 filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
243 i18n("&New"), this, 243 i18n("&New"), this,
244 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); 244 SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW);
245 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), 245 filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)),
246 i18n("&Open"), this, 246 i18n("&Open"), this,
247 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); 247 SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN);
248 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), 248 filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)),
249 i18n("&Close"), this, 249 i18n("&Close"), this,
250 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); 250 SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE);
251 filePopup->insertSeparator(); 251 filePopup->insertSeparator();
252 filePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
253 i18n("&Add password"), this,
254 SLOT(addPwd_slot()), 0,
255 BUTTON_POPUP_MANAGE_ADD);
256 filePopup->insertSeparator();
252 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 257 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
253 i18n("&Save"), this, 258 i18n("&Save"), this,
254 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 259 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
255 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 260 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
256 i18n("Save &as..."), 261 i18n("Save &as..."),
257 this, SLOT(saveAs_slot()), 0, 262 this, SLOT(saveAs_slot()), 0,
258 BUTTON_POPUP_FILE_SAVEAS); 263 BUTTON_POPUP_FILE_SAVEAS);
259 filePopup->insertSeparator(); 264 filePopup->insertSeparator();
260 // "file/export" popup menu 265 // "file/export" popup menu
261 exportPopup->insertItem(i18n("&Text-file..."), this, 266 exportPopup->insertItem(i18n("&Text-file..."), this,
262 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 267 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
263 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 268 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
264 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 269 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
265 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 270 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
266 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); 271 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV);
267#ifdef CONFIG_KWALLETIF 272#ifdef CONFIG_KWALLETIF
268 exportPopup->insertItem(i18n("&KWallet..."), this, 273 exportPopup->insertItem(i18n("&KWallet..."), this,
269 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 274 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
270#endif 275#endif
271 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 276 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
272 i18n("E&xport"), exportPopup, 277 i18n("E&xport"), exportPopup,
273 BUTTON_POPUP_FILE_EXPORT); 278 BUTTON_POPUP_FILE_EXPORT);
274 // "file/import" popup menu 279 // "file/import" popup menu
275 importPopup->insertItem(i18n("&Text-file..."), this, 280 importPopup->insertItem(i18n("&Text-file..."), this,
276 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 281 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
277 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 282 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
278 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 283 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
279 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 284 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
280 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); 285 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV);
281#ifdef CONFIG_KWALLETIF 286#ifdef CONFIG_KWALLETIF
282 importPopup->insertItem(i18n("&KWallet..."), this, 287 importPopup->insertItem(i18n("&KWallet..."), this,
283 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 288 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
284#endif 289#endif
285 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 290 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
286 i18n("I&mport"), importPopup, 291 i18n("I&mport"), importPopup,
287 BUTTON_POPUP_FILE_IMPORT); 292 BUTTON_POPUP_FILE_IMPORT);
288 filePopup->insertSeparator(); 293 filePopup->insertSeparator();
294#if 0
289 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 295 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
290 i18n("&Print..."), this, 296 i18n("&Print..."), this,
291 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 297 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
292 filePopup->insertSeparator(); 298 filePopup->insertSeparator();
299#endif
293 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 300 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
294 i18n("&Quit"), this, 301 i18n("&Quit"), this,
295 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 302 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
296 menuBar()->insertItem(i18n("&File"), filePopup); 303 menuBar()->insertItem(i18n("&File"), filePopup);
297// "manage" popup menu 304// "manage" popup menu
298 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 305 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
299 i18n("&Add password"), this, 306 i18n("&Add password"), this,
300 SLOT(addPwd_slot()), 0, 307 SLOT(addPwd_slot()), 0,
301 BUTTON_POPUP_MANAGE_ADD); 308 BUTTON_POPUP_MANAGE_ADD);
309 managePopup->insertSeparator();
302 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 310 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
303 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 311 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
304 BUTTON_POPUP_MANAGE_EDIT); 312 BUTTON_POPUP_MANAGE_EDIT);
305 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 313 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
306 i18n("&Delete"), this, SLOT(deletePwd_slot()), 314 i18n("&Delete"), this, SLOT(deletePwd_slot()),
307 0, BUTTON_POPUP_MANAGE_DEL); 315 0, BUTTON_POPUP_MANAGE_DEL);
308 managePopup->insertSeparator(); 316 managePopup->insertSeparator();
309 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 317 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
310 i18n("Change &Master Password"), this, 318 i18n("Change &Master Password"), this,
311 SLOT(changeMasterPwd_slot()), 0, 319 SLOT(changeMasterPwd_slot()), 0,
312 BUTTON_POPUP_MANAGE_CHANGEMP); 320 BUTTON_POPUP_MANAGE_CHANGEMP);
313 menuBar()->insertItem(i18n("&Manage"), managePopup); 321 menuBar()->insertItem(i18n("&Manage"), managePopup);
314// "chipcard" popup menu 322// "chipcard" popup menu
315#ifdef CONFIG_KEYCARD 323#ifdef CONFIG_KEYCARD
316 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 324 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
317 i18n("&Generate new key-card"), this, 325 i18n("&Generate new key-card"), this,
318 SLOT(genNewCard_slot()), 0, 326 SLOT(genNewCard_slot()), 0,
319 BUTTON_POPUP_CHIPCARD_GENNEW); 327 BUTTON_POPUP_CHIPCARD_GENNEW);
320 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 328 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
321 i18n("&Erase key-card"), this, 329 i18n("&Erase key-card"), this,
322 SLOT(eraseCard_slot()), 0, 330 SLOT(eraseCard_slot()), 0,
323 BUTTON_POPUP_CHIPCARD_DEL); 331 BUTTON_POPUP_CHIPCARD_DEL);
324 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 332 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
325 i18n("Read card-&ID"), this, 333 i18n("Read card-&ID"), this,
326 SLOT(readCardId_slot()), 0, 334 SLOT(readCardId_slot()), 0,
327 BUTTON_POPUP_CHIPCARD_READID); 335 BUTTON_POPUP_CHIPCARD_READID);
328 chipcardPopup->insertSeparator(); 336 chipcardPopup->insertSeparator();
329 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 337 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
330 i18n("&Make card backup-image"), this, 338 i18n("&Make card backup-image"), this,
331 SLOT(makeCardBackup_slot()), 0, 339 SLOT(makeCardBackup_slot()), 0,
332 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 340 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
333 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 341 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
334 i18n("&Replay card backup-image"), this, 342 i18n("&Replay card backup-image"), this,
335 SLOT(replayCardBackup_slot()), 0, 343 SLOT(replayCardBackup_slot()), 0,
336 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 344 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
337 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 345 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
338#endif // CONFIG_KEYCARD 346#endif // CONFIG_KEYCARD
339// "view" popup menu 347// "view" popup menu
340 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 348 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
341 i18n("&Find"), this, 349 i18n("&Find"), this,
342 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 350 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
343 viewPopup->insertSeparator(); 351 viewPopup->insertSeparator();
344 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 352 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
345 i18n("&Lock all entries"), this, 353 i18n("&Lock all entries"), this,
346 SLOT(lockWnd_slot()), 0, 354 SLOT(lockWnd_slot()), 0,
347 BUTTON_POPUP_VIEW_LOCK); 355 BUTTON_POPUP_VIEW_LOCK);
348 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 356 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
349 i18n("&Deep-lock all entries"), this, 357 i18n("&Deep-lock all entries"), this,
350 SLOT(deepLockWnd_slot()), 0, 358 SLOT(deepLockWnd_slot()), 0,
351 BUTTON_POPUP_VIEW_DEEPLOCK); 359 BUTTON_POPUP_VIEW_DEEPLOCK);
352 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 360 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
353 i18n("&Unlock all entries"), this, 361 i18n("&Unlock all entries"), this,
354 SLOT(unlockWnd_slot()), 0, 362 SLOT(unlockWnd_slot()), 0,
355 BUTTON_POPUP_VIEW_UNLOCK); 363 BUTTON_POPUP_VIEW_UNLOCK);
356 menuBar()->insertItem(i18n("&View"), viewPopup); 364 menuBar()->insertItem(i18n("&View"), viewPopup);
357// "options" popup menu 365// "options" popup menu
358 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 366 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
359 i18n("&Configure..."), this, 367 i18n("&Configure..."), this,
360 SLOT(config_slot()),0, 368 SLOT(config_slot()),0,
361 BUTTON_POPUP_OPTIONS_CONFIG); 369 BUTTON_POPUP_OPTIONS_CONFIG);
362 menuBar()->insertItem(i18n("&Options"), optionsPopup); 370 menuBar()->insertItem(i18n("&Options"), optionsPopup);
363// "help" popup menu 371// "help" popup menu
364#ifndef PWM_EMBEDDED 372#ifndef PWM_EMBEDDED
365 helpPopup = helpMenu(QString::null, false); 373 helpPopup = helpMenu(QString::null, false);
366#else 374#else
367 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 375 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
368 i18n("C&ategories..."), this, 376 i18n("C&ategories..."), this,
369 SLOT(category_slot()),0, 377 SLOT(category_slot()),0,
370 BUTTON_POPUP_OPTIONS_CATEGORY); 378 BUTTON_POPUP_OPTIONS_CATEGORY);
371 379
372 380
373 menuBar()->insertItem(i18n("&Sync"), syncPopup); 381 menuBar()->insertItem(i18n("&Sync"), syncPopup);
374 382
375 383
376 384
377 385
378 386
379 helpPopup = new KPopupMenu(this); 387 helpPopup = new KPopupMenu(this);
380 388
381 389
382 helpPopup->insertItem(i18n("&License"), this, 390 helpPopup->insertItem(i18n("&License"), this,
383 SLOT(showLicense_slot()), 0, 391 SLOT(showLicense_slot()), 0,
384 BUTTON_POPUP_HELP_LICENSE); 392 BUTTON_POPUP_HELP_LICENSE);
385 393
386 helpPopup->insertItem(i18n("&Faq"), this, 394 helpPopup->insertItem(i18n("&Faq"), this,
387 SLOT(faq_slot()), 0, 395 SLOT(faq_slot()), 0,
388 BUTTON_POPUP_HELP_FAQ); 396 BUTTON_POPUP_HELP_FAQ);
389 397
390 helpPopup->insertItem(i18n("&About PwManager"), this, 398 helpPopup->insertItem(i18n("&About PwManager"), this,
391 SLOT(createAboutData_slot()), 0, 399 SLOT(createAboutData_slot()), 0,
392 BUTTON_POPUP_HELP_ABOUT); 400 BUTTON_POPUP_HELP_ABOUT);
393 401
394 helpPopup->insertItem(i18n("&Sync HowTo"), this, 402 helpPopup->insertItem(i18n("&Sync HowTo"), this,
395 SLOT(syncHowTo_slot()), 0, 403 SLOT(syncHowTo_slot()), 0,
396 BUTTON_POPUP_HELP_SYNC); 404 BUTTON_POPUP_HELP_SYNC);
397 405
398 helpPopup->insertItem(i18n("&What's New"), this, 406 helpPopup->insertItem(i18n("&What's New"), this,
399 SLOT(whatsnew_slot()), 0, 407 SLOT(whatsnew_slot()), 0,
400 BUTTON_POPUP_HELP_WHATSNEW); 408 BUTTON_POPUP_HELP_WHATSNEW);
401 409
402#endif 410#endif
403 menuBar()->insertItem(i18n("&Help"), helpPopup); 411 menuBar()->insertItem(i18n("&Help"), helpPopup);
404 412
405} 413}
406 414
407void PwM::initToolbar() 415void PwM::initToolbar()
408{ 416{
409 KIconLoader* picons; 417 KIconLoader* picons;
410#ifndef PWM_EMBEDDED 418#ifndef PWM_EMBEDDED
411 KIconLoader icons; 419 KIconLoader icons;
412 picons = &icons; 420 picons = &icons;
413#else 421#else
414 picons = KGlobal::iconLoader(); 422 picons = KGlobal::iconLoader();
415#endif 423#endif
416 424
417#ifdef PWM_EMBEDDED 425#if 0
418 if ( QApplication::desktop()->width() > 320 )
419#endif
420 {
421 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 426 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
422 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 427 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
423 SLOT(new_slot()), true, i18n("New")); 428 SLOT(new_slot()), true, i18n("New"));
429#endif
424 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 430 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
425 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 431 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
426 SLOT(open_slot()), true, i18n("Open")); 432 SLOT(open_slot()), true, i18n("Open"));
433 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
434 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
435 SLOT(addPwd_slot()), true,
436 i18n("Add password"));
437 toolBar()->insertSeparator();
438
439 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
440 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
441 SLOT(find_slot()), true, i18n("Find entry"));
427 toolBar()->insertSeparator(); 442 toolBar()->insertSeparator();
428 }
429 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 443 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
430 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 444 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
431 SLOT(save_slot()), true, i18n("Save")); 445 SLOT(save_slot()), true, i18n("Save"));
446#if 0
432 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 447 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
433 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 448 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
434 SLOT(saveAs_slot()), true, i18n("Save as")); 449 SLOT(saveAs_slot()), true, i18n("Save as"));
450#endif
451
452
453#if 0
435 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 454 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
436 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 455 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
437 SLOT(print_slot()), true, i18n("Print...")); 456 SLOT(print_slot()), true, i18n("Print..."));
457#endif
438 toolBar()->insertSeparator(); 458 toolBar()->insertSeparator();
439 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
440 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
441 SLOT(addPwd_slot()), true,
442 i18n("Add password"));
443 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 459 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
444 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 460 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
445 SLOT(editPwd_slot()), true, 461 SLOT(editPwd_slot()), true,
446 i18n("Edit password")); 462 i18n("Edit password"));
447 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 463 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
448 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 464 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
449 SLOT(deletePwd_slot()), true, 465 SLOT(deletePwd_slot()), true,
450 i18n("Delete password")); 466 i18n("Delete password"));
451 toolBar()->insertSeparator(); 467 toolBar()->insertSeparator();
452 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
453 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
454 SLOT(find_slot()), true, i18n("Find entry"));
455 toolBar()->insertSeparator();
456 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 468 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
457 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 469 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
458 SLOT(lockWnd_slot()), true, 470 SLOT(lockWnd_slot()), true,
459 i18n("Lock all entries")); 471 i18n("Lock all entries"));
460 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 472 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
461 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 473 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
462 SLOT(deepLockWnd_slot()), true, 474 SLOT(deepLockWnd_slot()), true,
463 i18n("Deep-Lock all entries")); 475 i18n("Deep-Lock all entries"));
464 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 476 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
465 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 477 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
466 SLOT(unlockWnd_slot()), true, 478 SLOT(unlockWnd_slot()), true,
467 i18n("Unlock all entries")); 479 i18n("Unlock all entries"));
468} 480}
469 481
470void PwM::initMetrics() 482void PwM::initMetrics()
471{ 483{
472 QSize s = conf()->confWndMainWndSize(); 484 QSize s = conf()->confWndMainWndSize();
473 if (s.isValid()) 485 if (s.isValid())
474 resize(s); 486 resize(s);
475 else 487 else
476 resize(DEFAULT_SIZE); 488 resize(DEFAULT_SIZE);
477} 489}
478 490
479void PwM::updateCaption() 491void PwM::updateCaption()
480{ 492{
481 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 493 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
482} 494}
483 495
484void PwM::hideEvent(QHideEvent *) 496void PwM::hideEvent(QHideEvent *)
485{ 497{
486 if (isMinimized()) { 498 if (isMinimized()) {
487 if (init->tray()) { 499 if (init->tray()) {
488 forceMinimizeToTray = true; 500 forceMinimizeToTray = true;
489 close(); 501 close();
490 } 502 }
491 int mmlock = conf()->confGlobMinimizeLock(); 503 int mmlock = conf()->confGlobMinimizeLock();
492 switch (mmlock) { 504 switch (mmlock) {
493 case 0: // don't lock anything 505 case 0: // don't lock anything
494 break; 506 break;
495 case 1: {// normal lock 507 case 1: {// normal lock
496 curDoc()->lockAll(true); 508 curDoc()->lockAll(true);
497 break; 509 break;
498 } case 2: {// deep-lock 510 } case 2: {// deep-lock
499 curDoc()->deepLock(); 511 curDoc()->deepLock();
500 break; 512 break;
501 } default: 513 } default:
502 WARN(); 514 WARN();
503 } 515 }
504 } 516 }
505} 517}
506 518
507void PwM::setVirgin(bool v) 519void PwM::setVirgin(bool v)
508{ 520{
509 if (virgin == v) 521 if (virgin == v)
510 return; 522 return;
511 virgin = v; 523 virgin = v;
512 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 524 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
513 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 525 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
514 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 526 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
515 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 527 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
516 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 528 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
517 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 529 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
518 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 530 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
519 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 531 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
520 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 532 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
521 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 533 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
522 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 534 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
523 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 535 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
524 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 536 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
525 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 537 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
526 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 538 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
527 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 539 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
528 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 540 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
529 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 541 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
530 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 542 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
531 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 543 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
532} 544}
533 545
534void PwM::new_slot() 546void PwM::new_slot()
535{ 547{
536 init->createMainWnd(); 548 init->createMainWnd();
537} 549}
538 550
539//US ENH 551//US ENH
540void PwM::open_slot() 552void PwM::open_slot()
541{ 553{
542 open_slot(""); 554 open_slot("");
543} 555}
544 556
545void PwM::open_slot(QString fn) 557void PwM::open_slot(QString fn)
546{ 558{
547 openDoc(fn); 559 openDoc(fn);
548} 560}
549 561
550PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 562PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
551{ 563{
552 if (!isVirgin()) { 564 if (!isVirgin()) {
553 // open the document in a new window. 565 // open the document in a new window.
554 PwM *newInstance = init->createMainWnd(); 566 PwM *newInstance = init->createMainWnd();
555 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 567 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
556 if (!newDoc) { 568 if (!newDoc) {
557 newInstance->setForceQuit(true); 569 newInstance->setForceQuit(true);
558 delete_and_null(newInstance); 570 delete_and_null(newInstance);
559 } 571 }
560 return newDoc; 572 return newDoc;
561 } 573 }
562 574
563 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 575 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
564 return 0; 576 return 0;
565 showStatMsg(i18n("Successfully opened file.")); 577 showStatMsg(i18n("Successfully opened file."));
566 updateCaption(); 578 updateCaption();
567 setVirgin(false); 579 setVirgin(false);
568 return curDoc(); 580 return curDoc();
569} 581}
570 582
571PwMView * PwM::makeNewListView(PwMDoc *doc) 583PwMView * PwM::makeNewListView(PwMDoc *doc)
572{ 584{
573 PwMView *ret = new PwMView(this, this, doc); 585 PwMView *ret = new PwMView(this, this, doc);
574 ret->setFont(conf()->confGlobEntryFont()); 586 ret->setFont(conf()->confGlobEntryFont());
575 ret->show(); 587 ret->show();
576 return ret; 588 return ret;
577} 589}
578 590
579void PwM::close_slot() 591void PwM::close_slot()
580{ 592{
581 close(); 593 close();
582} 594}
583 595
584void PwM::quitButton_slot() 596void PwM::quitButton_slot()
585{ 597{
586 init->shutdownApp(0); 598 init->shutdownApp(0);
587} 599}
588 600
589void PwM::save_slot() 601void PwM::save_slot()
590{ 602{
591 save(); 603 save();
592} 604}
593 605
594bool PwM::save() 606bool PwM::save()
595{ 607{
596 if (!curDoc()->saveDocUi(curDoc())) 608 if (!curDoc()->saveDocUi(curDoc()))
597 return false; 609 return false;
598 showStatMsg(i18n("Successfully saved data.")); 610 showStatMsg(i18n("Successfully saved data."));
599 updateCaption(); 611 updateCaption();
600 return true; 612 return true;
601} 613}
602 614
603void PwM::saveAs_slot() 615void PwM::saveAs_slot()
604{ 616{
605 saveAs(); 617 saveAs();
606} 618}
607 619
608bool PwM::saveAs() 620bool PwM::saveAs()
609{ 621{
610 if (!curDoc()->saveAsDocUi(curDoc())) 622 if (!curDoc()->saveAsDocUi(curDoc()))
611 return false; 623 return false;
612 showStatMsg(i18n("Successfully saved data.")); 624 showStatMsg(i18n("Successfully saved data."));
613 updateCaption(); 625 updateCaption();
614 return true; 626 return true;
615} 627}
616 628
617//US ENH : changed code to run with older MOC 629//US ENH : changed code to run with older MOC
618void PwM::addPwd_slot() 630void PwM::addPwd_slot()
619{ 631{
620 addPwd_slot1(0, 0); 632 addPwd_slot1(0, 0);
621} 633}
622 634
623void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) 635void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
624{ 636{
625 PwMDoc *doc; 637 PwMDoc *doc;
626 if (_doc) { 638 if (_doc) {
627 doc = _doc; 639 doc = _doc;
628 } else { 640 } else {
629 doc = curDoc(); 641 doc = curDoc();
630 } 642 }
631 PWM_ASSERT(doc); 643 PWM_ASSERT(doc);
632 doc->timer()->getLock(DocTimer::id_autoLockTimer); 644 doc->timer()->getLock(DocTimer::id_autoLockTimer);
633#ifndef PWM_EMBEDDED 645#ifndef PWM_EMBEDDED
634 AddEntryWndImpl w; 646 AddEntryWndImpl w;
635#else 647#else
636 AddEntryWndImpl w(doc, this, "addentrywndimpl"); 648 AddEntryWndImpl w(doc, this, "addentrywndimpl");
637#endif 649#endif
638 650 w.setCaption( i18n ("Add new password") );
639 vector<string> catList; 651 vector<string> catList;
640 doc->getCategoryList(&catList); 652 doc->getCategoryList(&catList);
641 unsigned i, size = catList.size(); 653 unsigned i, size = catList.size();
642 for (i = 0; i < size; ++i) { 654 for (i = 0; i < size; ++i) {
643 w.addCategory(catList[i].c_str()); 655 w.addCategory(catList[i].c_str());
644 } 656 }
645 w.setCurrCategory(view->getCurrentCategory()); 657 w.setCurrCategory(view->getCurrentCategory());
646 if (pw) 658 if (pw)
647 w.pwLineEdit->setText(*pw); 659 w.pwLineEdit->setText(*pw);
648 660
649 tryAgain: 661 tryAgain:
650 if (w.exec() == 1) 662 if (w.exec() == 1)
651 { 663 {
652 PwMDataItem d; 664 PwMDataItem d;
653 665
654 //US BUG: to initialize all values of curEntr with meaningfulldata, 666 //US BUG: to initialize all values of curEntr with meaningfulldata,
655 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 667 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
656 // another option would be to create a constructor for PwMDataItem 668 // another option would be to create a constructor for PwMDataItem
657 d.clear(true); 669 d.clear(true);
658 670
659 d.desc = w.getDescription().latin1(); 671 d.desc = w.getDescription().latin1();
660 d.name = w.getUsername().latin1(); 672 d.name = w.getUsername().latin1();
661 d.pw = w.getPassword().latin1(); 673 d.pw = w.getPassword().latin1();
662 d.comment = w.getComment().latin1(); 674 d.comment = w.getComment().latin1();
663 d.url = w.getUrl().latin1(); 675 d.url = w.getUrl().latin1();
664 d.launcher = w.getLauncher().latin1(); 676 d.launcher = w.getLauncher().latin1();
665 PwMerror ret = doc->addEntry(w.getCategory(), &d); 677 PwMerror ret = doc->addEntry(w.getCategory(), &d);
666 if (ret == e_entryExists) { 678 if (ret == e_entryExists) {
667 KMessageBox::error(this, 679 KMessageBox::error(this,
668 i18n 680 i18n
669 ("An entry with this \"Description\",\n" 681 ("An entry with this \"Description\",\n"
670 "does already exist.\n" 682 "does already exist.\n"
671 "Please select another description."), 683 "Please select another description."),
672 i18n("entry already exists.")); 684 i18n("entry already exists."));
673 goto tryAgain; 685 goto tryAgain;
674 } else if (ret == e_maxAllowedEntr) { 686 } else if (ret == e_maxAllowedEntr) {
675 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 687 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
676 "has been reached.\nYou can't add more entries."), 688 "has been reached.\nYou can't add more entries."),
677 i18n("maximum number of entries")); 689 i18n("maximum number of entries"));
678 doc->timer()->putLock(DocTimer::id_autoLockTimer); 690 doc->timer()->putLock(DocTimer::id_autoLockTimer);
679 return; 691 return;
680 } 692 }
681 } 693 }
682 setVirgin(false); 694 setVirgin(false);
683 doc->timer()->putLock(DocTimer::id_autoLockTimer); 695 doc->timer()->putLock(DocTimer::id_autoLockTimer);
684} 696}
685 697
686//US ENH : changed code to run with older MOC 698//US ENH : changed code to run with older MOC
687void PwM::editPwd_slot() 699void PwM::editPwd_slot()
688{ 700{
689 editPwd_slot3(0,0,0); 701 editPwd_slot3(0,0,0);
690} 702}
691 703
692void PwM::editPwd_slot1(const QString *category) 704void PwM::editPwd_slot1(const QString *category)
693{ 705{
694 editPwd_slot3(category, 0, 0); 706 editPwd_slot3(category, 0, 0);
695} 707}
696 708
697void PwM::editPwd_slot3(const QString *category, const int *index, 709void PwM::editPwd_slot3(const QString *category, const int *index,
698 PwMDoc *_doc) 710 PwMDoc *_doc)
699{ 711{
700 PwMDoc *doc; 712 PwMDoc *doc;
701 if (_doc) { 713 if (_doc) {
702 doc = _doc; 714 doc = _doc;
703 } else { 715 } else {
704 doc = curDoc(); 716 doc = curDoc();
705 } 717 }
706 PWM_ASSERT(doc); 718 PWM_ASSERT(doc);
707 if (doc->isDocEmpty()) 719 if (doc->isDocEmpty())
708 return; 720 return;
709 if (doc->isDeepLocked()) 721 if (doc->isDeepLocked())
710 return; 722 return;
711 doc->timer()->getLock(DocTimer::id_autoLockTimer); 723 doc->timer()->getLock(DocTimer::id_autoLockTimer);
712 unsigned int curEntryIndex; 724 unsigned int curEntryIndex;
713 if (index) { 725 if (index) {
714 curEntryIndex = *index; 726 curEntryIndex = *index;
715 } else { 727 } else {
716 if (!(view->getCurEntryIndex(&curEntryIndex))) { 728 if (!(view->getCurEntryIndex(&curEntryIndex))) {
717 printDebug("couldn't get index. Maybe we have a binary entry here."); 729 printDebug("couldn't get index. Maybe we have a binary entry here.");
718 doc->timer()->putLock(DocTimer::id_autoLockTimer); 730 doc->timer()->putLock(DocTimer::id_autoLockTimer);
719 return; 731 return;
720 } 732 }
721 } 733 }
722 QString curCategory; 734 QString curCategory;
723 if (category) { 735 if (category) {
724 curCategory = *category; 736 curCategory = *category;
725 } else { 737 } else {
726 curCategory = view->getCurrentCategory(); 738 curCategory = view->getCurrentCategory();
727 } 739 }
728 PwMDataItem currItem; 740 PwMDataItem currItem;
729 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 741 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
730 doc->timer()->putLock(DocTimer::id_autoLockTimer); 742 doc->timer()->putLock(DocTimer::id_autoLockTimer);
731 return; 743 return;
732 } 744 }
733 BUG_ON(currItem.binary); 745 BUG_ON(currItem.binary);
734 746
735 AddEntryWndImpl w(doc); 747 AddEntryWndImpl w(doc);
748 w.setCaption( i18n ("Edit password") );
736 vector<string> catList; 749 vector<string> catList;
737 doc->getCategoryList(&catList); 750 doc->getCategoryList(&catList);
738 unsigned i, size = catList.size(); 751 unsigned i, size = catList.size();
739 for (i = 0; i < size; ++i) { 752 for (i = 0; i < size; ++i) {
740 w.addCategory(catList[i].c_str()); 753 w.addCategory(catList[i].c_str());
741 } 754 }
742 w.setCurrCategory(curCategory); 755 w.setCurrCategory(curCategory);
743 w.setDescription(currItem.desc.c_str()); 756 w.setDescription(currItem.desc.c_str());
744 w.setUsername(currItem.name.c_str()); 757 w.setUsername(currItem.name.c_str());
745 w.setPassword(currItem.pw.c_str()); 758 w.setPassword(currItem.pw.c_str());
746 w.setUrl(currItem.url.c_str()); 759 w.setUrl(currItem.url.c_str());
747 w.setLauncher(currItem.launcher.c_str()); 760 w.setLauncher(currItem.launcher.c_str());
748 w.setComment(currItem.comment.c_str()); 761 w.setComment(currItem.comment.c_str());
749 if (w.exec() == 1) { 762 if (w.exec() == 1) {
750 currItem.desc = w.getDescription().latin1(); 763 currItem.desc = w.getDescription().latin1();
751 currItem.name = w.getUsername().latin1(); 764 currItem.name = w.getUsername().latin1();
752 currItem.pw = w.getPassword().latin1(); 765 currItem.pw = w.getPassword().latin1();
753 currItem.comment = w.getComment().latin1(); 766 currItem.comment = w.getComment().latin1();
754 currItem.url = w.getUrl().latin1(); 767 currItem.url = w.getUrl().latin1();
755 currItem.launcher = w.getLauncher().latin1(); 768 currItem.launcher = w.getLauncher().latin1();
756 if (!doc->editEntry(curCategory, w.getCategory(), 769 if (!doc->editEntry(curCategory, w.getCategory(),
757 curEntryIndex, &currItem)) { 770 curEntryIndex, &currItem)) {
758 KMessageBox::error(this, 771 KMessageBox::error(this,
759 i18n("Couldn't edit the entry.\n" 772 i18n("Couldn't edit the entry.\n"
760 "Maybe you changed the category and\n" 773 "Maybe you changed the category and\n"
761 "this entry is already present\nin the new " 774 "this entry is already present\nin the new "
762 "category?"), 775 "category?"),
763 i18n("couldn't edit entry.")); 776 i18n("couldn't edit entry."));
764 doc->timer()->putLock(DocTimer::id_autoLockTimer); 777 doc->timer()->putLock(DocTimer::id_autoLockTimer);
765 return; 778 return;
766 } 779 }
767 } 780 }
768 doc->timer()->putLock(DocTimer::id_autoLockTimer); 781 doc->timer()->putLock(DocTimer::id_autoLockTimer);
769} 782}
770 783
771void PwM::deletePwd_slot() 784void PwM::deletePwd_slot()
772{ 785{
773 PWM_ASSERT(curDoc()); 786 PWM_ASSERT(curDoc());
774 if (curDoc()->isDocEmpty()) 787 if (curDoc()->isDocEmpty())
775 return; 788 return;
776 if (curDoc()->isDeepLocked()) 789 if (curDoc()->isDeepLocked())
777 return; 790 return;
778 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 791 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
779 unsigned int curEntryIndex = 0; 792 unsigned int curEntryIndex = 0;
780 if (!(view->getCurEntryIndex(&curEntryIndex))) { 793 if (!(view->getCurEntryIndex(&curEntryIndex))) {
781 printDebug("couldn't get index"); 794 printDebug("couldn't get index");
782 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 795 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
783 return; 796 return;
784 } 797 }
785 798
786 PwMDataItem currItem; 799 PwMDataItem currItem;
787 QString curCategory = view->getCurrentCategory(); 800 QString curCategory = view->getCurrentCategory();
788 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 801 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
789 printDebug("couldn't get entry"); 802 printDebug("couldn't get entry");
790 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 803 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
791 return; 804 return;
792 } 805 }
793 if (KMessageBox:: 806 if (KMessageBox::
794 questionYesNo(this, 807 questionYesNo(this,
795 i18n 808 i18n
796 ("Do you really want to delete\nthe selected entry") + 809 ("Do you really want to delete\nthe selected entry") +
797 " \n\"" + QString(currItem.desc.c_str()) 810 " \n\"" + QString(currItem.desc.c_str())
798 + "\" ?", i18n("delete?")) 811 + "\" ?", i18n("delete?"))
799 == KMessageBox::Yes) { 812 == KMessageBox::Yes) {
800 813
801 curDoc()->delEntry(curCategory, curEntryIndex); 814 curDoc()->delEntry(curCategory, curEntryIndex);
802 } 815 }
803 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 816 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
804} 817}
805 818
806void PwM::changeMasterPwd_slot() 819void PwM::changeMasterPwd_slot()
807{ 820{
808 PWM_ASSERT(curDoc()); 821 PWM_ASSERT(curDoc());
809 curDoc()->changeCurrentPw(); 822 curDoc()->changeCurrentPw();
810} 823}
811 824
812void PwM::lockWnd_slot() 825void PwM::lockWnd_slot()
813{ 826{
814 PWM_ASSERT(curDoc()); 827 PWM_ASSERT(curDoc());
815 curDoc()->lockAll(true); 828 curDoc()->lockAll(true);
816} 829}
817 830
818void PwM::deepLockWnd_slot() 831void PwM::deepLockWnd_slot()
819{ 832{
820 PWM_ASSERT(curDoc()); 833 PWM_ASSERT(curDoc());
821 curDoc()->deepLock(); 834 curDoc()->deepLock();
822} 835}
823 836
824void PwM::unlockWnd_slot() 837void PwM::unlockWnd_slot()
825{ 838{
826 PWM_ASSERT(curDoc()); 839 PWM_ASSERT(curDoc());
827 curDoc()->lockAll(false); 840 curDoc()->lockAll(false);
828} 841}
829 842
830void PwM::config_slot() 843void PwM::config_slot()
831{ 844{