summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/addentrywnd_emb.cpp7
-rw-r--r--pwmanager/pwmanager/commentbox.cpp1
-rw-r--r--pwmanager/pwmanager/pwm.cpp2
-rw-r--r--pwmanager/pwmanager/pwmview.cpp1
-rw-r--r--pwmanager/pwmanager/pwmviewstyle.cpp11
-rw-r--r--pwmanager/pwmanager/pwmviewstyle.h11
6 files changed, 30 insertions, 3 deletions
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp
index f065058..c2590f0 100644
--- a/pwmanager/pwmanager/addentrywnd_emb.cpp
+++ b/pwmanager/pwmanager/addentrywnd_emb.cpp
@@ -1,226 +1,233 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "addentrywnd_emb.h" 26#include "addentrywnd_emb.h"
27#include "pwmdoc.h" 27#include "pwmdoc.h"
28 28
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qtabwidget.h> 31#include <qtabwidget.h>
32#include <qgroupbox.h> 32#include <qgroupbox.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kcombobox.h> 34#include <kcombobox.h>
35#include <klineedit.h> 35#include <klineedit.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qmultilineedit.h> 37#include <qmultilineedit.h>
38 38
39/* 39/*
40 * Constructs a addEntryWnd as a child of 'parent', with the 40 * Constructs a addEntryWnd as a child of 'parent', with the
41 * name 'name' and widget flags set to 'f'. 41 * name 'name' and widget flags set to 'f'.
42 * 42 *
43 * The dialog will by default be modeless, unless you set 'modal' to 43 * The dialog will by default be modeless, unless you set 'modal' to
44 * TRUE to construct a modal dialog. 44 * TRUE to construct a modal dialog.
45 */ 45 */
46addEntryWnd::addEntryWnd( PwMDoc* d, QWidget* parent, const char* name) 46addEntryWnd::addEntryWnd( PwMDoc* d, QWidget* parent, const char* name)
47 : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ), 47 : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ),
48 KDialogBase::Ok | KDialogBase::Cancel, 48 KDialogBase::Ok | KDialogBase::Cancel,
49 KDialogBase::Ok, parent, name, true ), doc(d) 49 KDialogBase::Ok, parent, name, true ), doc(d)
50{ 50{
51 QWidget *page = plainPage(); 51 QWidget *page = plainPage();
52 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 52 QVBoxLayout *pageLayout = new QVBoxLayout( page );
53 53
54 QTabWidget* mTabWidget = new QTabWidget( page ); 54 QTabWidget* mTabWidget = new QTabWidget( page );
55 pageLayout->addWidget( mTabWidget ); 55 pageLayout->addWidget( mTabWidget );
56 56
57 //////////////////////////////////////////////////////////////////// 57 ////////////////////////////////////////////////////////////////////
58 // This is the Password tab 58 // This is the Password tab
59 QWidget *tab1 = new QWidget( mTabWidget ); 59 QWidget *tab1 = new QWidget( mTabWidget );
60 60
61 QGridLayout *layout = new QGridLayout( tab1, 3, 1 ); 61 QGridLayout *layout = new QGridLayout( tab1, 3, 1 );
62 layout->setMargin( KDialogBase::marginHint() ); 62 layout->setMargin( KDialogBase::marginHint() );
63 layout->setSpacing( KDialogBase::spacingHint() ); 63 layout->setSpacing( KDialogBase::spacingHint() );
64 64
65 65
66 66
67 int i = 0; 67 int i = 0;
68 descLineEdit = new KLineEdit( tab1, "descLineEdit" ); 68 descLineEdit = new KLineEdit( tab1, "descLineEdit" );
69 descLineLabel = new QLabel( descLineEdit, i18n("Description:"), tab1 ); 69 descLineLabel = new QLabel( descLineEdit, i18n("Description:"), tab1 );
70 layout->addWidget( descLineLabel, i, 0 ); 70 layout->addWidget( descLineLabel, i, 0 );
71 layout->addWidget( descLineEdit, i, 1 ); 71 layout->addWidget( descLineEdit, i, 1 );
72 i++; 72 i++;
73 73
74 categoryComboBox = new KComboBox( tab1 ); 74 categoryComboBox = new KComboBox( tab1 );
75 QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), tab1 ); 75 QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), tab1 );
76 layout->addWidget( label, i, 0 ); 76 layout->addWidget( label, i, 0 );
77 layout->addWidget( categoryComboBox, i, 1 ); 77 layout->addWidget( categoryComboBox, i, 1 );
78 i++; 78 i++;
79 categoryComboBox->setEditable( TRUE ); 79 categoryComboBox->setEditable( TRUE );
80 categoryComboBox->setSizeLimit( 100 ); 80 categoryComboBox->setSizeLimit( 100 );
81 categoryComboBox->setAutoCompletion( TRUE ); 81 categoryComboBox->setAutoCompletion( TRUE );
82 categoryComboBox->setDuplicatesEnabled( FALSE ); 82 categoryComboBox->setDuplicatesEnabled( FALSE );
83 connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); 83 connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&)));
84 84
85 85
86 usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); 86 usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" );
87 usernameLineLabel = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); 87 usernameLineLabel = new QLabel( usernameLineEdit, i18n("Username:"), tab1 );
88 layout->addWidget( usernameLineLabel, i, 0 ); 88 layout->addWidget( usernameLineLabel, i, 0 );
89 layout->addWidget( usernameLineEdit, i, 1 ); 89 layout->addWidget( usernameLineEdit, i, 1 );
90 i++; 90 i++;
91 91
92 pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); 92 pwLineEdit = new KLineEdit( tab1, "pwLineEdit" );
93 pwLineEdit->setEchoMode( QLineEdit::Password ); 93 pwLineEdit->setEchoMode( QLineEdit::Password );
94 pwLineLabel = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); 94 pwLineLabel = new QLabel( pwLineEdit, i18n("Password:"), tab1 );
95 layout->addWidget( pwLineLabel, i, 0 ); 95 layout->addWidget( pwLineLabel, i, 0 );
96 layout->addWidget( pwLineEdit, i, 1 ); 96 layout->addWidget( pwLineEdit, i, 1 );
97 i++; 97 i++;
98 98
99 revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); 99 revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" );
100 revealButton->setToggleButton( TRUE ); 100 revealButton->setToggleButton( TRUE );
101 layout->addWidget( revealButton, i, 0 ); 101 layout->addWidget( revealButton, i, 0 );
102 102
103 generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); 103 generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" );
104 layout->addWidget( generateButton, i, 1 ); 104 layout->addWidget( generateButton, i, 1 );
105 i++; 105 i++;
106 106
107 urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); 107 urlLineEdit = new KLineEdit( tab1, "urlLineEdit" );
108 label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); 108 label = new QLabel( urlLineEdit, i18n("URL:"), tab1 );
109 layout->addWidget( label, i, 0 ); 109 layout->addWidget( label, i, 0 );
110 layout->addWidget( urlLineEdit, i, 1 ); 110 layout->addWidget( urlLineEdit, i, 1 );
111 i++; 111 i++;
112 112
113 mTabWidget->addTab( tab1, i18n( "&Password" ) ); 113 mTabWidget->addTab( tab1, i18n( "&Password" ) );
114 114
115 115
116 //////////////////////////////////////////////////////////////////// 116 ////////////////////////////////////////////////////////////////////
117 // This is the Comment tab 117 // This is the Comment tab
118 QWidget *tab2 = new QWidget( mTabWidget ); 118 QWidget *tab2 = new QWidget( mTabWidget );
119 119
120 layout = new QGridLayout( tab2, 3, 1 ); 120 layout = new QGridLayout( tab2, 3, 1 );
121 layout->setMargin( KDialogBase::marginHintSmall() ); 121 layout->setMargin( KDialogBase::marginHintSmall() );
122 layout->setSpacing( KDialogBase::spacingHintSmall() ); 122 layout->setSpacing( KDialogBase::spacingHintSmall() );
123 i = 0; 123 i = 0;
124 124
125 commentTextEdit = new QMultiLineEdit(tab2); 125 commentTextEdit = new QMultiLineEdit(tab2);
126 layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 ); 126 layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 );
127 i++; 127 i++;
128 128
129 129
130 mTabWidget->addTab( tab2, i18n( "&Comments" ) ); 130 mTabWidget->addTab( tab2, i18n( "&Comments" ) );
131 131
132 132
133 //////////////////////////////////////////////////////////////////// 133 ////////////////////////////////////////////////////////////////////
134 // This is the Launcher tab 134 // This is the Launcher tab
135 QWidget *tab3 = new QWidget( mTabWidget ); 135 QWidget *tab3 = new QWidget( mTabWidget );
136 136
137 layout = new QGridLayout( tab3, 3, 1 ); 137 layout = new QGridLayout( tab3, 3, 1 );
138 layout->setMargin( KDialogBase::marginHintSmall() ); 138 layout->setMargin( KDialogBase::marginHintSmall() );
139 layout->setSpacing( KDialogBase::spacingHintSmall() ); 139 layout->setSpacing( KDialogBase::spacingHintSmall() );
140 i = 0; 140 i = 0;
141 141
142 launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); 142 launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" );
143 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); 143 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 );
144 144
145 QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); 145 QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 );
146 QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); 146 QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 );
147 QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); 147 QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 );
148 QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); 148 QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 );
149 QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); 149 QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 );
150 150
151 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); 151 label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 );
152 152
153 layout->addWidget( label1, i, 0 ); 153 layout->addWidget( label1, i, 0 );
154 layout->addWidget( label2, i, 1 ); 154 layout->addWidget( label2, i, 1 );
155 i++; 155 i++;
156 layout->addWidget( label3, i, 0 ); 156 layout->addWidget( label3, i, 0 );
157 layout->addWidget( label4, i, 1 ); 157 layout->addWidget( label4, i, 1 );
158 i++; 158 i++;
159 layout->addWidget( label5, i, 0 ); 159 layout->addWidget( label5, i, 0 );
160 i++; 160 i++;
161 161
162 layout->addWidget( label, i, 0 ); 162 layout->addWidget( label, i, 0 );
163 layout->addWidget( launcherLineEdit, i, 1 ); 163 layout->addWidget( launcherLineEdit, i, 1 );
164 i++; 164 i++;
165 165
166 166
167 mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); 167 mTabWidget->addTab( tab3, i18n( "&Launcher" ) );
168 168
169 // signals and slots connections 169 // signals and slots connections
170 connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); 170 connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) );
171 connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); 171 connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) );
172
173#if 0
174 if ( QApplication::desktop()->width() <= 640 && QApplication::desktop()->width() >= 480 ) {
175 resize ( 440, 400 );
176 }
177#endif
178
172} 179}
173 180
174/* 181/*
175 * Destroys the object and frees any allocated resources 182 * Destroys the object and frees any allocated resources
176 */ 183 */
177addEntryWnd::~addEntryWnd() 184addEntryWnd::~addEntryWnd()
178{ 185{
179 // no need to delete child widgets, Qt does it all for us 186 // no need to delete child widgets, Qt does it all for us
180} 187}
181 188
182void addEntryWnd::slotOk() 189void addEntryWnd::slotOk()
183{ 190{
184 qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); 191 qWarning( "addEntryWnd::slotOk(): Not implemented yet" );
185} 192}
186 193
187void addEntryWnd::revealButton_slot() 194void addEntryWnd::revealButton_slot()
188{ 195{
189 qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); 196 qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" );
190} 197}
191 198
192void addEntryWnd::generateButton_slot() 199void addEntryWnd::generateButton_slot()
193{ 200{
194 qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); 201 qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" );
195} 202}
196 203
197void addEntryWnd::advancedCommentButton_slot(bool) 204void addEntryWnd::advancedCommentButton_slot(bool)
198{ 205{
199 qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); 206 qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" );
200} 207}
201 208
202void addEntryWnd::categorySelected ( const QString & string ) 209void addEntryWnd::categorySelected ( const QString & string )
203{ 210{
204 unsigned int idx; 211 unsigned int idx;
205 bool found = doc->findCategory(string, &idx); 212 bool found = doc->findCategory(string, &idx);
206 213
207 if (found == true) 214 if (found == true)
208 { 215 {
209 qDebug("addEntryWnd::categorySelected found"); 216 qDebug("addEntryWnd::categorySelected found");
210 PwMCategoryItem* catitem = doc->getCategoryEntry(idx); 217 PwMCategoryItem* catitem = doc->getCategoryEntry(idx);
211 218
212 descLineLabel->setText(catitem->desc_text.c_str()); 219 descLineLabel->setText(catitem->desc_text.c_str());
213 usernameLineLabel->setText(catitem->name_text.c_str()); 220 usernameLineLabel->setText(catitem->name_text.c_str());
214 pwLineLabel->setText(catitem->pw_text.c_str()); 221 pwLineLabel->setText(catitem->pw_text.c_str());
215 return; 222 return;
216 } 223 }
217 else 224 else
218 { 225 {
219 qDebug("addEntryWnd::categorySelected NOT found"); 226 qDebug("addEntryWnd::categorySelected NOT found");
220 BUG(); 227 BUG();
221 } 228 }
222 229
223 230
224} 231}
225 232
226 233
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp
index e2d2d2b..0f32561 100644
--- a/pwmanager/pwmanager/commentbox.cpp
+++ b/pwmanager/pwmanager/commentbox.cpp
@@ -1,281 +1,282 @@
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( 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 setFocusPolicy( QWidget::ClickFocus );
235} 236}
236 237
237CommentBox::~CommentBox() 238CommentBox::~CommentBox()
238{ 239{
239} 240}
240 241
241void CommentBox::clear() 242void CommentBox::clear()
242{ 243{
243 this->hide(); 244 this->hide();
244} 245}
245 246
246 247
247void CommentBox::setText(const QString &text) 248void CommentBox::setText(const QString &text)
248{ 249{
249 QMultiLineEdit::setText( text); 250 QMultiLineEdit::setText( text);
250 if (!this->isVisible()) 251 if (!this->isVisible())
251 this->show(); 252 this->show();
252} 253}
253 254
254bool CommentBox::getText(QString *text) 255bool CommentBox::getText(QString *text)
255{ 256{
256 *text = this->text(); 257 *text = this->text();
257 return true; 258 return true;
258} 259}
259 260
260void CommentBox::setContent(const QString &dta) 261void CommentBox::setContent(const QString &dta)
261{ 262{
262 // if there's no data, hide the comment-box 263 // if there's no data, hide the comment-box
263 if (dta.isEmpty()) { 264 if (dta.isEmpty()) {
264 clear(); 265 clear();
265 return; 266 return;
266 } 267 }
267 268
268 // we assume it's plain text 269 // we assume it's plain text
269 setText(dta); 270 setText(dta);
270} 271}
271 272
272#endif 273#endif
273 274
274 275
275 276
276 277
277 278
278 279
279 280
280 281
281 282
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index fc6837f..aed8ec0 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -1,1529 +1,1531 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 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 <klocale.h> 20#include <klocale.h>
21#include <klistview.h> 21#include <klistview.h>
22#include <ktoolbar.h> 22#include <ktoolbar.h>
23#include <kfiledialog.h> 23#include <kfiledialog.h>
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#include <qstatusbar.h> 27#include <qstatusbar.h>
28 28
29#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
30#include <kmenubar.h> 30#include <kmenubar.h>
31#include <kstatusbar.h> 31#include <kstatusbar.h>
32#include <dcopclient.h> 32#include <dcopclient.h>
33#include "configwndimpl.h" 33#include "configwndimpl.h"
34#include "configuration.h" 34#include "configuration.h"
35#else 35#else
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38#include <pwmprefs.h> 38#include <pwmprefs.h>
39#include <kpimglobalprefs.h> 39#include <kpimglobalprefs.h>
40#include <kcmconfigs/kcmpwmconfig.h> 40#include <kcmconfigs/kcmpwmconfig.h>
41#include <kcmconfigs/kcmkdepimconfig.h> 41#include <kcmconfigs/kcmkdepimconfig.h>
42#include <kcmultidialog.h> 42#include <kcmultidialog.h>
43#include "editcategory.h" 43#include "editcategory.h"
44#endif 44#endif
45 45
46 46
47#ifndef DESKTOP_VERSION 47#ifndef DESKTOP_VERSION
48#include <qpe/global.h> 48#include <qpe/global.h>
49#endif 49#endif
50 50
51#include <qpixmap.h> 51#include <qpixmap.h>
52#include <qcheckbox.h> 52#include <qcheckbox.h>
53#include <qspinbox.h> 53#include <qspinbox.h>
54#include <qlineedit.h> 54#include <qlineedit.h>
55#include <qfileinfo.h> 55#include <qfileinfo.h>
56#include <qclipboard.h> 56#include <qclipboard.h>
57 57
58 58
59#include <stdio.h> 59#include <stdio.h>
60 60
61#include "pwm.h" 61#include "pwm.h"
62#include "pwminit.h" 62#include "pwminit.h"
63#include "pwmprint.h" 63#include "pwmprint.h"
64#include "addentrywndimpl.h" 64#include "addentrywndimpl.h"
65#include "globalstuff.h" 65#include "globalstuff.h"
66#include "findwndimpl.h" 66#include "findwndimpl.h"
67#include "csv.h" 67#include "csv.h"
68 68
69#ifdef CONFIG_KWALLETIF 69#ifdef CONFIG_KWALLETIF
70# include "kwalletif.h" 70# include "kwalletif.h"
71# include "kwalletemu.h" 71# include "kwalletemu.h"
72#endif 72#endif
73#ifdef CONFIG_KEYCARD 73#ifdef CONFIG_KEYCARD
74# include "pwmkeycard.h" 74# include "pwmkeycard.h"
75#endif 75#endif
76 76
77 77
78 #define DEFAULT_SIZE (QSize(700, 400)) 78 #define DEFAULT_SIZE (QSize(700, 400))
79 79
80// Button IDs for "file" popup menu 80// Button IDs for "file" popup menu
81enum { 81enum {
82 BUTTON_POPUP_FILE_NEW = 0, 82 BUTTON_POPUP_FILE_NEW = 0,
83 BUTTON_POPUP_FILE_OPEN, 83 BUTTON_POPUP_FILE_OPEN,
84 BUTTON_POPUP_FILE_CLOSE, 84 BUTTON_POPUP_FILE_CLOSE,
85 BUTTON_POPUP_FILE_SAVE, 85 BUTTON_POPUP_FILE_SAVE,
86 BUTTON_POPUP_FILE_SAVEAS, 86 BUTTON_POPUP_FILE_SAVEAS,
87 BUTTON_POPUP_FILE_EXPORT, 87 BUTTON_POPUP_FILE_EXPORT,
88 BUTTON_POPUP_FILE_IMPORT, 88 BUTTON_POPUP_FILE_IMPORT,
89 BUTTON_POPUP_FILE_PRINT, 89 BUTTON_POPUP_FILE_PRINT,
90 BUTTON_POPUP_FILE_QUIT 90 BUTTON_POPUP_FILE_QUIT
91}; 91};
92// Button IDs for "manage" popup menu 92// Button IDs for "manage" popup menu
93enum { 93enum {
94 BUTTON_POPUP_MANAGE_ADD = 0, 94 BUTTON_POPUP_MANAGE_ADD = 0,
95 BUTTON_POPUP_MANAGE_EDIT, 95 BUTTON_POPUP_MANAGE_EDIT,
96 BUTTON_POPUP_MANAGE_DEL, 96 BUTTON_POPUP_MANAGE_DEL,
97 BUTTON_POPUP_MANAGE_CHANGEMP 97 BUTTON_POPUP_MANAGE_CHANGEMP
98}; 98};
99// Button IDs for chipcard popup menu 99// Button IDs for chipcard popup menu
100enum { 100enum {
101#ifdef CONFIG_KEYCARD 101#ifdef CONFIG_KEYCARD
102 BUTTON_POPUP_CHIPCARD_GENNEW = 0, 102 BUTTON_POPUP_CHIPCARD_GENNEW = 0,
103 BUTTON_POPUP_CHIPCARD_DEL, 103 BUTTON_POPUP_CHIPCARD_DEL,
104 BUTTON_POPUP_CHIPCARD_READID, 104 BUTTON_POPUP_CHIPCARD_READID,
105 BUTTON_POPUP_CHIPCARD_SAVEBACKUP, 105 BUTTON_POPUP_CHIPCARD_SAVEBACKUP,
106 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP 106 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP
107#else // CONFIG_KEYCARD 107#else // CONFIG_KEYCARD
108 BUTTON_POPUP_CHIPCARD_NO = 0 108 BUTTON_POPUP_CHIPCARD_NO = 0
109#endif // CONFIG_KEYCARD 109#endif // CONFIG_KEYCARD
110}; 110};
111// Button IDs for "view" popup menu 111// Button IDs for "view" popup menu
112enum { 112enum {
113 BUTTON_POPUP_VIEW_FIND = 0, 113 BUTTON_POPUP_VIEW_FIND = 0,
114 BUTTON_POPUP_VIEW_LOCK, 114 BUTTON_POPUP_VIEW_LOCK,
115 BUTTON_POPUP_VIEW_DEEPLOCK, 115 BUTTON_POPUP_VIEW_DEEPLOCK,
116 BUTTON_POPUP_VIEW_UNLOCK 116 BUTTON_POPUP_VIEW_UNLOCK
117}; 117};
118// Button IDs for "options" popup menu 118// Button IDs for "options" popup menu
119enum { 119enum {
120 BUTTON_POPUP_OPTIONS_CONFIG = 0 120 BUTTON_POPUP_OPTIONS_CONFIG = 0
121#ifdef PWM_EMBEDDED 121#ifdef PWM_EMBEDDED
122 ,BUTTON_POPUP_OPTIONS_CATEGORY 122 ,BUTTON_POPUP_OPTIONS_CATEGORY
123#endif 123#endif
124}; 124};
125// Button IDs for "export" popup menu (in "file" popup menu) 125// Button IDs for "export" popup menu (in "file" popup menu)
126enum { 126enum {
127 BUTTON_POPUP_EXPORT_TEXT = 0, 127 BUTTON_POPUP_EXPORT_TEXT = 0,
128 BUTTON_POPUP_EXPORT_GPASMAN, 128 BUTTON_POPUP_EXPORT_GPASMAN,
129 BUTTON_POPUP_EXPORT_CSV 129 BUTTON_POPUP_EXPORT_CSV
130#ifdef CONFIG_KWALLETIF 130#ifdef CONFIG_KWALLETIF
131 ,BUTTON_POPUP_EXPORT_KWALLET 131 ,BUTTON_POPUP_EXPORT_KWALLET
132#endif 132#endif
133}; 133};
134// Button IDs for "import" popup menu (in "file" popup menu) 134// Button IDs for "import" popup menu (in "file" popup menu)
135enum { 135enum {
136 BUTTON_POPUP_IMPORT_TEXT = 0, 136 BUTTON_POPUP_IMPORT_TEXT = 0,
137 BUTTON_POPUP_IMPORT_GPASMAN, 137 BUTTON_POPUP_IMPORT_GPASMAN,
138 BUTTON_POPUP_IMPORT_CSV 138 BUTTON_POPUP_IMPORT_CSV
139#ifdef CONFIG_KWALLETIF 139#ifdef CONFIG_KWALLETIF
140 ,BUTTON_POPUP_IMPORT_KWALLET 140 ,BUTTON_POPUP_IMPORT_KWALLET
141#endif 141#endif
142}; 142};
143 143
144#ifdef PWM_EMBEDDED 144#ifdef PWM_EMBEDDED
145// Button IDs for "help" popup menu 145// Button IDs for "help" popup menu
146enum { 146enum {
147 BUTTON_POPUP_HELP_LICENSE = 0, 147 BUTTON_POPUP_HELP_LICENSE = 0,
148 BUTTON_POPUP_HELP_FAQ, 148 BUTTON_POPUP_HELP_FAQ,
149 BUTTON_POPUP_HELP_ABOUT, 149 BUTTON_POPUP_HELP_ABOUT,
150 BUTTON_POPUP_HELP_SYNC, 150 BUTTON_POPUP_HELP_SYNC,
151 BUTTON_POPUP_HELP_WHATSNEW 151 BUTTON_POPUP_HELP_WHATSNEW
152}; 152};
153#endif 153#endif
154 154
155// Button IDs for toolbar 155// Button IDs for toolbar
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)), 252 filePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
253 i18n("&Add password"), this, 253 i18n("&Add password"), this,
254 SLOT(addPwd_slot()), 0, 254 SLOT(addPwd_slot()), 0,
255 BUTTON_POPUP_MANAGE_ADD); 255 BUTTON_POPUP_MANAGE_ADD);
256 filePopup->insertSeparator(); 256 filePopup->insertSeparator();
257 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), 257 filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)),
258 i18n("&Save"), this, 258 i18n("&Save"), this,
259 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); 259 SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE);
260 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), 260 filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)),
261 i18n("Save &as..."), 261 i18n("Save &as..."),
262 this, SLOT(saveAs_slot()), 0, 262 this, SLOT(saveAs_slot()), 0,
263 BUTTON_POPUP_FILE_SAVEAS); 263 BUTTON_POPUP_FILE_SAVEAS);
264 filePopup->insertSeparator(); 264 filePopup->insertSeparator();
265 // "file/export" popup menu 265 // "file/export" popup menu
266 exportPopup->insertItem(i18n("&Text-file..."), this, 266 exportPopup->insertItem(i18n("&Text-file..."), this,
267 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); 267 SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT);
268 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 268 exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
269 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); 269 SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN);
270 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 270 exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
271 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); 271 SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV);
272#ifdef CONFIG_KWALLETIF 272#ifdef CONFIG_KWALLETIF
273 exportPopup->insertItem(i18n("&KWallet..."), this, 273 exportPopup->insertItem(i18n("&KWallet..."), this,
274 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); 274 SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET);
275#endif 275#endif
276 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), 276 filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)),
277 i18n("E&xport"), exportPopup, 277 i18n("E&xport"), exportPopup,
278 BUTTON_POPUP_FILE_EXPORT); 278 BUTTON_POPUP_FILE_EXPORT);
279 // "file/import" popup menu 279 // "file/import" popup menu
280 importPopup->insertItem(i18n("&Text-file..."), this, 280 importPopup->insertItem(i18n("&Text-file..."), this,
281 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); 281 SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT);
282 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, 282 importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this,
283 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); 283 SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN);
284 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, 284 importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this,
285 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); 285 SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV);
286#ifdef CONFIG_KWALLETIF 286#ifdef CONFIG_KWALLETIF
287 importPopup->insertItem(i18n("&KWallet..."), this, 287 importPopup->insertItem(i18n("&KWallet..."), this,
288 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); 288 SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET);
289#endif 289#endif
290 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), 290 filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)),
291 i18n("I&mport"), importPopup, 291 i18n("I&mport"), importPopup,
292 BUTTON_POPUP_FILE_IMPORT); 292 BUTTON_POPUP_FILE_IMPORT);
293 filePopup->insertSeparator(); 293 filePopup->insertSeparator();
294#if 0 294#if 0
295 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), 295 filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)),
296 i18n("&Print..."), this, 296 i18n("&Print..."), this,
297 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); 297 SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT);
298 filePopup->insertSeparator(); 298 filePopup->insertSeparator();
299#endif 299#endif
300 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), 300 filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)),
301 i18n("&Quit"), this, 301 i18n("&Quit"), this,
302 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); 302 SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT);
303 menuBar()->insertItem(i18n("&File"), filePopup); 303 menuBar()->insertItem(i18n("&File"), filePopup);
304// "manage" popup menu 304// "manage" popup menu
305 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), 305 managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)),
306 i18n("&Add password"), this, 306 i18n("&Add password"), this,
307 SLOT(addPwd_slot()), 0, 307 SLOT(addPwd_slot()), 0,
308 BUTTON_POPUP_MANAGE_ADD); 308 BUTTON_POPUP_MANAGE_ADD);
309 managePopup->insertSeparator(); 309 managePopup->insertSeparator();
310 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), 310 managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)),
311 i18n("&Edit"), this, SLOT(editPwd_slot()), 0, 311 i18n("&Edit"), this, SLOT(editPwd_slot()), 0,
312 BUTTON_POPUP_MANAGE_EDIT); 312 BUTTON_POPUP_MANAGE_EDIT);
313 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 313 managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
314 i18n("&Delete"), this, SLOT(deletePwd_slot()), 314 i18n("&Delete"), this, SLOT(deletePwd_slot()),
315 0, BUTTON_POPUP_MANAGE_DEL); 315 0, BUTTON_POPUP_MANAGE_DEL);
316 managePopup->insertSeparator(); 316 managePopup->insertSeparator();
317 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), 317 managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)),
318 i18n("Change &Master Password"), this, 318 i18n("Change &Master Password"), this,
319 SLOT(changeMasterPwd_slot()), 0, 319 SLOT(changeMasterPwd_slot()), 0,
320 BUTTON_POPUP_MANAGE_CHANGEMP); 320 BUTTON_POPUP_MANAGE_CHANGEMP);
321 menuBar()->insertItem(i18n("&Manage"), managePopup); 321 menuBar()->insertItem(i18n("&Manage"), managePopup);
322// "chipcard" popup menu 322// "chipcard" popup menu
323#ifdef CONFIG_KEYCARD 323#ifdef CONFIG_KEYCARD
324 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), 324 chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)),
325 i18n("&Generate new key-card"), this, 325 i18n("&Generate new key-card"), this,
326 SLOT(genNewCard_slot()), 0, 326 SLOT(genNewCard_slot()), 0,
327 BUTTON_POPUP_CHIPCARD_GENNEW); 327 BUTTON_POPUP_CHIPCARD_GENNEW);
328 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), 328 chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)),
329 i18n("&Erase key-card"), this, 329 i18n("&Erase key-card"), this,
330 SLOT(eraseCard_slot()), 0, 330 SLOT(eraseCard_slot()), 0,
331 BUTTON_POPUP_CHIPCARD_DEL); 331 BUTTON_POPUP_CHIPCARD_DEL);
332 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), 332 chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)),
333 i18n("Read card-&ID"), this, 333 i18n("Read card-&ID"), this,
334 SLOT(readCardId_slot()), 0, 334 SLOT(readCardId_slot()), 0,
335 BUTTON_POPUP_CHIPCARD_READID); 335 BUTTON_POPUP_CHIPCARD_READID);
336 chipcardPopup->insertSeparator(); 336 chipcardPopup->insertSeparator();
337 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), 337 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)),
338 i18n("&Make card backup-image"), this, 338 i18n("&Make card backup-image"), this,
339 SLOT(makeCardBackup_slot()), 0, 339 SLOT(makeCardBackup_slot()), 0,
340 BUTTON_POPUP_CHIPCARD_SAVEBACKUP); 340 BUTTON_POPUP_CHIPCARD_SAVEBACKUP);
341 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), 341 chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)),
342 i18n("&Replay card backup-image"), this, 342 i18n("&Replay card backup-image"), this,
343 SLOT(replayCardBackup_slot()), 0, 343 SLOT(replayCardBackup_slot()), 0,
344 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); 344 BUTTON_POPUP_CHIPCARD_REPLAYBACKUP);
345 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); 345 menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup);
346#endif // CONFIG_KEYCARD 346#endif // CONFIG_KEYCARD
347// "view" popup menu 347// "view" popup menu
348 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), 348 viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)),
349 i18n("&Find"), this, 349 i18n("&Find"), this,
350 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); 350 SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND);
351 viewPopup->insertSeparator(); 351 viewPopup->insertSeparator();
352 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), 352 viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)),
353 i18n("&Lock all entries"), this, 353 i18n("&Lock all entries"), this,
354 SLOT(lockWnd_slot()), 0, 354 SLOT(lockWnd_slot()), 0,
355 BUTTON_POPUP_VIEW_LOCK); 355 BUTTON_POPUP_VIEW_LOCK);
356 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), 356 viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)),
357 i18n("&Deep-lock all entries"), this, 357 i18n("&Deep-lock all entries"), this,
358 SLOT(deepLockWnd_slot()), 0, 358 SLOT(deepLockWnd_slot()), 0,
359 BUTTON_POPUP_VIEW_DEEPLOCK); 359 BUTTON_POPUP_VIEW_DEEPLOCK);
360 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), 360 viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)),
361 i18n("&Unlock all entries"), this, 361 i18n("&Unlock all entries"), this,
362 SLOT(unlockWnd_slot()), 0, 362 SLOT(unlockWnd_slot()), 0,
363 BUTTON_POPUP_VIEW_UNLOCK); 363 BUTTON_POPUP_VIEW_UNLOCK);
364 menuBar()->insertItem(i18n("&View"), viewPopup); 364 menuBar()->insertItem(i18n("&View"), viewPopup);
365// "options" popup menu 365// "options" popup menu
366 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 366 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
367 i18n("&Configure..."), this, 367 i18n("&Configure..."), this,
368 SLOT(config_slot()),0, 368 SLOT(config_slot()),0,
369 BUTTON_POPUP_OPTIONS_CONFIG); 369 BUTTON_POPUP_OPTIONS_CONFIG);
370 menuBar()->insertItem(i18n("&Options"), optionsPopup); 370 menuBar()->insertItem(i18n("&Options"), optionsPopup);
371// "help" popup menu 371// "help" popup menu
372#ifndef PWM_EMBEDDED 372#ifndef PWM_EMBEDDED
373 helpPopup = helpMenu(QString::null, false); 373 helpPopup = helpMenu(QString::null, false);
374#else 374#else
375 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), 375 optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)),
376 i18n("C&ategories..."), this, 376 i18n("C&ategories..."), this,
377 SLOT(category_slot()),0, 377 SLOT(category_slot()),0,
378 BUTTON_POPUP_OPTIONS_CATEGORY); 378 BUTTON_POPUP_OPTIONS_CATEGORY);
379 379
380 380
381 menuBar()->insertItem(i18n("&Sync"), syncPopup); 381 menuBar()->insertItem(i18n("&Sync"), syncPopup);
382 382
383 383
384 384
385 385
386 386
387 helpPopup = new KPopupMenu(this); 387 helpPopup = new KPopupMenu(this);
388 388
389 389
390 helpPopup->insertItem(i18n("&License"), this, 390 helpPopup->insertItem(i18n("&License"), this,
391 SLOT(showLicense_slot()), 0, 391 SLOT(showLicense_slot()), 0,
392 BUTTON_POPUP_HELP_LICENSE); 392 BUTTON_POPUP_HELP_LICENSE);
393 393
394 helpPopup->insertItem(i18n("&Faq"), this, 394 helpPopup->insertItem(i18n("&Faq"), this,
395 SLOT(faq_slot()), 0, 395 SLOT(faq_slot()), 0,
396 BUTTON_POPUP_HELP_FAQ); 396 BUTTON_POPUP_HELP_FAQ);
397 397
398 helpPopup->insertItem(i18n("&About PwManager"), this, 398 helpPopup->insertItem(i18n("&About PwManager"), this,
399 SLOT(createAboutData_slot()), 0, 399 SLOT(createAboutData_slot()), 0,
400 BUTTON_POPUP_HELP_ABOUT); 400 BUTTON_POPUP_HELP_ABOUT);
401 401
402 helpPopup->insertItem(i18n("&Sync HowTo"), this, 402 helpPopup->insertItem(i18n("&Sync HowTo"), this,
403 SLOT(syncHowTo_slot()), 0, 403 SLOT(syncHowTo_slot()), 0,
404 BUTTON_POPUP_HELP_SYNC); 404 BUTTON_POPUP_HELP_SYNC);
405 405
406 helpPopup->insertItem(i18n("&What's New"), this, 406 helpPopup->insertItem(i18n("&What's New"), this,
407 SLOT(whatsnew_slot()), 0, 407 SLOT(whatsnew_slot()), 0,
408 BUTTON_POPUP_HELP_WHATSNEW); 408 BUTTON_POPUP_HELP_WHATSNEW);
409 409
410#endif 410#endif
411 menuBar()->insertItem(i18n("&Help"), helpPopup); 411 menuBar()->insertItem(i18n("&Help"), helpPopup);
412 412
413} 413}
414 414
415void PwM::initToolbar() 415void PwM::initToolbar()
416{ 416{
417 KIconLoader* picons; 417 KIconLoader* picons;
418#ifndef PWM_EMBEDDED 418#ifndef PWM_EMBEDDED
419 KIconLoader icons; 419 KIconLoader icons;
420 picons = &icons; 420 picons = &icons;
421#else 421#else
422 picons = KGlobal::iconLoader(); 422 picons = KGlobal::iconLoader();
423#endif 423#endif
424 424
425#if 0 425#if 0
426 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), 426 toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar),
427 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, 427 BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this,
428 SLOT(new_slot()), true, i18n("New")); 428 SLOT(new_slot()), true, i18n("New"));
429#endif 429#endif
430 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), 430 toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar),
431 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, 431 BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this,
432 SLOT(open_slot()), true, i18n("Open")); 432 SLOT(open_slot()), true, i18n("Open"));
433 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), 433 toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar),
434 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, 434 BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this,
435 SLOT(addPwd_slot()), true, 435 SLOT(addPwd_slot()), true,
436 i18n("Add password")); 436 i18n("Add password"));
437 toolBar()->insertSeparator(); 437 toolBar()->insertSeparator();
438 438
439 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), 439 toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar),
440 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, 440 BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this,
441 SLOT(find_slot()), true, i18n("Find entry")); 441 SLOT(find_slot()), true, i18n("Find entry"));
442 toolBar()->insertSeparator(); 442 toolBar()->insertSeparator();
443 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), 443 toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar),
444 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, 444 BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this,
445 SLOT(save_slot()), true, i18n("Save")); 445 SLOT(save_slot()), true, i18n("Save"));
446#if 0 446#if 0
447 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), 447 toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar),
448 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, 448 BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this,
449 SLOT(saveAs_slot()), true, i18n("Save as")); 449 SLOT(saveAs_slot()), true, i18n("Save as"));
450#endif 450#endif
451 451
452 452
453#if 0 453#if 0
454 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), 454 toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar),
455 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, 455 BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this,
456 SLOT(print_slot()), true, i18n("Print...")); 456 SLOT(print_slot()), true, i18n("Print..."));
457#endif 457#endif
458 toolBar()->insertSeparator(); 458 toolBar()->insertSeparator();
459 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), 459 toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar),
460 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, 460 BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this,
461 SLOT(editPwd_slot()), true, 461 SLOT(editPwd_slot()), true,
462 i18n("Edit password")); 462 i18n("Edit password"));
463 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), 463 toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar),
464 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, 464 BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this,
465 SLOT(deletePwd_slot()), true, 465 SLOT(deletePwd_slot()), true,
466 i18n("Delete password")); 466 i18n("Delete password"));
467 toolBar()->insertSeparator(); 467 toolBar()->insertSeparator();
468 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), 468 toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar),
469 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, 469 BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this,
470 SLOT(lockWnd_slot()), true, 470 SLOT(lockWnd_slot()), true,
471 i18n("Lock all entries")); 471 i18n("Lock all entries"));
472 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), 472 toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar),
473 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, 473 BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this,
474 SLOT(deepLockWnd_slot()), true, 474 SLOT(deepLockWnd_slot()), true,
475 i18n("Deep-Lock all entries")); 475 i18n("Deep-Lock all entries"));
476 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), 476 toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar),
477 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, 477 BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this,
478 SLOT(unlockWnd_slot()), true, 478 SLOT(unlockWnd_slot()), true,
479 i18n("Unlock all entries")); 479 i18n("Unlock all entries"));
480} 480}
481 481
482void PwM::initMetrics() 482void PwM::initMetrics()
483{ 483{
484 QSize s = conf()->confWndMainWndSize(); 484 QSize s = conf()->confWndMainWndSize();
485 if (s.isValid()) 485 if (s.isValid())
486 resize(s); 486 resize(s);
487 else 487 else
488 resize(DEFAULT_SIZE); 488 resize(DEFAULT_SIZE);
489} 489}
490 490
491void PwM::updateCaption() 491void PwM::updateCaption()
492{ 492{
493 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); 493 setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER);
494} 494}
495 495
496void PwM::hideEvent(QHideEvent *) 496void PwM::hideEvent(QHideEvent *)
497{ 497{
498 if (isMinimized()) { 498 if (isMinimized()) {
499 if (init->tray()) { 499 if (init->tray()) {
500 forceMinimizeToTray = true; 500 forceMinimizeToTray = true;
501 close(); 501 close();
502 } 502 }
503 int mmlock = conf()->confGlobMinimizeLock(); 503 int mmlock = conf()->confGlobMinimizeLock();
504 switch (mmlock) { 504 switch (mmlock) {
505 case 0: // don't lock anything 505 case 0: // don't lock anything
506 break; 506 break;
507 case 1: {// normal lock 507 case 1: {// normal lock
508 curDoc()->lockAll(true); 508 curDoc()->lockAll(true);
509 break; 509 break;
510 } case 2: {// deep-lock 510 } case 2: {// deep-lock
511 curDoc()->deepLock(); 511 curDoc()->deepLock();
512 break; 512 break;
513 } default: 513 } default:
514 WARN(); 514 WARN();
515 } 515 }
516 } 516 }
517} 517}
518 518
519void PwM::setVirgin(bool v) 519void PwM::setVirgin(bool v)
520{ 520{
521 if (virgin == v) 521 if (virgin == v)
522 return; 522 return;
523 virgin = v; 523 virgin = v;
524 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); 524 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v);
525 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); 525 filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v);
526 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); 526 filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v);
527 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); 527 filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v);
528 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); 528 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v);
529 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); 529 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v);
530 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); 530 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v);
531 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); 531 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v);
532 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); 532 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v);
533 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); 533 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v);
534 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); 534 viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v);
535 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); 535 toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v);
536 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 536 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
537 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 537 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
538 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 538 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
539 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 539 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
540 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 540 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
541 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 541 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
542 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 542 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
543 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 543 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
544} 544}
545 545
546void PwM::new_slot() 546void PwM::new_slot()
547{ 547{
548 init->createMainWnd(); 548 init->createMainWnd();
549} 549}
550 550
551//US ENH 551//US ENH
552void PwM::open_slot() 552void PwM::open_slot()
553{ 553{
554 open_slot(""); 554 open_slot("");
555} 555}
556 556
557void PwM::open_slot(QString fn) 557void PwM::open_slot(QString fn)
558{ 558{
559 openDoc(fn); 559 openDoc(fn);
560} 560}
561 561
562PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 562PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
563{ 563{
564 if (!isVirgin()) { 564 if (!isVirgin()) {
565 // open the document in a new window. 565 // open the document in a new window.
566 PwM *newInstance = init->createMainWnd(); 566 PwM *newInstance = init->createMainWnd();
567 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 567 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
568 if (!newDoc) { 568 if (!newDoc) {
569 newInstance->setForceQuit(true); 569 newInstance->setForceQuit(true);
570 delete_and_null(newInstance); 570 delete_and_null(newInstance);
571 } 571 }
572 return newDoc; 572 return newDoc;
573 } 573 }
574 574
575 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 575 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
576 return 0; 576 return 0;
577 showStatMsg(i18n("Successfully opened file.")); 577 showStatMsg(i18n("Successfully opened file."));
578 updateCaption(); 578 updateCaption();
579 setVirgin(false); 579 setVirgin(false);
580 return curDoc(); 580 return curDoc();
581} 581}
582 582
583PwMView * PwM::makeNewListView(PwMDoc *doc) 583PwMView * PwM::makeNewListView(PwMDoc *doc)
584{ 584{
585 PwMView *ret = new PwMView(this, this, doc); 585 PwMView *ret = new PwMView(this, this, doc);
586 ret->setFont(conf()->confGlobEntryFont()); 586 ret->setFont(conf()->confGlobEntryFont());
587 ret->show(); 587 ret->show();
588 return ret; 588 return ret;
589} 589}
590 590
591void PwM::close_slot() 591void PwM::close_slot()
592{ 592{
593 close(); 593 close();
594} 594}
595 595
596void PwM::quitButton_slot() 596void PwM::quitButton_slot()
597{ 597{
598 init->shutdownApp(0); 598 init->shutdownApp(0);
599} 599}
600 600
601void PwM::save_slot() 601void PwM::save_slot()
602{ 602{
603 save(); 603 save();
604} 604}
605 605
606bool PwM::save() 606bool PwM::save()
607{ 607{
608 if (!curDoc()->saveDocUi(curDoc())) 608 if (!curDoc()->saveDocUi(curDoc()))
609 return false; 609 return false;
610 showStatMsg(i18n("Successfully saved data.")); 610 showStatMsg(i18n("Successfully saved data."));
611 updateCaption(); 611 updateCaption();
612 return true; 612 return true;
613} 613}
614 614
615void PwM::saveAs_slot() 615void PwM::saveAs_slot()
616{ 616{
617 saveAs(); 617 saveAs();
618} 618}
619 619
620bool PwM::saveAs() 620bool PwM::saveAs()
621{ 621{
622 if (!curDoc()->saveAsDocUi(curDoc())) 622 if (!curDoc()->saveAsDocUi(curDoc()))
623 return false; 623 return false;
624 showStatMsg(i18n("Successfully saved data.")); 624 showStatMsg(i18n("Successfully saved data."));
625 updateCaption(); 625 updateCaption();
626 return true; 626 return true;
627} 627}
628 628
629//US ENH : changed code to run with older MOC 629//US ENH : changed code to run with older MOC
630void PwM::addPwd_slot() 630void PwM::addPwd_slot()
631{ 631{
632 addPwd_slot1(0, 0); 632 addPwd_slot1(0, 0);
633} 633}
634 634
635void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) 635void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
636{ 636{
637 PwMDoc *doc; 637 PwMDoc *doc;
638 if (_doc) { 638 if (_doc) {
639 doc = _doc; 639 doc = _doc;
640 } else { 640 } else {
641 doc = curDoc(); 641 doc = curDoc();
642 } 642 }
643 PWM_ASSERT(doc); 643 PWM_ASSERT(doc);
644 doc->timer()->getLock(DocTimer::id_autoLockTimer); 644 doc->timer()->getLock(DocTimer::id_autoLockTimer);
645#ifndef PWM_EMBEDDED 645#ifndef PWM_EMBEDDED
646 AddEntryWndImpl w; 646 AddEntryWndImpl w;
647#else 647#else
648 AddEntryWndImpl w(doc, this, "addentrywndimpl"); 648 AddEntryWndImpl w(doc, this, "addentrywndimpl");
649#endif 649#endif
650 w.setCaption( i18n ("Add new password") ); 650 w.setCaption( i18n ("Add new password") );
651 vector<string> catList; 651 vector<string> catList;
652 doc->getCategoryList(&catList); 652 doc->getCategoryList(&catList);
653 unsigned i, size = catList.size(); 653 unsigned i, size = catList.size();
654 for (i = 0; i < size; ++i) { 654 for (i = 0; i < size; ++i) {
655 w.addCategory(catList[i].c_str()); 655 w.addCategory(catList[i].c_str());
656 } 656 }
657 w.setCurrCategory(view->getCurrentCategory()); 657 w.setCurrCategory(view->getCurrentCategory());
658 if (pw) 658 if (pw)
659 w.pwLineEdit->setText(*pw); 659 w.pwLineEdit->setText(*pw);
660 660
661 tryAgain: 661 tryAgain:
662 w.descLineEdit->setFocus();
662 if (w.exec() == 1) 663 if (w.exec() == 1)
663 { 664 {
664 PwMDataItem d; 665 PwMDataItem d;
665 666
666 //US BUG: to initialize all values of curEntr with meaningfulldata, 667 //US BUG: to initialize all values of curEntr with meaningfulldata,
667 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 668 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
668 // another option would be to create a constructor for PwMDataItem 669 // another option would be to create a constructor for PwMDataItem
669 d.clear(true); 670 d.clear(true);
670 671
671 d.desc = w.getDescription().latin1(); 672 d.desc = w.getDescription().latin1();
672 d.name = w.getUsername().latin1(); 673 d.name = w.getUsername().latin1();
673 d.pw = w.getPassword().latin1(); 674 d.pw = w.getPassword().latin1();
674 d.comment = w.getComment().latin1(); 675 d.comment = w.getComment().latin1();
675 d.url = w.getUrl().latin1(); 676 d.url = w.getUrl().latin1();
676 d.launcher = w.getLauncher().latin1(); 677 d.launcher = w.getLauncher().latin1();
677 PwMerror ret = doc->addEntry(w.getCategory(), &d); 678 PwMerror ret = doc->addEntry(w.getCategory(), &d);
678 if (ret == e_entryExists) { 679 if (ret == e_entryExists) {
679 KMessageBox::error(this, 680 KMessageBox::error(this,
680 i18n 681 i18n
681 ("An entry with this \"Description\",\n" 682 ("An entry with this \"Description\",\n"
682 "does already exist.\n" 683 "does already exist.\n"
683 "Please select another description."), 684 "Please select another description."),
684 i18n("entry already exists.")); 685 i18n("entry already exists."));
685 goto tryAgain; 686 goto tryAgain;
686 } else if (ret == e_maxAllowedEntr) { 687 } else if (ret == e_maxAllowedEntr) {
687 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 688 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
688 "has been reached.\nYou can't add more entries."), 689 "has been reached.\nYou can't add more entries."),
689 i18n("maximum number of entries")); 690 i18n("maximum number of entries"));
690 doc->timer()->putLock(DocTimer::id_autoLockTimer); 691 doc->timer()->putLock(DocTimer::id_autoLockTimer);
691 return; 692 return;
692 } 693 }
693 } 694 }
694 setVirgin(false); 695 setVirgin(false);
695 doc->timer()->putLock(DocTimer::id_autoLockTimer); 696 doc->timer()->putLock(DocTimer::id_autoLockTimer);
696} 697}
697 698
698//US ENH : changed code to run with older MOC 699//US ENH : changed code to run with older MOC
699void PwM::editPwd_slot() 700void PwM::editPwd_slot()
700{ 701{
701 editPwd_slot3(0,0,0); 702 editPwd_slot3(0,0,0);
702} 703}
703 704
704void PwM::editPwd_slot1(const QString *category) 705void PwM::editPwd_slot1(const QString *category)
705{ 706{
706 editPwd_slot3(category, 0, 0); 707 editPwd_slot3(category, 0, 0);
707} 708}
708 709
709void PwM::editPwd_slot3(const QString *category, const int *index, 710void PwM::editPwd_slot3(const QString *category, const int *index,
710 PwMDoc *_doc) 711 PwMDoc *_doc)
711{ 712{
712 PwMDoc *doc; 713 PwMDoc *doc;
713 if (_doc) { 714 if (_doc) {
714 doc = _doc; 715 doc = _doc;
715 } else { 716 } else {
716 doc = curDoc(); 717 doc = curDoc();
717 } 718 }
718 PWM_ASSERT(doc); 719 PWM_ASSERT(doc);
719 if (doc->isDocEmpty()) 720 if (doc->isDocEmpty())
720 return; 721 return;
721 if (doc->isDeepLocked()) 722 if (doc->isDeepLocked())
722 return; 723 return;
723 doc->timer()->getLock(DocTimer::id_autoLockTimer); 724 doc->timer()->getLock(DocTimer::id_autoLockTimer);
724 unsigned int curEntryIndex; 725 unsigned int curEntryIndex;
725 if (index) { 726 if (index) {
726 curEntryIndex = *index; 727 curEntryIndex = *index;
727 } else { 728 } else {
728 if (!(view->getCurEntryIndex(&curEntryIndex))) { 729 if (!(view->getCurEntryIndex(&curEntryIndex))) {
729 printDebug("couldn't get index. Maybe we have a binary entry here."); 730 printDebug("couldn't get index. Maybe we have a binary entry here.");
730 doc->timer()->putLock(DocTimer::id_autoLockTimer); 731 doc->timer()->putLock(DocTimer::id_autoLockTimer);
731 return; 732 return;
732 } 733 }
733 } 734 }
734 QString curCategory; 735 QString curCategory;
735 if (category) { 736 if (category) {
736 curCategory = *category; 737 curCategory = *category;
737 } else { 738 } else {
738 curCategory = view->getCurrentCategory(); 739 curCategory = view->getCurrentCategory();
739 } 740 }
740 PwMDataItem currItem; 741 PwMDataItem currItem;
741 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 742 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
742 doc->timer()->putLock(DocTimer::id_autoLockTimer); 743 doc->timer()->putLock(DocTimer::id_autoLockTimer);
743 return; 744 return;
744 } 745 }
745 BUG_ON(currItem.binary); 746 BUG_ON(currItem.binary);
746 747
747 AddEntryWndImpl w(doc); 748 AddEntryWndImpl w(doc);
748 w.setCaption( i18n ("Edit password") ); 749 w.setCaption( i18n ("Edit password") );
749 vector<string> catList; 750 vector<string> catList;
750 doc->getCategoryList(&catList); 751 doc->getCategoryList(&catList);
751 unsigned i, size = catList.size(); 752 unsigned i, size = catList.size();
752 for (i = 0; i < size; ++i) { 753 for (i = 0; i < size; ++i) {
753 w.addCategory(catList[i].c_str()); 754 w.addCategory(catList[i].c_str());
754 } 755 }
755 w.setCurrCategory(curCategory); 756 w.setCurrCategory(curCategory);
756 w.setDescription(currItem.desc.c_str()); 757 w.setDescription(currItem.desc.c_str());
757 w.setUsername(currItem.name.c_str()); 758 w.setUsername(currItem.name.c_str());
758 w.setPassword(currItem.pw.c_str()); 759 w.setPassword(currItem.pw.c_str());
759 w.setUrl(currItem.url.c_str()); 760 w.setUrl(currItem.url.c_str());
760 w.setLauncher(currItem.launcher.c_str()); 761 w.setLauncher(currItem.launcher.c_str());
761 w.setComment(currItem.comment.c_str()); 762 w.setComment(currItem.comment.c_str());
763 w.descLineEdit->setFocus();
762 if (w.exec() == 1) { 764 if (w.exec() == 1) {
763 currItem.desc = w.getDescription().latin1(); 765 currItem.desc = w.getDescription().latin1();
764 currItem.name = w.getUsername().latin1(); 766 currItem.name = w.getUsername().latin1();
765 currItem.pw = w.getPassword().latin1(); 767 currItem.pw = w.getPassword().latin1();
766 currItem.comment = w.getComment().latin1(); 768 currItem.comment = w.getComment().latin1();
767 currItem.url = w.getUrl().latin1(); 769 currItem.url = w.getUrl().latin1();
768 currItem.launcher = w.getLauncher().latin1(); 770 currItem.launcher = w.getLauncher().latin1();
769 if (!doc->editEntry(curCategory, w.getCategory(), 771 if (!doc->editEntry(curCategory, w.getCategory(),
770 curEntryIndex, &currItem)) { 772 curEntryIndex, &currItem)) {
771 KMessageBox::error(this, 773 KMessageBox::error(this,
772 i18n("Couldn't edit the entry.\n" 774 i18n("Couldn't edit the entry.\n"
773 "Maybe you changed the category and\n" 775 "Maybe you changed the category and\n"
774 "this entry is already present\nin the new " 776 "this entry is already present\nin the new "
775 "category?"), 777 "category?"),
776 i18n("couldn't edit entry.")); 778 i18n("couldn't edit entry."));
777 doc->timer()->putLock(DocTimer::id_autoLockTimer); 779 doc->timer()->putLock(DocTimer::id_autoLockTimer);
778 return; 780 return;
779 } 781 }
780 } 782 }
781 doc->timer()->putLock(DocTimer::id_autoLockTimer); 783 doc->timer()->putLock(DocTimer::id_autoLockTimer);
782} 784}
783 785
784void PwM::deletePwd_slot() 786void PwM::deletePwd_slot()
785{ 787{
786 PWM_ASSERT(curDoc()); 788 PWM_ASSERT(curDoc());
787 if (curDoc()->isDocEmpty()) 789 if (curDoc()->isDocEmpty())
788 return; 790 return;
789 if (curDoc()->isDeepLocked()) 791 if (curDoc()->isDeepLocked())
790 return; 792 return;
791 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 793 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
792 unsigned int curEntryIndex = 0; 794 unsigned int curEntryIndex = 0;
793 if (!(view->getCurEntryIndex(&curEntryIndex))) { 795 if (!(view->getCurEntryIndex(&curEntryIndex))) {
794 printDebug("couldn't get index"); 796 printDebug("couldn't get index");
795 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 797 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
796 return; 798 return;
797 } 799 }
798 800
799 PwMDataItem currItem; 801 PwMDataItem currItem;
800 QString curCategory = view->getCurrentCategory(); 802 QString curCategory = view->getCurrentCategory();
801 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 803 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
802 printDebug("couldn't get entry"); 804 printDebug("couldn't get entry");
803 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 805 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
804 return; 806 return;
805 } 807 }
806 if (KMessageBox:: 808 if (KMessageBox::
807 questionYesNo(this, 809 questionYesNo(this,
808 i18n 810 i18n
809 ("Do you really want to delete\nthe selected entry") + 811 ("Do you really want to delete\nthe selected entry") +
810 " \n\"" + QString(currItem.desc.c_str()) 812 " \n\"" + QString(currItem.desc.c_str())
811 + "\" ?", i18n("delete?")) 813 + "\" ?", i18n("delete?"))
812 == KMessageBox::Yes) { 814 == KMessageBox::Yes) {
813 815
814 curDoc()->delEntry(curCategory, curEntryIndex); 816 curDoc()->delEntry(curCategory, curEntryIndex);
815 } 817 }
816 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 818 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
817} 819}
818 820
819void PwM::changeMasterPwd_slot() 821void PwM::changeMasterPwd_slot()
820{ 822{
821 PWM_ASSERT(curDoc()); 823 PWM_ASSERT(curDoc());
822 curDoc()->changeCurrentPw(); 824 curDoc()->changeCurrentPw();
823} 825}
824 826
825void PwM::lockWnd_slot() 827void PwM::lockWnd_slot()
826{ 828{
827 PWM_ASSERT(curDoc()); 829 PWM_ASSERT(curDoc());
828 curDoc()->lockAll(true); 830 curDoc()->lockAll(true);
829} 831}
830 832
831void PwM::deepLockWnd_slot() 833void PwM::deepLockWnd_slot()
832{ 834{
833 PWM_ASSERT(curDoc()); 835 PWM_ASSERT(curDoc());
834 curDoc()->deepLock(); 836 curDoc()->deepLock();
835} 837}
836 838
837void PwM::unlockWnd_slot() 839void PwM::unlockWnd_slot()
838{ 840{
839 PWM_ASSERT(curDoc()); 841 PWM_ASSERT(curDoc());
840 curDoc()->lockAll(false); 842 curDoc()->lockAll(false);
841} 843}
842 844
843void PwM::config_slot() 845void PwM::config_slot()
844{ 846{
845 int oldStyle = conf()->confWndMainViewStyle(); 847 int oldStyle = conf()->confWndMainViewStyle();
846#ifdef PWM_EMBEDDED 848#ifdef PWM_EMBEDDED
847 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 849 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
848 850
849 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 851 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
850 ConfigureDialog->addModule(pwmcfg ); 852 ConfigureDialog->addModule(pwmcfg );
851 853
852 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 854 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
853 ConfigureDialog->addModule(kdelibcfg ); 855 ConfigureDialog->addModule(kdelibcfg );
854 856
855#ifndef DESKTOP_VERSION 857#ifndef DESKTOP_VERSION
856 ConfigureDialog->showMaximized(); 858 ConfigureDialog->showMaximized();
857#endif 859#endif
858 if ( ConfigureDialog->exec() ) 860 if ( ConfigureDialog->exec() )
859 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 861 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
860 delete ConfigureDialog; 862 delete ConfigureDialog;
861 863
862#else //PWM_EMBEDDED 864#else //PWM_EMBEDDED
863 // display the configuration window (modal mode) 865 // display the configuration window (modal mode)
864 if (!conf()->showConfWnd(this)) 866 if (!conf()->showConfWnd(this))
865 return; 867 return;
866#endif 868#endif
867 869
868 int newStyle = conf()->confWndMainViewStyle(); 870 int newStyle = conf()->confWndMainViewStyle();
869 // reinitialize tray 871 // reinitialize tray
870 init->initTray(); 872 init->initTray();
871 // reinitialize KWallet emulation 873 // reinitialize KWallet emulation
872 init->initKWalletEmu(); 874 init->initKWalletEmu();
873 875
874 PwMDocList *_dl = PwMDoc::getOpenDocList(); 876 PwMDocList *_dl = PwMDoc::getOpenDocList();
875 const vector<PwMDocList::listItem> *dl = _dl->getList(); 877 const vector<PwMDocList::listItem> *dl = _dl->getList();
876 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 878 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
877 end = dl->end(); 879 end = dl->end();
878 PwMDoc *doc; 880 PwMDoc *doc;
879 while (i != end) { 881 while (i != end) {
880 doc = (*i).doc; 882 doc = (*i).doc;
881 // unlock-without-mpw timeout 883 // unlock-without-mpw timeout
882 doc->timer()->start(DocTimer::id_mpwTimer); 884 doc->timer()->start(DocTimer::id_mpwTimer);
883 // auto-lock timeout 885 // auto-lock timeout
884 doc->timer()->start(DocTimer::id_autoLockTimer); 886 doc->timer()->start(DocTimer::id_autoLockTimer);
885 ++i; 887 ++i;
886 } 888 }
887 889
888 const QValueList<PwM *> *ml = init->mainWndList(); 890 const QValueList<PwM *> *ml = init->mainWndList();
889#ifndef PWM_EMBEDDED 891#ifndef PWM_EMBEDDED
890 QValueList<PwM *>::const_iterator i2 = ml->begin(), 892 QValueList<PwM *>::const_iterator i2 = ml->begin(),
891 end2 = ml->end(); 893 end2 = ml->end();
892#else 894#else
893 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 895 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
894 end2 = ml->end(); 896 end2 = ml->end();
895#endif 897#endif
896 PwM *pwm; 898 PwM *pwm;
897 while (i2 != end2) { 899 while (i2 != end2) {
898 pwm = *i2; 900 pwm = *i2;
899 // reinitialize the window style. 901 // reinitialize the window style.
900 if (oldStyle != newStyle) 902 if (oldStyle != newStyle)
901 pwm->curView()->initStyle(newStyle); 903 pwm->curView()->initStyle(newStyle);
902 // set the new font 904 // set the new font
903 pwm->curView()->setFont(conf()->confGlobEntryFont()); 905 pwm->curView()->setFont(conf()->confGlobEntryFont());
904 ++i2; 906 ++i2;
905 } 907 }
906} 908}
907 909
908void PwM::activateMpButton(bool activate) 910void PwM::activateMpButton(bool activate)
909{ 911{
910 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 912 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
911} 913}
912 914
913void PwM::closeEvent(QCloseEvent *e) 915void PwM::closeEvent(QCloseEvent *e)
914{ 916{
915 //qDebug("PwM::closeEvent "); 917 //qDebug("PwM::closeEvent ");
916 emit closed( this ); 918 emit closed( this );
917 return; 919 return;
918 e->accept(); 920 e->accept();
919} 921}
920 922
921void PwM::docClosed(PwMDoc *doc) 923void PwM::docClosed(PwMDoc *doc)
922{ 924{
923 //qDebug("PwM::docClosed "); 925 //qDebug("PwM::docClosed ");
924 PARAM_UNUSED(doc); 926 PARAM_UNUSED(doc);
925 PWM_ASSERT(doc == curDoc()); 927 PWM_ASSERT(doc == curDoc());
926 close(); 928 close();
927} 929}
928 930
929void PwM::find_slot() 931void PwM::find_slot()
930{ 932{
931 PWM_ASSERT(curDoc()); 933 PWM_ASSERT(curDoc());
932 if (curDoc()->isDocEmpty()) 934 if (curDoc()->isDocEmpty())
933 return; 935 return;
934 if (curDoc()->isDeepLocked()) 936 if (curDoc()->isDeepLocked())
935 return; 937 return;
936 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 938 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
937 FindWndImpl findWnd(view); 939 FindWndImpl findWnd(view);
938 findWnd.exec(); 940 findWnd.exec();
939 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 941 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
940} 942}
941 943
942void PwM::exportToText() 944void PwM::exportToText()
943{ 945{
944 PWM_ASSERT(curDoc()); 946 PWM_ASSERT(curDoc());
945 if (curDoc()->isDocEmpty()) { 947 if (curDoc()->isDocEmpty()) {
946 KMessageBox::information(this, 948 KMessageBox::information(this,
947 i18n 949 i18n
948 ("Sorry, there's nothing to export.\n" 950 ("Sorry, there's nothing to export.\n"
949 "Please first add some passwords."), 951 "Please first add some passwords."),
950 i18n("nothing to do")); 952 i18n("nothing to do"));
951 return; 953 return;
952 } 954 }
953 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 955 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
954 QString fn(KFileDialog::getSaveFileName(QString::null, 956 QString fn(KFileDialog::getSaveFileName(QString::null,
955 i18n("*|plain-text file"), 957 i18n("*|plain-text file"),
956 this)); 958 this));
957 if (fn == "") { 959 if (fn == "") {
958 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 960 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
959 return; 961 return;
960 } 962 }
961 963
962 PwMerror ret = curDoc()->exportToText(&fn); 964 PwMerror ret = curDoc()->exportToText(&fn);
963 if (ret != e_success) { 965 if (ret != e_success) {
964 KMessageBox::error(this, 966 KMessageBox::error(this,
965 i18n("Error: Couldn't write to file.\n" 967 i18n("Error: Couldn't write to file.\n"
966 "Please check if you have permission to write\n" 968 "Please check if you have permission to write\n"
967 "to the file in that directory."), 969 "to the file in that directory."),
968 i18n("error while writing")); 970 i18n("error while writing"));
969 } else 971 } else
970 showStatMsg(i18n("Successfully exported data.")); 972 showStatMsg(i18n("Successfully exported data."));
971 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 973 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
972} 974}
973 975
974bool PwM::importFromText() 976bool PwM::importFromText()
975{ 977{
976 if (!isVirgin()) { 978 if (!isVirgin()) {
977 if (KMessageBox::questionYesNo(this, 979 if (KMessageBox::questionYesNo(this,
978 i18n("Do you want to import the data\n" 980 i18n("Do you want to import the data\n"
979 "into the current document? (If you\n" 981 "into the current document? (If you\n"
980 "select \"no\", a new document will be\n" 982 "select \"no\", a new document will be\n"
981 "opened.)"), 983 "opened.)"),
982 i18n("import into this document?")) 984 i18n("import into this document?"))
983 == KMessageBox::No) { 985 == KMessageBox::No) {
984 // import the data to a new window. 986 // import the data to a new window.
985 PwM *newInstance = init->createMainWnd(); 987 PwM *newInstance = init->createMainWnd();
986 bool ok = newInstance->importFromText(); 988 bool ok = newInstance->importFromText();
987 if (!ok) { 989 if (!ok) {
988 newInstance->setForceQuit(true); 990 newInstance->setForceQuit(true);
989 delete_and_null(newInstance); 991 delete_and_null(newInstance);
990 } 992 }
991 return ok; 993 return ok;
992 } 994 }
993 } 995 }
994 996
995 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 997 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
996 PwMerror ret; 998 PwMerror ret;
997 QString path(KFileDialog::getOpenFileName(QString::null, 999 QString path(KFileDialog::getOpenFileName(QString::null,
998 i18n("*|PWM-exported text file"), 1000 i18n("*|PWM-exported text file"),
999 this)); 1001 this));
1000 if (path == "") 1002 if (path == "")
1001 goto cancelImport; 1003 goto cancelImport;
1002 1004
1003 ret = curDoc()->importFromText(&path, 0); 1005 ret = curDoc()->importFromText(&path, 0);
1004 if (ret == e_fileFormat) { 1006 if (ret == e_fileFormat) {
1005 KMessageBox::error(this, 1007 KMessageBox::error(this,
1006 i18n("Could not read file-format.\n" 1008 i18n("Could not read file-format.\n"
1007 "This seems to be _not_ a valid file\n" 1009 "This seems to be _not_ a valid file\n"
1008 "exported by PwM."), 1010 "exported by PwM."),
1009 i18n("invalid file-format")); 1011 i18n("invalid file-format"));
1010 goto cancelImport; 1012 goto cancelImport;
1011 } else if (ret == e_invalidArg) { 1013 } else if (ret == e_invalidArg) {
1012 BUG(); 1014 BUG();
1013 goto cancelImport; 1015 goto cancelImport;
1014 } else if (ret != e_success) { 1016 } else if (ret != e_success) {
1015 KMessageBox::error(this, 1017 KMessageBox::error(this,
1016 i18n("Could not import file!\n" 1018 i18n("Could not import file!\n"
1017 "Do you have permission to read this file?\n" 1019 "Do you have permission to read this file?\n"
1018 "Do you have enough free memory?"), 1020 "Do you have enough free memory?"),
1019 i18n("import failed")); 1021 i18n("import failed"));
1020 goto cancelImport; 1022 goto cancelImport;
1021 } 1023 }
1022 setVirgin(false); 1024 setVirgin(false);
1023 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1025 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1024 return true; 1026 return true;
1025 1027
1026cancelImport: 1028cancelImport:
1027 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1029 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1028 return false; 1030 return false;
1029} 1031}
1030 1032
1031void PwM::exportToGpasman() 1033void PwM::exportToGpasman()
1032{ 1034{
1033 PWM_ASSERT(curDoc()); 1035 PWM_ASSERT(curDoc());
1034 if (curDoc()->isDocEmpty()) { 1036 if (curDoc()->isDocEmpty()) {
1035 KMessageBox::information(this, 1037 KMessageBox::information(this,
1036 i18n 1038 i18n
1037 ("Sorry, there's nothing to export.\n" 1039 ("Sorry, there's nothing to export.\n"
1038 "Please first add some passwords."), 1040 "Please first add some passwords."),
1039 i18n("nothing to do")); 1041 i18n("nothing to do"));
1040 return; 1042 return;
1041 } 1043 }
1042 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1044 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1043 QString fn(KFileDialog::getSaveFileName(QString::null, 1045 QString fn(KFileDialog::getSaveFileName(QString::null,
1044 i18n("*|Gpasman or Kpasman file"), 1046 i18n("*|Gpasman or Kpasman file"),
1045 this)); 1047 this));
1046 if (fn == "") { 1048 if (fn == "") {
1047 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1049 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1048 return; 1050 return;
1049 } 1051 }
1050 1052
1051 PwMerror ret = curDoc()->exportToGpasman(&fn); 1053 PwMerror ret = curDoc()->exportToGpasman(&fn);
1052 if (ret != e_success) { 1054 if (ret != e_success) {
1053 if (ret == e_noPw) { 1055 if (ret == e_noPw) {
1054 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1056 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1055 return; 1057 return;
1056 } 1058 }
1057 KMessageBox::error(this, 1059 KMessageBox::error(this,
1058 i18n("Error: Couldn't write to file.\n" 1060 i18n("Error: Couldn't write to file.\n"
1059 "Please check if you have permission to write " 1061 "Please check if you have permission to write "
1060 "to the file in that directory."), 1062 "to the file in that directory."),
1061 i18n("error while writing")); 1063 i18n("error while writing"));
1062 } else 1064 } else
1063 showStatMsg(i18n("Successfully exported data.")); 1065 showStatMsg(i18n("Successfully exported data."));
1064 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1066 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1065} 1067}
1066 1068
1067 1069
1068 1070
1069void PwM::exportToCsv() 1071void PwM::exportToCsv()
1070{ 1072{
1071 PWM_ASSERT(curDoc()); 1073 PWM_ASSERT(curDoc());
1072 if (curDoc()->isDocEmpty()) { 1074 if (curDoc()->isDocEmpty()) {
1073 KMessageBox::information(this, 1075 KMessageBox::information(this,
1074 i18n 1076 i18n
1075 ("Sorry, there is nothing to export;\n" 1077 ("Sorry, there is nothing to export;\n"
1076 "please add some passwords first."), 1078 "please add some passwords first."),
1077 i18n("Nothing to Do")); 1079 i18n("Nothing to Do"));
1078 return; 1080 return;
1079 } 1081 }
1080 1082
1081 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1083 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1082 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); 1084 QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this));
1083 if (fn.isEmpty()) { 1085 if (fn.isEmpty()) {
1084 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1086 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1085 return; 1087 return;
1086 } 1088 }
1087 1089
1088 Csv csv(this); 1090 Csv csv(this);
1089 if (!csv.exportData(fn, curDoc())) { 1091 if (!csv.exportData(fn, curDoc())) {
1090 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1092 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1091 showStatMsg(i18n("CSV file export failed.")); 1093 showStatMsg(i18n("CSV file export failed."));
1092 return; 1094 return;
1093 } 1095 }
1094 showStatMsg(i18n("Successfully exported data.")); 1096 showStatMsg(i18n("Successfully exported data."));
1095 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1097 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1096} 1098}
1097 1099
1098bool PwM::importCsv() 1100bool PwM::importCsv()
1099{ 1101{
1100 Csv csv(this); 1102 Csv csv(this);
1101 if (!isVirgin()) { 1103 if (!isVirgin()) {
1102 if (KMessageBox::questionYesNo(this, 1104 if (KMessageBox::questionYesNo(this,
1103 i18n("Do you want to import the data\n" 1105 i18n("Do you want to import the data\n"
1104 "into the current document? (If you\n" 1106 "into the current document? (If you\n"
1105 "select \"no\", a new document will be\n" 1107 "select \"no\", a new document will be\n"
1106 "opened.)"), 1108 "opened.)"),
1107 i18n("Import into This Document?")) 1109 i18n("Import into This Document?"))
1108 == KMessageBox::No) { 1110 == KMessageBox::No) {
1109 // import the data to a new window. 1111 // import the data to a new window.
1110 PwM *newInstance = init->createMainWnd(); 1112 PwM *newInstance = init->createMainWnd();
1111 bool ok = newInstance->importCsv(); 1113 bool ok = newInstance->importCsv();
1112 if (!ok) { 1114 if (!ok) {
1113 newInstance->setForceQuit(true); 1115 newInstance->setForceQuit(true);
1114 delete_and_null(newInstance); 1116 delete_and_null(newInstance);
1115 } 1117 }
1116 return ok; 1118 return ok;
1117 } 1119 }
1118 } 1120 }
1119 1121
1120 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); 1122 QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this);
1121 if (filename.isEmpty()) 1123 if (filename.isEmpty())
1122 return false; 1124 return false;
1123 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1125 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1124 if (!csv.importData(filename, curDoc())) { 1126 if (!csv.importData(filename, curDoc())) {
1125 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1127 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1126 showStatMsg(i18n("CSV file import failed.")); 1128 showStatMsg(i18n("CSV file import failed."));
1127 return false; 1129 return false;
1128 } 1130 }
1129 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1131 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1130 KMessageBox::information(this, 1132 KMessageBox::information(this,
1131 i18n("Successfully imported the CSV data\n" 1133 i18n("Successfully imported the CSV data\n"
1132 "into the current document."), i18n("Successfully Imported")); 1134 "into the current document."), i18n("Successfully Imported"));
1133 showStatMsg(i18n("Successfully imported")); 1135 showStatMsg(i18n("Successfully imported"));
1134 setVirgin(false); 1136 setVirgin(false);
1135 return true; 1137 return true;
1136} 1138}
1137 1139
1138 1140
1139void PwM::exportToKWallet() 1141void PwM::exportToKWallet()
1140{ 1142{
1141#ifdef CONFIG_KWALLETIF 1143#ifdef CONFIG_KWALLETIF
1142 if (!checkAndAskForKWalletEmu()) 1144 if (!checkAndAskForKWalletEmu())
1143 return; 1145 return;
1144 PWM_ASSERT(curDoc()); 1146 PWM_ASSERT(curDoc());
1145 if (curDoc()->isDocEmpty()) { 1147 if (curDoc()->isDocEmpty()) {
1146 KMessageBox::information(this, 1148 KMessageBox::information(this,
1147 i18n 1149 i18n
1148 ("Sorry, there's nothing to export.\n" 1150 ("Sorry, there's nothing to export.\n"
1149 "Please first add some passwords."), 1151 "Please first add some passwords."),
1150 i18n("nothing to do")); 1152 i18n("nothing to do"));
1151 init->initKWalletEmu(); 1153 init->initKWalletEmu();
1152 return; 1154 return;
1153 } 1155 }
1154 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1156 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1155 KWalletIf walletIf(this); 1157 KWalletIf walletIf(this);
1156 if (walletIf.kwalletExport(curDoc())) { 1158 if (walletIf.kwalletExport(curDoc())) {
1157 KMessageBox::information(this, 1159 KMessageBox::information(this,
1158 i18n("Successfully exported the data of the current " 1160 i18n("Successfully exported the data of the current "
1159 "document to KWallet."), 1161 "document to KWallet."),
1160 i18n("Successfully exported data.")); 1162 i18n("Successfully exported data."));
1161 showStatMsg(i18n("Successfully exported data.")); 1163 showStatMsg(i18n("Successfully exported data."));
1162 } 1164 }
1163 init->initKWalletEmu(); 1165 init->initKWalletEmu();
1164 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1166 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1165#endif // CONFIG_KWALLETIF 1167#endif // CONFIG_KWALLETIF
1166} 1168}
1167 1169
1168bool PwM::importFromGpasman() 1170bool PwM::importFromGpasman()
1169{ 1171{
1170 if (!isVirgin()) { 1172 if (!isVirgin()) {
1171 if (KMessageBox::questionYesNo(this, 1173 if (KMessageBox::questionYesNo(this,
1172 i18n("Do you want to import the data\n" 1174 i18n("Do you want to import the data\n"
1173 "into the current document? (If you\n" 1175 "into the current document? (If you\n"
1174 "select \"no\", a new document will be\n" 1176 "select \"no\", a new document will be\n"
1175 "opened.)"), 1177 "opened.)"),
1176 i18n("import into this document?")) 1178 i18n("import into this document?"))
1177 == KMessageBox::No) { 1179 == KMessageBox::No) {
1178 // import the data to a new window. 1180 // import the data to a new window.
1179 PwM *newInstance = init->createMainWnd(); 1181 PwM *newInstance = init->createMainWnd();
1180 bool ok = newInstance->importFromGpasman(); 1182 bool ok = newInstance->importFromGpasman();
1181 if (!ok) { 1183 if (!ok) {
1182 newInstance->setForceQuit(true); 1184 newInstance->setForceQuit(true);
1183 delete_and_null(newInstance); 1185 delete_and_null(newInstance);
1184 } 1186 }
1185 return ok; 1187 return ok;
1186 } 1188 }
1187 } 1189 }
1188 1190
1189 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1191 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1190 PwMerror ret; 1192 PwMerror ret;
1191 QString path(KFileDialog::getOpenFileName(QString::null, 1193 QString path(KFileDialog::getOpenFileName(QString::null,
1192 i18n("*|Gpasman or Kpasman file"), this)); 1194 i18n("*|Gpasman or Kpasman file"), this));
1193 if (path == "") 1195 if (path == "")
1194 goto cancelImport; 1196 goto cancelImport;
1195 ret = curDoc()->importFromGpasman(&path); 1197 ret = curDoc()->importFromGpasman(&path);
1196 if (ret == e_wrongPw) { 1198 if (ret == e_wrongPw) {
1197 if (KMessageBox::questionYesNo(this, 1199 if (KMessageBox::questionYesNo(this,
1198 i18n 1200 i18n
1199 ("This is probably the wrong master-password\n" 1201 ("This is probably the wrong master-password\n"
1200 "you have typed in.\n" 1202 "you have typed in.\n"
1201 "There is no real way to determine the\n" 1203 "There is no real way to determine the\n"
1202 "correctness of the password in the Gpasman\n" 1204 "correctness of the password in the Gpasman\n"
1203 "file-format. But I think this\n" 1205 "file-format. But I think this\n"
1204 "password ist wrong.\n" 1206 "password ist wrong.\n"
1205 "Do you want to continue nevertheless?"), 1207 "Do you want to continue nevertheless?"),
1206 i18n("password error")) 1208 i18n("password error"))
1207 == KMessageBox::No) { 1209 == KMessageBox::No) {
1208 goto cancelImport; 1210 goto cancelImport;
1209 } 1211 }
1210 } else if (ret != e_success) { 1212 } else if (ret != e_success) {
1211 KMessageBox::error(this, 1213 KMessageBox::error(this,
1212 i18n("Could not import file!\n" 1214 i18n("Could not import file!\n"
1213 "Do you have permission to read this file?"), 1215 "Do you have permission to read this file?"),
1214 i18n("import failed")); 1216 i18n("import failed"));
1215 goto cancelImport; 1217 goto cancelImport;
1216 } 1218 }
1217 setVirgin(false); 1219 setVirgin(false);
1218 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1220 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1219 return true; 1221 return true;
1220 1222
1221cancelImport: 1223cancelImport:
1222 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1224 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1223 return false; 1225 return false;
1224} 1226}
1225 1227
1226#ifdef CONFIG_KWALLETIF 1228#ifdef CONFIG_KWALLETIF
1227bool PwM::checkAndAskForKWalletEmu() 1229bool PwM::checkAndAskForKWalletEmu()
1228{ 1230{
1229 if (init->kwalletEmu()) { 1231 if (init->kwalletEmu()) {
1230 /* KWallet emulation is enabled. We can't import/export 1232 /* KWallet emulation is enabled. We can't import/export
1231 * data from/to it, while emulation is active. 1233 * data from/to it, while emulation is active.
1232 */ 1234 */
1233 if (KMessageBox::questionYesNo(this, 1235 if (KMessageBox::questionYesNo(this,
1234 i18n("KWallet emulation is enabled.\n" 1236 i18n("KWallet emulation is enabled.\n"
1235 "You can't import or export data from/to " 1237 "You can't import or export data from/to "
1236 "the original KWallet, while the emulation " 1238 "the original KWallet, while the emulation "
1237 "is active.\n" 1239 "is active.\n"
1238 "Do you want to tempoarly disable the KWallet emulation?"), 1240 "Do you want to tempoarly disable the KWallet emulation?"),
1239 i18n("Tempoarly disable KWallet emulation?")) 1241 i18n("Tempoarly disable KWallet emulation?"))
1240 == KMessageBox::Yes) { 1242 == KMessageBox::Yes) {
1241 init->initKWalletEmu(true); 1243 init->initKWalletEmu(true);
1242 PWM_ASSERT(!init->kwalletEmu()); 1244 PWM_ASSERT(!init->kwalletEmu());
1243 return true; 1245 return true;
1244 } 1246 }
1245 return false; 1247 return false;
1246 } 1248 }
1247 return true; 1249 return true;
1248} 1250}
1249#endif // CONFIG_KWALLETIF 1251#endif // CONFIG_KWALLETIF
1250 1252
1251bool PwM::importKWallet() 1253bool PwM::importKWallet()
1252{ 1254{
1253#ifdef CONFIG_KWALLETIF 1255#ifdef CONFIG_KWALLETIF
1254 if (!checkAndAskForKWalletEmu()) 1256 if (!checkAndAskForKWalletEmu())
1255 return false; 1257 return false;
1256 KWalletIf walletIf(this); 1258 KWalletIf walletIf(this);
1257 if (!isVirgin()) { 1259 if (!isVirgin()) {
1258 if (KMessageBox::questionYesNo(this, 1260 if (KMessageBox::questionYesNo(this,
1259 i18n("Do you want to import the data " 1261 i18n("Do you want to import the data "
1260 "into the current document? (If you " 1262 "into the current document? (If you "
1261 "select \"no\", a new document will be " 1263 "select \"no\", a new document will be "
1262 "opened.)"), 1264 "opened.)"),
1263 i18n("import into this document?")) 1265 i18n("import into this document?"))
1264 == KMessageBox::No) { 1266 == KMessageBox::No) {
1265 // import the data to a new window. 1267 // import the data to a new window.
1266 PwM *newInstance = init->createMainWnd(); 1268 PwM *newInstance = init->createMainWnd();
1267 bool ok = newInstance->importKWallet(); 1269 bool ok = newInstance->importKWallet();
1268 if (!ok) { 1270 if (!ok) {
1269 newInstance->setForceQuit(true); 1271 newInstance->setForceQuit(true);
1270 delete_and_null(newInstance); 1272 delete_and_null(newInstance);
1271 goto exit_fail; 1273 goto exit_fail;
1272 } else { 1274 } else {
1273 goto exit_ok; 1275 goto exit_ok;
1274 } 1276 }
1275 } 1277 }
1276 } 1278 }
1277 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1279 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1278 if (!walletIf.kwalletImport(curDoc())) { 1280 if (!walletIf.kwalletImport(curDoc())) {
1279 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1281 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1280 showStatMsg(i18n("KWallet import failed")); 1282 showStatMsg(i18n("KWallet import failed"));
1281 goto exit_fail; 1283 goto exit_fail;
1282 } 1284 }
1283 KMessageBox::information(this, 1285 KMessageBox::information(this,
1284 i18n("Successfully imported the KWallet data " 1286 i18n("Successfully imported the KWallet data "
1285 "into the current document."), 1287 "into the current document."),
1286 i18n("successfully imported")); 1288 i18n("successfully imported"));
1287 showStatMsg(i18n("successfully imported")); 1289 showStatMsg(i18n("successfully imported"));
1288 setVirgin(false); 1290 setVirgin(false);
1289 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1291 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1290 1292
1291exit_ok: 1293exit_ok:
1292 init->initKWalletEmu(); 1294 init->initKWalletEmu();
1293 return true; 1295 return true;
1294 1296
1295exit_fail: 1297exit_fail:
1296 init->initKWalletEmu(); 1298 init->initKWalletEmu();
1297#endif // CONFIG_KWALLETIF 1299#endif // CONFIG_KWALLETIF
1298 return false; 1300 return false;
1299} 1301}
1300 1302
1301void PwM::print_slot() 1303void PwM::print_slot()
1302{ 1304{
1303 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 1305 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
1304#ifndef PWM_EMBEDDED 1306#ifndef PWM_EMBEDDED
1305 PwMPrint p(curDoc(), this); 1307 PwMPrint p(curDoc(), this);
1306 p.printNow(); 1308 p.printNow();
1307#else 1309#else
1308 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); 1310 qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED");
1309#endif 1311#endif
1310 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 1312 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
1311} 1313}
1312 1314
1313void PwM::genNewCard_slot() 1315void PwM::genNewCard_slot()
1314{ 1316{
1315#ifdef CONFIG_KEYCARD 1317#ifdef CONFIG_KEYCARD
1316 init->keycard()->genNewCard(); 1318 init->keycard()->genNewCard();
1317#endif 1319#endif
1318} 1320}
1319 1321
1320void PwM::eraseCard_slot() 1322void PwM::eraseCard_slot()
1321{ 1323{
1322#ifdef CONFIG_KEYCARD 1324#ifdef CONFIG_KEYCARD
1323 init->keycard()->eraseCard(); 1325 init->keycard()->eraseCard();
1324#endif 1326#endif
1325} 1327}
1326 1328
1327void PwM::readCardId_slot() 1329void PwM::readCardId_slot()
1328{ 1330{
1329#ifdef CONFIG_KEYCARD 1331#ifdef CONFIG_KEYCARD
1330 init->keycard()->displayKey(); 1332 init->keycard()->displayKey();
1331#endif 1333#endif
1332} 1334}
1333 1335
1334void PwM::makeCardBackup_slot() 1336void PwM::makeCardBackup_slot()
1335{ 1337{
1336#ifdef CONFIG_KEYCARD 1338#ifdef CONFIG_KEYCARD
1337 init->keycard()->makeBackupImage(); 1339 init->keycard()->makeBackupImage();
1338#endif 1340#endif
1339} 1341}
1340 1342
1341void PwM::replayCardBackup_slot() 1343void PwM::replayCardBackup_slot()
1342{ 1344{
1343#ifdef CONFIG_KEYCARD 1345#ifdef CONFIG_KEYCARD
1344 init->keycard()->replayBackupImage(); 1346 init->keycard()->replayBackupImage();
1345#endif 1347#endif
1346} 1348}
1347 1349
1348void PwM::execLauncher_slot() 1350void PwM::execLauncher_slot()
1349{ 1351{
1350 PWM_ASSERT(curDoc()); 1352 PWM_ASSERT(curDoc());
1351 if (curDoc()->isDeepLocked()) 1353 if (curDoc()->isDeepLocked())
1352 return; 1354 return;
1353 unsigned int curEntryIndex; 1355 unsigned int curEntryIndex;
1354 if (!view->getCurEntryIndex(&curEntryIndex)) 1356 if (!view->getCurEntryIndex(&curEntryIndex))
1355 return; 1357 return;
1356 bool ret = curDoc()->execLauncher(view->getCurrentCategory(), 1358 bool ret = curDoc()->execLauncher(view->getCurrentCategory(),
1357 curEntryIndex); 1359 curEntryIndex);
1358 if (ret) 1360 if (ret)
1359 showStatMsg(i18n("Executed the \"Launcher\".")); 1361 showStatMsg(i18n("Executed the \"Launcher\"."));
1360 else 1362 else
1361 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); 1363 showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!"));
1362} 1364}
1363 1365
1364void PwM::goToURL_slot() 1366void PwM::goToURL_slot()
1365{ 1367{
1366 PWM_ASSERT(curDoc()); 1368 PWM_ASSERT(curDoc());
1367 if (curDoc()->isDeepLocked()) 1369 if (curDoc()->isDeepLocked())
1368 return; 1370 return;
1369 unsigned int curEntryIndex; 1371 unsigned int curEntryIndex;
1370 if (!view->getCurEntryIndex(&curEntryIndex)) 1372 if (!view->getCurEntryIndex(&curEntryIndex))
1371 return; 1373 return;
1372 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1374 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1373 curEntryIndex); 1375 curEntryIndex);
1374 if (ret) 1376 if (ret)
1375 showStatMsg(i18n("started browser with current URL.")); 1377 showStatMsg(i18n("started browser with current URL."));
1376 else 1378 else
1377 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1379 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1378} 1380}
1379 1381
1380void PwM::copyToClipboard(const QString &s) 1382void PwM::copyToClipboard(const QString &s)
1381{ 1383{
1382 QClipboard *cb = QApplication::clipboard(); 1384 QClipboard *cb = QApplication::clipboard();
1383#ifndef PWM_EMBEDDED 1385#ifndef PWM_EMBEDDED
1384 if (cb->supportsSelection()) 1386 if (cb->supportsSelection())
1385 cb->setText(s, QClipboard::Selection); 1387 cb->setText(s, QClipboard::Selection);
1386 cb->setText(s, QClipboard::Clipboard); 1388 cb->setText(s, QClipboard::Clipboard);
1387#else 1389#else
1388 cb->setText(s); 1390 cb->setText(s);
1389 1391
1390#endif 1392#endif
1391 1393
1392} 1394}
1393 1395
1394 1396
1395void PwM::showStatMsg(const QString &msg) 1397void PwM::showStatMsg(const QString &msg)
1396{ 1398{
1397#ifdef DESKTOP_VERSION 1399#ifdef DESKTOP_VERSION
1398 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); 1400 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1399#else 1401#else
1400 //qDebug("Statusbar : %s",msg.latin1()); 1402 //qDebug("Statusbar : %s",msg.latin1());
1401 Global::statusMessage(msg); 1403 Global::statusMessage(msg);
1402#endif 1404#endif
1403} 1405}
1404 1406
1405void PwM::focusInEvent(QFocusEvent *e) 1407void PwM::focusInEvent(QFocusEvent *e)
1406{ 1408{
1407 if (e->gotFocus()) { 1409 if (e->gotFocus()) {
1408 emit gotFocus(this); 1410 emit gotFocus(this);
1409 } else if (e->lostFocus()) { 1411 } else if (e->lostFocus()) {
1410 emit lostFocus(this); 1412 emit lostFocus(this);
1411 } 1413 }
1412} 1414}
1413 1415
1414 1416
1415#ifdef PWM_EMBEDDED 1417#ifdef PWM_EMBEDDED
1416 1418
1417void PwM::category_slot() 1419void PwM::category_slot()
1418{ 1420{
1419 PwMDoc *doc = curDoc(); 1421 PwMDoc *doc = curDoc();
1420 PWM_ASSERT(doc); 1422 PWM_ASSERT(doc);
1421 doc->timer()->getLock(DocTimer::id_autoLockTimer); 1423 doc->timer()->getLock(DocTimer::id_autoLockTimer);
1422 1424
1423 editCategoryWnd w(doc, this, "editcategory"); 1425 editCategoryWnd w(doc, this, "editcategory");
1424/* 1426/*
1425 vector<string> catList; 1427 vector<string> catList;
1426 doc->getCategoryList(&catList); 1428 doc->getCategoryList(&catList);
1427 unsigned i, size = catList.size(); 1429 unsigned i, size = catList.size();
1428 for (i = 0; i < size; ++i) { 1430 for (i = 0; i < size; ++i) {
1429 w.addCategory(catList[i].c_str()); 1431 w.addCategory(catList[i].c_str());
1430 } 1432 }
1431 w.setCurrCategory(view->getCurrentCategory()); 1433 w.setCurrCategory(view->getCurrentCategory());
1432 if (pw) 1434 if (pw)
1433 w.pwLineEdit->setText(*pw); 1435 w.pwLineEdit->setText(*pw);
1434*/ 1436*/
1435 w.setCurrCategory(view->getCurrentCategory()); 1437 w.setCurrCategory(view->getCurrentCategory());
1436 1438
1437 tryAgain: 1439 tryAgain:
1438 if (w.exec() == 1) 1440 if (w.exec() == 1)
1439 { 1441 {
1440 PwMDataItem d; 1442 PwMDataItem d;
1441 1443
1442 //US BUG: to initialize all values of curEntr with meaningfulldata, 1444 //US BUG: to initialize all values of curEntr with meaningfulldata,
1443 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 1445 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
1444 // another option would be to create a constructor for PwMDataItem 1446 // another option would be to create a constructor for PwMDataItem
1445 d.clear(true); 1447 d.clear(true);
1446 /* 1448 /*
1447 d.desc = w.getDescription().latin1(); 1449 d.desc = w.getDescription().latin1();
1448 d.name = w.getUsername().latin1(); 1450 d.name = w.getUsername().latin1();
1449 d.pw = w.getPassword().latin1(); 1451 d.pw = w.getPassword().latin1();
1450 d.comment = w.getComment().latin1(); 1452 d.comment = w.getComment().latin1();
1451 d.url = w.getUrl().latin1(); 1453 d.url = w.getUrl().latin1();
1452 d.launcher = w.getLauncher().latin1(); 1454 d.launcher = w.getLauncher().latin1();
1453 PwMerror ret = doc->addEntry(w.getCategory(), &d); 1455 PwMerror ret = doc->addEntry(w.getCategory(), &d);
1454 if (ret == e_entryExists) { 1456 if (ret == e_entryExists) {
1455 KMessageBox::error(this, 1457 KMessageBox::error(this,
1456 i18n 1458 i18n
1457 ("An entry with this \"Description\",\n" 1459 ("An entry with this \"Description\",\n"
1458 "does already exist.\n" 1460 "does already exist.\n"
1459 "Please select another description."), 1461 "Please select another description."),
1460 i18n("entry already exists.")); 1462 i18n("entry already exists."));
1461 goto tryAgain; 1463 goto tryAgain;
1462 } else if (ret == e_maxAllowedEntr) { 1464 } else if (ret == e_maxAllowedEntr) {
1463 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 1465 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
1464 "has been reached.\nYou can't add more entries."), 1466 "has been reached.\nYou can't add more entries."),
1465 i18n("maximum number of entries")); 1467 i18n("maximum number of entries"));
1466 doc->timer()->putLock(DocTimer::id_autoLockTimer); 1468 doc->timer()->putLock(DocTimer::id_autoLockTimer);
1467 return; 1469 return;
1468 } 1470 }
1469 */ 1471 */
1470 } 1472 }
1471 setVirgin(false); 1473 setVirgin(false);
1472 doc->timer()->putLock(DocTimer::id_autoLockTimer); 1474 doc->timer()->putLock(DocTimer::id_autoLockTimer);
1473} 1475}
1474 1476
1475 1477
1476void PwM::whatsnew_slot() 1478void PwM::whatsnew_slot()
1477{ 1479{
1478 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1480 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1479} 1481}
1480 1482
1481void PwM::showLicense_slot() 1483void PwM::showLicense_slot()
1482{ 1484{
1483 KApplication::showLicence(); 1485 KApplication::showLicence();
1484} 1486}
1485 1487
1486void PwM::faq_slot() 1488void PwM::faq_slot()
1487{ 1489{
1488 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1490 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1489} 1491}
1490 1492
1491void PwM::syncHowTo_slot() 1493void PwM::syncHowTo_slot()
1492{ 1494{
1493 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1495 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1494} 1496}
1495 1497
1496 1498
1497void PwM::createAboutData_slot() 1499void PwM::createAboutData_slot()
1498{ 1500{
1499 QString version; 1501 QString version;
1500#include <../version> 1502#include <../version>
1501; 1503;
1502 QMessageBox::about( this, "About PwManager/Pi", 1504 QMessageBox::about( this, "About PwManager/Pi",
1503 "PwManager/Platform-independent\n" 1505 "PwManager/Platform-independent\n"
1504 "(PWM/Pi) " +version + " - " + 1506 "(PWM/Pi) " +version + " - " +
1505#ifdef DESKTOP_VERSION 1507#ifdef DESKTOP_VERSION
1506 "Desktop Edition\n" 1508 "Desktop Edition\n"
1507#else 1509#else
1508 "PDA-Edition\n" 1510 "PDA-Edition\n"
1509 "for: Zaurus 5500 / 7x0 / 8x0\n" 1511 "for: Zaurus 5500 / 7x0 / 8x0\n"
1510#endif 1512#endif
1511 1513
1512 "(c) 2004 Ulf Schenk\n" 1514 "(c) 2004 Ulf Schenk\n"
1513 "(c) 2004 Lutz Rogowski\n" 1515 "(c) 2004 Lutz Rogowski\n"
1514 "(c) 1997-2004, The KDE PIM Team\n" 1516 "(c) 1997-2004, The KDE PIM Team\n"
1515 1517
1516 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" 1518 "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n"
1517 "Matt Scifo - mscifo@o1.com\n" 1519 "Matt Scifo - mscifo@o1.com\n"
1518 "Elias Probst - elias.probst@gmx.de\n" 1520 "Elias Probst - elias.probst@gmx.de\n"
1519 "George Staikos - staikos@kde.org\n" 1521 "George Staikos - staikos@kde.org\n"
1520 "Matthew Palmer - mjp16@uow.edu.au\n" 1522 "Matthew Palmer - mjp16@uow.edu.au\n"
1521 "Olivier Sessink - gpasman@nl.linux.org\n" 1523 "Olivier Sessink - gpasman@nl.linux.org\n"
1522 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" 1524 "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n"
1523 "Troy Engel - tengel@sonic.net\n" 1525 "Troy Engel - tengel@sonic.net\n"
1524 "Wickey - wickey@gmx.at\n" 1526 "Wickey - wickey@gmx.at\n"
1525 "Ian MacGregor - original documentation author.\n" 1527 "Ian MacGregor - original documentation author.\n"
1526 ); 1528 );
1527} 1529}
1528 1530
1529 1531
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index 8c4d9cc..7f7dd6f 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -1,620 +1,621 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 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 "pwmview.h" 20#include "pwmview.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "globalstuff.h" 22#include "globalstuff.h"
23#include "pwm.h" 23#include "pwm.h"
24#include "rencatwnd.h" 24#include "rencatwnd.h"
25#ifndef PWM_EMBEDDED 25#ifndef PWM_EMBEDDED
26#include "configuration.h" 26#include "configuration.h"
27#else 27#else
28#include "pwmprefs.h" 28#include "pwmprefs.h"
29#endif 29#endif
30#include "commentbox.h" 30#include "commentbox.h"
31 31
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qpoint.h> 36#include <qpoint.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qlayout.h> 38#include <qlayout.h>
39 39
40//US ENH: wouldn't it be a good idea if we could use this consts everywhere else. 40//US ENH: wouldn't it be a good idea if we could use this consts everywhere else.
41//US ENH: for examle in listviewpwm.cpp 41//US ENH: for examle in listviewpwm.cpp
42//US ENH: Because of that I transfer them into the headerfile. 42//US ENH: Because of that I transfer them into the headerfile.
43/* 43/*
44 #define COLUMN_DESC 0 44 #define COLUMN_DESC 0
45 #define COLUMN_NAME 1 45 #define COLUMN_NAME 1
46 #define COLUMN_PW 2 46 #define COLUMN_PW 2
47 #define COLUMN_URL 3 47 #define COLUMN_URL 3
48 #define COLUMN_LAUNCHER 4 48 #define COLUMN_LAUNCHER 4
49*/ 49*/
50 50
51PwMView::PwMView(PwM *_mainClass, 51PwMView::PwMView(PwM *_mainClass,
52 QWidget *parent, PwMDoc *_doc, 52 QWidget *parent, PwMDoc *_doc,
53 const char *name) 53 const char *name)
54 : PwMViewStyle(parent, name) 54 : PwMViewStyle(parent, name)
55{ 55{
56 PWM_ASSERT(_mainClass); 56 PWM_ASSERT(_mainClass);
57 PWM_ASSERT(parent); 57 PWM_ASSERT(parent);
58 PWM_ASSERT(_doc); 58 PWM_ASSERT(_doc);
59 setView(this); 59 setView(this);
60 doc = _doc; 60 doc = _doc;
61 doc->setListViewPointer(this); 61 doc->setListViewPointer(this);
62 mainClass = _mainClass; 62 mainClass = _mainClass;
63 resize(_mainClass->size()); 63 resize(_mainClass->size());
64 initStyle(conf()->confWndMainViewStyle()); 64 initStyle(conf()->confWndMainViewStyle());
65 initCtxMenu(); 65 initCtxMenu();
66 doc->setCurrentView(this); 66 doc->setCurrentView(this);
67 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); 67 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView()));
68 connect(this, SIGNAL(editPW()), mainClass, SLOT(editPwd_slot()));
68} 69}
69 70
70PwMView::~PwMView() 71PwMView::~PwMView()
71{ 72{
72} 73}
73 74
74void PwMView::initCtxMenu() 75void PwMView::initCtxMenu()
75{ 76{
76 ctxMenu = new QPopupMenu(this); 77 ctxMenu = new QPopupMenu(this);
77 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); 78 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot()));
78 ctxMenu->insertSeparator(); 79 ctxMenu->insertSeparator();
79 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); 80 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot()));
80 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); 81 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot()));
81 ctxMenu->insertSeparator(); 82 ctxMenu->insertSeparator();
82 ctxMenu->insertItem(i18n("copy password to clipboard"), 83 ctxMenu->insertItem(i18n("copy password to clipboard"),
83 this, SLOT(copyPwToClip())); 84 this, SLOT(copyPwToClip()));
84 ctxMenu->insertItem(i18n("copy username to clipboard"), 85 ctxMenu->insertItem(i18n("copy username to clipboard"),
85 this, SLOT(copyNameToClip())); 86 this, SLOT(copyNameToClip()));
86 ctxMenu->insertItem(i18n("copy description to clipboard"), 87 ctxMenu->insertItem(i18n("copy description to clipboard"),
87 this, SLOT(copyDescToClip())); 88 this, SLOT(copyDescToClip()));
88 ctxMenu->insertItem(i18n("copy url to clipboard"), 89 ctxMenu->insertItem(i18n("copy url to clipboard"),
89 this, SLOT(copyUrlToClip())); 90 this, SLOT(copyUrlToClip()));
90 ctxMenu->insertItem(i18n("copy launcher to clipboard"), 91 ctxMenu->insertItem(i18n("copy launcher to clipboard"),
91 this, SLOT(copyLauncherToClip())); 92 this, SLOT(copyLauncherToClip()));
92 ctxMenu->insertItem(i18n("copy comment to clipboard"), 93 ctxMenu->insertItem(i18n("copy comment to clipboard"),
93 this, SLOT(copyCommentToClip())); 94 this, SLOT(copyCommentToClip()));
94 ctxMenu->insertSeparator(); 95 ctxMenu->insertSeparator();
95 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, 96 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass,
96 SLOT(execLauncher_slot())); 97 SLOT(execLauncher_slot()));
97 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, 98 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass,
98 SLOT(goToURL_slot())); 99 SLOT(goToURL_slot()));
99} 100}
100 101
101void PwMView::resizeEvent(QResizeEvent *) 102void PwMView::resizeEvent(QResizeEvent *)
102{ 103{
103 resizeView(size()); 104 resizeView(size());
104} 105}
105 106
106void PwMView::refreshCommentTextEdit(QListViewItem *curItem) 107void PwMView::refreshCommentTextEdit(QListViewItem *curItem)
107{ 108{
108 PWM_ASSERT(commentBox); 109 PWM_ASSERT(commentBox);
109 if (!curItem) 110 if (!curItem)
110 return; 111 return;
111 string comment; 112 string comment;
112 PwMerror ret; 113 PwMerror ret;
113 ret = document()->getCommentByLvp(getCurrentCategory(), 114 ret = document()->getCommentByLvp(getCurrentCategory(),
114 lv->childCount() - lv->itemIndex(curItem) - 1, 115 lv->childCount() - lv->itemIndex(curItem) - 1,
115 &comment); 116 &comment);
116 if (ret == e_binEntry) { 117 if (ret == e_binEntry) {
117 commentBox->setContent(i18n("This is a binary entry.\n" 118 commentBox->setContent(i18n("This is a binary entry.\n"
118 "It is not a normal password-entry, as it contains " 119 "It is not a normal password-entry, as it contains "
119 "binary data, which PwManager can't display here.")); 120 "binary data, which PwManager can't display here."));
120 } else if (ret == e_normalEntry) { 121 } else if (ret == e_normalEntry) {
121 commentBox->setContent(comment.c_str()); 122 commentBox->setContent(comment.c_str());
122 } else { 123 } else {
123 BUG(); 124 BUG();
124 return; 125 return;
125 } 126 }
126 lv->ensureItemVisible(curItem); 127 lv->ensureItemVisible(curItem);
127} 128}
128 129
129void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) 130void PwMView::keyReleaseEvent(QKeyEvent * /*e*/)
130{ 131{
131 refreshCommentTextEdit(lv->currentItem()); 132 refreshCommentTextEdit(lv->currentItem());
132} 133}
133 134
134bool PwMView::getCurEntryIndex(unsigned int *index) 135bool PwMView::getCurEntryIndex(unsigned int *index)
135{ 136{
136 QListViewItem *current = lv->currentItem(); 137 QListViewItem *current = lv->currentItem();
137 if (!current) 138 if (!current)
138 return false; 139 return false;
139 return getDocEntryIndex(index, current); 140 return getDocEntryIndex(index, current);
140} 141}
141 142
142bool PwMView::getDocEntryIndex(unsigned int *index, 143bool PwMView::getDocEntryIndex(unsigned int *index,
143 const QListViewItem *item) 144 const QListViewItem *item)
144{ 145{
145 vector<unsigned int> foundPositions; 146 vector<unsigned int> foundPositions;
146 PwMDataItem curItem; 147 PwMDataItem curItem;
147 curItem.desc = item->text(COLUMN_DESC).latin1(); 148 curItem.desc = item->text(COLUMN_DESC).latin1();
148 curItem.name = item->text(COLUMN_NAME).latin1(); 149 curItem.name = item->text(COLUMN_NAME).latin1();
149 document()->getCommentByLvp(getCurrentCategory(), 150 document()->getCommentByLvp(getCurrentCategory(),
150 lv->childCount() - lv->itemIndex(item) - 1, 151 lv->childCount() - lv->itemIndex(item) - 1,
151 &curItem.comment); 152 &curItem.comment);
152 curItem.url = item->text(COLUMN_URL).latin1(); 153 curItem.url = item->text(COLUMN_URL).latin1();
153 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); 154 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1();
154 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | 155 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC |
155 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | 156 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL |
156 SEARCH_IN_LAUNCHER, 157 SEARCH_IN_LAUNCHER,
157 &foundPositions, true); 158 &foundPositions, true);
158 if (foundPositions.size()) { 159 if (foundPositions.size()) {
159 *index = foundPositions[0]; 160 *index = foundPositions[0];
160 return true; 161 return true;
161 } 162 }
162 163
163 return false; 164 return false;
164} 165}
165 166
166void PwMView::handleToggle(QListViewItem *item) 167void PwMView::handleToggle(QListViewItem *item)
167{ 168{
168 PWM_ASSERT(doc); 169 PWM_ASSERT(doc);
169 if (!item) 170 if (!item)
170 return; 171 return;
171 QCheckListItem *clItem = (QCheckListItem *)item; 172 QCheckListItem *clItem = (QCheckListItem *)item;
172 QString curCat(getCurrentCategory()); 173 QString curCat(getCurrentCategory());
173 174
174 // find document position of this entry. 175 // find document position of this entry.
175 unsigned int curEntryDocIndex; 176 unsigned int curEntryDocIndex;
176 if (!getDocEntryIndex(&curEntryDocIndex, item)) 177 if (!getDocEntryIndex(&curEntryDocIndex, item))
177 return; 178 return;
178 179
179 // hack to refresh the comment, if only one item is present 180 // hack to refresh the comment, if only one item is present
180 if (lv->childCount() == 1) 181 if (lv->childCount() == 1)
181 refreshCommentTextEdit(lv->currentItem()); 182 refreshCommentTextEdit(lv->currentItem());
182 183
183 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) 184 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn())
184 return; // this is just a click somewhere on the entry 185 return; // this is just a click somewhere on the entry
185 if (doc->isDeepLocked()) { 186 if (doc->isDeepLocked()) {
186 PwMerror ret; 187 PwMerror ret;
187 ret = doc->deepLock(false); 188 ret = doc->deepLock(false);
188 if (ret != e_success) 189 if (ret != e_success)
189 clItem->setOn(false); 190 clItem->setOn(false);
190 return; 191 return;
191 } 192 }
192 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); 193 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn());
193} 194}
194 195
195void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) 196void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int)
196{ 197{
197 if (!item) 198 if (!item)
198 return; 199 return;
199 ctxMenu->move(point); 200 ctxMenu->move(point);
200 /* don't use ctxMenu->exec() here, as it generates race conditions 201 /* don't use ctxMenu->exec() here, as it generates race conditions
201 * with the card interface code. Believe it or not. :) 202 * with the card interface code. Believe it or not. :)
202 */ 203 */
203 ctxMenu->show(); 204 ctxMenu->show();
204} 205}
205 206
206void PwMView::updateCategories() 207void PwMView::updateCategories()
207{ 208{
208 //qDebug("PwMView::updateCategories() "); 209 //qDebug("PwMView::updateCategories() ");
209 QString oldSel(getCurrentCategory()); 210 QString oldSel(getCurrentCategory());
210 delAllCategories(); 211 delAllCategories();
211 QStringList catList; 212 QStringList catList;
212 document()->getCategoryList(&catList); 213 document()->getCategoryList(&catList);
213 catList.sort(); 214 catList.sort();
214#ifndef PWM_EMBEDDED 215#ifndef PWM_EMBEDDED
215 QStringList::iterator i = catList.begin(), 216 QStringList::iterator i = catList.begin(),
216 end = catList.end(); 217 end = catList.end();
217#else 218#else
218 QStringList::Iterator i = catList.begin(), 219 QStringList::Iterator i = catList.begin(),
219 end = catList.end(); 220 end = catList.end();
220#endif 221#endif
221 while (i != end) { 222 while (i != end) {
222 addCategory(*i); 223 addCategory(*i);
223 ++i; 224 ++i;
224 } 225 }
225 selectCategory(oldSel); 226 selectCategory(oldSel);
226} 227}
227 228
228void PwMView::shiftToView() 229void PwMView::shiftToView()
229{ 230{
230 int cX = lv->contentsX(); 231 int cX = lv->contentsX();
231 int cY = lv->contentsY(); 232 int cY = lv->contentsY();
232 commentBox->clear(); 233 commentBox->clear();
233 234
234 unsigned int catDocIndex; 235 unsigned int catDocIndex;
235 if (unlikely( 236 if (unlikely(
236 !(document()->findCategory(getCurrentCategory(), 237 !(document()->findCategory(getCurrentCategory(),
237 &catDocIndex)))) { 238 &catDocIndex)))) {
238 BUG(); 239 BUG();
239 } 240 }
240 241
241 // ensure all listViewPos are set 242 // ensure all listViewPos are set
242 doc->ensureLvp(); 243 doc->ensureLvp();
243 244
244 // clear all tmp-data vectors 245 // clear all tmp-data vectors
245 unsigned int i, entries = doc->numEntries(catDocIndex); 246 unsigned int i, entries = doc->numEntries(catDocIndex);
246 if (entries) { 247 if (entries) {
247 mainClass->setVirgin(false); 248 mainClass->setVirgin(false);
248 } 249 }
249 vector<PwMDataItem> tmpSorted; 250 vector<PwMDataItem> tmpSorted;
250 PwMDataItem currItem; 251 PwMDataItem currItem;
251 currItem.clear(); 252 currItem.clear();
252 tmpSorted.insert(tmpSorted.begin(), entries, currItem); 253 tmpSorted.insert(tmpSorted.begin(), entries, currItem);
253 254
254 // Sort items and store them in tempoary tmpSorted. 255 // Sort items and store them in tempoary tmpSorted.
255 for (i = 0; i < entries; ++i) { 256 for (i = 0; i < entries; ++i) {
256 doc->getEntry(catDocIndex, i, &currItem); 257 doc->getEntry(catDocIndex, i, &currItem);
257 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos); 258 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos);
258 tmpSorted[currItem.listViewPos] = currItem; 259 tmpSorted[currItem.listViewPos] = currItem;
259 } 260 }
260 261
261 // shift tempoary data to ListView. 262 // shift tempoary data to ListView.
262 tmpDisableSort(); 263 tmpDisableSort();
263 lv->clear(); 264 lv->clear();
264 265
265 //US ENH: adjust the headers of the table according the category texts 266 //US ENH: adjust the headers of the table according the category texts
266 { 267 {
267 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex); 268 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex);
268 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str()); 269 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str());
269 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str()); 270 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str());
270 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str()); 271 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str());
271 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str()); 272 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str());
272 } 273 }
273 274
274 QCheckListItem *newItem; 275 QCheckListItem *newItem;
275 vector<PwMDataItem>::iterator it = tmpSorted.begin(), 276 vector<PwMDataItem>::iterator it = tmpSorted.begin(),
276 end = tmpSorted.end(); 277 end = tmpSorted.end();
277 while (it != end) { 278 while (it != end) {
278 newItem = new ListViewItemPwM(lv); 279 newItem = new ListViewItemPwM(lv);
279 newItem->setText(COLUMN_DESC, (*it).desc.c_str()); 280 newItem->setText(COLUMN_DESC, (*it).desc.c_str());
280 if ((*it).binary) { 281 if ((*it).binary) {
281 newItem->setText(COLUMN_NAME, ""); 282 newItem->setText(COLUMN_NAME, "");
282 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); 283 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>"));
283 newItem->setText(COLUMN_URL, ""); 284 newItem->setText(COLUMN_URL, "");
284 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 285 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
285 } else { 286 } else {
286 newItem->setText(COLUMN_NAME, (*it).name.c_str()); 287 newItem->setText(COLUMN_NAME, (*it).name.c_str());
287 if ((*it).lockStat) { 288 if ((*it).lockStat) {
288 newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) 289 newItem->setText(COLUMN_PW, QString((*it).pw.c_str())
289 + " " 290 + " "
290 + i18n("To unlock click the icon on the left.")); 291 + i18n("To unlock click the icon on the left."));
291 } else { 292 } else {
292 newItem->setText(COLUMN_PW, (*it).pw.c_str()); 293 newItem->setText(COLUMN_PW, (*it).pw.c_str());
293 } 294 }
294 newItem->setText(COLUMN_URL, (*it).url.c_str()); 295 newItem->setText(COLUMN_URL, (*it).url.c_str());
295 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 296 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
296 } 297 }
297 newItem->setOn(!((*it).lockStat)); 298 newItem->setOn(!((*it).lockStat));
298 lv->insertItem(newItem); 299 lv->insertItem(newItem);
299 ++it; 300 ++it;
300 } 301 }
301 tmpReEnableSort(); 302 tmpReEnableSort();
302 303
303 if (cY || cX) 304 if (cY || cX)
304 lv->setContentsPos(cX, cY); 305 lv->setContentsPos(cX, cY);
305} 306}
306 307
307void PwMView::reorgLp() 308void PwMView::reorgLp()
308{ 309{
309 if (!lv->childCount()) 310 if (!lv->childCount())
310 return; 311 return;
311 PWM_ASSERT(doc); 312 PWM_ASSERT(doc);
312 PWM_ASSERT(!doc->isDocEmpty()); 313 PWM_ASSERT(!doc->isDocEmpty());
313 QListViewItem *currItem; 314 QListViewItem *currItem;
314 vector<unsigned int> foundPos; 315 vector<unsigned int> foundPos;
315 /* This searchIn _should_ be: 316 /* This searchIn _should_ be:
316 *const unsigned int searchIn = SEARCH_IN_DESC; 317 *const unsigned int searchIn = SEARCH_IN_DESC;
317 * But we want backward compatibility (see comment in PwMDoc::addEntry()). 318 * But we want backward compatibility (see comment in PwMDoc::addEntry()).
318 * So we need to search again, if we don't find the entry. (see below) 319 * So we need to search again, if we don't find the entry. (see below)
319 */ 320 */
320 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | 321 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME |
321 SEARCH_IN_URL | SEARCH_IN_LAUNCHER; 322 SEARCH_IN_URL | SEARCH_IN_LAUNCHER;
322 QString curCat(getCurrentCategory()); 323 QString curCat(getCurrentCategory());
323 PwMDataItem findThis; 324 PwMDataItem findThis;
324 unsigned int i, cnt = lv->childCount(); 325 unsigned int i, cnt = lv->childCount();
325 for (i = 0; i < cnt; ++i) { 326 for (i = 0; i < cnt; ++i) {
326 currItem = lv->itemAtIndex(i); 327 currItem = lv->itemAtIndex(i);
327 findThis.desc = currItem->text(COLUMN_DESC).latin1(); 328 findThis.desc = currItem->text(COLUMN_DESC).latin1();
328 findThis.name = currItem->text(COLUMN_NAME).latin1(); 329 findThis.name = currItem->text(COLUMN_NAME).latin1();
329 findThis.url = currItem->text(COLUMN_URL).latin1(); 330 findThis.url = currItem->text(COLUMN_URL).latin1();
330 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); 331 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1();
331 doc->findEntry(curCat, findThis, searchIn, 332 doc->findEntry(curCat, findThis, searchIn,
332 &foundPos, true); 333 &foundPos, true);
333 if (!foundPos.size()) { 334 if (!foundPos.size()) {
334 /* Did not find the entry. We seem to have a binary 335 /* Did not find the entry. We seem to have a binary
335 * entry here (pray for it!). So search again with 336 * entry here (pray for it!). So search again with
336 * the "correct" searchIn flags. 337 * the "correct" searchIn flags.
337 */ 338 */
338 const unsigned int searchIn2 = SEARCH_IN_DESC; 339 const unsigned int searchIn2 = SEARCH_IN_DESC;
339 doc->findEntry(curCat, findThis, searchIn2, 340 doc->findEntry(curCat, findThis, searchIn2,
340 &foundPos, true); 341 &foundPos, true);
341 if (unlikely(!foundPos.size())) { 342 if (unlikely(!foundPos.size())) {
342 BUG(); 343 BUG();
343 continue; 344 continue;
344 } 345 }
345 /* We assert that it's a binary entry, now. 346 /* We assert that it's a binary entry, now.
346 * No chance to efficiently verify it here. 347 * No chance to efficiently verify it here.
347 */ 348 */
348 } 349 }
349 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); 350 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1);
350 } 351 }
351} 352}
352 353
353void PwMView::selAt(int index) 354void PwMView::selAt(int index)
354{ 355{
355 QListViewItem *item = lv->itemAtIndex(index); 356 QListViewItem *item = lv->itemAtIndex(index);
356 if (!item) 357 if (!item)
357 return; 358 return;
358 lv->setCurrentItem(item); 359 lv->setCurrentItem(item);
359 lv->ensureItemVisible(item); 360 lv->ensureItemVisible(item);
360} 361}
361 362
362void PwMView::renCatButton_slot() 363void PwMView::renCatButton_slot()
363{ 364{
364 if (doc->isDeepLocked()) 365 if (doc->isDeepLocked())
365 return; 366 return;
366 RenCatWnd wnd(this); 367 RenCatWnd wnd(this);
367 if (wnd.exec() == 1) { 368 if (wnd.exec() == 1) {
368 QString newName(wnd.getNewName()); 369 QString newName(wnd.getNewName());
369 if (newName == "") 370 if (newName == "")
370 return; 371 return;
371 document()->renameCategory(getCurrentCategory(), 372 document()->renameCategory(getCurrentCategory(),
372 newName); 373 newName);
373 } 374 }
374} 375}
375 376
376void PwMView::delCatButton_slot() 377void PwMView::delCatButton_slot()
377{ 378{
378 if (doc->isDeepLocked()) 379 if (doc->isDeepLocked())
379 return; 380 return;
380 if (numCategories() <= 1) { 381 if (numCategories() <= 1) {
381 mainClass->showStatMsg(i18n("Can't remove the last category.")); 382 mainClass->showStatMsg(i18n("Can't remove the last category."));
382 return; 383 return;
383 } 384 }
384 if (KMessageBox::questionYesNo(this, 385 if (KMessageBox::questionYesNo(this,
385 i18n("Do you really want to\n" 386 i18n("Do you really want to\n"
386 "delete the selected\n" 387 "delete the selected\n"
387 "category? All password-\n" 388 "category? All password-\n"
388 "entries will be lost in\n" 389 "entries will be lost in\n"
389 "this category!\n"), 390 "this category!\n"),
390 i18n("Delete category?")) 391 i18n("Delete category?"))
391 == KMessageBox::No) { 392 == KMessageBox::No) {
392 return; 393 return;
393 } 394 }
394 document()->delCategory(getCurrentCategory()); 395 document()->delCategory(getCurrentCategory());
395} 396}
396 397
397void PwMView::copyPwToClip() 398void PwMView::copyPwToClip()
398{ 399{
399 if (doc->isDeepLocked()) 400 if (doc->isDeepLocked())
400 return; 401 return;
401 unsigned int curIndex = 0; 402 unsigned int curIndex = 0;
402 if (!getCurEntryIndex(&curIndex)) 403 if (!getCurEntryIndex(&curIndex))
403 return; 404 return;
404 PwMDataItem d; 405 PwMDataItem d;
405 document()->getDataChangedLock(); 406 document()->getDataChangedLock();
406 document()->getEntry(getCurrentCategory(), curIndex, &d, true); 407 document()->getEntry(getCurrentCategory(), curIndex, &d, true);
407 document()->putDataChangedLock(); 408 document()->putDataChangedLock();
408 PwM::copyToClipboard(d.pw.c_str()); 409 PwM::copyToClipboard(d.pw.c_str());
409} 410}
410 411
411void PwMView::copyNameToClip() 412void PwMView::copyNameToClip()
412{ 413{
413 if (doc->isDeepLocked()) 414 if (doc->isDeepLocked())
414 return; 415 return;
415 unsigned int curIndex = 0; 416 unsigned int curIndex = 0;
416 if (!getCurEntryIndex(&curIndex)) 417 if (!getCurEntryIndex(&curIndex))
417 return; 418 return;
418 PwMDataItem d; 419 PwMDataItem d;
419 document()->getEntry(getCurrentCategory(), curIndex, &d); 420 document()->getEntry(getCurrentCategory(), curIndex, &d);
420 PwM::copyToClipboard(d.name.c_str()); 421 PwM::copyToClipboard(d.name.c_str());
421} 422}
422 423
423void PwMView::copyDescToClip() 424void PwMView::copyDescToClip()
424{ 425{
425 if (doc->isDeepLocked()) 426 if (doc->isDeepLocked())
426 return; 427 return;
427 unsigned int curIndex = 0; 428 unsigned int curIndex = 0;
428 if (!getCurEntryIndex(&curIndex)) 429 if (!getCurEntryIndex(&curIndex))
429 return; 430 return;
430 PwMDataItem d; 431 PwMDataItem d;
431 document()->getEntry(getCurrentCategory(), curIndex, &d); 432 document()->getEntry(getCurrentCategory(), curIndex, &d);
432 PwM::copyToClipboard(d.desc.c_str()); 433 PwM::copyToClipboard(d.desc.c_str());
433} 434}
434 435
435void PwMView::copyUrlToClip() 436void PwMView::copyUrlToClip()
436{ 437{
437 if (doc->isDeepLocked()) 438 if (doc->isDeepLocked())
438 return; 439 return;
439 unsigned int curIndex = 0; 440 unsigned int curIndex = 0;
440 if (!getCurEntryIndex(&curIndex)) 441 if (!getCurEntryIndex(&curIndex))
441 return; 442 return;
442 PwMDataItem d; 443 PwMDataItem d;
443 document()->getEntry(getCurrentCategory(), curIndex, &d); 444 document()->getEntry(getCurrentCategory(), curIndex, &d);
444 PwM::copyToClipboard(d.url.c_str()); 445 PwM::copyToClipboard(d.url.c_str());
445} 446}
446 447
447void PwMView::copyLauncherToClip() 448void PwMView::copyLauncherToClip()
448{ 449{
449 if (doc->isDeepLocked()) 450 if (doc->isDeepLocked())
450 return; 451 return;
451 unsigned int curIndex = 0; 452 unsigned int curIndex = 0;
452 if (!getCurEntryIndex(&curIndex)) 453 if (!getCurEntryIndex(&curIndex))
453 return; 454 return;
454 PwMDataItem d; 455 PwMDataItem d;
455 document()->getEntry(getCurrentCategory(), curIndex, &d); 456 document()->getEntry(getCurrentCategory(), curIndex, &d);
456 PwM::copyToClipboard(d.launcher.c_str()); 457 PwM::copyToClipboard(d.launcher.c_str());
457} 458}
458 459
459void PwMView::copyCommentToClip() 460void PwMView::copyCommentToClip()
460{ 461{
461 if (doc->isDeepLocked()) 462 if (doc->isDeepLocked())
462 return; 463 return;
463 unsigned int curIndex = 0; 464 unsigned int curIndex = 0;
464 if (!getCurEntryIndex(&curIndex)) 465 if (!getCurEntryIndex(&curIndex))
465 return; 466 return;
466 PwMDataItem d; 467 PwMDataItem d;
467 document()->getEntry(getCurrentCategory(), curIndex, &d); 468 document()->getEntry(getCurrentCategory(), curIndex, &d);
468 PwM::copyToClipboard(d.comment.c_str()); 469 PwM::copyToClipboard(d.comment.c_str());
469} 470}
470 471
471/************************************************************************ 472/************************************************************************
472 * 473 *
473 * 474 *
474 * 475 *
475 ************************************************************************/ 476 ************************************************************************/
476 477
477 478
478PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name ) 479PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name )
479 : QTextBrowser( parent, name ) 480 : QTextBrowser( parent, name )
480 481
481 482
482{ 483{
483//US setWrapPolicy( QTextEdit::AtWordBoundary ); 484//US setWrapPolicy( QTextEdit::AtWordBoundary );
484 setLinkUnderline( false ); 485 setLinkUnderline( false );
485 // setVScrollBarMode( QScrollView::AlwaysOff ); 486 // setVScrollBarMode( QScrollView::AlwaysOff );
486 //setHScrollBarMode( QScrollView::AlwaysOff ); 487 //setHScrollBarMode( QScrollView::AlwaysOff );
487 488
488//US QStyleSheet *sheet = styleSheet(); 489//US QStyleSheet *sheet = styleSheet();
489//US QStyleSheetItem *link = sheet->item( "a" ); 490//US QStyleSheetItem *link = sheet->item( "a" );
490//US link->setColor( KGlobalSettings::linkColor() ); 491//US link->setColor( KGlobalSettings::linkColor() );
491 492
492} 493}
493 494
494void PwMDataItemView::setPwMDataItem( const PwMDataItem& a ) 495void PwMDataItemView::setPwMDataItem( const PwMDataItem& a )
495 496
496{ 497{
497 mItem = a; 498 mItem = a;
498 // clear view 499 // clear view
499 setText( QString::null ); 500 setText( QString::null );
500 501
501 502
502 QString dynamicPart; 503 QString dynamicPart;
503 QString format = "<tr><td align=\"right\"><b>%1</b></td>" 504 QString format = "<tr><td align=\"right\"><b>%1</b></td>"
504 "<td align=\"left\">%2</td></tr>"; 505 "<td align=\"left\">%2</td></tr>";
505 506
506 dynamicPart += format 507 dynamicPart += format
507 .arg( i18n("LastUpdate") ) 508 .arg( i18n("LastUpdate") )
508 .arg( mItem.meta.update.toString().latin1() ); 509 .arg( mItem.meta.update.toString().latin1() );
509 510
510 dynamicPart += format 511 dynamicPart += format
511 .arg( i18n("Description") ) 512 .arg( i18n("Description") )
512 .arg( mItem.desc.c_str() ); 513 .arg( mItem.desc.c_str() );
513 514
514 dynamicPart += format 515 dynamicPart += format
515 .arg( i18n("Name") ) 516 .arg( i18n("Name") )
516 .arg( mItem.name.c_str() ); 517 .arg( mItem.name.c_str() );
517 518
518 dynamicPart += format 519 dynamicPart += format
519 .arg( i18n("Password") ) 520 .arg( i18n("Password") )
520 .arg( mItem.pw.c_str() ); 521 .arg( mItem.pw.c_str() );
521 522
522 QString comment(mItem.pw.c_str()); 523 QString comment(mItem.pw.c_str());
523 dynamicPart += format 524 dynamicPart += format
524 .arg( i18n("Comment") ) 525 .arg( i18n("Comment") )
525 .arg( comment.replace( QRegExp("\n"), "<br>" ) ); 526 .arg( comment.replace( QRegExp("\n"), "<br>" ) );
526 527
527 dynamicPart += format 528 dynamicPart += format
528 .arg( i18n("URL") ) 529 .arg( i18n("URL") )
529 .arg( mItem.url.c_str() ); 530 .arg( mItem.url.c_str() );
530 531
531 dynamicPart += format 532 dynamicPart += format
532 .arg( i18n("Launcher") ) 533 .arg( i18n("Launcher") )
533 .arg( mItem.launcher.c_str() ); 534 .arg( mItem.launcher.c_str() );
534 535
535 QString mText = "<table><td colspan=\"2\">&nbsp;</td>"; 536 QString mText = "<table><td colspan=\"2\">&nbsp;</td>";
536 537
537 mText += dynamicPart; 538 mText += dynamicPart;
538 mText += "</table>"; 539 mText += "</table>";
539 540
540 // at last display it... 541 // at last display it...
541 setText( mText ); 542 setText( mText );
542 543
543} 544}
544 545
545PwMDataItem PwMDataItemView::pwmdataitem() const 546PwMDataItem PwMDataItemView::pwmdataitem() const
546{ 547{
547 return mItem; 548 return mItem;
548} 549}
549 550
550/************************************************************************ 551/************************************************************************
551 * 552 *
552 * 553 *
553 * 554 *
554 ************************************************************************/ 555 ************************************************************************/
555 556
556 557
557PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name ) 558PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name )
558 : KDialogBase(parent, name, true , 559 : KDialogBase(parent, name, true ,
559 i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false) 560 i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false)
560{ 561{
561 findButton( Close )->setText( i18n("Cancel Sync")); 562 findButton( Close )->setText( i18n("Cancel Sync"));
562 findButton( Ok )->setText( i18n("Remote")); 563 findButton( Ok )->setText( i18n("Remote"));
563 findButton( User1 )->setText( i18n("Local")); 564 findButton( User1 )->setText( i18n("Local"));
564 QWidget* topframe = new QWidget( this ); 565 QWidget* topframe = new QWidget( this );
565 setMainWidget( topframe ); 566 setMainWidget( topframe );
566 QBoxLayout* bl; 567 QBoxLayout* bl;
567 if ( QApplication::desktop()->width() < 640 ) { 568 if ( QApplication::desktop()->width() < 640 ) {
568 bl = new QVBoxLayout( topframe ); 569 bl = new QVBoxLayout( topframe );
569 } else { 570 } else {
570 bl = new QHBoxLayout( topframe ); 571 bl = new QHBoxLayout( topframe );
571 } 572 }
572 QVBox* subframe = new QVBox( topframe ); 573 QVBox* subframe = new QVBox( topframe );
573 bl->addWidget(subframe ); 574 bl->addWidget(subframe );
574 QLabel* lab = new QLabel( i18n("Local Entry"), subframe ); 575 QLabel* lab = new QLabel( i18n("Local Entry"), subframe );
575 if ( takeloc ) 576 if ( takeloc )
576 lab->setBackgroundColor(Qt::green.light() ); 577 lab->setBackgroundColor(Qt::green.light() );
577 PwMDataItemView * av = new PwMDataItemView( subframe ); 578 PwMDataItemView * av = new PwMDataItemView( subframe );
578 av->setPwMDataItem( loc ); 579 av->setPwMDataItem( loc );
579 subframe = new QVBox( topframe ); 580 subframe = new QVBox( topframe );
580 bl->addWidget(subframe ); 581 bl->addWidget(subframe );
581 lab = new QLabel( i18n("Remote Entry"), subframe ); 582 lab = new QLabel( i18n("Remote Entry"), subframe );
582 if ( !takeloc ) 583 if ( !takeloc )
583 lab->setBackgroundColor(Qt::green.light() ); 584 lab->setBackgroundColor(Qt::green.light() );
584 av = new PwMDataItemView( subframe ); 585 av = new PwMDataItemView( subframe );
585 av->setPwMDataItem( rem ); 586 av->setPwMDataItem( rem );
586 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 587 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
587 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 588 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
588#ifndef DESKTOP_VERSION 589#ifndef DESKTOP_VERSION
589 showMaximized(); 590 showMaximized();
590#else 591#else
591 resize ( 640, 400 ); 592 resize ( 640, 400 );
592#endif 593#endif
593} 594}
594 595
595int PwMDataItemChooser::executeD( bool local ) 596int PwMDataItemChooser::executeD( bool local )
596{ 597{
597 mSyncResult = 3; 598 mSyncResult = 3;
598 if ( local ) 599 if ( local )
599 findButton( User1 )->setFocus(); 600 findButton( User1 )->setFocus();
600 else 601 else
601 findButton( Ok )->setFocus(); 602 findButton( Ok )->setFocus();
602 exec(); 603 exec();
603 return mSyncResult; 604 return mSyncResult;
604} 605}
605void PwMDataItemChooser::slot_remote() 606void PwMDataItemChooser::slot_remote()
606{ 607{
607 mSyncResult = 2; 608 mSyncResult = 2;
608 accept(); 609 accept();
609} 610}
610void PwMDataItemChooser::slot_local() 611void PwMDataItemChooser::slot_local()
611{ 612{
612 mSyncResult = 1; 613 mSyncResult = 1;
613 accept(); 614 accept();
614} 615}
615 616
616 617
617 618
618#ifndef PWM_EMBEDDED 619#ifndef PWM_EMBEDDED
619#include "pwmview.moc" 620#include "pwmview.moc"
620#endif 621#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp
index 0af1473..5f25880 100644
--- a/pwmanager/pwmanager/pwmviewstyle.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle.cpp
@@ -1,239 +1,250 @@
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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.0.1 of pwmanager 15 * This file is originaly based on version 1.0.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#include "pwmviewstyle.h" 21#include "pwmviewstyle.h"
22#include "pwmexception.h" 22#include "pwmexception.h"
23#include "pwmviewstyle_0.h" 23#include "pwmviewstyle_0.h"
24#include "pwmviewstyle_1.h" 24#include "pwmviewstyle_1.h"
25#include "listviewpwm.h" 25#include "listviewpwm.h"
26#include "pwmview.h" 26#include "pwmview.h"
27#include "commentbox.h" 27#include "commentbox.h"
28#ifndef PWM_EMBEDDED 28#ifndef PWM_EMBEDDED
29#include "configuration.h" 29#include "configuration.h"
30#else 30#else
31#include "pwmprefs.h" 31#include "pwmprefs.h"
32#endif 32#endif
33 33
34PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) 34PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name)
35 : QWidget(parent, name) 35 : QWidget(parent, name)
36{ 36{
37 curStyle = style_notset; 37 curStyle = style_notset;
38 s0 = 0; 38 s0 = 0;
39 s1 = 0; 39 s1 = 0;
40} 40}
41 41
42PwMViewStyle::~PwMViewStyle() 42PwMViewStyle::~PwMViewStyle()
43{ 43{
44 //US ENH : store the size of the listviewcolumns 44 //US ENH : store the size of the listviewcolumns
45 switch (curStyle) 45 switch (curStyle)
46 { 46 {
47 case style_0: 47 case style_0:
48 s0->saveSettings(PWMPrefs::instance()); 48 s0->saveSettings(PWMPrefs::instance());
49 break; 49 break;
50 case style_1: 50 case style_1:
51 s1->saveSettings(PWMPrefs::instance()); 51 s1->saveSettings(PWMPrefs::instance());
52 break; 52 break;
53 default: 53 default:
54 BUG(); 54 BUG();
55 } 55 }
56 56
57 57
58 PWMPrefs::instance()->writeConfig(); 58 PWMPrefs::instance()->writeConfig();
59 59
60 delete_ifnot_null(s0); 60 delete_ifnot_null(s0);
61 delete_ifnot_null(s1); 61 delete_ifnot_null(s1);
62} 62}
63 63
64void PwMViewStyle::editPassWord( QListViewItem * i )
65{
66 if ( !i )
67 return;
68 emit editPW();
69}
64void PwMViewStyle::initStyle(style_t style) 70void PwMViewStyle::initStyle(style_t style)
65{ 71{
66 printDebug(string("initializing style ") + tostr(style)); 72 printDebug(string("initializing style ") + tostr(style));
67 bool wasMaximized = v->isMaximized(); 73 bool wasMaximized = v->isMaximized();
68 if (v->isVisible()) 74 if (v->isVisible())
69 v->hide(); 75 v->hide();
70 switch (style) { 76 switch (style) {
71 case style_0: 77 case style_0:
72 delete_ifnot_null(s0); 78 delete_ifnot_null(s0);
73 delete_ifnot_null(s1); 79 delete_ifnot_null(s1);
74 s0 = new PwMViewStyle_0(v); 80 s0 = new PwMViewStyle_0(v);
75 lv = s0->getLv(); 81 lv = s0->getLv();
76 commentBox = s0->getCommentBox(); 82 commentBox = s0->getCommentBox();
77 break; 83 break;
78 case style_1: 84 case style_1:
79 delete_ifnot_null(s0); 85 delete_ifnot_null(s0);
80 delete_ifnot_null(s1); 86 delete_ifnot_null(s1);
81 s1 = new PwMViewStyle_1(v); 87 s1 = new PwMViewStyle_1(v);
82 lv = s1->getLv(); 88 lv = s1->getLv();
83 commentBox = s1->getCommentBox(); 89 commentBox = s1->getCommentBox();
84 break; 90 break;
85 default: 91 default:
86 BUG(); 92 BUG();
87 return; 93 return;
88 } 94 }
89 curStyle = style; 95 curStyle = style;
90 connect(lv, SIGNAL(pressed(QListViewItem *)), 96 connect(lv, SIGNAL(pressed(QListViewItem *)),
91 v, SLOT(handleToggle(QListViewItem *))); 97 v, SLOT(handleToggle(QListViewItem *)));
92 connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)), 98 connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)),
93 v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int))); 99 v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int)));
94 connect(lv, SIGNAL(clicked(QListViewItem *)), 100 connect(lv, SIGNAL(clicked(QListViewItem *)),
95 v, SLOT(refreshCommentTextEdit(QListViewItem *))); 101 v, SLOT(refreshCommentTextEdit(QListViewItem *)));
102 connect(lv, SIGNAL(returnPressed(QListViewItem *)),
103 this, SLOT(editPassWord(QListViewItem *)));
104 connect(lv, SIGNAL(doubleClicked(QListViewItem *)),
105 this, SLOT(editPassWord(QListViewItem *)));
106
96 lv->addColumn(i18n("Description"), 180); 107 lv->addColumn(i18n("Description"), 180);
97 lv->addColumn(i18n("Username"), 150); 108 lv->addColumn(i18n("Username"), 150);
98 lv->addColumn(i18n("Password"), 150); 109 lv->addColumn(i18n("Password"), 150);
99 lv->addColumn(i18n("URL"), 180); 110 lv->addColumn(i18n("URL"), 180);
100 lv->addColumn(i18n("Launcher"), 120); 111 lv->addColumn(i18n("Launcher"), 120);
101 v->tmpReEnableSort(); 112 v->tmpReEnableSort();
102 113
103 //US ENH : load the size of the listviewcolumns 114 //US ENH : load the size of the listviewcolumns
104 switch (curStyle) 115 switch (curStyle)
105 { 116 {
106 case style_0: 117 case style_0:
107 s0->restoreSettings(PWMPrefs::instance()); 118 s0->restoreSettings(PWMPrefs::instance());
108 break; 119 break;
109 case style_1: 120 case style_1:
110 s1->restoreSettings(PWMPrefs::instance()); 121 s1->restoreSettings(PWMPrefs::instance());
111 break; 122 break;
112 default: 123 default:
113 BUG(); 124 BUG();
114 } 125 }
115 126
116 resizeView(v->size()); 127 resizeView(v->size());
117 v->updateView(); 128 v->updateView();
118 if (wasMaximized) { 129 if (wasMaximized) {
119 v->showMaximized(); 130 v->showMaximized();
120 } else { 131 } else {
121 v->show(); 132 v->show();
122 } 133 }
123 connect(lv, SIGNAL(layoutChanged()), 134 connect(lv, SIGNAL(layoutChanged()),
124 v, SLOT(reorgLp())); 135 v, SLOT(reorgLp()));
125} 136}
126 137
127void PwMViewStyle::resizeView(const QSize &size) 138void PwMViewStyle::resizeView(const QSize &size)
128{ 139{
129 switch (curStyle) { 140 switch (curStyle) {
130 case style_0: 141 case style_0:
131 PWM_ASSERT(s0); 142 PWM_ASSERT(s0);
132 s0->resize(size); 143 s0->resize(size);
133 return; 144 return;
134 case style_1: 145 case style_1:
135 PWM_ASSERT(s1); 146 PWM_ASSERT(s1);
136 s1->resize(size); 147 s1->resize(size);
137 return; 148 return;
138 default: 149 default:
139 BUG(); 150 BUG();
140 } 151 }
141} 152}
142 153
143QString PwMViewStyle::getCurrentCategory() 154QString PwMViewStyle::getCurrentCategory()
144{ 155{
145 switch (curStyle) { 156 switch (curStyle) {
146 case style_0: 157 case style_0:
147 PWM_ASSERT(s0); 158 PWM_ASSERT(s0);
148 return s0->getCurrentCategory(); 159 return s0->getCurrentCategory();
149 case style_1: 160 case style_1:
150 PWM_ASSERT(s1); 161 PWM_ASSERT(s1);
151 return s1->getCurrentCategory(); 162 return s1->getCurrentCategory();
152 default: 163 default:
153 BUG(); 164 BUG();
154 } 165 }
155 return ""; 166 return "";
156} 167}
157 168
158void PwMViewStyle::addCategory(const QString &cat) 169void PwMViewStyle::addCategory(const QString &cat)
159{ 170{
160 switch (curStyle) { 171 switch (curStyle) {
161 case style_0: 172 case style_0:
162 PWM_ASSERT(s0); 173 PWM_ASSERT(s0);
163 s0->addCategory(cat); 174 s0->addCategory(cat);
164 return; 175 return;
165 case style_1: 176 case style_1:
166 PWM_ASSERT(s1); 177 PWM_ASSERT(s1);
167 s1->addCategory(cat); 178 s1->addCategory(cat);
168 return; 179 return;
169 default: 180 default:
170 BUG(); 181 BUG();
171 } 182 }
172} 183}
173 184
174void PwMViewStyle::delCategory(const QString &cat) 185void PwMViewStyle::delCategory(const QString &cat)
175{ 186{
176 switch (curStyle) { 187 switch (curStyle) {
177 case style_0: 188 case style_0:
178 PWM_ASSERT(s0); 189 PWM_ASSERT(s0);
179 s0->delCategory(cat); 190 s0->delCategory(cat);
180 return; 191 return;
181 case style_1: 192 case style_1:
182 PWM_ASSERT(s1); 193 PWM_ASSERT(s1);
183 s1->delCategory(cat); 194 s1->delCategory(cat);
184 return; 195 return;
185 default: 196 default:
186 BUG(); 197 BUG();
187 } 198 }
188} 199}
189 200
190void PwMViewStyle::delAllCategories() 201void PwMViewStyle::delAllCategories()
191{ 202{
192 switch (curStyle) { 203 switch (curStyle) {
193 case style_0: 204 case style_0:
194 PWM_ASSERT(s0); 205 PWM_ASSERT(s0);
195 s0->delAllCategories(); 206 s0->delAllCategories();
196 return; 207 return;
197 case style_1: 208 case style_1:
198 PWM_ASSERT(s1); 209 PWM_ASSERT(s1);
199 s1->delAllCategories(); 210 s1->delAllCategories();
200 return; 211 return;
201 default: 212 default:
202 BUG(); 213 BUG();
203 } 214 }
204} 215}
205 216
206void PwMViewStyle::selectCategory(const QString &cat) 217void PwMViewStyle::selectCategory(const QString &cat)
207{ 218{
208 switch (curStyle) { 219 switch (curStyle) {
209 case style_0: 220 case style_0:
210 PWM_ASSERT(s0); 221 PWM_ASSERT(s0);
211 s0->selectCategory(cat); 222 s0->selectCategory(cat);
212 return; 223 return;
213 case style_1: 224 case style_1:
214 PWM_ASSERT(s1); 225 PWM_ASSERT(s1);
215 s1->selectCategory(cat); 226 s1->selectCategory(cat);
216 return; 227 return;
217 default: 228 default:
218 BUG(); 229 BUG();
219 } 230 }
220} 231}
221 232
222int PwMViewStyle::numCategories() 233int PwMViewStyle::numCategories()
223{ 234{
224 switch (curStyle) { 235 switch (curStyle) {
225 case style_0: 236 case style_0:
226 PWM_ASSERT(s0); 237 PWM_ASSERT(s0);
227 return s0->numCategories(); 238 return s0->numCategories();
228 case style_1: 239 case style_1:
229 PWM_ASSERT(s1); 240 PWM_ASSERT(s1);
230 return s1->numCategories(); 241 return s1->numCategories();
231 default: 242 default:
232 BUG(); 243 BUG();
233 } 244 }
234 return 0; 245 return 0;
235} 246}
236 247
237#ifndef PWM_EMBEDDED 248#ifndef PWM_EMBEDDED
238#include "pwmviewstyle.moc" 249#include "pwmviewstyle.moc"
239#endif 250#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle.h b/pwmanager/pwmanager/pwmviewstyle.h
index bf5ce91..5656cbc 100644
--- a/pwmanager/pwmanager/pwmviewstyle.h
+++ b/pwmanager/pwmanager/pwmviewstyle.h
@@ -1,108 +1,113 @@
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/*************************************************************************** 13/***************************************************************************
14 * copyright (C) 2004 by Ulf Schenk 14 * copyright (C) 2004 by Ulf Schenk
15 * This file is originaly based on version 1.0.1 of pwmanager 15 * This file is originaly based on version 1.0.1 of pwmanager
16 * and was modified to run on embedded devices that run microkde 16 * and was modified to run on embedded devices that run microkde
17 * 17 *
18 * $Id$ 18 * $Id$
19 **************************************************************************/ 19 **************************************************************************/
20 20
21#ifndef PWMVIEWSTYLE_H 21#ifndef PWMVIEWSTYLE_H
22#define PWMVIEWSTYLE_H 22#define PWMVIEWSTYLE_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qsplitter.h> 25#include <qsplitter.h>
26#include <qhbox.h> 26#include <qhbox.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30#ifndef PWM_EMBEDDED 30#ifndef PWM_EMBEDDED
31#include <qtextedit.h> 31#include <qtextedit.h>
32#else 32#else
33#include <qmultilineedit.h> 33#include <qmultilineedit.h>
34#endif 34#endif
35 35
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlistbox.h> 37#include <qlistbox.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qsize.h> 39#include <qsize.h>
40 40
41class ListViewPwM; 41class ListViewPwM;
42class PwMViewStyle_0; 42class PwMViewStyle_0;
43class PwMViewStyle_1; 43class PwMViewStyle_1;
44class PwMView; 44class PwMView;
45class QListViewItem;
45class CommentBox; 46class CommentBox;
46 47
47class PwMViewStyle : public QWidget 48class PwMViewStyle : public QWidget
48{ 49{
49 Q_OBJECT 50 Q_OBJECT
50 51
51public: 52public:
52 enum style_t 53 enum style_t
53 { 54 {
54 style_notset= -1, 55 style_notset= -1,
55 style_0 = 0, 56 style_0 = 0,
56 style_1 = 1 57 style_1 = 1
57 }; 58 };
58 59
59public: 60public:
60 PwMViewStyle(QWidget *parent = 0, const char *name = 0); 61 PwMViewStyle(QWidget *parent = 0, const char *name = 0);
61 ~PwMViewStyle(); 62 ~PwMViewStyle();
62 63
63 /** initialize a new style */ 64 /** initialize a new style */
64 void initStyle(style_t style); 65 void initStyle(style_t style);
65 void initStyle(int style) 66 void initStyle(int style)
66 { initStyle(static_cast<style_t>(style)); } 67 { initStyle(static_cast<style_t>(style)); }
67 /** returns the currently used style */ 68 /** returns the currently used style */
68 style_t getCurStyle() 69 style_t getCurStyle()
69 { return curStyle; } 70 { return curStyle; }
70 void setView(PwMView *view) 71 void setView(PwMView *view)
71 { v = view; } 72 { v = view; }
72 73
73 /** returns the currently selected category */ 74 /** returns the currently selected category */
74 QString getCurrentCategory(); 75 QString getCurrentCategory();
75 76
76protected: 77protected:
77 /** add Category to the view */ 78 /** add Category to the view */
78 void addCategory(const QString &cat); 79 void addCategory(const QString &cat);
79 /** delete Category from view */ 80 /** delete Category from view */
80 void delCategory(const QString &cat); 81 void delCategory(const QString &cat);
81 /** delete all categories from view */ 82 /** delete all categories from view */
82 void delAllCategories(); 83 void delAllCategories();
83 /** select the specified category */ 84 /** select the specified category */
84 void selectCategory(const QString &cat); 85 void selectCategory(const QString &cat);
85 /** returns the number of categories in this view. 86 /** returns the number of categories in this view.
86 * This value dosn't say anything about the number of 87 * This value dosn't say anything about the number of
87 * categories in the document. 88 * categories in the document.
88 */ 89 */
89 int numCategories(); 90 int numCategories();
90 /** resize the view */ 91 /** resize the view */
91 void resizeView(const QSize &size); 92 void resizeView(const QSize &size);
93 ListViewPwM *lv;
94 CommentBox *commentBox;
95
96protected slots:
97 void editPassWord( QListViewItem * );
92 98
93private: 99private:
94 /** which style has the view? 100 /** which style has the view?
95 * KListBox on the left, 101 * KListBox on the left,
96 * or QComboBox on the top? 102 * or QComboBox on the top?
97 */ 103 */
98 style_t curStyle; 104 style_t curStyle;
99 105
100 PwMViewStyle_0 *s0; 106 PwMViewStyle_0 *s0;
101 PwMViewStyle_1 *s1; 107 PwMViewStyle_1 *s1;
102 PwMView *v; 108 PwMView *v;
109 signals:
110 void editPW();
103 111
104protected:
105 ListViewPwM *lv;
106 CommentBox *commentBox;
107}; 112};
108#endif 113#endif