author | ulf69 <ulf69> | 2004-10-29 05:20:48 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-29 05:20:48 (UTC) |
commit | 41e3625b8c38ff45e70b59416a519d59a5f4d937 (patch) (unidiff) | |
tree | 587b57d51bc77a699fd63cf10e53bf6f9f72a1b7 | |
parent | 08a4582f8e5184b8abb7d97781c4fc37ee7edf90 (diff) | |
download | kdepimpi-41e3625b8c38ff45e70b59416a519d59a5f4d937.zip kdepimpi-41e3625b8c38ff45e70b59416a519d59a5f4d937.tar.gz kdepimpi-41e3625b8c38ff45e70b59416a519d59a5f4d937.tar.bz2 |
display alternating category text in the add/edit dialogbox
-rw-r--r-- | pwmanager/pwmanager/addentrywnd_emb.cpp | 45 | ||||
-rw-r--r-- | pwmanager/pwmanager/addentrywnd_emb.h | 8 | ||||
-rw-r--r-- | pwmanager/pwmanager/addentrywndimpl.cpp | 7 | ||||
-rw-r--r-- | pwmanager/pwmanager/addentrywndimpl.h | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 4 |
5 files changed, 51 insertions, 15 deletions
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp index dd09d13..f065058 100644 --- a/pwmanager/pwmanager/addentrywnd_emb.cpp +++ b/pwmanager/pwmanager/addentrywnd_emb.cpp | |||
@@ -1,199 +1,226 @@ | |||
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 | 28 | ||
28 | #include <qlayout.h> | 29 | #include <qlayout.h> |
29 | #include <qlabel.h> | 30 | #include <qlabel.h> |
30 | #include <qtabwidget.h> | 31 | #include <qtabwidget.h> |
31 | #include <qgroupbox.h> | 32 | #include <qgroupbox.h> |
32 | #include <klocale.h> | 33 | #include <klocale.h> |
33 | #include <kcombobox.h> | 34 | #include <kcombobox.h> |
34 | #include <klineedit.h> | 35 | #include <klineedit.h> |
35 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
36 | #include <qmultilineedit.h> | 37 | #include <qmultilineedit.h> |
37 | 38 | ||
38 | /* | 39 | /* |
39 | * Constructs a addEntryWnd as a child of 'parent', with the | 40 | * Constructs a addEntryWnd as a child of 'parent', with the |
40 | * name 'name' and widget flags set to 'f'. | 41 | * name 'name' and widget flags set to 'f'. |
41 | * | 42 | * |
42 | * 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 |
43 | * TRUE to construct a modal dialog. | 44 | * TRUE to construct a modal dialog. |
44 | */ | 45 | */ |
45 | addEntryWnd::addEntryWnd( QWidget* parent, const char* name) | 46 | addEntryWnd::addEntryWnd( PwMDoc* d, QWidget* parent, const char* name) |
46 | : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ), | 47 | : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ), |
47 | KDialogBase::Ok | KDialogBase::Cancel, | 48 | KDialogBase::Ok | KDialogBase::Cancel, |
48 | KDialogBase::Ok, parent, name, true ) | 49 | KDialogBase::Ok, parent, name, true ), doc(d) |
49 | { | 50 | { |
50 | QWidget *page = plainPage(); | 51 | QWidget *page = plainPage(); |
51 | QVBoxLayout *pageLayout = new QVBoxLayout( page ); | 52 | QVBoxLayout *pageLayout = new QVBoxLayout( page ); |
52 | 53 | ||
53 | QTabWidget* mTabWidget = new QTabWidget( page ); | 54 | QTabWidget* mTabWidget = new QTabWidget( page ); |
54 | pageLayout->addWidget( mTabWidget ); | 55 | pageLayout->addWidget( mTabWidget ); |
55 | 56 | ||
56 | //////////////////////////////////////////////////////////////////// | 57 | //////////////////////////////////////////////////////////////////// |
57 | // This is the Password tab | 58 | // This is the Password tab |
58 | QWidget *tab1 = new QWidget( mTabWidget ); | 59 | QWidget *tab1 = new QWidget( mTabWidget ); |
59 | 60 | ||
60 | QGridLayout *layout = new QGridLayout( tab1, 3, 1 ); | 61 | QGridLayout *layout = new QGridLayout( tab1, 3, 1 ); |
61 | layout->setMargin( KDialogBase::marginHint() ); | 62 | layout->setMargin( KDialogBase::marginHint() ); |
62 | layout->setSpacing( KDialogBase::spacingHint() ); | 63 | layout->setSpacing( KDialogBase::spacingHint() ); |
63 | 64 | ||
64 | 65 | ||
65 | 66 | ||
66 | int i = 0; | 67 | int i = 0; |
67 | descLineEdit = new KLineEdit( tab1, "descLineEdit" ); | 68 | descLineEdit = new KLineEdit( tab1, "descLineEdit" ); |
68 | QLabel* label = new QLabel( descLineEdit, i18n("Description:"), tab1 ); | 69 | descLineLabel = new QLabel( descLineEdit, i18n("Description:"), tab1 ); |
69 | layout->addWidget( label, i, 0 ); | 70 | layout->addWidget( descLineLabel, i, 0 ); |
70 | layout->addWidget( descLineEdit, i, 1 ); | 71 | layout->addWidget( descLineEdit, i, 1 ); |
71 | i++; | 72 | i++; |
72 | 73 | ||
73 | categoryComboBox = new KComboBox( tab1 ); | 74 | categoryComboBox = new KComboBox( tab1 ); |
74 | label = new QLabel( categoryComboBox, i18n("Category:"), tab1 ); | 75 | QLabel* label = new QLabel( categoryComboBox, i18n("Category:"), tab1 ); |
75 | layout->addWidget( label, i, 0 ); | 76 | layout->addWidget( label, i, 0 ); |
76 | layout->addWidget( categoryComboBox, i, 1 ); | 77 | layout->addWidget( categoryComboBox, i, 1 ); |
77 | i++; | 78 | i++; |
78 | categoryComboBox->setEditable( TRUE ); | 79 | categoryComboBox->setEditable( TRUE ); |
79 | categoryComboBox->setSizeLimit( 100 ); | 80 | categoryComboBox->setSizeLimit( 100 ); |
80 | categoryComboBox->setAutoCompletion( TRUE ); | 81 | categoryComboBox->setAutoCompletion( TRUE ); |
81 | categoryComboBox->setDuplicatesEnabled( FALSE ); | 82 | categoryComboBox->setDuplicatesEnabled( FALSE ); |
83 | connect(categoryComboBox,SIGNAL(activated(const QString&)), SLOT(categorySelected(const QString&))); | ||
84 | |||
82 | 85 | ||
83 | usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); | 86 | usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); |
84 | label = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); | 87 | usernameLineLabel = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); |
85 | layout->addWidget( label, i, 0 ); | 88 | layout->addWidget( usernameLineLabel, i, 0 ); |
86 | layout->addWidget( usernameLineEdit, i, 1 ); | 89 | layout->addWidget( usernameLineEdit, i, 1 ); |
87 | i++; | 90 | i++; |
88 | 91 | ||
89 | pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); | 92 | pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); |
90 | pwLineEdit->setEchoMode( QLineEdit::Password ); | 93 | pwLineEdit->setEchoMode( QLineEdit::Password ); |
91 | label = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); | 94 | pwLineLabel = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); |
92 | layout->addWidget( label, i, 0 ); | 95 | layout->addWidget( pwLineLabel, i, 0 ); |
93 | layout->addWidget( pwLineEdit, i, 1 ); | 96 | layout->addWidget( pwLineEdit, i, 1 ); |
94 | i++; | 97 | i++; |
95 | 98 | ||
96 | revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); | 99 | revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); |
97 | revealButton->setToggleButton( TRUE ); | 100 | revealButton->setToggleButton( TRUE ); |
98 | layout->addWidget( revealButton, i, 0 ); | 101 | layout->addWidget( revealButton, i, 0 ); |
99 | 102 | ||
100 | generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); | 103 | generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); |
101 | layout->addWidget( generateButton, i, 1 ); | 104 | layout->addWidget( generateButton, i, 1 ); |
102 | i++; | 105 | i++; |
103 | 106 | ||
104 | urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); | 107 | urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); |
105 | label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); | 108 | label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); |
106 | layout->addWidget( label, i, 0 ); | 109 | layout->addWidget( label, i, 0 ); |
107 | layout->addWidget( urlLineEdit, i, 1 ); | 110 | layout->addWidget( urlLineEdit, i, 1 ); |
108 | i++; | 111 | i++; |
109 | 112 | ||
110 | mTabWidget->addTab( tab1, i18n( "&Password" ) ); | 113 | mTabWidget->addTab( tab1, i18n( "&Password" ) ); |
111 | 114 | ||
112 | 115 | ||
113 | //////////////////////////////////////////////////////////////////// | 116 | //////////////////////////////////////////////////////////////////// |
114 | // This is the Comment tab | 117 | // This is the Comment tab |
115 | QWidget *tab2 = new QWidget( mTabWidget ); | 118 | QWidget *tab2 = new QWidget( mTabWidget ); |
116 | 119 | ||
117 | layout = new QGridLayout( tab2, 3, 1 ); | 120 | layout = new QGridLayout( tab2, 3, 1 ); |
118 | layout->setMargin( KDialogBase::marginHintSmall() ); | 121 | layout->setMargin( KDialogBase::marginHintSmall() ); |
119 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 122 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
120 | i = 0; | 123 | i = 0; |
121 | 124 | ||
122 | commentTextEdit = new QMultiLineEdit(tab2); | 125 | commentTextEdit = new QMultiLineEdit(tab2); |
123 | layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 ); | 126 | layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 ); |
124 | i++; | 127 | i++; |
125 | 128 | ||
126 | 129 | ||
127 | mTabWidget->addTab( tab2, i18n( "&Comments" ) ); | 130 | mTabWidget->addTab( tab2, i18n( "&Comments" ) ); |
128 | 131 | ||
129 | 132 | ||
130 | //////////////////////////////////////////////////////////////////// | 133 | //////////////////////////////////////////////////////////////////// |
131 | // This is the Launcher tab | 134 | // This is the Launcher tab |
132 | QWidget *tab3 = new QWidget( mTabWidget ); | 135 | QWidget *tab3 = new QWidget( mTabWidget ); |
133 | 136 | ||
134 | layout = new QGridLayout( tab3, 3, 1 ); | 137 | layout = new QGridLayout( tab3, 3, 1 ); |
135 | layout->setMargin( KDialogBase::marginHintSmall() ); | 138 | layout->setMargin( KDialogBase::marginHintSmall() ); |
136 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 139 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
137 | i = 0; | 140 | i = 0; |
138 | 141 | ||
139 | launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); | 142 | launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); |
140 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); | 143 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); |
141 | 144 | ||
142 | QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); | 145 | QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); |
143 | QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); | 146 | QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); |
144 | QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); | 147 | QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); |
145 | QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); | 148 | QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); |
146 | QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); | 149 | QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); |
147 | 150 | ||
148 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); | 151 | label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); |
149 | 152 | ||
150 | layout->addWidget( label1, i, 0 ); | 153 | layout->addWidget( label1, i, 0 ); |
151 | layout->addWidget( label2, i, 1 ); | 154 | layout->addWidget( label2, i, 1 ); |
152 | i++; | 155 | i++; |
153 | layout->addWidget( label3, i, 0 ); | 156 | layout->addWidget( label3, i, 0 ); |
154 | layout->addWidget( label4, i, 1 ); | 157 | layout->addWidget( label4, i, 1 ); |
155 | i++; | 158 | i++; |
156 | layout->addWidget( label5, i, 0 ); | 159 | layout->addWidget( label5, i, 0 ); |
157 | i++; | 160 | i++; |
158 | 161 | ||
159 | layout->addWidget( label, i, 0 ); | 162 | layout->addWidget( label, i, 0 ); |
160 | layout->addWidget( launcherLineEdit, i, 1 ); | 163 | layout->addWidget( launcherLineEdit, i, 1 ); |
161 | i++; | 164 | i++; |
162 | 165 | ||
163 | 166 | ||
164 | mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); | 167 | mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); |
165 | 168 | ||
166 | // signals and slots connections | 169 | // signals and slots connections |
167 | connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); | 170 | connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); |
168 | connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); | 171 | connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); |
169 | } | 172 | } |
170 | 173 | ||
171 | /* | 174 | /* |
172 | * Destroys the object and frees any allocated resources | 175 | * Destroys the object and frees any allocated resources |
173 | */ | 176 | */ |
174 | addEntryWnd::~addEntryWnd() | 177 | addEntryWnd::~addEntryWnd() |
175 | { | 178 | { |
176 | // no need to delete child widgets, Qt does it all for us | 179 | // no need to delete child widgets, Qt does it all for us |
177 | } | 180 | } |
178 | 181 | ||
179 | void addEntryWnd::slotOk() | 182 | void addEntryWnd::slotOk() |
180 | { | 183 | { |
181 | qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); | 184 | qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); |
182 | } | 185 | } |
183 | 186 | ||
184 | void addEntryWnd::revealButton_slot() | 187 | void addEntryWnd::revealButton_slot() |
185 | { | 188 | { |
186 | qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); | 189 | qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); |
187 | } | 190 | } |
188 | 191 | ||
189 | void addEntryWnd::generateButton_slot() | 192 | void addEntryWnd::generateButton_slot() |
190 | { | 193 | { |
191 | qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); | 194 | qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); |
192 | } | 195 | } |
193 | 196 | ||
194 | void addEntryWnd::advancedCommentButton_slot(bool) | 197 | void addEntryWnd::advancedCommentButton_slot(bool) |
195 | { | 198 | { |
196 | qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); | 199 | qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); |
197 | } | 200 | } |
198 | 201 | ||
202 | void addEntryWnd::categorySelected ( const QString & string ) | ||
203 | { | ||
204 | unsigned int idx; | ||
205 | bool found = doc->findCategory(string, &idx); | ||
206 | |||
207 | if (found == true) | ||
208 | { | ||
209 | qDebug("addEntryWnd::categorySelected found"); | ||
210 | PwMCategoryItem* catitem = doc->getCategoryEntry(idx); | ||
211 | |||
212 | descLineLabel->setText(catitem->desc_text.c_str()); | ||
213 | usernameLineLabel->setText(catitem->name_text.c_str()); | ||
214 | pwLineLabel->setText(catitem->pw_text.c_str()); | ||
215 | return; | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | qDebug("addEntryWnd::categorySelected NOT found"); | ||
220 | BUG(); | ||
221 | } | ||
222 | |||
223 | |||
224 | } | ||
225 | |||
199 | 226 | ||
diff --git a/pwmanager/pwmanager/addentrywnd_emb.h b/pwmanager/pwmanager/addentrywnd_emb.h index 83761dc..966d9d2 100644 --- a/pwmanager/pwmanager/addentrywnd_emb.h +++ b/pwmanager/pwmanager/addentrywnd_emb.h | |||
@@ -1,72 +1,78 @@ | |||
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 | #ifndef ADDENTRYWND_EMB_H | 26 | #ifndef ADDENTRYWND_EMB_H |
27 | #define ADDENTRYWND_EMB_H | 27 | #define ADDENTRYWND_EMB_H |
28 | 28 | ||
29 | #include <qvariant.h> | 29 | #include <qvariant.h> |
30 | #include <kdialogbase.h> | 30 | #include <kdialogbase.h> |
31 | 31 | ||
32 | class QVBoxLayout; | 32 | class QVBoxLayout; |
33 | class QHBoxLayout; | 33 | class QHBoxLayout; |
34 | class QGridLayout; | 34 | class QGridLayout; |
35 | class QSpacerItem; | 35 | class QSpacerItem; |
36 | class KLineEdit; | 36 | class KLineEdit; |
37 | class QPushButton; | 37 | class QPushButton; |
38 | class KComboBox; | 38 | class KComboBox; |
39 | class QLabel; | 39 | class QLabel; |
40 | class QGroupBox; | 40 | class QGroupBox; |
41 | class QMultiLineEdit; | 41 | class QMultiLineEdit; |
42 | class PwMDoc; | ||
42 | 43 | ||
43 | class addEntryWnd : public KDialogBase | 44 | class addEntryWnd : public KDialogBase |
44 | { | 45 | { |
45 | Q_OBJECT | 46 | Q_OBJECT |
46 | 47 | ||
47 | public: | 48 | public: |
48 | addEntryWnd( QWidget* parent = 0, const char* name = 0); | 49 | addEntryWnd( PwMDoc* doc, QWidget* parent = 0, const char* name = 0); |
49 | ~addEntryWnd(); | 50 | ~addEntryWnd(); |
50 | 51 | ||
51 | KLineEdit* launcherLineEdit; | 52 | KLineEdit* launcherLineEdit; |
52 | QPushButton* generateButton; | 53 | QPushButton* generateButton; |
53 | KLineEdit* descLineEdit; | 54 | KLineEdit* descLineEdit; |
54 | KComboBox* categoryComboBox; | 55 | KComboBox* categoryComboBox; |
55 | KLineEdit* usernameLineEdit; | 56 | KLineEdit* usernameLineEdit; |
56 | KLineEdit* pwLineEdit; | 57 | KLineEdit* pwLineEdit; |
57 | KLineEdit* urlLineEdit; | 58 | KLineEdit* urlLineEdit; |
59 | QLabel* descLineLabel; | ||
60 | QLabel* usernameLineLabel; | ||
61 | QLabel* pwLineLabel; | ||
58 | 62 | ||
59 | QPushButton* revealButton; | 63 | QPushButton* revealButton; |
60 | QMultiLineEdit* commentTextEdit; | 64 | QMultiLineEdit* commentTextEdit; |
65 | PwMDoc* doc; | ||
61 | 66 | ||
62 | public slots: | 67 | public slots: |
63 | virtual void revealButton_slot(); | 68 | virtual void revealButton_slot(); |
64 | virtual void generateButton_slot(); | 69 | virtual void generateButton_slot(); |
65 | virtual void advancedCommentButton_slot(bool on); | 70 | virtual void advancedCommentButton_slot(bool on); |
66 | 71 | ||
67 | protected slots: | 72 | protected slots: |
68 | virtual void slotOk(); | 73 | virtual void slotOk(); |
74 | virtual void categorySelected ( const QString & string ); | ||
69 | 75 | ||
70 | }; | 76 | }; |
71 | 77 | ||
72 | #endif // ADDENTRYWND_H | 78 | #endif // ADDENTRYWND_H |
diff --git a/pwmanager/pwmanager/addentrywndimpl.cpp b/pwmanager/pwmanager/addentrywndimpl.cpp index d47f32c..fa6b6c0 100644 --- a/pwmanager/pwmanager/addentrywndimpl.cpp +++ b/pwmanager/pwmanager/addentrywndimpl.cpp | |||
@@ -1,217 +1,220 @@ | |||
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 | * Many very good improvements and the original implementations of * | 6 | * Many very good improvements and the original implementations of * |
7 | * them came from Matt Scifo <mscifo@o1.com> * | 7 | * them came from Matt Scifo <mscifo@o1.com> * |
8 | * * | 8 | * * |
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License version 2 * | 10 | * it under the terms of the GNU General Public License version 2 * |
11 | * as published by the Free Software Foundation. * | 11 | * as published by the Free Software Foundation. * |
12 | * * | 12 | * * |
13 | ***************************************************************************/ | 13 | ***************************************************************************/ |
14 | 14 | ||
15 | /*************************************************************************** | 15 | /*************************************************************************** |
16 | * copyright (C) 2004 by Ulf Schenk | 16 | * copyright (C) 2004 by Ulf Schenk |
17 | * This file is originaly based on version 1.0.1 of pwmanager | 17 | * This file is originaly based on version 1.0.1 of pwmanager |
18 | * and was modified to run on embedded devices that run microkde | 18 | * and was modified to run on embedded devices that run microkde |
19 | * | 19 | * |
20 | * $Id$ | 20 | * $Id$ |
21 | **************************************************************************/ | 21 | **************************************************************************/ |
22 | 22 | ||
23 | #include "addentrywndimpl.h" | 23 | #include "addentrywndimpl.h" |
24 | #include "pwmexception.h" | 24 | #include "pwmexception.h" |
25 | #include "pwgenwndimpl.h" | 25 | #include "pwgenwndimpl.h" |
26 | #ifndef PWM_EMBEDDED | 26 | #ifndef PWM_EMBEDDED |
27 | #include "advcommeditimpl.h" | 27 | #include "advcommeditimpl.h" |
28 | #endif | 28 | #endif |
29 | #include "htmlgen.h" | 29 | #include "htmlgen.h" |
30 | 30 | ||
31 | #include <kmessagebox.h> | 31 | #include <kmessagebox.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | 37 | ||
38 | 38 | ||
39 | #ifndef PWM_EMBEDDED | 39 | #ifndef PWM_EMBEDDED |
40 | AddEntryWndImpl::AddEntryWndImpl() | 40 | AddEntryWndImpl::AddEntryWndImpl() |
41 | : addEntryWnd( 0, "AddEntryWndImpl", TRUE) | 41 | : addEntryWnd( 0, "AddEntryWndImpl", TRUE) |
42 | #else | 42 | #else |
43 | AddEntryWndImpl::AddEntryWndImpl( QWidget* parent, const char* name) | 43 | AddEntryWndImpl::AddEntryWndImpl( PwMDoc* doc, QWidget* parent, const char* name) |
44 | : addEntryWnd( parent, name) | 44 | : addEntryWnd( doc, parent, name) |
45 | #endif | 45 | #endif |
46 | { | 46 | { |
47 | #ifndef PWM_EMBEDDED | 47 | #ifndef PWM_EMBEDDED |
48 | editAdvCommentButton = 0; | 48 | editAdvCommentButton = 0; |
49 | commentTextEdit = 0; | 49 | commentTextEdit = 0; |
50 | #endif | 50 | #endif |
51 | switchComment(false); | 51 | switchComment(false); |
52 | pwGen = new PwGenWndImpl(this); | 52 | pwGen = new PwGenWndImpl(this); |
53 | } | 53 | } |
54 | 54 | ||
55 | AddEntryWndImpl::~AddEntryWndImpl() | 55 | AddEntryWndImpl::~AddEntryWndImpl() |
56 | { | 56 | { |
57 | #ifndef PWM_EMBEDDED | 57 | #ifndef PWM_EMBEDDED |
58 | delete_ifnot_null(editAdvCommentButton); | 58 | delete_ifnot_null(editAdvCommentButton); |
59 | delete_ifnot_null(commentTextEdit); | 59 | delete_ifnot_null(commentTextEdit); |
60 | #endif | 60 | #endif |
61 | delete pwGen; | 61 | delete pwGen; |
62 | } | 62 | } |
63 | 63 | ||
64 | #ifdef PWM_EMBEDDED | 64 | #ifdef PWM_EMBEDDED |
65 | void AddEntryWndImpl::slotOk() | 65 | void AddEntryWndImpl::slotOk() |
66 | { | 66 | { |
67 | slotApply(); | 67 | slotApply(); |
68 | 68 | ||
69 | if (pwLineEdit->text().isEmpty()) { | 69 | if (pwLineEdit->text().isEmpty()) { |
70 | KMessageBox::error(this, | 70 | KMessageBox::error(this, |
71 | i18n("Sorry, you haven't set a password."), | 71 | i18n("Sorry, you haven't set a password."), |
72 | i18n("no password")); | 72 | i18n("no password")); |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | 75 | ||
76 | if (descLineEdit->text().isEmpty()) { | 76 | if (descLineEdit->text().isEmpty()) { |
77 | KMessageBox::error(this, | 77 | KMessageBox::error(this, |
78 | i18n("You haven't set a \"Description\"."), | 78 | i18n("You haven't set a \"Description\"."), |
79 | i18n("Description not set")); | 79 | i18n("Description not set")); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | KDialogBase::slotOk(); | 83 | KDialogBase::slotOk(); |
84 | } | 84 | } |
85 | #else | 85 | #else |
86 | 86 | ||
87 | void AddEntryWndImpl::okButton_slot() | 87 | void AddEntryWndImpl::okButton_slot() |
88 | { | 88 | { |
89 | if (pwLineEdit->text().isEmpty()) { | 89 | if (pwLineEdit->text().isEmpty()) { |
90 | KMessageBox::error(this, | 90 | KMessageBox::error(this, |
91 | i18n("Sorry, you haven't set a password."), | 91 | i18n("Sorry, you haven't set a password."), |
92 | i18n("no password")); | 92 | i18n("no password")); |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | if (descLineEdit->text().isEmpty()) { | 95 | if (descLineEdit->text().isEmpty()) { |
96 | KMessageBox::error(this, | 96 | KMessageBox::error(this, |
97 | i18n | 97 | i18n |
98 | ("You haven't set a \"Description\"."), | 98 | ("You haven't set a \"Description\"."), |
99 | i18n("Description not set")); | 99 | i18n("Description not set")); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | done(1); | 102 | done(1); |
103 | } | 103 | } |
104 | 104 | ||
105 | void AddEntryWndImpl::cancelButton_slot() | 105 | void AddEntryWndImpl::cancelButton_slot() |
106 | { | 106 | { |
107 | done(2); | 107 | done(2); |
108 | } | 108 | } |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | void AddEntryWndImpl::setCurrCategory(const QString &cat) | 111 | void AddEntryWndImpl::setCurrCategory(const QString &cat) |
112 | { | 112 | { |
113 | int i, count = categoryComboBox->count(); | 113 | int i, count = categoryComboBox->count(); |
114 | 114 | ||
115 | for (i = 0; i < count; ++i) { | 115 | for (i = 0; i < count; ++i) { |
116 | if (categoryComboBox->text(i) == cat) { | 116 | if (categoryComboBox->text(i) == cat) { |
117 | categoryComboBox->setCurrentItem(i); | 117 | categoryComboBox->setCurrentItem(i); |
118 | #ifdef PWM_EMBEDDED | ||
119 | categorySelected(cat); | ||
120 | #endif | ||
118 | return; | 121 | return; |
119 | } | 122 | } |
120 | } | 123 | } |
121 | BUG(); | 124 | BUG(); |
122 | } | 125 | } |
123 | 126 | ||
124 | void AddEntryWndImpl::revealButton_slot() | 127 | void AddEntryWndImpl::revealButton_slot() |
125 | { | 128 | { |
126 | if (revealButton->isOn()) { | 129 | if (revealButton->isOn()) { |
127 | pwLineEdit->setEchoMode(QLineEdit::Normal); | 130 | pwLineEdit->setEchoMode(QLineEdit::Normal); |
128 | } else { | 131 | } else { |
129 | pwLineEdit->setEchoMode(QLineEdit::Password); | 132 | pwLineEdit->setEchoMode(QLineEdit::Password); |
130 | } | 133 | } |
131 | } | 134 | } |
132 | 135 | ||
133 | void AddEntryWndImpl::generateButton_slot() | 136 | void AddEntryWndImpl::generateButton_slot() |
134 | { | 137 | { |
135 | if (!pwGen->exec()) | 138 | if (!pwGen->exec()) |
136 | return; | 139 | return; |
137 | setPassword(pwGen->getPassword()); | 140 | setPassword(pwGen->getPassword()); |
138 | } | 141 | } |
139 | 142 | ||
140 | QString AddEntryWndImpl::getComment() | 143 | QString AddEntryWndImpl::getComment() |
141 | { | 144 | { |
142 | #ifndef PWM_EMBEDDED | 145 | #ifndef PWM_EMBEDDED |
143 | if (isAdvancedComment()) { | 146 | if (isAdvancedComment()) { |
144 | return advCommentDta; | 147 | return advCommentDta; |
145 | } | 148 | } |
146 | #endif | 149 | #endif |
147 | return commentTextEdit->text(); | 150 | return commentTextEdit->text(); |
148 | } | 151 | } |
149 | 152 | ||
150 | void AddEntryWndImpl::setComment(const QString &comm) | 153 | void AddEntryWndImpl::setComment(const QString &comm) |
151 | { | 154 | { |
152 | #ifndef PWM_EMBEDDED | 155 | #ifndef PWM_EMBEDDED |
153 | if (HtmlGen::isHtml(comm)) { | 156 | if (HtmlGen::isHtml(comm)) { |
154 | advancedCommentButton->setOn(true); | 157 | advancedCommentButton->setOn(true); |
155 | advCommentDta = comm; | 158 | advCommentDta = comm; |
156 | } else { | 159 | } else { |
157 | advancedCommentButton->setOn(false); | 160 | advancedCommentButton->setOn(false); |
158 | commentTextEdit->setText(comm); | 161 | commentTextEdit->setText(comm); |
159 | } | 162 | } |
160 | #else | 163 | #else |
161 | commentTextEdit->setText(comm); | 164 | commentTextEdit->setText(comm); |
162 | #endif | 165 | #endif |
163 | } | 166 | } |
164 | 167 | ||
165 | void AddEntryWndImpl::advancedCommentButton_slot(bool on) | 168 | void AddEntryWndImpl::advancedCommentButton_slot(bool on) |
166 | { | 169 | { |
167 | #ifndef PWM_EMBEDDED | 170 | #ifndef PWM_EMBEDDED |
168 | switchComment(on); | 171 | switchComment(on); |
169 | #endif | 172 | #endif |
170 | } | 173 | } |
171 | 174 | ||
172 | void AddEntryWndImpl::switchComment(bool toAdvanced) | 175 | void AddEntryWndImpl::switchComment(bool toAdvanced) |
173 | { | 176 | { |
174 | #ifndef PWM_EMBEDDED | 177 | #ifndef PWM_EMBEDDED |
175 | 178 | ||
176 | useAdvComment = toAdvanced; | 179 | useAdvComment = toAdvanced; |
177 | if (toAdvanced) { | 180 | if (toAdvanced) { |
178 | if (commentTextEdit) { | 181 | if (commentTextEdit) { |
179 | savedCommentText = commentTextEdit->text(); | 182 | savedCommentText = commentTextEdit->text(); |
180 | delete_and_null(commentTextEdit); | 183 | delete_and_null(commentTextEdit); |
181 | } | 184 | } |
182 | if (editAdvCommentButton) | 185 | if (editAdvCommentButton) |
183 | return; | 186 | return; |
184 | editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."), | 187 | editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."), |
185 | commentDummy); | 188 | commentDummy); |
186 | editAdvCommentButton->resize(commentDummy->size().width(), 50); | 189 | editAdvCommentButton->resize(commentDummy->size().width(), 50); |
187 | connect(editAdvCommentButton, SIGNAL(clicked()), | 190 | connect(editAdvCommentButton, SIGNAL(clicked()), |
188 | this, SLOT(editAdvCommentButton_slot())); | 191 | this, SLOT(editAdvCommentButton_slot())); |
189 | editAdvCommentButton->show(); | 192 | editAdvCommentButton->show(); |
190 | } else { | 193 | } else { |
191 | delete_ifnot_null(editAdvCommentButton); | 194 | delete_ifnot_null(editAdvCommentButton); |
192 | if (commentTextEdit) | 195 | if (commentTextEdit) |
193 | return; | 196 | return; |
194 | 197 | ||
195 | commentTextEdit = new QTextEdit(commentDummy); | 198 | commentTextEdit = new QTextEdit(commentDummy); |
196 | commentTextEdit->setTextFormat(Qt::PlainText); | 199 | commentTextEdit->setTextFormat(Qt::PlainText); |
197 | commentTextEdit->resize(commentDummy->size()); | 200 | commentTextEdit->resize(commentDummy->size()); |
198 | commentTextEdit->setText(savedCommentText); | 201 | commentTextEdit->setText(savedCommentText); |
199 | commentTextEdit->show(); | 202 | commentTextEdit->show(); |
200 | } | 203 | } |
201 | #endif | 204 | #endif |
202 | } | 205 | } |
203 | 206 | ||
204 | void AddEntryWndImpl::editAdvCommentButton_slot() | 207 | void AddEntryWndImpl::editAdvCommentButton_slot() |
205 | { | 208 | { |
206 | #ifndef PWM_EMBEDDED | 209 | #ifndef PWM_EMBEDDED |
207 | AdvCommEditImpl editor(this); | 210 | AdvCommEditImpl editor(this); |
208 | editor.setHtmlDta(advCommentDta); | 211 | editor.setHtmlDta(advCommentDta); |
209 | if (editor.exec()) | 212 | if (editor.exec()) |
210 | return; | 213 | return; |
211 | advCommentDta = editor.getHtmlDta(); | 214 | advCommentDta = editor.getHtmlDta(); |
212 | #endif | 215 | #endif |
213 | } | 216 | } |
214 | 217 | ||
215 | #ifndef PWM_EMBEDDED | 218 | #ifndef PWM_EMBEDDED |
216 | #include "addentrywndimpl.moc" | 219 | #include "addentrywndimpl.moc" |
217 | #endif | 220 | #endif |
diff --git a/pwmanager/pwmanager/addentrywndimpl.h b/pwmanager/pwmanager/addentrywndimpl.h index ce9a594..e13eb54 100644 --- a/pwmanager/pwmanager/addentrywndimpl.h +++ b/pwmanager/pwmanager/addentrywndimpl.h | |||
@@ -1,127 +1,127 @@ | |||
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 | #ifndef __ADDENTRYWNDIMPL_H | 20 | #ifndef __ADDENTRYWNDIMPL_H |
21 | #define __ADDENTRYWNDIMPL_H | 21 | #define __ADDENTRYWNDIMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | #ifndef PWM_EMBEDDED | 24 | #ifndef PWM_EMBEDDED |
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include <qtextedit.h> | 26 | #include <qtextedit.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | #include "addentrywnd.h" | 28 | #include "addentrywnd.h" |
29 | #else | 29 | #else |
30 | #include <klineedit.h> | 30 | #include <klineedit.h> |
31 | #include <kcombobox.h> | 31 | #include <kcombobox.h> |
32 | #include <qmultilineedit.h> | 32 | #include <qmultilineedit.h> |
33 | #include "addentrywnd_emb.h" | 33 | #include "addentrywnd_emb.h" |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
37 | 37 | ||
38 | class PwGenWndImpl; | 38 | class PwGenWndImpl; |
39 | 39 | ||
40 | /** "add/edit" Window */ | 40 | /** "add/edit" Window */ |
41 | class AddEntryWndImpl : public addEntryWnd | 41 | class AddEntryWndImpl : public addEntryWnd |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | #ifndef PWM_EMBEDDED | 45 | #ifndef PWM_EMBEDDED |
46 | AddEntryWndImpl(); | 46 | AddEntryWndImpl(); |
47 | #else | 47 | #else |
48 | AddEntryWndImpl( QWidget* parent = 0, const char* name = 0); | 48 | AddEntryWndImpl( PwMDoc* doc, QWidget* parent = 0, const char* name = 0); |
49 | #endif | 49 | #endif |
50 | ~AddEntryWndImpl(); | 50 | ~AddEntryWndImpl(); |
51 | 51 | ||
52 | /* get... functions */ | 52 | /* get... functions */ |
53 | QString getDescription() | 53 | QString getDescription() |
54 | { return descLineEdit->text(); } | 54 | { return descLineEdit->text(); } |
55 | QString getCategory() | 55 | QString getCategory() |
56 | { return categoryComboBox->currentText(); } | 56 | { return categoryComboBox->currentText(); } |
57 | QString getUsername() | 57 | QString getUsername() |
58 | { return usernameLineEdit->text(); } | 58 | { return usernameLineEdit->text(); } |
59 | QString getPassword() | 59 | QString getPassword() |
60 | { return pwLineEdit->text(); } | 60 | { return pwLineEdit->text(); } |
61 | QString getUrl() | 61 | QString getUrl() |
62 | { return urlLineEdit->text(); } | 62 | { return urlLineEdit->text(); } |
63 | QString getLauncher() | 63 | QString getLauncher() |
64 | { return launcherLineEdit->text(); } | 64 | { return launcherLineEdit->text(); } |
65 | QString getComment(); | 65 | QString getComment(); |
66 | 66 | ||
67 | /* set... functions */ | 67 | /* set... functions */ |
68 | void setDescription(const QString &desc) | 68 | void setDescription(const QString &desc) |
69 | { descLineEdit->setText(desc); } | 69 | { descLineEdit->setText(desc); } |
70 | void setCurrCategory(const QString &cat); | 70 | void setCurrCategory(const QString &cat); |
71 | void addCategory(const QString &cat) | 71 | void addCategory(const QString &cat) |
72 | { categoryComboBox->insertItem(cat); } | 72 | { categoryComboBox->insertItem(cat); } |
73 | void setUsername(const QString &name) | 73 | void setUsername(const QString &name) |
74 | { usernameLineEdit->setText(name); } | 74 | { usernameLineEdit->setText(name); } |
75 | void setPassword(const QString &pw) | 75 | void setPassword(const QString &pw) |
76 | { pwLineEdit->setText(pw); } | 76 | { pwLineEdit->setText(pw); } |
77 | void setUrl(const QString &url) | 77 | void setUrl(const QString &url) |
78 | { urlLineEdit->setText(url); } | 78 | { urlLineEdit->setText(url); } |
79 | void setLauncher(const QString launcher) | 79 | void setLauncher(const QString launcher) |
80 | { launcherLineEdit->setText(launcher); } | 80 | { launcherLineEdit->setText(launcher); } |
81 | void setComment(const QString &comm); | 81 | void setComment(const QString &comm); |
82 | 82 | ||
83 | /** are we using an advanced comment */ | 83 | /** are we using an advanced comment */ |
84 | bool isAdvancedComment() | 84 | bool isAdvancedComment() |
85 | { return useAdvComment; } | 85 | { return useAdvComment; } |
86 | 86 | ||
87 | public slots: | 87 | public slots: |
88 | #ifndef PWM_EMBEDDED | 88 | #ifndef PWM_EMBEDDED |
89 | //MOC_SKIP_BEGIN | 89 | //MOC_SKIP_BEGIN |
90 | /** OK button pressed */ | 90 | /** OK button pressed */ |
91 | void okButton_slot(); | 91 | void okButton_slot(); |
92 | /** cancel button pressed */ | 92 | /** cancel button pressed */ |
93 | void cancelButton_slot(); | 93 | void cancelButton_slot(); |
94 | //MOC_SKIP_END | 94 | //MOC_SKIP_END |
95 | #else | 95 | #else |
96 | virtual void slotOk(); | 96 | virtual void slotOk(); |
97 | #endif | 97 | #endif |
98 | /** Reveal button pressed */ | 98 | /** Reveal button pressed */ |
99 | void revealButton_slot(); | 99 | void revealButton_slot(); |
100 | /** Generate button pressed */ | 100 | /** Generate button pressed */ |
101 | void generateButton_slot(); | 101 | void generateButton_slot(); |
102 | /** advanced comment button pressed */ | 102 | /** advanced comment button pressed */ |
103 | void advancedCommentButton_slot(bool on); | 103 | void advancedCommentButton_slot(bool on); |
104 | /** edit advanced comment button pressed */ | 104 | /** edit advanced comment button pressed */ |
105 | void editAdvCommentButton_slot(); | 105 | void editAdvCommentButton_slot(); |
106 | 106 | ||
107 | protected: | 107 | protected: |
108 | void switchComment(bool toAdvanced); | 108 | void switchComment(bool toAdvanced); |
109 | 109 | ||
110 | protected: | 110 | protected: |
111 | QPushButton *editAdvCommentButton; | 111 | QPushButton *editAdvCommentButton; |
112 | #ifndef PWM_EMBEDDED | 112 | #ifndef PWM_EMBEDDED |
113 | QTextEdit *commentTextEdit; | 113 | QTextEdit *commentTextEdit; |
114 | #else | 114 | #else |
115 | //nothing here | 115 | //nothing here |
116 | #endif | 116 | #endif |
117 | /** saved data from normal comment text edit box */ | 117 | /** saved data from normal comment text edit box */ |
118 | QString savedCommentText; | 118 | QString savedCommentText; |
119 | /** use an advanced comment? */ | 119 | /** use an advanced comment? */ |
120 | bool useAdvComment; | 120 | bool useAdvComment; |
121 | /** data of advanced comment (if available) */ | 121 | /** data of advanced comment (if available) */ |
122 | QString advCommentDta; | 122 | QString advCommentDta; |
123 | /** password generation object */ | 123 | /** password generation object */ |
124 | PwGenWndImpl *pwGen; | 124 | PwGenWndImpl *pwGen; |
125 | }; | 125 | }; |
126 | 126 | ||
127 | #endif | 127 | #endif |
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index bd98d72..9642a43 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -252,868 +252,868 @@ void PwM::initMenubar() | |||
252 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), | 252 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), |
253 | i18n("&Save"), this, | 253 | i18n("&Save"), this, |
254 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); | 254 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); |
255 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), | 255 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), |
256 | i18n("Save &as..."), | 256 | i18n("Save &as..."), |
257 | this, SLOT(saveAs_slot()), 0, | 257 | this, SLOT(saveAs_slot()), 0, |
258 | BUTTON_POPUP_FILE_SAVEAS); | 258 | BUTTON_POPUP_FILE_SAVEAS); |
259 | filePopup->insertSeparator(); | 259 | filePopup->insertSeparator(); |
260 | // "file/export" popup menu | 260 | // "file/export" popup menu |
261 | exportPopup->insertItem(i18n("&Text-file..."), this, | 261 | exportPopup->insertItem(i18n("&Text-file..."), this, |
262 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); | 262 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); |
263 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 263 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
264 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); | 264 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); |
265 | exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, | 265 | exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, |
266 | SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); | 266 | SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); |
267 | #ifdef CONFIG_KWALLETIF | 267 | #ifdef CONFIG_KWALLETIF |
268 | exportPopup->insertItem(i18n("&KWallet..."), this, | 268 | exportPopup->insertItem(i18n("&KWallet..."), this, |
269 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); | 269 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); |
270 | #endif | 270 | #endif |
271 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), | 271 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), |
272 | i18n("E&xport"), exportPopup, | 272 | i18n("E&xport"), exportPopup, |
273 | BUTTON_POPUP_FILE_EXPORT); | 273 | BUTTON_POPUP_FILE_EXPORT); |
274 | // "file/import" popup menu | 274 | // "file/import" popup menu |
275 | importPopup->insertItem(i18n("&Text-file..."), this, | 275 | importPopup->insertItem(i18n("&Text-file..."), this, |
276 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); | 276 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); |
277 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 277 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
278 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); | 278 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); |
279 | importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, | 279 | importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, |
280 | SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); | 280 | SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); |
281 | #ifdef CONFIG_KWALLETIF | 281 | #ifdef CONFIG_KWALLETIF |
282 | importPopup->insertItem(i18n("&KWallet..."), this, | 282 | importPopup->insertItem(i18n("&KWallet..."), this, |
283 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); | 283 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); |
284 | #endif | 284 | #endif |
285 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), | 285 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), |
286 | i18n("I&mport"), importPopup, | 286 | i18n("I&mport"), importPopup, |
287 | BUTTON_POPUP_FILE_IMPORT); | 287 | BUTTON_POPUP_FILE_IMPORT); |
288 | filePopup->insertSeparator(); | 288 | filePopup->insertSeparator(); |
289 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), | 289 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), |
290 | i18n("&Print..."), this, | 290 | i18n("&Print..."), this, |
291 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); | 291 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); |
292 | filePopup->insertSeparator(); | 292 | filePopup->insertSeparator(); |
293 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), | 293 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), |
294 | i18n("&Quit"), this, | 294 | i18n("&Quit"), this, |
295 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); | 295 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); |
296 | menuBar()->insertItem(i18n("&File"), filePopup); | 296 | menuBar()->insertItem(i18n("&File"), filePopup); |
297 | // "manage" popup menu | 297 | // "manage" popup menu |
298 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), | 298 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), |
299 | i18n("&Add password"), this, | 299 | i18n("&Add password"), this, |
300 | SLOT(addPwd_slot()), 0, | 300 | SLOT(addPwd_slot()), 0, |
301 | BUTTON_POPUP_MANAGE_ADD); | 301 | BUTTON_POPUP_MANAGE_ADD); |
302 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), | 302 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), |
303 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, | 303 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, |
304 | BUTTON_POPUP_MANAGE_EDIT); | 304 | BUTTON_POPUP_MANAGE_EDIT); |
305 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 305 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
306 | i18n("&Delete"), this, SLOT(deletePwd_slot()), | 306 | i18n("&Delete"), this, SLOT(deletePwd_slot()), |
307 | 0, BUTTON_POPUP_MANAGE_DEL); | 307 | 0, BUTTON_POPUP_MANAGE_DEL); |
308 | managePopup->insertSeparator(); | 308 | managePopup->insertSeparator(); |
309 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), | 309 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), |
310 | i18n("Change &Master Password"), this, | 310 | i18n("Change &Master Password"), this, |
311 | SLOT(changeMasterPwd_slot()), 0, | 311 | SLOT(changeMasterPwd_slot()), 0, |
312 | BUTTON_POPUP_MANAGE_CHANGEMP); | 312 | BUTTON_POPUP_MANAGE_CHANGEMP); |
313 | menuBar()->insertItem(i18n("&Manage"), managePopup); | 313 | menuBar()->insertItem(i18n("&Manage"), managePopup); |
314 | // "chipcard" popup menu | 314 | // "chipcard" popup menu |
315 | #ifdef CONFIG_KEYCARD | 315 | #ifdef CONFIG_KEYCARD |
316 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 316 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
317 | i18n("&Generate new key-card"), this, | 317 | i18n("&Generate new key-card"), this, |
318 | SLOT(genNewCard_slot()), 0, | 318 | SLOT(genNewCard_slot()), 0, |
319 | BUTTON_POPUP_CHIPCARD_GENNEW); | 319 | BUTTON_POPUP_CHIPCARD_GENNEW); |
320 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 320 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
321 | i18n("&Erase key-card"), this, | 321 | i18n("&Erase key-card"), this, |
322 | SLOT(eraseCard_slot()), 0, | 322 | SLOT(eraseCard_slot()), 0, |
323 | BUTTON_POPUP_CHIPCARD_DEL); | 323 | BUTTON_POPUP_CHIPCARD_DEL); |
324 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), | 324 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), |
325 | i18n("Read card-&ID"), this, | 325 | i18n("Read card-&ID"), this, |
326 | SLOT(readCardId_slot()), 0, | 326 | SLOT(readCardId_slot()), 0, |
327 | BUTTON_POPUP_CHIPCARD_READID); | 327 | BUTTON_POPUP_CHIPCARD_READID); |
328 | chipcardPopup->insertSeparator(); | 328 | chipcardPopup->insertSeparator(); |
329 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), | 329 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), |
330 | i18n("&Make card backup-image"), this, | 330 | i18n("&Make card backup-image"), this, |
331 | SLOT(makeCardBackup_slot()), 0, | 331 | SLOT(makeCardBackup_slot()), 0, |
332 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); | 332 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); |
333 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), | 333 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), |
334 | i18n("&Replay card backup-image"), this, | 334 | i18n("&Replay card backup-image"), this, |
335 | SLOT(replayCardBackup_slot()), 0, | 335 | SLOT(replayCardBackup_slot()), 0, |
336 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); | 336 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); |
337 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); | 337 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); |
338 | #endif // CONFIG_KEYCARD | 338 | #endif // CONFIG_KEYCARD |
339 | // "view" popup menu | 339 | // "view" popup menu |
340 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), | 340 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), |
341 | i18n("&Find"), this, | 341 | i18n("&Find"), this, |
342 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); | 342 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); |
343 | viewPopup->insertSeparator(); | 343 | viewPopup->insertSeparator(); |
344 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), | 344 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), |
345 | i18n("&Lock all entries"), this, | 345 | i18n("&Lock all entries"), this, |
346 | SLOT(lockWnd_slot()), 0, | 346 | SLOT(lockWnd_slot()), 0, |
347 | BUTTON_POPUP_VIEW_LOCK); | 347 | BUTTON_POPUP_VIEW_LOCK); |
348 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), | 348 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), |
349 | i18n("&Deep-lock all entries"), this, | 349 | i18n("&Deep-lock all entries"), this, |
350 | SLOT(deepLockWnd_slot()), 0, | 350 | SLOT(deepLockWnd_slot()), 0, |
351 | BUTTON_POPUP_VIEW_DEEPLOCK); | 351 | BUTTON_POPUP_VIEW_DEEPLOCK); |
352 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), | 352 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), |
353 | i18n("&Unlock all entries"), this, | 353 | i18n("&Unlock all entries"), this, |
354 | SLOT(unlockWnd_slot()), 0, | 354 | SLOT(unlockWnd_slot()), 0, |
355 | BUTTON_POPUP_VIEW_UNLOCK); | 355 | BUTTON_POPUP_VIEW_UNLOCK); |
356 | menuBar()->insertItem(i18n("&View"), viewPopup); | 356 | menuBar()->insertItem(i18n("&View"), viewPopup); |
357 | // "options" popup menu | 357 | // "options" popup menu |
358 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), | 358 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), |
359 | i18n("&Configure..."), this, | 359 | i18n("&Configure..."), this, |
360 | SLOT(config_slot()), | 360 | SLOT(config_slot()), |
361 | BUTTON_POPUP_OPTIONS_CONFIG); | 361 | BUTTON_POPUP_OPTIONS_CONFIG); |
362 | menuBar()->insertItem(i18n("&Options"), optionsPopup); | 362 | menuBar()->insertItem(i18n("&Options"), optionsPopup); |
363 | // "help" popup menu | 363 | // "help" popup menu |
364 | #ifndef PWM_EMBEDDED | 364 | #ifndef PWM_EMBEDDED |
365 | helpPopup = helpMenu(QString::null, false); | 365 | helpPopup = helpMenu(QString::null, false); |
366 | #else | 366 | #else |
367 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), | 367 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), |
368 | i18n("C&ategories..."), this, | 368 | i18n("C&ategories..."), this, |
369 | SLOT(category_slot()), | 369 | SLOT(category_slot()), |
370 | BUTTON_POPUP_OPTIONS_CATEGORY); | 370 | BUTTON_POPUP_OPTIONS_CATEGORY); |
371 | 371 | ||
372 | 372 | ||
373 | menuBar()->insertItem(i18n("&Sync"), syncPopup); | 373 | menuBar()->insertItem(i18n("&Sync"), syncPopup); |
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | 377 | ||
378 | 378 | ||
379 | helpPopup = new KPopupMenu(this); | 379 | helpPopup = new KPopupMenu(this); |
380 | 380 | ||
381 | 381 | ||
382 | helpPopup->insertItem(i18n("&License"), this, | 382 | helpPopup->insertItem(i18n("&License"), this, |
383 | SLOT(showLicense_slot()), 0, | 383 | SLOT(showLicense_slot()), 0, |
384 | BUTTON_POPUP_HELP_LICENSE); | 384 | BUTTON_POPUP_HELP_LICENSE); |
385 | 385 | ||
386 | helpPopup->insertItem(i18n("&Faq"), this, | 386 | helpPopup->insertItem(i18n("&Faq"), this, |
387 | SLOT(faq_slot()), 0, | 387 | SLOT(faq_slot()), 0, |
388 | BUTTON_POPUP_HELP_FAQ); | 388 | BUTTON_POPUP_HELP_FAQ); |
389 | 389 | ||
390 | helpPopup->insertItem(i18n("&About PwManager"), this, | 390 | helpPopup->insertItem(i18n("&About PwManager"), this, |
391 | SLOT(createAboutData_slot()), 0, | 391 | SLOT(createAboutData_slot()), 0, |
392 | BUTTON_POPUP_HELP_ABOUT); | 392 | BUTTON_POPUP_HELP_ABOUT); |
393 | 393 | ||
394 | helpPopup->insertItem(i18n("&Sync HowTo"), this, | 394 | helpPopup->insertItem(i18n("&Sync HowTo"), this, |
395 | SLOT(syncHowTo_slot()), 0, | 395 | SLOT(syncHowTo_slot()), 0, |
396 | BUTTON_POPUP_HELP_SYNC); | 396 | BUTTON_POPUP_HELP_SYNC); |
397 | 397 | ||
398 | helpPopup->insertItem(i18n("&What's New"), this, | 398 | helpPopup->insertItem(i18n("&What's New"), this, |
399 | SLOT(whatsnew_slot()), 0, | 399 | SLOT(whatsnew_slot()), 0, |
400 | BUTTON_POPUP_HELP_WHATSNEW); | 400 | BUTTON_POPUP_HELP_WHATSNEW); |
401 | 401 | ||
402 | #endif | 402 | #endif |
403 | menuBar()->insertItem(i18n("&Help"), helpPopup); | 403 | menuBar()->insertItem(i18n("&Help"), helpPopup); |
404 | 404 | ||
405 | } | 405 | } |
406 | 406 | ||
407 | void PwM::initToolbar() | 407 | void PwM::initToolbar() |
408 | { | 408 | { |
409 | KIconLoader* picons; | 409 | KIconLoader* picons; |
410 | #ifndef PWM_EMBEDDED | 410 | #ifndef PWM_EMBEDDED |
411 | KIconLoader icons; | 411 | KIconLoader icons; |
412 | picons = &icons; | 412 | picons = &icons; |
413 | #else | 413 | #else |
414 | picons = KGlobal::iconLoader(); | 414 | picons = KGlobal::iconLoader(); |
415 | #endif | 415 | #endif |
416 | 416 | ||
417 | #ifdef PWM_EMBEDDED | 417 | #ifdef PWM_EMBEDDED |
418 | if ( QApplication::desktop()->width() > 320 ) | 418 | if ( QApplication::desktop()->width() > 320 ) |
419 | #endif | 419 | #endif |
420 | { | 420 | { |
421 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), | 421 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), |
422 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, | 422 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, |
423 | SLOT(new_slot()), true, i18n("New")); | 423 | SLOT(new_slot()), true, i18n("New")); |
424 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), | 424 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), |
425 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, | 425 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, |
426 | SLOT(open_slot()), true, i18n("Open")); | 426 | SLOT(open_slot()), true, i18n("Open")); |
427 | toolBar()->insertSeparator(); | 427 | toolBar()->insertSeparator(); |
428 | } | 428 | } |
429 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), | 429 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), |
430 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, | 430 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, |
431 | SLOT(save_slot()), true, i18n("Save")); | 431 | SLOT(save_slot()), true, i18n("Save")); |
432 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), | 432 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), |
433 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, | 433 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, |
434 | SLOT(saveAs_slot()), true, i18n("Save as")); | 434 | SLOT(saveAs_slot()), true, i18n("Save as")); |
435 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), | 435 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), |
436 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, | 436 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, |
437 | SLOT(print_slot()), true, i18n("Print...")); | 437 | SLOT(print_slot()), true, i18n("Print...")); |
438 | toolBar()->insertSeparator(); | 438 | toolBar()->insertSeparator(); |
439 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), | 439 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), |
440 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, | 440 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, |
441 | SLOT(addPwd_slot()), true, | 441 | SLOT(addPwd_slot()), true, |
442 | i18n("Add password")); | 442 | i18n("Add password")); |
443 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), | 443 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), |
444 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, | 444 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, |
445 | SLOT(editPwd_slot()), true, | 445 | SLOT(editPwd_slot()), true, |
446 | i18n("Edit password")); | 446 | i18n("Edit password")); |
447 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), | 447 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), |
448 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, | 448 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, |
449 | SLOT(deletePwd_slot()), true, | 449 | SLOT(deletePwd_slot()), true, |
450 | i18n("Delete password")); | 450 | i18n("Delete password")); |
451 | toolBar()->insertSeparator(); | 451 | toolBar()->insertSeparator(); |
452 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), | 452 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), |
453 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, | 453 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, |
454 | SLOT(find_slot()), true, i18n("Find entry")); | 454 | SLOT(find_slot()), true, i18n("Find entry")); |
455 | toolBar()->insertSeparator(); | 455 | toolBar()->insertSeparator(); |
456 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), | 456 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), |
457 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, | 457 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, |
458 | SLOT(lockWnd_slot()), true, | 458 | SLOT(lockWnd_slot()), true, |
459 | i18n("Lock all entries")); | 459 | i18n("Lock all entries")); |
460 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), | 460 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), |
461 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, | 461 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, |
462 | SLOT(deepLockWnd_slot()), true, | 462 | SLOT(deepLockWnd_slot()), true, |
463 | i18n("Deep-Lock all entries")); | 463 | i18n("Deep-Lock all entries")); |
464 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), | 464 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), |
465 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, | 465 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, |
466 | SLOT(unlockWnd_slot()), true, | 466 | SLOT(unlockWnd_slot()), true, |
467 | i18n("Unlock all entries")); | 467 | i18n("Unlock all entries")); |
468 | } | 468 | } |
469 | 469 | ||
470 | void PwM::initMetrics() | 470 | void PwM::initMetrics() |
471 | { | 471 | { |
472 | QSize s = conf()->confWndMainWndSize(); | 472 | QSize s = conf()->confWndMainWndSize(); |
473 | if (s.isValid()) | 473 | if (s.isValid()) |
474 | resize(s); | 474 | resize(s); |
475 | else | 475 | else |
476 | resize(DEFAULT_SIZE); | 476 | resize(DEFAULT_SIZE); |
477 | } | 477 | } |
478 | 478 | ||
479 | void PwM::updateCaption() | 479 | void PwM::updateCaption() |
480 | { | 480 | { |
481 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); | 481 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); |
482 | } | 482 | } |
483 | 483 | ||
484 | void PwM::hideEvent(QHideEvent *) | 484 | void PwM::hideEvent(QHideEvent *) |
485 | { | 485 | { |
486 | if (isMinimized()) { | 486 | if (isMinimized()) { |
487 | if (init->tray()) { | 487 | if (init->tray()) { |
488 | forceMinimizeToTray = true; | 488 | forceMinimizeToTray = true; |
489 | close(); | 489 | close(); |
490 | } | 490 | } |
491 | int mmlock = conf()->confGlobMinimizeLock(); | 491 | int mmlock = conf()->confGlobMinimizeLock(); |
492 | switch (mmlock) { | 492 | switch (mmlock) { |
493 | case 0: // don't lock anything | 493 | case 0: // don't lock anything |
494 | break; | 494 | break; |
495 | case 1: {// normal lock | 495 | case 1: {// normal lock |
496 | curDoc()->lockAll(true); | 496 | curDoc()->lockAll(true); |
497 | break; | 497 | break; |
498 | } case 2: {// deep-lock | 498 | } case 2: {// deep-lock |
499 | curDoc()->deepLock(); | 499 | curDoc()->deepLock(); |
500 | break; | 500 | break; |
501 | } default: | 501 | } default: |
502 | WARN(); | 502 | WARN(); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | } | 505 | } |
506 | 506 | ||
507 | void PwM::setVirgin(bool v) | 507 | void PwM::setVirgin(bool v) |
508 | { | 508 | { |
509 | if (virgin == v) | 509 | if (virgin == v) |
510 | return; | 510 | return; |
511 | virgin = v; | 511 | virgin = v; |
512 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); | 512 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); |
513 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); | 513 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); |
514 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); | 514 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); |
515 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); | 515 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); |
516 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); | 516 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); |
517 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); | 517 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); |
518 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); | 518 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); |
519 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); | 519 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); |
520 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); | 520 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); |
521 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); | 521 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); |
522 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); | 522 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); |
523 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); | 523 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); |
524 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); | 524 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); |
525 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); | 525 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); |
526 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); | 526 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); |
527 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); | 527 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); |
528 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); | 528 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); |
529 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); | 529 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); |
530 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); | 530 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); |
531 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); | 531 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); |
532 | } | 532 | } |
533 | 533 | ||
534 | void PwM::new_slot() | 534 | void PwM::new_slot() |
535 | { | 535 | { |
536 | init->createMainWnd(); | 536 | init->createMainWnd(); |
537 | } | 537 | } |
538 | 538 | ||
539 | //US ENH | 539 | //US ENH |
540 | void PwM::open_slot() | 540 | void PwM::open_slot() |
541 | { | 541 | { |
542 | open_slot(""); | 542 | open_slot(""); |
543 | } | 543 | } |
544 | 544 | ||
545 | void PwM::open_slot(QString fn) | 545 | void PwM::open_slot(QString fn) |
546 | { | 546 | { |
547 | openDoc(fn); | 547 | openDoc(fn); |
548 | } | 548 | } |
549 | 549 | ||
550 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) | 550 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) |
551 | { | 551 | { |
552 | if (!isVirgin()) { | 552 | if (!isVirgin()) { |
553 | // open the document in a new window. | 553 | // open the document in a new window. |
554 | PwM *newInstance = init->createMainWnd(); | 554 | PwM *newInstance = init->createMainWnd(); |
555 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); | 555 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); |
556 | if (!newDoc) { | 556 | if (!newDoc) { |
557 | newInstance->setForceQuit(true); | 557 | newInstance->setForceQuit(true); |
558 | delete_and_null(newInstance); | 558 | delete_and_null(newInstance); |
559 | } | 559 | } |
560 | return newDoc; | 560 | return newDoc; |
561 | } | 561 | } |
562 | 562 | ||
563 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) | 563 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) |
564 | return 0; | 564 | return 0; |
565 | showStatMsg(i18n("Successfully opened file.")); | 565 | showStatMsg(i18n("Successfully opened file.")); |
566 | updateCaption(); | 566 | updateCaption(); |
567 | setVirgin(false); | 567 | setVirgin(false); |
568 | return curDoc(); | 568 | return curDoc(); |
569 | } | 569 | } |
570 | 570 | ||
571 | PwMView * PwM::makeNewListView(PwMDoc *doc) | 571 | PwMView * PwM::makeNewListView(PwMDoc *doc) |
572 | { | 572 | { |
573 | PwMView *ret = new PwMView(this, this, doc); | 573 | PwMView *ret = new PwMView(this, this, doc); |
574 | ret->setFont(conf()->confGlobEntryFont()); | 574 | ret->setFont(conf()->confGlobEntryFont()); |
575 | ret->show(); | 575 | ret->show(); |
576 | return ret; | 576 | return ret; |
577 | } | 577 | } |
578 | 578 | ||
579 | void PwM::close_slot() | 579 | void PwM::close_slot() |
580 | { | 580 | { |
581 | close(); | 581 | close(); |
582 | } | 582 | } |
583 | 583 | ||
584 | void PwM::quitButton_slot() | 584 | void PwM::quitButton_slot() |
585 | { | 585 | { |
586 | init->shutdownApp(0); | 586 | init->shutdownApp(0); |
587 | } | 587 | } |
588 | 588 | ||
589 | void PwM::save_slot() | 589 | void PwM::save_slot() |
590 | { | 590 | { |
591 | save(); | 591 | save(); |
592 | } | 592 | } |
593 | 593 | ||
594 | bool PwM::save() | 594 | bool PwM::save() |
595 | { | 595 | { |
596 | if (!curDoc()->saveDocUi(curDoc())) | 596 | if (!curDoc()->saveDocUi(curDoc())) |
597 | return false; | 597 | return false; |
598 | showStatMsg(i18n("Successfully saved data.")); | 598 | showStatMsg(i18n("Successfully saved data.")); |
599 | updateCaption(); | 599 | updateCaption(); |
600 | return true; | 600 | return true; |
601 | } | 601 | } |
602 | 602 | ||
603 | void PwM::saveAs_slot() | 603 | void PwM::saveAs_slot() |
604 | { | 604 | { |
605 | saveAs(); | 605 | saveAs(); |
606 | } | 606 | } |
607 | 607 | ||
608 | bool PwM::saveAs() | 608 | bool PwM::saveAs() |
609 | { | 609 | { |
610 | if (!curDoc()->saveAsDocUi(curDoc())) | 610 | if (!curDoc()->saveAsDocUi(curDoc())) |
611 | return false; | 611 | return false; |
612 | showStatMsg(i18n("Successfully saved data.")); | 612 | showStatMsg(i18n("Successfully saved data.")); |
613 | updateCaption(); | 613 | updateCaption(); |
614 | return true; | 614 | return true; |
615 | } | 615 | } |
616 | 616 | ||
617 | //US ENH : changed code to run with older MOC | 617 | //US ENH : changed code to run with older MOC |
618 | void PwM::addPwd_slot() | 618 | void PwM::addPwd_slot() |
619 | { | 619 | { |
620 | addPwd_slot1(0, 0); | 620 | addPwd_slot1(0, 0); |
621 | } | 621 | } |
622 | 622 | ||
623 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) | 623 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) |
624 | { | 624 | { |
625 | PwMDoc *doc; | 625 | PwMDoc *doc; |
626 | if (_doc) { | 626 | if (_doc) { |
627 | doc = _doc; | 627 | doc = _doc; |
628 | } else { | 628 | } else { |
629 | doc = curDoc(); | 629 | doc = curDoc(); |
630 | } | 630 | } |
631 | PWM_ASSERT(doc); | 631 | PWM_ASSERT(doc); |
632 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 632 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
633 | #ifndef PWM_EMBEDDED | 633 | #ifndef PWM_EMBEDDED |
634 | AddEntryWndImpl w; | 634 | AddEntryWndImpl w; |
635 | #else | 635 | #else |
636 | AddEntryWndImpl w(this, "addentrywndimpl"); | 636 | AddEntryWndImpl w(doc, this, "addentrywndimpl"); |
637 | #endif | 637 | #endif |
638 | 638 | ||
639 | vector<string> catList; | 639 | vector<string> catList; |
640 | doc->getCategoryList(&catList); | 640 | doc->getCategoryList(&catList); |
641 | unsigned i, size = catList.size(); | 641 | unsigned i, size = catList.size(); |
642 | for (i = 0; i < size; ++i) { | 642 | for (i = 0; i < size; ++i) { |
643 | w.addCategory(catList[i].c_str()); | 643 | w.addCategory(catList[i].c_str()); |
644 | } | 644 | } |
645 | w.setCurrCategory(view->getCurrentCategory()); | 645 | w.setCurrCategory(view->getCurrentCategory()); |
646 | if (pw) | 646 | if (pw) |
647 | w.pwLineEdit->setText(*pw); | 647 | w.pwLineEdit->setText(*pw); |
648 | 648 | ||
649 | tryAgain: | 649 | tryAgain: |
650 | if (w.exec() == 1) | 650 | if (w.exec() == 1) |
651 | { | 651 | { |
652 | PwMDataItem d; | 652 | PwMDataItem d; |
653 | 653 | ||
654 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 654 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
655 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. | 655 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. |
656 | // another option would be to create a constructor for PwMDataItem | 656 | // another option would be to create a constructor for PwMDataItem |
657 | d.clear(true); | 657 | d.clear(true); |
658 | 658 | ||
659 | d.desc = w.getDescription().latin1(); | 659 | d.desc = w.getDescription().latin1(); |
660 | d.name = w.getUsername().latin1(); | 660 | d.name = w.getUsername().latin1(); |
661 | d.pw = w.getPassword().latin1(); | 661 | d.pw = w.getPassword().latin1(); |
662 | d.comment = w.getComment().latin1(); | 662 | d.comment = w.getComment().latin1(); |
663 | d.url = w.getUrl().latin1(); | 663 | d.url = w.getUrl().latin1(); |
664 | d.launcher = w.getLauncher().latin1(); | 664 | d.launcher = w.getLauncher().latin1(); |
665 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 665 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
666 | if (ret == e_entryExists) { | 666 | if (ret == e_entryExists) { |
667 | KMessageBox::error(this, | 667 | KMessageBox::error(this, |
668 | i18n | 668 | i18n |
669 | ("An entry with this \"Description\",\n" | 669 | ("An entry with this \"Description\",\n" |
670 | "does already exist.\n" | 670 | "does already exist.\n" |
671 | "Please select another description."), | 671 | "Please select another description."), |
672 | i18n("entry already exists.")); | 672 | i18n("entry already exists.")); |
673 | goto tryAgain; | 673 | goto tryAgain; |
674 | } else if (ret == e_maxAllowedEntr) { | 674 | } else if (ret == e_maxAllowedEntr) { |
675 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" | 675 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" |
676 | "has been reached.\nYou can't add more entries."), | 676 | "has been reached.\nYou can't add more entries."), |
677 | i18n("maximum number of entries")); | 677 | i18n("maximum number of entries")); |
678 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 678 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
679 | return; | 679 | return; |
680 | } | 680 | } |
681 | } | 681 | } |
682 | setVirgin(false); | 682 | setVirgin(false); |
683 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 683 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
684 | } | 684 | } |
685 | 685 | ||
686 | //US ENH : changed code to run with older MOC | 686 | //US ENH : changed code to run with older MOC |
687 | void PwM::editPwd_slot() | 687 | void PwM::editPwd_slot() |
688 | { | 688 | { |
689 | editPwd_slot3(0,0,0); | 689 | editPwd_slot3(0,0,0); |
690 | } | 690 | } |
691 | 691 | ||
692 | void PwM::editPwd_slot1(const QString *category) | 692 | void PwM::editPwd_slot1(const QString *category) |
693 | { | 693 | { |
694 | editPwd_slot3(category, 0, 0); | 694 | editPwd_slot3(category, 0, 0); |
695 | } | 695 | } |
696 | 696 | ||
697 | void PwM::editPwd_slot3(const QString *category, const int *index, | 697 | void PwM::editPwd_slot3(const QString *category, const int *index, |
698 | PwMDoc *_doc) | 698 | PwMDoc *_doc) |
699 | { | 699 | { |
700 | PwMDoc *doc; | 700 | PwMDoc *doc; |
701 | if (_doc) { | 701 | if (_doc) { |
702 | doc = _doc; | 702 | doc = _doc; |
703 | } else { | 703 | } else { |
704 | doc = curDoc(); | 704 | doc = curDoc(); |
705 | } | 705 | } |
706 | PWM_ASSERT(doc); | 706 | PWM_ASSERT(doc); |
707 | if (doc->isDocEmpty()) | 707 | if (doc->isDocEmpty()) |
708 | return; | 708 | return; |
709 | if (doc->isDeepLocked()) | 709 | if (doc->isDeepLocked()) |
710 | return; | 710 | return; |
711 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 711 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
712 | unsigned int curEntryIndex; | 712 | unsigned int curEntryIndex; |
713 | if (index) { | 713 | if (index) { |
714 | curEntryIndex = *index; | 714 | curEntryIndex = *index; |
715 | } else { | 715 | } else { |
716 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 716 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
717 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 717 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
718 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 718 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
719 | return; | 719 | return; |
720 | } | 720 | } |
721 | } | 721 | } |
722 | QString curCategory; | 722 | QString curCategory; |
723 | if (category) { | 723 | if (category) { |
724 | curCategory = *category; | 724 | curCategory = *category; |
725 | } else { | 725 | } else { |
726 | curCategory = view->getCurrentCategory(); | 726 | curCategory = view->getCurrentCategory(); |
727 | } | 727 | } |
728 | PwMDataItem currItem; | 728 | PwMDataItem currItem; |
729 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 729 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
730 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 730 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
731 | return; | 731 | return; |
732 | } | 732 | } |
733 | BUG_ON(currItem.binary); | 733 | BUG_ON(currItem.binary); |
734 | 734 | ||
735 | AddEntryWndImpl w; | 735 | AddEntryWndImpl w(doc); |
736 | vector<string> catList; | 736 | vector<string> catList; |
737 | doc->getCategoryList(&catList); | 737 | doc->getCategoryList(&catList); |
738 | unsigned i, size = catList.size(); | 738 | unsigned i, size = catList.size(); |
739 | for (i = 0; i < size; ++i) { | 739 | for (i = 0; i < size; ++i) { |
740 | w.addCategory(catList[i].c_str()); | 740 | w.addCategory(catList[i].c_str()); |
741 | } | 741 | } |
742 | w.setCurrCategory(curCategory); | 742 | w.setCurrCategory(curCategory); |
743 | w.setDescription(currItem.desc.c_str()); | 743 | w.setDescription(currItem.desc.c_str()); |
744 | w.setUsername(currItem.name.c_str()); | 744 | w.setUsername(currItem.name.c_str()); |
745 | w.setPassword(currItem.pw.c_str()); | 745 | w.setPassword(currItem.pw.c_str()); |
746 | w.setUrl(currItem.url.c_str()); | 746 | w.setUrl(currItem.url.c_str()); |
747 | w.setLauncher(currItem.launcher.c_str()); | 747 | w.setLauncher(currItem.launcher.c_str()); |
748 | w.setComment(currItem.comment.c_str()); | 748 | w.setComment(currItem.comment.c_str()); |
749 | if (w.exec() == 1) { | 749 | if (w.exec() == 1) { |
750 | currItem.desc = w.getDescription().latin1(); | 750 | currItem.desc = w.getDescription().latin1(); |
751 | currItem.name = w.getUsername().latin1(); | 751 | currItem.name = w.getUsername().latin1(); |
752 | currItem.pw = w.getPassword().latin1(); | 752 | currItem.pw = w.getPassword().latin1(); |
753 | currItem.comment = w.getComment().latin1(); | 753 | currItem.comment = w.getComment().latin1(); |
754 | currItem.url = w.getUrl().latin1(); | 754 | currItem.url = w.getUrl().latin1(); |
755 | currItem.launcher = w.getLauncher().latin1(); | 755 | currItem.launcher = w.getLauncher().latin1(); |
756 | if (!doc->editEntry(curCategory, w.getCategory(), | 756 | if (!doc->editEntry(curCategory, w.getCategory(), |
757 | curEntryIndex, &currItem)) { | 757 | curEntryIndex, &currItem)) { |
758 | KMessageBox::error(this, | 758 | KMessageBox::error(this, |
759 | i18n("Couldn't edit the entry.\n" | 759 | i18n("Couldn't edit the entry.\n" |
760 | "Maybe you changed the category and\n" | 760 | "Maybe you changed the category and\n" |
761 | "this entry is already present\nin the new " | 761 | "this entry is already present\nin the new " |
762 | "category?"), | 762 | "category?"), |
763 | i18n("couldn't edit entry.")); | 763 | i18n("couldn't edit entry.")); |
764 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 764 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
765 | return; | 765 | return; |
766 | } | 766 | } |
767 | } | 767 | } |
768 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 768 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
769 | } | 769 | } |
770 | 770 | ||
771 | void PwM::deletePwd_slot() | 771 | void PwM::deletePwd_slot() |
772 | { | 772 | { |
773 | PWM_ASSERT(curDoc()); | 773 | PWM_ASSERT(curDoc()); |
774 | if (curDoc()->isDocEmpty()) | 774 | if (curDoc()->isDocEmpty()) |
775 | return; | 775 | return; |
776 | if (curDoc()->isDeepLocked()) | 776 | if (curDoc()->isDeepLocked()) |
777 | return; | 777 | return; |
778 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 778 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
779 | unsigned int curEntryIndex = 0; | 779 | unsigned int curEntryIndex = 0; |
780 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 780 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
781 | printDebug("couldn't get index"); | 781 | printDebug("couldn't get index"); |
782 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 782 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
783 | return; | 783 | return; |
784 | } | 784 | } |
785 | 785 | ||
786 | PwMDataItem currItem; | 786 | PwMDataItem currItem; |
787 | QString curCategory = view->getCurrentCategory(); | 787 | QString curCategory = view->getCurrentCategory(); |
788 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 788 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
789 | printDebug("couldn't get entry"); | 789 | printDebug("couldn't get entry"); |
790 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 790 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
791 | return; | 791 | return; |
792 | } | 792 | } |
793 | if (KMessageBox:: | 793 | if (KMessageBox:: |
794 | questionYesNo(this, | 794 | questionYesNo(this, |
795 | i18n | 795 | i18n |
796 | ("Do you really want to delete\nthe selected entry") + | 796 | ("Do you really want to delete\nthe selected entry") + |
797 | " \n\"" + QString(currItem.desc.c_str()) | 797 | " \n\"" + QString(currItem.desc.c_str()) |
798 | + "\" ?", i18n("delete?")) | 798 | + "\" ?", i18n("delete?")) |
799 | == KMessageBox::Yes) { | 799 | == KMessageBox::Yes) { |
800 | 800 | ||
801 | curDoc()->delEntry(curCategory, curEntryIndex); | 801 | curDoc()->delEntry(curCategory, curEntryIndex); |
802 | } | 802 | } |
803 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 803 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
804 | } | 804 | } |
805 | 805 | ||
806 | void PwM::changeMasterPwd_slot() | 806 | void PwM::changeMasterPwd_slot() |
807 | { | 807 | { |
808 | PWM_ASSERT(curDoc()); | 808 | PWM_ASSERT(curDoc()); |
809 | curDoc()->changeCurrentPw(); | 809 | curDoc()->changeCurrentPw(); |
810 | } | 810 | } |
811 | 811 | ||
812 | void PwM::lockWnd_slot() | 812 | void PwM::lockWnd_slot() |
813 | { | 813 | { |
814 | PWM_ASSERT(curDoc()); | 814 | PWM_ASSERT(curDoc()); |
815 | curDoc()->lockAll(true); | 815 | curDoc()->lockAll(true); |
816 | } | 816 | } |
817 | 817 | ||
818 | void PwM::deepLockWnd_slot() | 818 | void PwM::deepLockWnd_slot() |
819 | { | 819 | { |
820 | PWM_ASSERT(curDoc()); | 820 | PWM_ASSERT(curDoc()); |
821 | curDoc()->deepLock(); | 821 | curDoc()->deepLock(); |
822 | } | 822 | } |
823 | 823 | ||
824 | void PwM::unlockWnd_slot() | 824 | void PwM::unlockWnd_slot() |
825 | { | 825 | { |
826 | PWM_ASSERT(curDoc()); | 826 | PWM_ASSERT(curDoc()); |
827 | curDoc()->lockAll(false); | 827 | curDoc()->lockAll(false); |
828 | } | 828 | } |
829 | 829 | ||
830 | void PwM::config_slot() | 830 | void PwM::config_slot() |
831 | { | 831 | { |
832 | int oldStyle = conf()->confWndMainViewStyle(); | 832 | int oldStyle = conf()->confWndMainViewStyle(); |
833 | #ifdef PWM_EMBEDDED | 833 | #ifdef PWM_EMBEDDED |
834 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | 834 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); |
835 | 835 | ||
836 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | 836 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); |
837 | ConfigureDialog->addModule(pwmcfg ); | 837 | ConfigureDialog->addModule(pwmcfg ); |
838 | 838 | ||
839 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 839 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
840 | ConfigureDialog->addModule(kdelibcfg ); | 840 | ConfigureDialog->addModule(kdelibcfg ); |
841 | 841 | ||
842 | #ifndef DESKTOP_VERSION | 842 | #ifndef DESKTOP_VERSION |
843 | ConfigureDialog->showMaximized(); | 843 | ConfigureDialog->showMaximized(); |
844 | #endif | 844 | #endif |
845 | if ( ConfigureDialog->exec() ) | 845 | if ( ConfigureDialog->exec() ) |
846 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 846 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
847 | delete ConfigureDialog; | 847 | delete ConfigureDialog; |
848 | 848 | ||
849 | #else //PWM_EMBEDDED | 849 | #else //PWM_EMBEDDED |
850 | // display the configuration window (modal mode) | 850 | // display the configuration window (modal mode) |
851 | if (!conf()->showConfWnd(this)) | 851 | if (!conf()->showConfWnd(this)) |
852 | return; | 852 | return; |
853 | #endif | 853 | #endif |
854 | 854 | ||
855 | int newStyle = conf()->confWndMainViewStyle(); | 855 | int newStyle = conf()->confWndMainViewStyle(); |
856 | // reinitialize tray | 856 | // reinitialize tray |
857 | init->initTray(); | 857 | init->initTray(); |
858 | // reinitialize KWallet emulation | 858 | // reinitialize KWallet emulation |
859 | init->initKWalletEmu(); | 859 | init->initKWalletEmu(); |
860 | 860 | ||
861 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 861 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
862 | const vector<PwMDocList::listItem> *dl = _dl->getList(); | 862 | const vector<PwMDocList::listItem> *dl = _dl->getList(); |
863 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 863 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
864 | end = dl->end(); | 864 | end = dl->end(); |
865 | PwMDoc *doc; | 865 | PwMDoc *doc; |
866 | while (i != end) { | 866 | while (i != end) { |
867 | doc = (*i).doc; | 867 | doc = (*i).doc; |
868 | // unlock-without-mpw timeout | 868 | // unlock-without-mpw timeout |
869 | doc->timer()->start(DocTimer::id_mpwTimer); | 869 | doc->timer()->start(DocTimer::id_mpwTimer); |
870 | // auto-lock timeout | 870 | // auto-lock timeout |
871 | doc->timer()->start(DocTimer::id_autoLockTimer); | 871 | doc->timer()->start(DocTimer::id_autoLockTimer); |
872 | ++i; | 872 | ++i; |
873 | } | 873 | } |
874 | 874 | ||
875 | const QValueList<PwM *> *ml = init->mainWndList(); | 875 | const QValueList<PwM *> *ml = init->mainWndList(); |
876 | #ifndef PWM_EMBEDDED | 876 | #ifndef PWM_EMBEDDED |
877 | QValueList<PwM *>::const_iterator i2 = ml->begin(), | 877 | QValueList<PwM *>::const_iterator i2 = ml->begin(), |
878 | end2 = ml->end(); | 878 | end2 = ml->end(); |
879 | #else | 879 | #else |
880 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), | 880 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), |
881 | end2 = ml->end(); | 881 | end2 = ml->end(); |
882 | #endif | 882 | #endif |
883 | PwM *pwm; | 883 | PwM *pwm; |
884 | while (i2 != end2) { | 884 | while (i2 != end2) { |
885 | pwm = *i2; | 885 | pwm = *i2; |
886 | // reinitialize the window style. | 886 | // reinitialize the window style. |
887 | if (oldStyle != newStyle) | 887 | if (oldStyle != newStyle) |
888 | pwm->curView()->initStyle(newStyle); | 888 | pwm->curView()->initStyle(newStyle); |
889 | // set the new font | 889 | // set the new font |
890 | pwm->curView()->setFont(conf()->confGlobEntryFont()); | 890 | pwm->curView()->setFont(conf()->confGlobEntryFont()); |
891 | ++i2; | 891 | ++i2; |
892 | } | 892 | } |
893 | } | 893 | } |
894 | 894 | ||
895 | void PwM::activateMpButton(bool activate) | 895 | void PwM::activateMpButton(bool activate) |
896 | { | 896 | { |
897 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); | 897 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); |
898 | } | 898 | } |
899 | 899 | ||
900 | void PwM::closeEvent(QCloseEvent *e) | 900 | void PwM::closeEvent(QCloseEvent *e) |
901 | { | 901 | { |
902 | qDebug("PwM::closeEvent "); | 902 | qDebug("PwM::closeEvent "); |
903 | emit closed( this ); | 903 | emit closed( this ); |
904 | return; | 904 | return; |
905 | e->accept(); | 905 | e->accept(); |
906 | } | 906 | } |
907 | 907 | ||
908 | void PwM::docClosed(PwMDoc *doc) | 908 | void PwM::docClosed(PwMDoc *doc) |
909 | { | 909 | { |
910 | qDebug("PwM::docClosed "); | 910 | qDebug("PwM::docClosed "); |
911 | PARAM_UNUSED(doc); | 911 | PARAM_UNUSED(doc); |
912 | PWM_ASSERT(doc == curDoc()); | 912 | PWM_ASSERT(doc == curDoc()); |
913 | close(); | 913 | close(); |
914 | } | 914 | } |
915 | 915 | ||
916 | void PwM::find_slot() | 916 | void PwM::find_slot() |
917 | { | 917 | { |
918 | PWM_ASSERT(curDoc()); | 918 | PWM_ASSERT(curDoc()); |
919 | if (curDoc()->isDocEmpty()) | 919 | if (curDoc()->isDocEmpty()) |
920 | return; | 920 | return; |
921 | if (curDoc()->isDeepLocked()) | 921 | if (curDoc()->isDeepLocked()) |
922 | return; | 922 | return; |
923 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 923 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
924 | FindWndImpl findWnd(view); | 924 | FindWndImpl findWnd(view); |
925 | findWnd.exec(); | 925 | findWnd.exec(); |
926 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 926 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
927 | } | 927 | } |
928 | 928 | ||
929 | void PwM::exportToText() | 929 | void PwM::exportToText() |
930 | { | 930 | { |
931 | PWM_ASSERT(curDoc()); | 931 | PWM_ASSERT(curDoc()); |
932 | if (curDoc()->isDocEmpty()) { | 932 | if (curDoc()->isDocEmpty()) { |
933 | KMessageBox::information(this, | 933 | KMessageBox::information(this, |
934 | i18n | 934 | i18n |
935 | ("Sorry, there's nothing to export.\n" | 935 | ("Sorry, there's nothing to export.\n" |
936 | "Please first add some passwords."), | 936 | "Please first add some passwords."), |
937 | i18n("nothing to do")); | 937 | i18n("nothing to do")); |
938 | return; | 938 | return; |
939 | } | 939 | } |
940 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 940 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
941 | QString fn(KFileDialog::getSaveFileName(QString::null, | 941 | QString fn(KFileDialog::getSaveFileName(QString::null, |
942 | i18n("*|plain-text file"), | 942 | i18n("*|plain-text file"), |
943 | this)); | 943 | this)); |
944 | if (fn == "") { | 944 | if (fn == "") { |
945 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 945 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
946 | return; | 946 | return; |
947 | } | 947 | } |
948 | 948 | ||
949 | PwMerror ret = curDoc()->exportToText(&fn); | 949 | PwMerror ret = curDoc()->exportToText(&fn); |
950 | if (ret != e_success) { | 950 | if (ret != e_success) { |
951 | KMessageBox::error(this, | 951 | KMessageBox::error(this, |
952 | i18n("Error: Couldn't write to file.\n" | 952 | i18n("Error: Couldn't write to file.\n" |
953 | "Please check if you have permission to write\n" | 953 | "Please check if you have permission to write\n" |
954 | "to the file in that directory."), | 954 | "to the file in that directory."), |
955 | i18n("error while writing")); | 955 | i18n("error while writing")); |
956 | } else | 956 | } else |
957 | showStatMsg(i18n("Successfully exported data.")); | 957 | showStatMsg(i18n("Successfully exported data.")); |
958 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 958 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
959 | } | 959 | } |
960 | 960 | ||
961 | bool PwM::importFromText() | 961 | bool PwM::importFromText() |
962 | { | 962 | { |
963 | if (!isVirgin()) { | 963 | if (!isVirgin()) { |
964 | if (KMessageBox::questionYesNo(this, | 964 | if (KMessageBox::questionYesNo(this, |
965 | i18n("Do you want to import the data\n" | 965 | i18n("Do you want to import the data\n" |
966 | "into the current document? (If you\n" | 966 | "into the current document? (If you\n" |
967 | "select \"no\", a new document will be\n" | 967 | "select \"no\", a new document will be\n" |
968 | "opened.)"), | 968 | "opened.)"), |
969 | i18n("import into this document?")) | 969 | i18n("import into this document?")) |
970 | == KMessageBox::No) { | 970 | == KMessageBox::No) { |
971 | // import the data to a new window. | 971 | // import the data to a new window. |
972 | PwM *newInstance = init->createMainWnd(); | 972 | PwM *newInstance = init->createMainWnd(); |
973 | bool ok = newInstance->importFromText(); | 973 | bool ok = newInstance->importFromText(); |
974 | if (!ok) { | 974 | if (!ok) { |
975 | newInstance->setForceQuit(true); | 975 | newInstance->setForceQuit(true); |
976 | delete_and_null(newInstance); | 976 | delete_and_null(newInstance); |
977 | } | 977 | } |
978 | return ok; | 978 | return ok; |
979 | } | 979 | } |
980 | } | 980 | } |
981 | 981 | ||
982 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 982 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
983 | PwMerror ret; | 983 | PwMerror ret; |
984 | QString path(KFileDialog::getOpenFileName(QString::null, | 984 | QString path(KFileDialog::getOpenFileName(QString::null, |
985 | i18n("*|PWM-exported text file"), | 985 | i18n("*|PWM-exported text file"), |
986 | this)); | 986 | this)); |
987 | if (path == "") | 987 | if (path == "") |
988 | goto cancelImport; | 988 | goto cancelImport; |
989 | 989 | ||
990 | ret = curDoc()->importFromText(&path, 0); | 990 | ret = curDoc()->importFromText(&path, 0); |
991 | if (ret == e_fileFormat) { | 991 | if (ret == e_fileFormat) { |
992 | KMessageBox::error(this, | 992 | KMessageBox::error(this, |
993 | i18n("Could not read file-format.\n" | 993 | i18n("Could not read file-format.\n" |
994 | "This seems to be _not_ a valid file\n" | 994 | "This seems to be _not_ a valid file\n" |
995 | "exported by PwM."), | 995 | "exported by PwM."), |
996 | i18n("invalid file-format")); | 996 | i18n("invalid file-format")); |
997 | goto cancelImport; | 997 | goto cancelImport; |
998 | } else if (ret == e_invalidArg) { | 998 | } else if (ret == e_invalidArg) { |
999 | BUG(); | 999 | BUG(); |
1000 | goto cancelImport; | 1000 | goto cancelImport; |
1001 | } else if (ret != e_success) { | 1001 | } else if (ret != e_success) { |
1002 | KMessageBox::error(this, | 1002 | KMessageBox::error(this, |
1003 | i18n("Could not import file!\n" | 1003 | i18n("Could not import file!\n" |
1004 | "Do you have permission to read this file?\n" | 1004 | "Do you have permission to read this file?\n" |
1005 | "Do you have enough free memory?"), | 1005 | "Do you have enough free memory?"), |
1006 | i18n("import failed")); | 1006 | i18n("import failed")); |
1007 | goto cancelImport; | 1007 | goto cancelImport; |
1008 | } | 1008 | } |
1009 | setVirgin(false); | 1009 | setVirgin(false); |
1010 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1010 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1011 | return true; | 1011 | return true; |
1012 | 1012 | ||
1013 | cancelImport: | 1013 | cancelImport: |
1014 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1014 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1015 | return false; | 1015 | return false; |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | void PwM::exportToGpasman() | 1018 | void PwM::exportToGpasman() |
1019 | { | 1019 | { |
1020 | PWM_ASSERT(curDoc()); | 1020 | PWM_ASSERT(curDoc()); |
1021 | if (curDoc()->isDocEmpty()) { | 1021 | if (curDoc()->isDocEmpty()) { |
1022 | KMessageBox::information(this, | 1022 | KMessageBox::information(this, |
1023 | i18n | 1023 | i18n |
1024 | ("Sorry, there's nothing to export.\n" | 1024 | ("Sorry, there's nothing to export.\n" |
1025 | "Please first add some passwords."), | 1025 | "Please first add some passwords."), |
1026 | i18n("nothing to do")); | 1026 | i18n("nothing to do")); |
1027 | return; | 1027 | return; |
1028 | } | 1028 | } |
1029 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1029 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1030 | QString fn(KFileDialog::getSaveFileName(QString::null, | 1030 | QString fn(KFileDialog::getSaveFileName(QString::null, |
1031 | i18n("*|Gpasman or Kpasman file"), | 1031 | i18n("*|Gpasman or Kpasman file"), |
1032 | this)); | 1032 | this)); |
1033 | if (fn == "") { | 1033 | if (fn == "") { |
1034 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1034 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1035 | return; | 1035 | return; |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 1038 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
1039 | if (ret != e_success) { | 1039 | if (ret != e_success) { |
1040 | if (ret == e_noPw) { | 1040 | if (ret == e_noPw) { |
1041 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1041 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1042 | return; | 1042 | return; |
1043 | } | 1043 | } |
1044 | KMessageBox::error(this, | 1044 | KMessageBox::error(this, |
1045 | i18n("Error: Couldn't write to file.\n" | 1045 | i18n("Error: Couldn't write to file.\n" |
1046 | "Please check if you have permission to write " | 1046 | "Please check if you have permission to write " |
1047 | "to the file in that directory."), | 1047 | "to the file in that directory."), |
1048 | i18n("error while writing")); | 1048 | i18n("error while writing")); |
1049 | } else | 1049 | } else |
1050 | showStatMsg(i18n("Successfully exported data.")); | 1050 | showStatMsg(i18n("Successfully exported data.")); |
1051 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1051 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | 1054 | ||
1055 | 1055 | ||
1056 | void PwM::exportToCsv() | 1056 | void PwM::exportToCsv() |
1057 | { | 1057 | { |
1058 | PWM_ASSERT(curDoc()); | 1058 | PWM_ASSERT(curDoc()); |
1059 | if (curDoc()->isDocEmpty()) { | 1059 | if (curDoc()->isDocEmpty()) { |
1060 | KMessageBox::information(this, | 1060 | KMessageBox::information(this, |
1061 | i18n | 1061 | i18n |
1062 | ("Sorry, there is nothing to export;\n" | 1062 | ("Sorry, there is nothing to export;\n" |
1063 | "please add some passwords first."), | 1063 | "please add some passwords first."), |
1064 | i18n("Nothing to Do")); | 1064 | i18n("Nothing to Do")); |
1065 | return; | 1065 | return; |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1068 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1069 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); | 1069 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); |
1070 | if (fn.isEmpty()) { | 1070 | if (fn.isEmpty()) { |
1071 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1071 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1072 | return; | 1072 | return; |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | Csv csv(this); | 1075 | Csv csv(this); |
1076 | if (!csv.exportData(fn, curDoc())) { | 1076 | if (!csv.exportData(fn, curDoc())) { |
1077 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1077 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1078 | showStatMsg(i18n("CSV file export failed.")); | 1078 | showStatMsg(i18n("CSV file export failed.")); |
1079 | return; | 1079 | return; |
1080 | } | 1080 | } |
1081 | showStatMsg(i18n("Successfully exported data.")); | 1081 | showStatMsg(i18n("Successfully exported data.")); |
1082 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1082 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | bool PwM::importCsv() | 1085 | bool PwM::importCsv() |
1086 | { | 1086 | { |
1087 | Csv csv(this); | 1087 | Csv csv(this); |
1088 | if (!isVirgin()) { | 1088 | if (!isVirgin()) { |
1089 | if (KMessageBox::questionYesNo(this, | 1089 | if (KMessageBox::questionYesNo(this, |
1090 | i18n("Do you want to import the data\n" | 1090 | i18n("Do you want to import the data\n" |
1091 | "into the current document? (If you\n" | 1091 | "into the current document? (If you\n" |
1092 | "select \"no\", a new document will be\n" | 1092 | "select \"no\", a new document will be\n" |
1093 | "opened.)"), | 1093 | "opened.)"), |
1094 | i18n("Import into This Document?")) | 1094 | i18n("Import into This Document?")) |
1095 | == KMessageBox::No) { | 1095 | == KMessageBox::No) { |
1096 | // import the data to a new window. | 1096 | // import the data to a new window. |
1097 | PwM *newInstance = init->createMainWnd(); | 1097 | PwM *newInstance = init->createMainWnd(); |
1098 | bool ok = newInstance->importCsv(); | 1098 | bool ok = newInstance->importCsv(); |
1099 | if (!ok) { | 1099 | if (!ok) { |
1100 | newInstance->setForceQuit(true); | 1100 | newInstance->setForceQuit(true); |
1101 | delete_and_null(newInstance); | 1101 | delete_and_null(newInstance); |
1102 | } | 1102 | } |
1103 | return ok; | 1103 | return ok; |
1104 | } | 1104 | } |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); | 1107 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); |
1108 | if (filename.isEmpty()) | 1108 | if (filename.isEmpty()) |
1109 | return false; | 1109 | return false; |
1110 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1110 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1111 | if (!csv.importData(filename, curDoc())) { | 1111 | if (!csv.importData(filename, curDoc())) { |
1112 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1112 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1113 | showStatMsg(i18n("CSV file import failed.")); | 1113 | showStatMsg(i18n("CSV file import failed.")); |
1114 | return false; | 1114 | return false; |
1115 | } | 1115 | } |
1116 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1116 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1117 | KMessageBox::information(this, | 1117 | KMessageBox::information(this, |
1118 | i18n("Successfully imported the CSV data\n" | 1118 | i18n("Successfully imported the CSV data\n" |
1119 | "into the current document."), i18n("Successfully Imported")); | 1119 | "into the current document."), i18n("Successfully Imported")); |