summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-03 13:42:15 (UTC)
committer zautrix <zautrix>2005-03-03 13:42:15 (UTC)
commit91feaad38e5f81063fa496a4e2988aa791267fd1 (patch) (unidiff)
treefc408221a6b1a664f3574657a336526726aa9ccc
parent806a806422872b6f31183267c6b084d425458902 (diff)
downloadkdepimpi-91feaad38e5f81063fa496a4e2988aa791267fd1.zip
kdepimpi-91feaad38e5f81063fa496a4e2988aa791267fd1.tar.gz
kdepimpi-91feaad38e5f81063fa496a4e2988aa791267fd1.tar.bz2
more pw fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/commentbox.cpp10
-rw-r--r--pwmanager/pwmanager/commentbox.h4
-rw-r--r--pwmanager/pwmanager/listviewpwm.cpp8
-rw-r--r--pwmanager/pwmanager/listviewpwm.h1
-rw-r--r--pwmanager/pwmanager/pwm.cpp2
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp58
-rw-r--r--pwmanager/pwmanager/pwmdoc.h2
-rw-r--r--pwmanager/pwmanager/pwmview.cpp2
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_0.cpp20
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_0.h4
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_1.cpp19
-rw-r--r--pwmanager/pwmanager/pwmviewstyle_1.h2
12 files changed, 121 insertions, 11 deletions
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp
index 51f88b2..5416856 100644
--- a/pwmanager/pwmanager/commentbox.cpp
+++ b/pwmanager/pwmanager/commentbox.cpp
@@ -40,244 +40,244 @@ CommentBox::CommentBox(QWidget *_parentWidget)
40 parentWidget = _parentWidget; 40 parentWidget = _parentWidget;
41 textDta = 0; 41 textDta = 0;
42 htmlDta = 0; 42 htmlDta = 0;
43 mode = mode_notSet; 43 mode = mode_notSet;
44 setFont( prefs->mViewFont ); 44 setFont( prefs->mViewFont );
45} 45}
46 46
47CommentBox::~CommentBox() 47CommentBox::~CommentBox()
48{ 48{
49 clearText(); 49 clearText();
50 clearHtml(); 50 clearHtml();
51} 51}
52 52
53void CommentBox::clear() 53void CommentBox::clear()
54{ 54{
55 clearText(); 55 clearText();
56 clearHtml(); 56 clearHtml();
57 mode = mode_notSet; 57 mode = mode_notSet;
58 this->hide(); 58 this->hide();
59} 59}
60 60
61void CommentBox::clearText() 61void CommentBox::clearText()
62{ 62{
63 delete_ifnot_null(textDta); 63 delete_ifnot_null(textDta);
64} 64}
65 65
66void CommentBox::clearHtml() 66void CommentBox::clearHtml()
67{ 67{
68 delete_ifnot_null(htmlDta); 68 delete_ifnot_null(htmlDta);
69} 69}
70 70
71void CommentBox::setText(const QString &text) 71void CommentBox::setText(const QString &text)
72{ 72{
73 switchTo(mode_text); 73 switchTo(mode_text);
74 PWM_ASSERT(textDta); 74 PWM_ASSERT(textDta);
75 textDta->setText( text); 75 textDta->setText( text);
76 if (!textDta->isVisible()) 76 if (!textDta->isVisible())
77 textDta->show(); 77 textDta->show();
78} 78}
79 79
80bool CommentBox::getText(QString *text) 80bool CommentBox::getText(QString *text)
81{ 81{
82 if (mode != mode_text) 82 if (mode != mode_text)
83 return false; 83 return false;
84 PWM_ASSERT(text); 84 PWM_ASSERT(text);
85 if (!textDta) { 85 if (!textDta) {
86 *text = ""; 86 *text = "";
87 return true; 87 return true;
88 } 88 }
89 *text = textDta->text(); 89 *text = textDta->text();
90 return true; 90 return true;
91} 91}
92 92
93void CommentBox::setHtml(QString code) 93void CommentBox::setHtml(QString code)
94{ 94{
95 switchTo(mode_html); 95 switchTo(mode_html);
96 PWM_ASSERT(htmlDta); 96 PWM_ASSERT(htmlDta);
97 if (!HtmlGen::replaceSSDummy(&code)) 97 if (!HtmlGen::replaceSSDummy(&code))
98 printWarn("CommentBox::setHtml(): replaceSSDummy() failed!"); 98 printWarn("CommentBox::setHtml(): replaceSSDummy() failed!");
99 htmlDta->begin(); 99 htmlDta->begin();
100 htmlDta->write(code); 100 htmlDta->write(code);
101 htmlDta->end(); 101 htmlDta->end();
102 htmlDta->show(); 102 htmlDta->show();
103} 103}
104 104
105void CommentBox::setContent(const QString &dta) 105void CommentBox::setContent(const QString &dta)
106{ 106{
107 // if there's no data, hide the comment-box 107 // if there's no data, hide the comment-box
108 if (dta.isEmpty()) { 108 if (dta.isEmpty()) {
109 clear(); 109 clear();
110 return; 110 return;
111 } 111 }
112 if (HtmlGen::isHtml(dta)) { 112 if (HtmlGen::isHtml(dta)) {
113 setHtml(dta); 113 setHtml(dta);
114 return; 114 return;
115 } 115 }
116 // we assume it's plain text 116 // we assume it's plain text
117 setText(dta); 117 setText(dta);
118} 118}
119 119
120void CommentBox::switchTo(commentBoxMode newMode) 120void CommentBox::switchTo(commentBoxMode newMode)
121{ 121{
122 if (newMode == mode) 122 if (newMode == mode)
123 return; 123 return;
124 124
125 // cleanup old mode 125 // cleanup old mode
126 switch (mode) { 126 switch (mode) {
127 case mode_text: 127 case mode_text:
128 clearText(); 128 clearText();
129 break; 129 break;
130 case mode_html: 130 case mode_html:
131 clearHtml(); 131 clearHtml();
132 break; 132 break;
133 default: 133 default:
134 break; 134 break;
135 } 135 }
136 136
137 // setup new mode 137 // setup new mode
138 switch (newMode) { 138 switch (newMode) {
139 case mode_text: 139 case mode_text:
140 textDta = new QTextEdit(parentWidget); 140 textDta = new QTextEdit(parentWidget);
141 textDta->setTextFormat(Qt::PlainText); 141 textDta->setTextFormat(Qt::PlainText);
142 textDta->setReadOnly(true); 142 textDta->setReadOnly(true);
143 textDta->show(); 143 textDta->show();
144 break; 144 break;
145 case mode_html: 145 case mode_html:
146 htmlDta = new KHTMLPart(parentWidget, 0, 146 htmlDta = new KHTMLPart(parentWidget, 0,
147 parentWidget); 147 parentWidget);
148 htmlDta->show(); 148 htmlDta->show();
149 break; 149 break;
150 default: 150 default:
151 BUG(); 151 BUG();
152 break; 152 break;
153 } 153 }
154 154
155 mode = newMode; 155 mode = newMode;
156} 156}
157 157
158void CommentBox::show() 158void CommentBox::show()
159{ 159{
160 switch (mode) { 160 switch (mode) {
161 case mode_text: 161 case mode_text:
162 PWM_ASSERT(textDta); 162 PWM_ASSERT(textDta);
163 textDta->show(); 163 textDta->show();
164 break; 164 break;
165 case mode_html: 165 case mode_html:
166 PWM_ASSERT(htmlDta); 166 PWM_ASSERT(htmlDta);
167 htmlDta->show(); 167 htmlDta->show();
168 break; 168 break;
169 default: 169 default:
170 break; 170 break;
171 } 171 }
172 172
173} 173}
174 174
175void CommentBox::hide() 175void CommentBox::hide()
176{ 176{
177 switch (mode) { 177 switch (mode) {
178 case mode_text: 178 case mode_text:
179 PWM_ASSERT(textDta); 179 PWM_ASSERT(textDta);
180 textDta->hide(); 180 textDta->hide();
181 break; 181 break;
182 case mode_html: 182 case mode_html:
183 PWM_ASSERT(htmlDta); 183 PWM_ASSERT(htmlDta);
184 htmlDta->hide(); 184 htmlDta->hide();
185 break; 185 break;
186 default: 186 default:
187 break; 187 break;
188 } 188 }
189} 189}
190 190
191void CommentBox::resize(const QSize &size) 191void CommentBox::resize(const QSize &size)
192{ 192{
193 switch (mode) { 193 switch (mode) {
194 case mode_text: 194 case mode_text:
195 PWM_ASSERT(textDta); 195 PWM_ASSERT(textDta);
196 textDta->resize(size); 196 textDta->resize(size);
197 break; 197 break;
198 case mode_html: 198 case mode_html:
199 PWM_ASSERT(htmlDta); 199 PWM_ASSERT(htmlDta);
200 htmlDta->view()->resize(size); 200 htmlDta->view()->resize(size);
201 break; 201 break;
202 default: 202 default:
203 break; 203 break;
204 } 204 }
205 205
206} 206}
207 207
208QSize CommentBox::size() 208QSize CommentBox::size()
209{ 209{
210 switch (mode) { 210 switch (mode) {
211 case mode_text: 211 case mode_text:
212 PWM_ASSERT(textDta); 212 PWM_ASSERT(textDta);
213 return textDta->size(); 213 return textDta->size();
214 break; 214 break;
215 case mode_html: 215 case mode_html:
216 PWM_ASSERT(htmlDta); 216 PWM_ASSERT(htmlDta);
217 return htmlDta->view()->size(); 217 return htmlDta->view()->size();
218 break; 218 break;
219 default: 219 default:
220 break; 220 break;
221 } 221 }
222 222
223 return QSize(); 223 return QSize();
224} 224}
225 225
226 226
227//////////////////////////////////////////////////////////////////////// 227////////////////////////////////////////////////////////////////////////
228 228
229#else 229#else
230 230
231CommentBox::CommentBox(QWidget *_parentWidget) 231CommentBox::CommentBox(QWidget *_parentWidget)
232 : QMultiLineEdit(_parentWidget) 232 : QTextBrowser(_parentWidget)
233 233
234{ 234{
235 this->setReadOnly(true); 235 //this->setReadOnly(true);
236 setFocusPolicy( QWidget::ClickFocus ); 236 setFocusPolicy( QWidget::ClickFocus );
237} 237}
238 238
239CommentBox::~CommentBox() 239CommentBox::~CommentBox()
240{ 240{
241} 241}
242 242
243void CommentBox::clear() 243void CommentBox::clear()
244{ 244{
245 this->hide(); 245 this->hide();
246} 246}
247 247
248 248
249void CommentBox::setText(const QString &text) 249void CommentBox::setText(const QString &text)
250{ 250{
251 QMultiLineEdit::setText( text); 251 QTextBrowser::setText( text);
252 if (!this->isVisible()) 252 if (!isVisible())
253 this->show(); 253 show();
254} 254}
255 255
256bool CommentBox::getText(QString *text) 256bool CommentBox::getText(QString *text)
257{ 257{
258 *text = this->text(); 258 *text = this->text();
259 return true; 259 return true;
260} 260}
261 261
262void CommentBox::setContent(const QString &dta) 262void CommentBox::setContent(const QString &dta)
263{ 263{
264 // if there's no data, hide the comment-box 264 // if there's no data, hide the comment-box
265 if (dta.isEmpty()) { 265 if (dta.isEmpty()) {
266 clear(); 266 clear();
267 return; 267 return;
268 } 268 }
269 269
270 // we assume it's plain text 270 // we assume it's plain text
271 setText(dta); 271 setText(dta);
272} 272}
273 273
274#endif 274#endif
275 275
276 276
277 277
278 278
279 279
280 280
281 281
282 282
283 283
diff --git a/pwmanager/pwmanager/commentbox.h b/pwmanager/pwmanager/commentbox.h
index 352867c..3103353 100644
--- a/pwmanager/pwmanager/commentbox.h
+++ b/pwmanager/pwmanager/commentbox.h
@@ -1,124 +1,124 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef COMMENTBOX_H 20#ifndef COMMENTBOX_H
21#define COMMENTBOX_H 21#define COMMENTBOX_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qsize.h> 24#include <qsize.h>
25class QWidget; 25class QWidget;
26class QTextEdit; 26class QTextEdit;
27class KHTMLPart; 27class KHTMLPart;
28 28
29#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
30 30
31class CommentBox 31class CommentBox
32{ 32{
33protected: 33protected:
34 enum commentBoxMode 34 enum commentBoxMode
35 { 35 {
36 mode_notSet = 0, 36 mode_notSet = 0,
37 mode_text, 37 mode_text,
38 mode_html 38 mode_html
39 }; 39 };
40 40
41public: 41public:
42 CommentBox(QWidget *_parentWidget); 42 CommentBox(QWidget *_parentWidget);
43 ~CommentBox(); 43 ~CommentBox();
44 44
45 /** clear all data in the comment box */ 45 /** clear all data in the comment box */
46 void clear(); 46 void clear();
47 /** show the comment box */ 47 /** show the comment box */
48 void show(); 48 void show();
49 /** hide the comment box */ 49 /** hide the comment box */
50 void hide(); 50 void hide();
51 /** resize the comment box */ 51 /** resize the comment box */
52 void resize(const QSize &size); 52 void resize(const QSize &size);
53 void resize(int w, int h) 53 void resize(int w, int h)
54 { resize(QSize(w, h)); } 54 { resize(QSize(w, h)); }
55 /** get the size of the comment box */ 55 /** get the size of the comment box */
56 QSize size(); 56 QSize size();
57 /** if neccessary switch to text-mode and 57 /** if neccessary switch to text-mode and
58 * insert this text into the comment box 58 * insert this text into the comment box
59 */ 59 */
60 void setText(const QString &text); 60 void setText(const QString &text);
61 /** get the text of the comment box. 61 /** get the text of the comment box.
62 * If it's not in text-mode it returns false 62 * If it's not in text-mode it returns false
63 */ 63 */
64 bool getText(QString *text); 64 bool getText(QString *text);
65 /** if neccessary switch to HTML-mode and 65 /** if neccessary switch to HTML-mode and
66 * insert this html code into the comment box 66 * insert this html code into the comment box
67 */ 67 */
68 void setHtml(QString code); 68 void setHtml(QString code);
69 /** checks "dta" for its type, sets the correct 69 /** checks "dta" for its type, sets the correct
70 * mode and writes "dta" to the comment box 70 * mode and writes "dta" to the comment box
71 */ 71 */
72 void setContent(const QString &dta); 72 void setContent(const QString &dta);
73 73
74protected: 74protected:
75 /** switch the current mode */ 75 /** switch the current mode */
76 void switchTo(commentBoxMode newMode); 76 void switchTo(commentBoxMode newMode);
77 /** clear all text data */ 77 /** clear all text data */
78 void clearText(); 78 void clearText();
79 /** clear all HTML data */ 79 /** clear all HTML data */
80 void clearHtml(); 80 void clearHtml();
81 81
82protected: 82protected:
83 /** parent widget for this comment box */ 83 /** parent widget for this comment box */
84 QWidget *parentWidget; 84 QWidget *parentWidget;
85 /** current comment box usage type */ 85 /** current comment box usage type */
86 commentBoxMode mode; 86 commentBoxMode mode;
87 /** if the comment box is a normal textbox, data is stored here */ 87 /** if the comment box is a normal textbox, data is stored here */
88 QTextEdit *textDta; 88 QTextEdit *textDta;
89 /** if the comment box is a HTML box, data is stored here */ 89 /** if the comment box is a HTML box, data is stored here */
90 KHTMLPart *htmlDta; 90 KHTMLPart *htmlDta;
91}; 91};
92 92
93#else 93#else
94#include <qmultilineedit.h> 94#include <qtextbrowser.h>
95/** Implementation of the advanced HTML comment box */ 95/** Implementation of the advanced HTML comment box */
96//US ENH: CommentBox must be derived from QWidget, to allow the splitter to set a initial size 96//US ENH: CommentBox must be derived from QWidget, to allow the splitter to set a initial size
97// without conflicting with the two display modes 97// without conflicting with the two display modes
98 98
99class CommentBox : public QMultiLineEdit 99class CommentBox : public QTextBrowser
100{ 100{
101public: 101public:
102 CommentBox(QWidget *_parentWidget); 102 CommentBox(QWidget *_parentWidget);
103 ~CommentBox(); 103 ~CommentBox();
104 104
105 /** clear all data in the comment box */ 105 /** clear all data in the comment box */
106 void clear(); 106 void clear();
107 /** if neccessary switch to text-mode and 107 /** if neccessary switch to text-mode and
108 * insert this text into the comment box 108 * insert this text into the comment box
109 */ 109 */
110 void setText(const QString &text); 110 void setText(const QString &text);
111 /** get the text of the comment box. 111 /** get the text of the comment box.
112 * If it's not in text-mode it returns false 112 * If it's not in text-mode it returns false
113 */ 113 */
114 bool getText(QString *text); 114 bool getText(QString *text);
115 /** if neccessary switch to HTML-mode and 115 /** if neccessary switch to HTML-mode and
116 * insert this html code into the comment box 116 * insert this html code into the comment box
117 */ 117 */
118 void setContent(const QString &dta); 118 void setContent(const QString &dta);
119 119
120}; 120};
121#endif 121#endif
122 122
123 123
124#endif 124#endif
diff --git a/pwmanager/pwmanager/listviewpwm.cpp b/pwmanager/pwmanager/listviewpwm.cpp
index 85e788c..8d46fff 100644
--- a/pwmanager/pwmanager/listviewpwm.cpp
+++ b/pwmanager/pwmanager/listviewpwm.cpp
@@ -1,113 +1,121 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "listviewpwm.h" 20#include "listviewpwm.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "pwmview.h" 22#include "pwmview.h"
23 23
24#include <qpainter.h> 24#include <qpainter.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26 26
27#include <kiconloader.h> 27#include <kiconloader.h>
28 28
29#ifdef PWM_EMBEDDED 29#ifdef PWM_EMBEDDED
30#include <kglobal.h> 30#include <kglobal.h>
31#endif 31#endif
32 32
33ListViewPwM::ListViewPwM(QWidget *parent, const char *name) 33ListViewPwM::ListViewPwM(QWidget *parent, const char *name)
34 : KListView(parent, name) 34 : KListView(parent, name)
35{ 35{
36 //setResizeMode(QListView::AllColumns); 36 //setResizeMode(QListView::AllColumns);
37 setAllColumnsShowFocus (true ); 37 setAllColumnsShowFocus (true );
38} 38}
39 39
40bool ListViewPwM::event(QEvent *e) 40bool ListViewPwM::event(QEvent *e)
41{ 41{
42 if (e->type() == QEvent::LayoutHint) 42 if (e->type() == QEvent::LayoutHint)
43 emit layoutChanged(); 43 emit layoutChanged();
44 if (e->type() == QEvent::KeyPress) {
45 QKeyEvent* ke = (QKeyEvent*) e;
46 if ( ke->key() == Qt::Key_Space) {
47 emit toggleOverview();
48 return true;
49 }
50
51 }
44 return KListView::event(e); 52 return KListView::event(e);
45} 53}
46 54
47 55
48QPixmap * ListViewItemPwM::onPix = 0; 56QPixmap * ListViewItemPwM::onPix = 0;
49QPixmap * ListViewItemPwM::offPix = 0; 57QPixmap * ListViewItemPwM::offPix = 0;
50 58
51ListViewItemPwM::ListViewItemPwM(QListView *parent) 59ListViewItemPwM::ListViewItemPwM(QListView *parent)
52 : QCheckListItem(parent, "", QCheckListItem::CheckBox) 60 : QCheckListItem(parent, "", QCheckListItem::CheckBox)
53{ 61{
54 if (!onPix) { 62 if (!onPix) {
55 PWM_ASSERT(!offPix); 63 PWM_ASSERT(!offPix);
56 KIconLoader* picons; 64 KIconLoader* picons;
57#ifndef PWM_EMBEDDED 65#ifndef PWM_EMBEDDED
58 KIconLoader il; 66 KIconLoader il;
59 picons = &il; 67 picons = &il;
60#else 68#else
61 picons = KGlobal::iconLoader(); 69 picons = KGlobal::iconLoader();
62#endif 70#endif
63 71
64 KIconLoader il; 72 KIconLoader il;
65#ifndef PWM_EMBEDDED 73#ifndef PWM_EMBEDDED
66 static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small)); 74 static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small));
67#else 75#else
68 static QPixmap onP(picons->loadIcon("decrypted", KIcon::Small)); 76 static QPixmap onP(picons->loadIcon("decrypted", KIcon::Small));
69#endif 77#endif
70 onPix = &onP; 78 onPix = &onP;
71 static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small)); 79 static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small));
72 offPix = &offP; 80 offPix = &offP;
73 } 81 }
74} 82}
75 83
76void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg, 84void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg,
77 int column, int width, int align) 85 int column, int width, int align)
78{ 86{
79 // qDebug("ListViewItemPwM::paintCell column=%i", column); 87 // qDebug("ListViewItemPwM::paintCell column=%i", column);
80 if (!p) 88 if (!p)
81 return; 89 return;
82 //US BUG: 90 //US BUG:
83 if (column != COLUMN_DESC) { 91 if (column != COLUMN_DESC) {
84 QCheckListItem::paintCell(p, cg, column, width, align); 92 QCheckListItem::paintCell(p, cg, column, width, align);
85 return; 93 return;
86 } 94 }
87 QPixmap *curPix = isOn() ? onPix : offPix; 95 QPixmap *curPix = isOn() ? onPix : offPix;
88 int pixSpace = curPix->width(); 96 int pixSpace = curPix->width();
89 pixSpace += 4; 97 pixSpace += 4;
90#ifndef PWM_EMBEDDED 98#ifndef PWM_EMBEDDED
91 QRect window(p->viewport()); 99 QRect window(p->viewport());
92 // clear the rectangle (we have to clear it first. see QT doc) 100 // clear the rectangle (we have to clear it first. see QT doc)
93 p->eraseRect(0, 0, pixSpace, window.height()); 101 p->eraseRect(0, 0, pixSpace, window.height());
94 // now draw the pixmap 102 // now draw the pixmap
95 int y = (height() - curPix->height()) / 2; 103 int y = (height() - curPix->height()) / 2;
96 p->drawPixmap(1, y, *curPix); 104 p->drawPixmap(1, y, *curPix);
97 window.moveLeft(pixSpace); 105 window.moveLeft(pixSpace);
98 p->setViewport(window); 106 p->setViewport(window);
99#else 107#else
100 p->eraseRect(0, 0, pixSpace, height()); 108 p->eraseRect(0, 0, pixSpace, height());
101 // now draw the pixmap 109 // now draw the pixmap
102 int y = (height() - curPix->height()) / 2; 110 int y = (height() - curPix->height()) / 2;
103 p->drawPixmap(1, y, *curPix); 111 p->drawPixmap(1, y, *curPix);
104 p->translate( pixSpace, 0 ); 112 p->translate( pixSpace, 0 );
105 113
106#endif 114#endif
107 QListViewItem::paintCell(p, cg, column, width - pixSpace, align); 115 QListViewItem::paintCell(p, cg, column, width - pixSpace, align);
108 116
109} 117}
110 118
111#ifndef PWM_EMBEDDED 119#ifndef PWM_EMBEDDED
112#include "listviewpwm.moc" 120#include "listviewpwm.moc"
113#endif 121#endif
diff --git a/pwmanager/pwmanager/listviewpwm.h b/pwmanager/pwmanager/listviewpwm.h
index e6471c6..840ee73 100644
--- a/pwmanager/pwmanager/listviewpwm.h
+++ b/pwmanager/pwmanager/listviewpwm.h
@@ -1,57 +1,58 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef __LISTVIEW_H 20#ifndef __LISTVIEW_H
21#define __LISTVIEW_H 21#define __LISTVIEW_H
22 22
23#include <klistview.h> 23#include <klistview.h>
24 24
25/** PwManager implementation of the list view. 25/** PwManager implementation of the list view.
26 * Derived from KListView. 26 * Derived from KListView.
27 */ 27 */
28class ListViewPwM : public KListView 28class ListViewPwM : public KListView
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 ListViewPwM(QWidget *parent = 0, const char *name = 0); 32 ListViewPwM(QWidget *parent = 0, const char *name = 0);
33 33
34signals: 34signals:
35 void layoutChanged(); 35 void layoutChanged();
36 void toggleOverview();
36 37
37protected: 38protected:
38 virtual bool event(QEvent *e); 39 virtual bool event(QEvent *e);
39}; 40};
40 41
41class ListViewItemPwM : public QCheckListItem 42class ListViewItemPwM : public QCheckListItem
42{ 43{
43public: 44public:
44 ListViewItemPwM(QListView *parent); 45 ListViewItemPwM(QListView *parent);
45 46
46protected: 47protected:
47 void paintCell(QPainter *p, const QColorGroup &cg, 48 void paintCell(QPainter *p, const QColorGroup &cg,
48 int column, int width, int align); 49 int column, int width, int align);
49 50
50protected: 51protected:
51 /** pixmap to display for an item with state "on" */ 52 /** pixmap to display for an item with state "on" */
52 static QPixmap *onPix; 53 static QPixmap *onPix;
53 /** pixmap to display for an item with state "off" */ 54 /** pixmap to display for an item with state "off" */
54 static QPixmap *offPix; 55 static QPixmap *offPix;
55}; 56};
56 57
57#endif 58#endif
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index aed8ec0..9187380 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -538,402 +538,402 @@ void PwM::setVirgin(bool v)
538 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 538 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
539 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 539 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
540 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 540 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
541 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 541 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
542 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 542 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
543 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 543 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
544} 544}
545 545
546void PwM::new_slot() 546void PwM::new_slot()
547{ 547{
548 init->createMainWnd(); 548 init->createMainWnd();
549} 549}
550 550
551//US ENH 551//US ENH
552void PwM::open_slot() 552void PwM::open_slot()
553{ 553{
554 open_slot(""); 554 open_slot("");
555} 555}
556 556
557void PwM::open_slot(QString fn) 557void PwM::open_slot(QString fn)
558{ 558{
559 openDoc(fn); 559 openDoc(fn);
560} 560}
561 561
562PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 562PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
563{ 563{
564 if (!isVirgin()) { 564 if (!isVirgin()) {
565 // open the document in a new window. 565 // open the document in a new window.
566 PwM *newInstance = init->createMainWnd(); 566 PwM *newInstance = init->createMainWnd();
567 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 567 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
568 if (!newDoc) { 568 if (!newDoc) {
569 newInstance->setForceQuit(true); 569 newInstance->setForceQuit(true);
570 delete_and_null(newInstance); 570 delete_and_null(newInstance);
571 } 571 }
572 return newDoc; 572 return newDoc;
573 } 573 }
574 574
575 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 575 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
576 return 0; 576 return 0;
577 showStatMsg(i18n("Successfully opened file.")); 577 showStatMsg(i18n("Successfully opened file."));
578 updateCaption(); 578 updateCaption();
579 setVirgin(false); 579 setVirgin(false);
580 return curDoc(); 580 return curDoc();
581} 581}
582 582
583PwMView * PwM::makeNewListView(PwMDoc *doc) 583PwMView * PwM::makeNewListView(PwMDoc *doc)
584{ 584{
585 PwMView *ret = new PwMView(this, this, doc); 585 PwMView *ret = new PwMView(this, this, doc);
586 ret->setFont(conf()->confGlobEntryFont()); 586 ret->setFont(conf()->confGlobEntryFont());
587 ret->show(); 587 ret->show();
588 return ret; 588 return ret;
589} 589}
590 590
591void PwM::close_slot() 591void PwM::close_slot()
592{ 592{
593 close(); 593 close();
594} 594}
595 595
596void PwM::quitButton_slot() 596void PwM::quitButton_slot()
597{ 597{
598 init->shutdownApp(0); 598 init->shutdownApp(0);
599} 599}
600 600
601void PwM::save_slot() 601void PwM::save_slot()
602{ 602{
603 save(); 603 save();
604} 604}
605 605
606bool PwM::save() 606bool PwM::save()
607{ 607{
608 if (!curDoc()->saveDocUi(curDoc())) 608 if (!curDoc()->saveDocUi(curDoc()))
609 return false; 609 return false;
610 showStatMsg(i18n("Successfully saved data.")); 610 showStatMsg(i18n("Successfully saved data."));
611 updateCaption(); 611 updateCaption();
612 return true; 612 return true;
613} 613}
614 614
615void PwM::saveAs_slot() 615void PwM::saveAs_slot()
616{ 616{
617 saveAs(); 617 saveAs();
618} 618}
619 619
620bool PwM::saveAs() 620bool PwM::saveAs()
621{ 621{
622 if (!curDoc()->saveAsDocUi(curDoc())) 622 if (!curDoc()->saveAsDocUi(curDoc()))
623 return false; 623 return false;
624 showStatMsg(i18n("Successfully saved data.")); 624 showStatMsg(i18n("Successfully saved data."));
625 updateCaption(); 625 updateCaption();
626 return true; 626 return true;
627} 627}
628 628
629//US ENH : changed code to run with older MOC 629//US ENH : changed code to run with older MOC
630void PwM::addPwd_slot() 630void PwM::addPwd_slot()
631{ 631{
632 addPwd_slot1(0, 0); 632 addPwd_slot1(0, 0);
633} 633}
634 634
635void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) 635void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
636{ 636{
637 PwMDoc *doc; 637 PwMDoc *doc;
638 if (_doc) { 638 if (_doc) {
639 doc = _doc; 639 doc = _doc;
640 } else { 640 } else {
641 doc = curDoc(); 641 doc = curDoc();
642 } 642 }
643 PWM_ASSERT(doc); 643 PWM_ASSERT(doc);
644 doc->timer()->getLock(DocTimer::id_autoLockTimer); 644 doc->timer()->getLock(DocTimer::id_autoLockTimer);
645#ifndef PWM_EMBEDDED 645#ifndef PWM_EMBEDDED
646 AddEntryWndImpl w; 646 AddEntryWndImpl w;
647#else 647#else
648 AddEntryWndImpl w(doc, this, "addentrywndimpl"); 648 AddEntryWndImpl w(doc, this, "addentrywndimpl");
649#endif 649#endif
650 w.setCaption( i18n ("Add new password") ); 650 w.setCaption( i18n ("Add new password") );
651 vector<string> catList; 651 vector<string> catList;
652 doc->getCategoryList(&catList); 652 doc->getCategoryList(&catList);
653 unsigned i, size = catList.size(); 653 unsigned i, size = catList.size();
654 for (i = 0; i < size; ++i) { 654 for (i = 0; i < size; ++i) {
655 w.addCategory(catList[i].c_str()); 655 w.addCategory(catList[i].c_str());
656 } 656 }
657 w.setCurrCategory(view->getCurrentCategory()); 657 w.setCurrCategory(view->getCurrentCategory());
658 if (pw) 658 if (pw)
659 w.pwLineEdit->setText(*pw); 659 w.pwLineEdit->setText(*pw);
660 660
661 tryAgain: 661 tryAgain:
662 w.descLineEdit->setFocus(); 662 w.descLineEdit->setFocus();
663 if (w.exec() == 1) 663 if (w.exec() == 1)
664 { 664 {
665 PwMDataItem d; 665 PwMDataItem d;
666 666
667 //US BUG: to initialize all values of curEntr with meaningfulldata, 667 //US BUG: to initialize all values of curEntr with meaningfulldata,
668 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 668 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
669 // another option would be to create a constructor for PwMDataItem 669 // another option would be to create a constructor for PwMDataItem
670 d.clear(true); 670 d.clear(true);
671 671
672 d.desc = w.getDescription().latin1(); 672 d.desc = w.getDescription().latin1();
673 d.name = w.getUsername().latin1(); 673 d.name = w.getUsername().latin1();
674 d.pw = w.getPassword().latin1(); 674 d.pw = w.getPassword().latin1();
675 d.comment = w.getComment().latin1(); 675 d.comment = w.getComment().latin1();
676 d.url = w.getUrl().latin1(); 676 d.url = w.getUrl().latin1();
677 d.launcher = w.getLauncher().latin1(); 677 d.launcher = w.getLauncher().latin1();
678 PwMerror ret = doc->addEntry(w.getCategory(), &d); 678 PwMerror ret = doc->addEntry(w.getCategory(), &d);
679 if (ret == e_entryExists) { 679 if (ret == e_entryExists) {
680 KMessageBox::error(this, 680 KMessageBox::error(this,
681 i18n 681 i18n
682 ("An entry with this \"Description\",\n" 682 ("An entry with this \"Description\",\n"
683 "does already exist.\n" 683 "does already exist.\n"
684 "Please select another description."), 684 "Please select another description."),
685 i18n("entry already exists.")); 685 i18n("entry already exists."));
686 goto tryAgain; 686 goto tryAgain;
687 } else if (ret == e_maxAllowedEntr) { 687 } else if (ret == e_maxAllowedEntr) {
688 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 688 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
689 "has been reached.\nYou can't add more entries."), 689 "has been reached.\nYou can't add more entries."),
690 i18n("maximum number of entries")); 690 i18n("maximum number of entries"));
691 doc->timer()->putLock(DocTimer::id_autoLockTimer); 691 doc->timer()->putLock(DocTimer::id_autoLockTimer);
692 return; 692 return;
693 } 693 }
694 } 694 }
695 setVirgin(false); 695 setVirgin(false);
696 doc->timer()->putLock(DocTimer::id_autoLockTimer); 696 doc->timer()->putLock(DocTimer::id_autoLockTimer);
697} 697}
698 698
699//US ENH : changed code to run with older MOC 699//US ENH : changed code to run with older MOC
700void PwM::editPwd_slot() 700void PwM::editPwd_slot()
701{ 701{
702 editPwd_slot3(0,0,0); 702 editPwd_slot3(0,0,0);
703} 703}
704 704
705void PwM::editPwd_slot1(const QString *category) 705void PwM::editPwd_slot1(const QString *category)
706{ 706{
707 editPwd_slot3(category, 0, 0); 707 editPwd_slot3(category, 0, 0);
708} 708}
709 709
710void PwM::editPwd_slot3(const QString *category, const int *index, 710void PwM::editPwd_slot3(const QString *category, const int *index,
711 PwMDoc *_doc) 711 PwMDoc *_doc)
712{ 712{
713 PwMDoc *doc; 713 PwMDoc *doc;
714 if (_doc) { 714 if (_doc) {
715 doc = _doc; 715 doc = _doc;
716 } else { 716 } else {
717 doc = curDoc(); 717 doc = curDoc();
718 } 718 }
719 PWM_ASSERT(doc); 719 PWM_ASSERT(doc);
720 if (doc->isDocEmpty()) 720 if (doc->isDocEmpty())
721 return; 721 return;
722 if (doc->isDeepLocked()) 722 if (doc->isDeepLocked())
723 return; 723 return;
724 doc->timer()->getLock(DocTimer::id_autoLockTimer); 724 doc->timer()->getLock(DocTimer::id_autoLockTimer);
725 unsigned int curEntryIndex; 725 unsigned int curEntryIndex;
726 if (index) { 726 if (index) {
727 curEntryIndex = *index; 727 curEntryIndex = *index;
728 } else { 728 } else {
729 if (!(view->getCurEntryIndex(&curEntryIndex))) { 729 if (!(view->getCurEntryIndex(&curEntryIndex))) {
730 qDebug("couldn't get index. Maybe we have a binary entry here. ");
730 printDebug("couldn't get index. Maybe we have a binary entry here."); 731 printDebug("couldn't get index. Maybe we have a binary entry here.");
731 doc->timer()->putLock(DocTimer::id_autoLockTimer); 732 doc->timer()->putLock(DocTimer::id_autoLockTimer);
732 return; 733 return;
733 } 734 }
734 } 735 }
735 QString curCategory; 736 QString curCategory;
736 if (category) { 737 if (category) {
737 curCategory = *category; 738 curCategory = *category;
738 } else { 739 } else {
739 curCategory = view->getCurrentCategory(); 740 curCategory = view->getCurrentCategory();
740 } 741 }
741 PwMDataItem currItem; 742 PwMDataItem currItem;
742 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 743 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
743 doc->timer()->putLock(DocTimer::id_autoLockTimer); 744 doc->timer()->putLock(DocTimer::id_autoLockTimer);
744 return; 745 return;
745 } 746 }
746 BUG_ON(currItem.binary); 747 BUG_ON(currItem.binary);
747
748 AddEntryWndImpl w(doc); 748 AddEntryWndImpl w(doc);
749 w.setCaption( i18n ("Edit password") ); 749 w.setCaption( i18n ("Edit password") );
750 vector<string> catList; 750 vector<string> catList;
751 doc->getCategoryList(&catList); 751 doc->getCategoryList(&catList);
752 unsigned i, size = catList.size(); 752 unsigned i, size = catList.size();
753 for (i = 0; i < size; ++i) { 753 for (i = 0; i < size; ++i) {
754 w.addCategory(catList[i].c_str()); 754 w.addCategory(catList[i].c_str());
755 } 755 }
756 w.setCurrCategory(curCategory); 756 w.setCurrCategory(curCategory);
757 w.setDescription(currItem.desc.c_str()); 757 w.setDescription(currItem.desc.c_str());
758 w.setUsername(currItem.name.c_str()); 758 w.setUsername(currItem.name.c_str());
759 w.setPassword(currItem.pw.c_str()); 759 w.setPassword(currItem.pw.c_str());
760 w.setUrl(currItem.url.c_str()); 760 w.setUrl(currItem.url.c_str());
761 w.setLauncher(currItem.launcher.c_str()); 761 w.setLauncher(currItem.launcher.c_str());
762 w.setComment(currItem.comment.c_str()); 762 w.setComment(currItem.comment.c_str());
763 w.descLineEdit->setFocus(); 763 w.descLineEdit->setFocus();
764 if (w.exec() == 1) { 764 if (w.exec() == 1) {
765 currItem.desc = w.getDescription().latin1(); 765 currItem.desc = w.getDescription().latin1();
766 currItem.name = w.getUsername().latin1(); 766 currItem.name = w.getUsername().latin1();
767 currItem.pw = w.getPassword().latin1(); 767 currItem.pw = w.getPassword().latin1();
768 currItem.comment = w.getComment().latin1(); 768 currItem.comment = w.getComment().latin1();
769 currItem.url = w.getUrl().latin1(); 769 currItem.url = w.getUrl().latin1();
770 currItem.launcher = w.getLauncher().latin1(); 770 currItem.launcher = w.getLauncher().latin1();
771 if (!doc->editEntry(curCategory, w.getCategory(), 771 if (!doc->editEntry(curCategory, w.getCategory(),
772 curEntryIndex, &currItem)) { 772 curEntryIndex, &currItem)) {
773 KMessageBox::error(this, 773 KMessageBox::error(this,
774 i18n("Couldn't edit the entry.\n" 774 i18n("Couldn't edit the entry.\n"
775 "Maybe you changed the category and\n" 775 "Maybe you changed the category and\n"
776 "this entry is already present\nin the new " 776 "this entry is already present\nin the new "
777 "category?"), 777 "category?"),
778 i18n("couldn't edit entry.")); 778 i18n("couldn't edit entry."));
779 doc->timer()->putLock(DocTimer::id_autoLockTimer); 779 doc->timer()->putLock(DocTimer::id_autoLockTimer);
780 return; 780 return;
781 } 781 }
782 } 782 }
783 doc->timer()->putLock(DocTimer::id_autoLockTimer); 783 doc->timer()->putLock(DocTimer::id_autoLockTimer);
784} 784}
785 785
786void PwM::deletePwd_slot() 786void PwM::deletePwd_slot()
787{ 787{
788 PWM_ASSERT(curDoc()); 788 PWM_ASSERT(curDoc());
789 if (curDoc()->isDocEmpty()) 789 if (curDoc()->isDocEmpty())
790 return; 790 return;
791 if (curDoc()->isDeepLocked()) 791 if (curDoc()->isDeepLocked())
792 return; 792 return;
793 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 793 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
794 unsigned int curEntryIndex = 0; 794 unsigned int curEntryIndex = 0;
795 if (!(view->getCurEntryIndex(&curEntryIndex))) { 795 if (!(view->getCurEntryIndex(&curEntryIndex))) {
796 printDebug("couldn't get index"); 796 printDebug("couldn't get index");
797 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 797 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
798 return; 798 return;
799 } 799 }
800 800
801 PwMDataItem currItem; 801 PwMDataItem currItem;
802 QString curCategory = view->getCurrentCategory(); 802 QString curCategory = view->getCurrentCategory();
803 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 803 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
804 printDebug("couldn't get entry"); 804 printDebug("couldn't get entry");
805 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 805 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
806 return; 806 return;
807 } 807 }
808 if (KMessageBox:: 808 if (KMessageBox::
809 questionYesNo(this, 809 questionYesNo(this,
810 i18n 810 i18n
811 ("Do you really want to delete\nthe selected entry") + 811 ("Do you really want to delete\nthe selected entry") +
812 " \n\"" + QString(currItem.desc.c_str()) 812 " \n\"" + QString(currItem.desc.c_str())
813 + "\" ?", i18n("delete?")) 813 + "\" ?", i18n("delete?"))
814 == KMessageBox::Yes) { 814 == KMessageBox::Yes) {
815 815
816 curDoc()->delEntry(curCategory, curEntryIndex); 816 curDoc()->delEntry(curCategory, curEntryIndex);
817 } 817 }
818 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 818 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
819} 819}
820 820
821void PwM::changeMasterPwd_slot() 821void PwM::changeMasterPwd_slot()
822{ 822{
823 PWM_ASSERT(curDoc()); 823 PWM_ASSERT(curDoc());
824 curDoc()->changeCurrentPw(); 824 curDoc()->changeCurrentPw();
825} 825}
826 826
827void PwM::lockWnd_slot() 827void PwM::lockWnd_slot()
828{ 828{
829 PWM_ASSERT(curDoc()); 829 PWM_ASSERT(curDoc());
830 curDoc()->lockAll(true); 830 curDoc()->lockAll(true);
831} 831}
832 832
833void PwM::deepLockWnd_slot() 833void PwM::deepLockWnd_slot()
834{ 834{
835 PWM_ASSERT(curDoc()); 835 PWM_ASSERT(curDoc());
836 curDoc()->deepLock(); 836 curDoc()->deepLock();
837} 837}
838 838
839void PwM::unlockWnd_slot() 839void PwM::unlockWnd_slot()
840{ 840{
841 PWM_ASSERT(curDoc()); 841 PWM_ASSERT(curDoc());
842 curDoc()->lockAll(false); 842 curDoc()->lockAll(false);
843} 843}
844 844
845void PwM::config_slot() 845void PwM::config_slot()
846{ 846{
847 int oldStyle = conf()->confWndMainViewStyle(); 847 int oldStyle = conf()->confWndMainViewStyle();
848#ifdef PWM_EMBEDDED 848#ifdef PWM_EMBEDDED
849 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); 849 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true );
850 850
851 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); 851 KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" );
852 ConfigureDialog->addModule(pwmcfg ); 852 ConfigureDialog->addModule(pwmcfg );
853 853
854 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 854 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
855 ConfigureDialog->addModule(kdelibcfg ); 855 ConfigureDialog->addModule(kdelibcfg );
856 856
857#ifndef DESKTOP_VERSION 857#ifndef DESKTOP_VERSION
858 ConfigureDialog->showMaximized(); 858 ConfigureDialog->showMaximized();
859#endif 859#endif
860 if ( ConfigureDialog->exec() ) 860 if ( ConfigureDialog->exec() )
861 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 861 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
862 delete ConfigureDialog; 862 delete ConfigureDialog;
863 863
864#else //PWM_EMBEDDED 864#else //PWM_EMBEDDED
865 // display the configuration window (modal mode) 865 // display the configuration window (modal mode)
866 if (!conf()->showConfWnd(this)) 866 if (!conf()->showConfWnd(this))
867 return; 867 return;
868#endif 868#endif
869 869
870 int newStyle = conf()->confWndMainViewStyle(); 870 int newStyle = conf()->confWndMainViewStyle();
871 // reinitialize tray 871 // reinitialize tray
872 init->initTray(); 872 init->initTray();
873 // reinitialize KWallet emulation 873 // reinitialize KWallet emulation
874 init->initKWalletEmu(); 874 init->initKWalletEmu();
875 875
876 PwMDocList *_dl = PwMDoc::getOpenDocList(); 876 PwMDocList *_dl = PwMDoc::getOpenDocList();
877 const vector<PwMDocList::listItem> *dl = _dl->getList(); 877 const vector<PwMDocList::listItem> *dl = _dl->getList();
878 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 878 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
879 end = dl->end(); 879 end = dl->end();
880 PwMDoc *doc; 880 PwMDoc *doc;
881 while (i != end) { 881 while (i != end) {
882 doc = (*i).doc; 882 doc = (*i).doc;
883 // unlock-without-mpw timeout 883 // unlock-without-mpw timeout
884 doc->timer()->start(DocTimer::id_mpwTimer); 884 doc->timer()->start(DocTimer::id_mpwTimer);
885 // auto-lock timeout 885 // auto-lock timeout
886 doc->timer()->start(DocTimer::id_autoLockTimer); 886 doc->timer()->start(DocTimer::id_autoLockTimer);
887 ++i; 887 ++i;
888 } 888 }
889 889
890 const QValueList<PwM *> *ml = init->mainWndList(); 890 const QValueList<PwM *> *ml = init->mainWndList();
891#ifndef PWM_EMBEDDED 891#ifndef PWM_EMBEDDED
892 QValueList<PwM *>::const_iterator i2 = ml->begin(), 892 QValueList<PwM *>::const_iterator i2 = ml->begin(),
893 end2 = ml->end(); 893 end2 = ml->end();
894#else 894#else
895 QValueList<PwM *>::ConstIterator i2 = ml->begin(), 895 QValueList<PwM *>::ConstIterator i2 = ml->begin(),
896 end2 = ml->end(); 896 end2 = ml->end();
897#endif 897#endif
898 PwM *pwm; 898 PwM *pwm;
899 while (i2 != end2) { 899 while (i2 != end2) {
900 pwm = *i2; 900 pwm = *i2;
901 // reinitialize the window style. 901 // reinitialize the window style.
902 if (oldStyle != newStyle) 902 if (oldStyle != newStyle)
903 pwm->curView()->initStyle(newStyle); 903 pwm->curView()->initStyle(newStyle);
904 // set the new font 904 // set the new font
905 pwm->curView()->setFont(conf()->confGlobEntryFont()); 905 pwm->curView()->setFont(conf()->confGlobEntryFont());
906 ++i2; 906 ++i2;
907 } 907 }
908} 908}
909 909
910void PwM::activateMpButton(bool activate) 910void PwM::activateMpButton(bool activate)
911{ 911{
912 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); 912 managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate);
913} 913}
914 914
915void PwM::closeEvent(QCloseEvent *e) 915void PwM::closeEvent(QCloseEvent *e)
916{ 916{
917 //qDebug("PwM::closeEvent "); 917 //qDebug("PwM::closeEvent ");
918 emit closed( this ); 918 emit closed( this );
919 return; 919 return;
920 e->accept(); 920 e->accept();
921} 921}
922 922
923void PwM::docClosed(PwMDoc *doc) 923void PwM::docClosed(PwMDoc *doc)
924{ 924{
925 //qDebug("PwM::docClosed "); 925 //qDebug("PwM::docClosed ");
926 PARAM_UNUSED(doc); 926 PARAM_UNUSED(doc);
927 PWM_ASSERT(doc == curDoc()); 927 PWM_ASSERT(doc == curDoc());
928 close(); 928 close();
929} 929}
930 930
931void PwM::find_slot() 931void PwM::find_slot()
932{ 932{
933 PWM_ASSERT(curDoc()); 933 PWM_ASSERT(curDoc());
934 if (curDoc()->isDocEmpty()) 934 if (curDoc()->isDocEmpty())
935 return; 935 return;
936 if (curDoc()->isDeepLocked()) 936 if (curDoc()->isDeepLocked())
937 return; 937 return;
938 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 938 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
939 FindWndImpl findWnd(view); 939 FindWndImpl findWnd(view);
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 1f15ffd..6fbe110 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -1052,407 +1052,463 @@ PwMerror PwMDoc::addCategory(const QString &category, unsigned int *categoryInde
1052 if (findCategory(category, categoryIndex)) 1052 if (findCategory(category, categoryIndex))
1053 return e_categoryExists; 1053 return e_categoryExists;
1054 } 1054 }
1055 PwMCategoryItem item; 1055 PwMCategoryItem item;
1056 //US ENH: clear item to initialize with default values, or create a constructor 1056 //US ENH: clear item to initialize with default values, or create a constructor
1057 item.clear(); 1057 item.clear();
1058 1058
1059 item.name = category.latin1(); 1059 item.name = category.latin1();
1060 dti.dta.push_back(item); 1060 dti.dta.push_back(item);
1061 if (categoryIndex) 1061 if (categoryIndex)
1062 *categoryIndex = dti.dta.size() - 1; 1062 *categoryIndex = dti.dta.size() - 1;
1063 return e_success; 1063 return e_success;
1064} 1064}
1065 1065
1066bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty) 1066bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlagDirty)
1067{ 1067{
1068 unsigned int cat = 0; 1068 unsigned int cat = 0;
1069 1069
1070 if (!findCategory(category, &cat)) { 1070 if (!findCategory(category, &cat)) {
1071 BUG(); 1071 BUG();
1072 return false; 1072 return false;
1073 } 1073 }
1074 1074
1075 return delEntry(cat, index, dontFlagDirty); 1075 return delEntry(cat, index, dontFlagDirty);
1076} 1076}
1077 1077
1078bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty) 1078bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty)
1079{ 1079{
1080 if (isDeepLocked()) 1080 if (isDeepLocked())
1081 return false; 1081 return false;
1082 if (index > dti.dta[category].d.size() - 1) 1082 if (index > dti.dta[category].d.size() - 1)
1083 return false; 1083 return false;
1084 getDataChangedLock(); 1084 getDataChangedLock();
1085 if (!lockAt(category, index, false)) { 1085 if (!lockAt(category, index, false)) {
1086 putDataChangedLock(); 1086 putDataChangedLock();
1087 return false; 1087 return false;
1088 } 1088 }
1089 putDataChangedLock(); 1089 putDataChangedLock();
1090 int lvPos = dti.dta[category].d[index].listViewPos; 1090 int lvPos = dti.dta[category].d[index].listViewPos;
1091 1091
1092 // delete entry 1092 // delete entry
1093 dti.dta[category].d.erase(dti.dta[category].d.begin() + index); 1093 dti.dta[category].d.erase(dti.dta[category].d.begin() + index);
1094 1094
1095 unsigned int i, entries = numEntries(category); 1095 unsigned int i, entries = numEntries(category);
1096 if (!entries) { 1096 if (!entries) {
1097 // no more entries in this category, so 1097 // no more entries in this category, so
1098 // we can delete it, too. 1098 // we can delete it, too.
1099 BUG_ON(!delCategory(category)); 1099 BUG_ON(!delCategory(category));
1100 // delCategory() flags it dirty, so we need not to do so. 1100 // delCategory() flags it dirty, so we need not to do so.
1101 return true; 1101 return true;
1102 } 1102 }
1103 for (i = 0; i < entries; ++i) { 1103 for (i = 0; i < entries; ++i) {
1104 // decrement all listViewPositions that are greater than the deleted. 1104 // decrement all listViewPositions that are greater than the deleted.
1105 if (dti.dta[category].d[i].listViewPos > lvPos) 1105 if (dti.dta[category].d[i].listViewPos > lvPos)
1106 --dti.dta[category].d[i].listViewPos; 1106 --dti.dta[category].d[i].listViewPos;
1107 } 1107 }
1108 1108
1109 if (!dontFlagDirty) 1109 if (!dontFlagDirty)
1110 flagDirty(); 1110 flagDirty();
1111 return true; 1111 return true;
1112} 1112}
1113 1113
1114bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory, 1114bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory,
1115 unsigned int index, PwMDataItem *d, bool updateMeta) 1115 unsigned int index, PwMDataItem *d, bool updateMeta)
1116{ 1116{
1117 PWM_ASSERT(d); 1117 PWM_ASSERT(d);
1118 unsigned int oldCat = 0; 1118 unsigned int oldCat = 0;
1119 1119
1120 if (!findCategory(oldCategory, &oldCat)) { 1120 if (!findCategory(oldCategory, &oldCat)) {
1121 BUG(); 1121 BUG();
1122 return false; 1122 return false;
1123 } 1123 }
1124 1124
1125 return editEntry(oldCat, newCategory, index, d, updateMeta); 1125 return editEntry(oldCat, newCategory, index, d, updateMeta);
1126} 1126}
1127 1127
1128bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory, 1128bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory,
1129 unsigned int index, PwMDataItem *d, bool updateMeta) 1129 unsigned int index, PwMDataItem *d, bool updateMeta)
1130{ 1130{
1131 if (isDeepLocked()) 1131 if (isDeepLocked())
1132 return false; 1132 return false;
1133 if (updateMeta) { 1133 if (updateMeta) {
1134 d->meta.update = QDateTime::currentDateTime(); 1134 d->meta.update = QDateTime::currentDateTime();
1135 if (d->meta.create.isNull()) { 1135 if (d->meta.create.isNull()) {
1136 d->meta.create = d->meta.update; 1136 d->meta.create = d->meta.update;
1137 } 1137 }
1138 } 1138 }
1139 if (dti.dta[oldCategory].name != newCategory.latin1()) { 1139 if (dti.dta[oldCategory].name != newCategory.latin1()) {
1140 // the user changed the category. 1140 // the user changed the category.
1141 PwMerror ret; 1141 PwMerror ret;
1142 d->rev = 0; 1142 d->rev = 0;
1143 ret = addEntry(newCategory, d, true, false); 1143 ret = addEntry(newCategory, d, true, false);
1144 if (ret != e_success) 1144 if (ret != e_success)
1145 return false; 1145 return false;
1146 if (!delEntry(oldCategory, index, true)) 1146 if (!delEntry(oldCategory, index, true))
1147 return false; 1147 return false;
1148 } else { 1148 } else {
1149 d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter. 1149 d->rev = dti.dta[oldCategory].d[index].rev + 1; // increment revision counter.
1150 dti.dta[oldCategory].d[index] = *d; 1150 dti.dta[oldCategory].d[index] = *d;
1151 } 1151 }
1152 flagDirty(); 1152 flagDirty();
1153 return true; 1153 return true;
1154} 1154}
1155 1155
1156unsigned int PwMDoc::numEntries(const QString &category) 1156unsigned int PwMDoc::numEntries(const QString &category)
1157{ 1157{
1158 unsigned int cat = 0; 1158 unsigned int cat = 0;
1159 1159
1160 if (!findCategory(category, &cat)) { 1160 if (!findCategory(category, &cat)) {
1161 BUG(); 1161 BUG();
1162 return 0; 1162 return 0;
1163 } 1163 }
1164 1164
1165 return numEntries(cat); 1165 return numEntries(cat);
1166} 1166}
1167 1167
1168bool PwMDoc::serializeDta(string *d) 1168bool PwMDoc::serializeDta(string *d)
1169{ 1169{
1170 PWM_ASSERT(d); 1170 PWM_ASSERT(d);
1171 Serializer ser; 1171 Serializer ser;
1172 if (!ser.serialize(dti)) 1172 if (!ser.serialize(dti))
1173 return false; 1173 return false;
1174 d->assign(ser.getXml()); 1174 d->assign(ser.getXml());
1175 if (!d->size()) 1175 if (!d->size())
1176 return false; 1176 return false;
1177 return true; 1177 return true;
1178} 1178}
1179 1179
1180bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked) 1180bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked)
1181{ 1181{
1182 PWM_ASSERT(d); 1182 PWM_ASSERT(d);
1183#ifndef PWM_EMBEDDED 1183#ifndef PWM_EMBEDDED
1184 try { 1184 try {
1185 1185
1186 Serializer ser(d->c_str()); 1186 Serializer ser(d->c_str());
1187 ser.setDefaultLockStat(entriesLocked); 1187 ser.setDefaultLockStat(entriesLocked);
1188 if (!ser.deSerialize(&dti)) 1188 if (!ser.deSerialize(&dti))
1189 return false; 1189 return false;
1190 } catch (PwMException) { 1190 } catch (PwMException) {
1191 return false; 1191 return false;
1192 } 1192 }
1193#else 1193#else
1194 Serializer ser(d->c_str()); 1194 Serializer ser(d->c_str());
1195 ser.setDefaultLockStat(entriesLocked); 1195 ser.setDefaultLockStat(entriesLocked);
1196 if (!ser.deSerialize(&dti)) 1196 if (!ser.deSerialize(&dti))
1197 return false; 1197 return false;
1198#endif 1198#endif
1199 1199
1200 emitDataChanged(this); 1200 emitDataChanged(this);
1201 return true; 1201 return true;
1202} 1202}
1203 1203
1204bool PwMDoc::getEntry(const QString &category, unsigned int index, 1204bool PwMDoc::getEntry(const QString &category, unsigned int index,
1205 PwMDataItem * d, bool unlockIfLocked) 1205 PwMDataItem * d, bool unlockIfLocked)
1206{ 1206{
1207 PWM_ASSERT(d); 1207 PWM_ASSERT(d);
1208 unsigned int cat = 0; 1208 unsigned int cat = 0;
1209 1209
1210 if (!findCategory(category, &cat)) { 1210 if (!findCategory(category, &cat)) {
1211 BUG(); 1211 BUG();
1212 return false; 1212 return false;
1213 } 1213 }
1214 1214
1215 return getEntry(cat, index, d, unlockIfLocked); 1215 return getEntry(cat, index, d, unlockIfLocked);
1216} 1216}
1217 1217
1218bool PwMDoc::getEntry(unsigned int category, unsigned int index, 1218bool PwMDoc::getEntry(unsigned int category, unsigned int index,
1219 PwMDataItem *d, bool unlockIfLocked) 1219 PwMDataItem *d, bool unlockIfLocked)
1220{ 1220{
1221 if (index > dti.dta[category].d.size() - 1) 1221 if (index > dti.dta[category].d.size() - 1)
1222 return false; 1222 return false;
1223 1223
1224 bool locked = isLocked(category, index); 1224 bool locked = isLocked(category, index);
1225 if (locked) { 1225 if (locked) {
1226 /* this entry is locked. We don't return a password, 1226 /* this entry is locked. We don't return a password,
1227 * until it's unlocked by the user by inserting 1227 * until it's unlocked by the user by inserting
1228 * chipcard or entering the mpw 1228 * chipcard or entering the mpw
1229 */ 1229 */
1230 if (unlockIfLocked) { 1230 if (unlockIfLocked) {
1231 if (!lockAt(category, index, false)) { 1231 if (!lockAt(category, index, false)) {
1232 return false; 1232 return false;
1233 } 1233 }
1234 locked = false; 1234 locked = false;
1235 } 1235 }
1236 } 1236 }
1237 1237
1238 *d = dti.dta[category].d[index]; 1238 *d = dti.dta[category].d[index];
1239 if (locked) 1239 if (locked)
1240 d->pw = LOCKED_STRING.latin1(); 1240 d->pw = LOCKED_STRING.latin1();
1241 1241
1242 return true; 1242 return true;
1243} 1243}
1244
1245PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos, 1244PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos,
1246 string *foundComment) 1245 string *foundComment)
1247{ 1246{
1248 PWM_ASSERT(foundComment); 1247 PWM_ASSERT(foundComment);
1249 unsigned int cat = 0; 1248 unsigned int cat = 0;
1250 1249
1251 if (!findCategory(category, &cat)) 1250 if (!findCategory(category, &cat))
1252 return e_invalidArg; 1251 return e_invalidArg;
1253 1252
1254 unsigned int i, entries = numEntries(cat); 1253 unsigned int i, entries = numEntries(cat);
1255 for (i = 0; i < entries; ++i) { 1254 for (i = 0; i < entries; ++i) {
1256 if (dti.dta[cat].d[i].listViewPos == listViewPos) { 1255 if (dti.dta[cat].d[i].listViewPos == listViewPos) {
1257 *foundComment = dti.dta[cat].d[i].comment; 1256 *foundComment = dti.dta[cat].d[i].comment;
1258 if (dti.dta[cat].d[i].binary) 1257 if (dti.dta[cat].d[i].binary)
1259 return e_binEntry; 1258 return e_binEntry;
1260 return e_normalEntry; 1259 return e_normalEntry;
1261 } 1260 }
1262 } 1261 }
1263 BUG(); 1262 BUG();
1264 return e_generic; 1263 return e_generic;
1265} 1264}
1266 1265
1266PwMerror PwMDoc::getCommentByLvp_long(const QString &category, int listViewPos,
1267 string *foundComment)
1268{
1269 PWM_ASSERT(foundComment);
1270 unsigned int cat = 0;
1271
1272 if (!findCategory(category, &cat))
1273 return e_invalidArg;
1274
1275 unsigned int i, entries = numEntries(cat);
1276 for (i = 0; i < entries; ++i) {
1277 if (dti.dta[cat].d[i].listViewPos == listViewPos) {
1278 if (dti.dta[cat].d[i].binary)
1279 return e_binEntry;
1280 PwMCategoryItem* catItem = getCategoryEntry(cat);
1281 QString retval;
1282 QString tempval = QString (dti.dta[cat].d[i].desc.c_str());
1283 if ( !tempval.isEmpty() ) {
1284 retval += "<b>" +QString ( catItem->desc_text.c_str() )+ ":</b> "+ tempval+"<br>" ;
1285 }
1286 tempval = QString (dti.dta[cat].d[i].name.c_str());
1287 if ( !tempval.isEmpty() ) {
1288 retval += "<b>" +QString ( catItem->name_text.c_str() ) + ":</b> "+ tempval+"<br>" ;
1289 }
1290 tempval = QString (dti.dta[cat].d[i].pw.c_str());
1291 if ( !tempval.isEmpty() ) {
1292 if ( dti.dta[cat].d[i].lockStat )
1293 retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + i18n("<LOCKED>") +"<br>" ;
1294 else
1295 retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + tempval+"<br>" ;
1296 }
1297 tempval = QString (dti.dta[cat].d[i].url.c_str());
1298 if ( !tempval.isEmpty() ) {
1299 retval += "<b>" +i18n("URL:")+ "</b> " + tempval+"<br>" ;
1300 }
1301 tempval = QString (dti.dta[cat].d[i].launcher.c_str());
1302 if ( !tempval.isEmpty() ) {
1303 retval += "<b>" +i18n("Launcher:")+ "</b> " + tempval+"<br>" ;
1304 }
1305 tempval = QString (dti.dta[cat].d[i].comment.c_str());
1306 if ( !tempval.isEmpty() ) {
1307 tempval.replace(QRegExp ( "\n" ), "<br>" );
1308 retval += "<b>" +i18n("Comment:")+ "</b><br>" + tempval+"<br>" ;
1309 }
1310
1311 string ret ( retval.latin1() );
1312
1313
1314 // *foundComment = dti.dta[cat].d[i].comment;
1315 *foundComment = ret;
1316 return e_normalEntry;
1317 }
1318 }
1319 BUG();
1320 return e_generic;
1321}
1322
1267bool PwMDoc::compressDta(string *d, char algo) 1323bool PwMDoc::compressDta(string *d, char algo)
1268{ 1324{
1269 PWM_ASSERT(d); 1325 PWM_ASSERT(d);
1270 switch (algo) { 1326 switch (algo) {
1271 case PWM_COMPRESS_GZIP: { 1327 case PWM_COMPRESS_GZIP: {
1272 CompressGzip comp; 1328 CompressGzip comp;
1273 return comp.compress(d); 1329 return comp.compress(d);
1274 } 1330 }
1275#ifndef PWM_EMBEDDED 1331#ifndef PWM_EMBEDDED
1276 case PWM_COMPRESS_BZIP2: { 1332 case PWM_COMPRESS_BZIP2: {
1277 CompressBzip2 comp; 1333 CompressBzip2 comp;
1278 return comp.compress(d); 1334 return comp.compress(d);
1279 } 1335 }
1280#endif 1336#endif
1281 case PWM_COMPRESS_NONE: { 1337 case PWM_COMPRESS_NONE: {
1282 return true; 1338 return true;
1283 } default: { 1339 } default: {
1284 BUG(); 1340 BUG();
1285 } 1341 }
1286 } 1342 }
1287 return false; 1343 return false;
1288} 1344}
1289 1345
1290bool PwMDoc::decompressDta(string *d, char algo) 1346bool PwMDoc::decompressDta(string *d, char algo)
1291{ 1347{
1292 PWM_ASSERT(d); 1348 PWM_ASSERT(d);
1293 switch (algo) { 1349 switch (algo) {
1294 case PWM_COMPRESS_GZIP: { 1350 case PWM_COMPRESS_GZIP: {
1295 CompressGzip comp; 1351 CompressGzip comp;
1296 return comp.decompress(d); 1352 return comp.decompress(d);
1297 } 1353 }
1298#ifndef PWM_EMBEDDED 1354#ifndef PWM_EMBEDDED
1299 case PWM_COMPRESS_BZIP2: { 1355 case PWM_COMPRESS_BZIP2: {
1300 CompressBzip2 comp; 1356 CompressBzip2 comp;
1301 return comp.decompress(d); 1357 return comp.decompress(d);
1302 } 1358 }
1303#endif 1359#endif
1304 case PWM_COMPRESS_NONE: { 1360 case PWM_COMPRESS_NONE: {
1305 return true; 1361 return true;
1306 } 1362 }
1307 } 1363 }
1308 return false; 1364 return false;
1309} 1365}
1310 1366
1311PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo, 1367PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo,
1312 char hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase 1368 char hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase
1313) 1369)
1314{ 1370{
1315 PWM_ASSERT(d); 1371 PWM_ASSERT(d);
1316 PWM_ASSERT(pw); 1372 PWM_ASSERT(pw);
1317 PWM_ASSERT(f); 1373 PWM_ASSERT(f);
1318 1374
1319 size_t encSize; 1375 size_t encSize;
1320 byte *encrypted = 0; 1376 byte *encrypted = 0;
1321 1377
1322 switch (algo) { 1378 switch (algo) {
1323 case PWM_CRYPT_BLOWFISH: { 1379 case PWM_CRYPT_BLOWFISH: {
1324 Blowfish::padNull(d); 1380 Blowfish::padNull(d);
1325 encSize = d->length(); 1381 encSize = d->length();
1326 encrypted = new byte[encSize]; 1382 encrypted = new byte[encSize];
1327 Blowfish bf; 1383 Blowfish bf;
1328 if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) { 1384 if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) {
1329 delete [] encrypted; 1385 delete [] encrypted;
1330 return e_weakPw; 1386 return e_weakPw;
1331 } 1387 }
1332 bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize); 1388 bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize);
1333 break; 1389 break;
1334 } 1390 }
1335 case PWM_CRYPT_AES128: 1391 case PWM_CRYPT_AES128:
1336 /*... fall through */ 1392 /*... fall through */
1337 case PWM_CRYPT_AES192: 1393 case PWM_CRYPT_AES192:
1338 case PWM_CRYPT_AES256: 1394 case PWM_CRYPT_AES256:
1339 case PWM_CRYPT_3DES: 1395 case PWM_CRYPT_3DES:
1340 case PWM_CRYPT_TWOFISH: 1396 case PWM_CRYPT_TWOFISH:
1341 case PWM_CRYPT_TWOFISH128: { 1397 case PWM_CRYPT_TWOFISH128: {
1342 if (!LibGCryptIf::available()) 1398 if (!LibGCryptIf::available())
1343 return e_cryptNotImpl; 1399 return e_cryptNotImpl;
1344 LibGCryptIf gc; 1400 LibGCryptIf gc;
1345 PwMerror err; 1401 PwMerror err;
1346 unsigned char *plain = new unsigned char[d->length() + 1024]; 1402 unsigned char *plain = new unsigned char[d->length() + 1024];
1347 memcpy(plain, d->c_str(), d->length()); 1403 memcpy(plain, d->c_str(), d->length());
1348 err = gc.encrypt(&encrypted, 1404 err = gc.encrypt(&encrypted,
1349 &encSize, 1405 &encSize,
1350 plain, 1406 plain,
1351 d->length(), 1407 d->length(),
1352 reinterpret_cast<const unsigned char *>(pw->latin1()), 1408 reinterpret_cast<const unsigned char *>(pw->latin1()),
1353 pw->length(), 1409 pw->length(),
1354 algo, 1410 algo,
1355 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase 1411 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase
1356 ); 1412 );
1357 delete [] plain; 1413 delete [] plain;
1358 if (err != e_success) 1414 if (err != e_success)
1359 return e_cryptNotImpl; 1415 return e_cryptNotImpl;
1360 break; 1416 break;
1361 } 1417 }
1362 default: { 1418 default: {
1363 delete_ifnot_null_array(encrypted); 1419 delete_ifnot_null_array(encrypted);
1364 return e_cryptNotImpl; 1420 return e_cryptNotImpl;
1365 } } 1421 } }
1366 1422
1367 // write encrypted data to file 1423 // write encrypted data to file
1368 if (f->writeBlock(reinterpret_cast<const char *>(encrypted), 1424 if (f->writeBlock(reinterpret_cast<const char *>(encrypted),
1369 static_cast<Q_ULONG>(encSize)) 1425 static_cast<Q_ULONG>(encSize))
1370 != static_cast<Q_LONG>(encSize)) { 1426 != static_cast<Q_LONG>(encSize)) {
1371 delete_ifnot_null_array(encrypted); 1427 delete_ifnot_null_array(encrypted);
1372 return e_writeFile; 1428 return e_writeFile;
1373 } 1429 }
1374 delete_ifnot_null_array(encrypted); 1430 delete_ifnot_null_array(encrypted);
1375 return e_success; 1431 return e_success;
1376} 1432}
1377 1433
1378PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, 1434PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw,
1379 char algo, 1435 char algo,
1380 char hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase 1436 char hashalgo, //US BUG: pass _hashalgo because we need it in hashPassphrase
1381 QFile *f) 1437 QFile *f)
1382{ 1438{
1383 PWM_ASSERT(d); 1439 PWM_ASSERT(d);
1384 PWM_ASSERT(pw); 1440 PWM_ASSERT(pw);
1385 PWM_ASSERT(f); 1441 PWM_ASSERT(f);
1386 1442
1387 unsigned int cryptLen = f->size() - pos; 1443 unsigned int cryptLen = f->size() - pos;
1388 byte *encrypted = new byte[cryptLen]; 1444 byte *encrypted = new byte[cryptLen];
1389 byte *decrypted = new byte[cryptLen]; 1445 byte *decrypted = new byte[cryptLen];
1390 1446
1391 f->at(pos); 1447 f->at(pos);
1392#ifndef PWM_EMBEDDED 1448#ifndef PWM_EMBEDDED
1393 if (f->readBlock(reinterpret_cast<char *>(encrypted), 1449 if (f->readBlock(reinterpret_cast<char *>(encrypted),
1394 static_cast<Q_ULONG>(cryptLen)) 1450 static_cast<Q_ULONG>(cryptLen))
1395 != static_cast<Q_LONG>(cryptLen)) { 1451 != static_cast<Q_LONG>(cryptLen)) {
1396 delete [] encrypted; 1452 delete [] encrypted;
1397 delete [] decrypted; 1453 delete [] decrypted;
1398 return e_readFile; 1454 return e_readFile;
1399 } 1455 }
1400#else 1456#else
1401 if (f->readBlock((char *)(encrypted), 1457 if (f->readBlock((char *)(encrypted),
1402 (unsigned long)(cryptLen)) 1458 (unsigned long)(cryptLen))
1403 != (long)(cryptLen)) { 1459 != (long)(cryptLen)) {
1404 delete [] encrypted; 1460 delete [] encrypted;
1405 delete [] decrypted; 1461 delete [] decrypted;
1406 return e_readFile; 1462 return e_readFile;
1407 } 1463 }
1408#endif 1464#endif
1409 switch (algo) { 1465 switch (algo) {
1410 case PWM_CRYPT_BLOWFISH: { 1466 case PWM_CRYPT_BLOWFISH: {
1411 Blowfish bf; 1467 Blowfish bf;
1412 bf.bf_setkey((byte *) pw->latin1(), pw->length()); 1468 bf.bf_setkey((byte *) pw->latin1(), pw->length());
1413 bf.bf_decrypt(decrypted, encrypted, cryptLen); 1469 bf.bf_decrypt(decrypted, encrypted, cryptLen);
1414 break; 1470 break;
1415 } 1471 }
1416 case PWM_CRYPT_AES128: 1472 case PWM_CRYPT_AES128:
1417 /*... fall through */ 1473 /*... fall through */
1418 case PWM_CRYPT_AES192: 1474 case PWM_CRYPT_AES192:
1419 case PWM_CRYPT_AES256: 1475 case PWM_CRYPT_AES256:
1420 case PWM_CRYPT_3DES: 1476 case PWM_CRYPT_3DES:
1421 case PWM_CRYPT_TWOFISH: 1477 case PWM_CRYPT_TWOFISH:
1422 case PWM_CRYPT_TWOFISH128: { 1478 case PWM_CRYPT_TWOFISH128: {
1423 if (!LibGCryptIf::available()) 1479 if (!LibGCryptIf::available())
1424 return e_cryptNotImpl; 1480 return e_cryptNotImpl;
1425 LibGCryptIf gc; 1481 LibGCryptIf gc;
1426 PwMerror err; 1482 PwMerror err;
1427 err = gc.decrypt(&decrypted, 1483 err = gc.decrypt(&decrypted,
1428 &cryptLen, 1484 &cryptLen,
1429 encrypted, 1485 encrypted,
1430 cryptLen, 1486 cryptLen,
1431 reinterpret_cast<const unsigned char *>(pw->latin1()), 1487 reinterpret_cast<const unsigned char *>(pw->latin1()),
1432 pw->length(), 1488 pw->length(),
1433 algo, 1489 algo,
1434 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase 1490 hashalgo //US BUG: pass _hashalgo because we need it in hashPassphrase
1435); 1491);
1436 if (err != e_success) { 1492 if (err != e_success) {
1437 delete [] encrypted; 1493 delete [] encrypted;
1438 delete [] decrypted; 1494 delete [] decrypted;
1439 return e_cryptNotImpl; 1495 return e_cryptNotImpl;
1440 } 1496 }
1441 break; 1497 break;
1442 } 1498 }
1443 default: { 1499 default: {
1444 delete [] encrypted; 1500 delete [] encrypted;
1445 delete [] decrypted; 1501 delete [] decrypted;
1446 return e_cryptNotImpl; 1502 return e_cryptNotImpl;
1447 } } 1503 } }
1448 delete [] encrypted; 1504 delete [] encrypted;
1449#ifndef PWM_EMBEDDED 1505#ifndef PWM_EMBEDDED
1450 d->assign(reinterpret_cast<const char *>(decrypted), 1506 d->assign(reinterpret_cast<const char *>(decrypted),
1451 static_cast<string::size_type>(cryptLen)); 1507 static_cast<string::size_type>(cryptLen));
1452#else 1508#else
1453 d->assign((const char *)(decrypted), 1509 d->assign((const char *)(decrypted),
1454 (string::size_type)(cryptLen)); 1510 (string::size_type)(cryptLen));
1455#endif 1511#endif
1456 delete [] decrypted; 1512 delete [] decrypted;
1457 if (algo == PWM_CRYPT_BLOWFISH) { 1513 if (algo == PWM_CRYPT_BLOWFISH) {
1458 if (!Blowfish::unpadNull(d)) { 1514 if (!Blowfish::unpadNull(d)) {
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 9fcdda7..45dd729 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -345,384 +345,386 @@ protected:
345 /* Hm, I think we shouldn't really use a "list" here, should we? 345 /* Hm, I think we shouldn't really use a "list" here, should we?
346 * So I decided to actually use a vector. 346 * So I decided to actually use a vector.
347 */ 347 */
348 vector<listItem> docList; 348 vector<listItem> docList;
349 /** This value is used to get a new number for yet unnamed 349 /** This value is used to get a new number for yet unnamed
350 * documents. It is incremented on every request. So it's 350 * documents. It is incremented on every request. So it's
351 * theoretically possible to overflow it, but... :) 351 * theoretically possible to overflow it, but... :)
352 */ 352 */
353 static unsigned int unnamedDocCnt; 353 static unsigned int unnamedDocCnt;
354}; 354};
355 355
356/** implements timers for the document */ 356/** implements timers for the document */
357class DocTimer : public QObject 357class DocTimer : public QObject
358{ 358{
359 Q_OBJECT 359 Q_OBJECT
360public: 360public:
361 enum TimerIDs 361 enum TimerIDs
362 { 362 {
363 id_mpwTimer, 363 id_mpwTimer,
364 id_autoLockTimer, 364 id_autoLockTimer,
365 id_metaCheckTimer 365 id_metaCheckTimer
366 }; 366 };
367 367
368public: 368public:
369 DocTimer(PwMDoc *_doc); 369 DocTimer(PwMDoc *_doc);
370 ~DocTimer(); 370 ~DocTimer();
371 371
372 /** start the timer */ 372 /** start the timer */
373 void start(TimerIDs timer); 373 void start(TimerIDs timer);
374 /** stop the timer */ 374 /** stop the timer */
375 void stop(TimerIDs timer); 375 void stop(TimerIDs timer);
376 /** get the lock for a timer. 376 /** get the lock for a timer.
377 * This lock is a recursive lock. When a lock is 377 * This lock is a recursive lock. When a lock is
378 * held, the timer will be stopped and timeout is 378 * held, the timer will be stopped and timeout is
379 * guaranteed to not happen 379 * guaranteed to not happen
380 */ 380 */
381 void getLock(TimerIDs timer); 381 void getLock(TimerIDs timer);
382 /** put a recursive timer lock */ 382 /** put a recursive timer lock */
383 void putLock(TimerIDs timer); 383 void putLock(TimerIDs timer);
384 384
385protected slots: 385protected slots:
386 /** timeout slot for the mpw timer */ 386 /** timeout slot for the mpw timer */
387 void mpwTimeout(); 387 void mpwTimeout();
388 /** timeout slot for the autoLock timer */ 388 /** timeout slot for the autoLock timer */
389 void autoLockTimeout(); 389 void autoLockTimeout();
390 /** timeout slot for the metaCheck timer */ 390 /** timeout slot for the metaCheck timer */
391 void metaCheckTimeout(); 391 void metaCheckTimeout();
392 392
393protected: 393protected:
394 /** pointer to the document associated with this timer. */ 394 /** pointer to the document associated with this timer. */
395 PwMDoc *doc; 395 PwMDoc *doc;
396 /** timer object for mpw timer */ 396 /** timer object for mpw timer */
397 QTimer *mpwTimer; 397 QTimer *mpwTimer;
398 /** timer object for the autoLock timer */ 398 /** timer object for the autoLock timer */
399 QTimer *autoLockTimer; 399 QTimer *autoLockTimer;
400 /** timer object for the metaCheck timer */ 400 /** timer object for the metaCheck timer */
401 QTimer *metaCheckTimer; 401 QTimer *metaCheckTimer;
402 /** lock counter for the mpw timer */ 402 /** lock counter for the mpw timer */
403 unsigned int mpwLock; 403 unsigned int mpwLock;
404 /** lock counter for the autoLock timer */ 404 /** lock counter for the autoLock timer */
405 unsigned int autoLockLock; 405 unsigned int autoLockLock;
406 /** lock counter for the metaCheck timer */ 406 /** lock counter for the metaCheck timer */
407 unsigned int metaCheckLock; 407 unsigned int metaCheckLock;
408}; 408};
409 409
410/** Document class for PwM */ 410/** Document class for PwM */
411//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required. 411//US ENH: derived from KSyncInterfaces, to get called by PwM when a sync is required.
412// But PwMDoc is handling the sync by itself. 412// But PwMDoc is handling the sync by itself.
413class PwMDoc : public PwMDocUi, public KSyncInterface 413class PwMDoc : public PwMDocUi, public KSyncInterface
414 414
415{ 415{
416 Q_OBJECT 416 Q_OBJECT
417 friend class DocTimer; 417 friend class DocTimer;
418 418
419public: 419public:
420 /** construtor */ 420 /** construtor */
421 PwMDoc(QObject* parent = 0, const char *name = 0); 421 PwMDoc(QObject* parent = 0, const char *name = 0);
422 /** destructor */ 422 /** destructor */
423 ~PwMDoc(); 423 ~PwMDoc();
424 424
425 /** returns a pointer to a list of all open documents */ 425 /** returns a pointer to a list of all open documents */
426 static PwMDocList* getOpenDocList() 426 static PwMDocList* getOpenDocList()
427 { return &openDocList; } 427 { return &openDocList; }
428 428
429 /** flag document dirty. dta changed */ 429 /** flag document dirty. dta changed */
430 void flagDirty() 430 void flagDirty()
431 { 431 {
432 setDocStatFlag(DOC_STAT_DISK_DIRTY); 432 setDocStatFlag(DOC_STAT_DISK_DIRTY);
433 emitDataChanged(this); 433 emitDataChanged(this);
434 } 434 }
435 /** modified? */ 435 /** modified? */
436 bool isDirty() 436 bool isDirty()
437 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); } 437 { return getDocStatFlag(DOC_STAT_DISK_DIRTY); }
438 /** save document to disk */ 438 /** save document to disk */
439 PwMerror saveDoc(char compress, const QString *file = 0); 439 PwMerror saveDoc(char compress, const QString *file = 0);
440 /** read document from file. 440 /** read document from file.
441 * "openLocked is must be set to either of these values: 441 * "openLocked is must be set to either of these values:
442 * 0 == open with all entries unlocked 442 * 0 == open with all entries unlocked
443 * 1 == open with all entries locked 443 * 1 == open with all entries locked
444 * 2 == open deep-locked 444 * 2 == open deep-locked
445 */ 445 */
446 PwMerror openDoc(const QString *file, int openLocked); 446 PwMerror openDoc(const QString *file, int openLocked);
447 /** export document to ascii-textfile */ 447 /** export document to ascii-textfile */
448 PwMerror exportToText(const QString *file); 448 PwMerror exportToText(const QString *file);
449 /** export document to gpasman / kpasman file */ 449 /** export document to gpasman / kpasman file */
450 PwMerror exportToGpasman(const QString *file); 450 PwMerror exportToGpasman(const QString *file);
451 /** import document from ascii-textfile */ 451 /** import document from ascii-textfile */
452 PwMerror importFromText(const QString *file, int format = -1); 452 PwMerror importFromText(const QString *file, int format = -1);
453 /** import document from gpasman / kpasman file */ 453 /** import document from gpasman / kpasman file */
454 PwMerror importFromGpasman(const QString *file); 454 PwMerror importFromGpasman(const QString *file);
455 /** add new entry */ 455 /** add new entry */
456 PwMerror addEntry(const QString &category, PwMDataItem *d, 456 PwMerror addEntry(const QString &category, PwMDataItem *d,
457 bool dontFlagDirty = false, bool updateMeta = true); 457 bool dontFlagDirty = false, bool updateMeta = true);
458 /** add new category. This function doesn't flag the document dirty! */ 458 /** add new category. This function doesn't flag the document dirty! */
459 PwMerror addCategory(const QString &category, unsigned int *categoryIndex, 459 PwMerror addCategory(const QString &category, unsigned int *categoryIndex,
460 bool checkIfExist = true); 460 bool checkIfExist = true);
461 /** rename an existing category */ 461 /** rename an existing category */
462 bool renameCategory(const QString &category, const QString &newName); 462 bool renameCategory(const QString &category, const QString &newName);
463 /** rename an existing category */ 463 /** rename an existing category */
464 bool renameCategory(unsigned int category, const QString &newName, 464 bool renameCategory(unsigned int category, const QString &newName,
465 bool dontFlagDirty = false); 465 bool dontFlagDirty = false);
466 /** delete an existing category */ 466 /** delete an existing category */
467 bool delCategory(const QString &category); 467 bool delCategory(const QString &category);
468 /** delete an existing category */ 468 /** delete an existing category */
469 bool delCategory(unsigned int category, bool dontFlagDirty = false); 469 bool delCategory(unsigned int category, bool dontFlagDirty = false);
470 /** returns a list of all category-names */ 470 /** returns a list of all category-names */
471 void getCategoryList(vector<string> *list); 471 void getCategoryList(vector<string> *list);
472 /** returns a list of all category-names */ 472 /** returns a list of all category-names */
473 void getCategoryList(QStringList *list); 473 void getCategoryList(QStringList *list);
474 /** returns a list of all entry-descs in the given category */ 474 /** returns a list of all entry-descs in the given category */
475 void getEntryList(const QString &category, QStringList *list); 475 void getEntryList(const QString &category, QStringList *list);
476 /** returns a list of all entry-descs in the given category */ 476 /** returns a list of all entry-descs in the given category */
477 void getEntryList(const QString &category, vector<string> *list); 477 void getEntryList(const QString &category, vector<string> *list);
478 /** returns a list of all entry-descs in the given category */ 478 /** returns a list of all entry-descs in the given category */
479 void getEntryList(unsigned int category, vector<string> *list); 479 void getEntryList(unsigned int category, vector<string> *list);
480 /** returns a list of all entry-descs in the given category */ 480 /** returns a list of all entry-descs in the given category */
481 void getEntryList(unsigned int category, QStringList *list); 481 void getEntryList(unsigned int category, QStringList *list);
482 /** delete entry */ 482 /** delete entry */
483 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false); 483 bool delEntry(const QString &category, unsigned int index, bool dontFlagDirty = false);
484 /** delete entry */ 484 /** delete entry */
485 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false); 485 bool delEntry(unsigned int category, unsigned int index, bool dontFlagDirty = false);
486 /** edit entry */ 486 /** edit entry */
487 bool editEntry(const QString &oldCategory, const QString &newCategory, 487 bool editEntry(const QString &oldCategory, const QString &newCategory,
488 unsigned int index, PwMDataItem *d, bool updateMeta = true); 488 unsigned int index, PwMDataItem *d, bool updateMeta = true);
489 /** edit entry */ 489 /** edit entry */
490 bool editEntry(unsigned int oldCategory, const QString &newCategory, 490 bool editEntry(unsigned int oldCategory, const QString &newCategory,
491 unsigned int index, PwMDataItem *d, bool updateMeta = true); 491 unsigned int index, PwMDataItem *d, bool updateMeta = true);
492 /** finds the category with the "name" and return it's index */ 492 /** finds the category with the "name" and return it's index */
493 bool findCategory(const QString &name, unsigned int *index); 493 bool findCategory(const QString &name, unsigned int *index);
494 /** search for an entry "find" and check while searching only for 494 /** search for an entry "find" and check while searching only for
495 * the data-fields specified by "searchIn". To set the "searchIn" 495 * the data-fields specified by "searchIn". To set the "searchIn"
496 * value, we may use one or more of the SEARCH_IN_* defines at 496 * value, we may use one or more of the SEARCH_IN_* defines at
497 * the top of this header-file. It returns the positions of all 497 * the top of this header-file. It returns the positions of all
498 * matched entries in "foundPositions". If "breakAfterFound" is true, 498 * matched entries in "foundPositions". If "breakAfterFound" is true,
499 * the function terminates after the first occurence of the entry 499 * the function terminates after the first occurence of the entry
500 * and doesn't go on searching. So foundPositions->size() is never 500 * and doesn't go on searching. So foundPositions->size() is never
501 * > 1 if breakAfterFound is true. 501 * > 1 if breakAfterFound is true.
502 */ 502 */
503 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, 503 void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
504 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 504 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
505 bool caseSensitive = true, bool exactWordMatch = true, 505 bool caseSensitive = true, bool exactWordMatch = true,
506 bool sortByLvp = false); 506 bool sortByLvp = false);
507 /** see the above funtion. This function allows to set the category by name. */ 507 /** see the above funtion. This function allows to set the category by name. */
508 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, 508 void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn,
509 vector<unsigned int> *foundPositions, bool breakAfterFound = false, 509 vector<unsigned int> *foundPositions, bool breakAfterFound = false,
510 bool caseSensitive = true, bool exactWordMatch = true, 510 bool caseSensitive = true, bool exactWordMatch = true,
511 bool sortByLvp = false); 511 bool sortByLvp = false);
512 /** returns number of entries */ 512 /** returns number of entries */
513 unsigned int numEntries(const QString &category); 513 unsigned int numEntries(const QString &category);
514 unsigned int numEntries(unsigned int category) 514 unsigned int numEntries(unsigned int category)
515 { return dti.dta[category].d.size(); } 515 { return dti.dta[category].d.size(); }
516 /** returns number of categories */ 516 /** returns number of categories */
517 unsigned int numCategories() 517 unsigned int numCategories()
518 { return dti.dta.size(); } 518 { return dti.dta.size(); }
519 /** returns the name of the category at "index" */ 519 /** returns the name of the category at "index" */
520 const string* getCategory(unsigned int index) 520 const string* getCategory(unsigned int index)
521 { return (&(dti.dta[index].name)); } 521 { return (&(dti.dta[index].name)); }
522 522
523 /** returns the data of item at "index". 523 /** returns the data of item at "index".
524 * It unlocks the entry if it's locked and unlockIfLocked is true. 524 * It unlocks the entry if it's locked and unlockIfLocked is true.
525 * If the entry is locked, but unlockIfLocked is false, it'll not return 525 * If the entry is locked, but unlockIfLocked is false, it'll not return
526 * the pw. 526 * the pw.
527 */ 527 */
528 bool getEntry(const QString &category, unsigned int index, 528 bool getEntry(const QString &category, unsigned int index,
529 PwMDataItem *d, bool unlockIfLocked = false); 529 PwMDataItem *d, bool unlockIfLocked = false);
530 bool getEntry(unsigned int category, unsigned int index, 530 bool getEntry(unsigned int category, unsigned int index,
531 PwMDataItem *d, bool unlockIfLocked = false); 531 PwMDataItem *d, bool unlockIfLocked = false);
532 /** returns the comment-string by looking at the category 532 /** returns the comment-string by looking at the category
533 * and the listViewPos 533 * and the listViewPos
534 */ 534 */
535 PwMerror getCommentByLvp(const QString &category, int listViewPos, 535 PwMerror getCommentByLvp(const QString &category, int listViewPos,
536 string *foundComment); 536 string *foundComment);
537 PwMerror getCommentByLvp_long(const QString &category, int listViewPos,
538 string *foundComment);
537 /** checks if a password is already available. (currentPw) */ 539 /** checks if a password is already available. (currentPw) */
538 bool isPwAvailable() 540 bool isPwAvailable()
539 { return (currentPw != ""); } 541 { return (currentPw != ""); }
540 /** un/lock entry at "index". If needed, ask for password. */ 542 /** un/lock entry at "index". If needed, ask for password. */
541 bool lockAt(const QString &category, unsigned int index, 543 bool lockAt(const QString &category, unsigned int index,
542 bool lock = true); 544 bool lock = true);
543 bool lockAt(unsigned int category, unsigned int index, 545 bool lockAt(unsigned int category, unsigned int index,
544 bool lock = true); 546 bool lock = true);
545 /** returns the lock-status at "index" */ 547 /** returns the lock-status at "index" */
546 bool isLocked(const QString &category, unsigned int index); 548 bool isLocked(const QString &category, unsigned int index);
547 bool isLocked(unsigned int category, unsigned int index) 549 bool isLocked(unsigned int category, unsigned int index)
548 { return dti.dta[category].d[index].lockStat; } 550 { return dti.dta[category].d[index].lockStat; }
549 /** returns the deeplock status */ 551 /** returns the deeplock status */
550 bool isDeepLocked() 552 bool isDeepLocked()
551 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } 553 { return getDocStatFlag(DOC_STAT_DEEPLOCKED); }
552 /** (un)lock all entries */ 554 /** (un)lock all entries */
553 bool lockAll(bool lock); 555 bool lockAll(bool lock);
554 /** unlocks all entries tempoarly. 556 /** unlocks all entries tempoarly.
555 * 1st NOTE: Be very careful with this function! :) 557 * 1st NOTE: Be very careful with this function! :)
556 * 2nd NOTE: After you have called unlockAll_Tempoary(); , 558 * 2nd NOTE: After you have called unlockAll_Tempoary(); ,
557 * please DON'T forget to call unlockAll_Tempoary(true); 559 * please DON'T forget to call unlockAll_Tempoary(true);
558 * _before_ the user (or someone else) is able to change 560 * _before_ the user (or someone else) is able to change
559 * the document! 561 * the document!
560 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary 562 * 3rd NOTE: Please DON'T change "dta" while the data is tempoary
561 * unlocked! This will cause corruption. 563 * unlocked! This will cause corruption.
562 */ 564 */
563 bool unlockAll_tempoary(bool revert = false); 565 bool unlockAll_tempoary(bool revert = false);
564 /** deep-(un)locks the document. 566 /** deep-(un)locks the document.
565 * deep-locking writes all data to the file, deletes all data 567 * deep-locking writes all data to the file, deletes all data
566 * in memory, but doesn't close the document. 568 * in memory, but doesn't close the document.
567 * deep-locking is only available, if the user previously saved 569 * deep-locking is only available, if the user previously saved
568 * the doc to a file (with a password). 570 * the doc to a file (with a password).
569 * If "saveToFile" is false, it does NOT write the data to the file! 571 * If "saveToFile" is false, it does NOT write the data to the file!
570 */ 572 */
571 PwMerror deepLock(bool lock = true, bool saveToFile = true); 573 PwMerror deepLock(bool lock = true, bool saveToFile = true);
572 /** is unlockable without pw? */ 574 /** is unlockable without pw? */
573 bool unlockWoPw() 575 bool unlockWoPw()
574 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); } 576 { return getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); }
575 /** get the "currentPassword" */ 577 /** get the "currentPassword" */
576 const QString& getCurrentPw() 578 const QString& getCurrentPw()
577 { return currentPw; } 579 { return currentPw; }
578 /** open a window and request the user to change the mpw */ 580 /** open a window and request the user to change the mpw */
579 void changeCurrentPw(); 581 void changeCurrentPw();
580 /** set the "listViewPos" variable of "dta" */ 582 /** set the "listViewPos" variable of "dta" */
581 void setListViewPos(const QString &category, unsigned int index, 583 void setListViewPos(const QString &category, unsigned int index,
582 int pos); 584 int pos);
583 /** set the "listViewPos" variable of "dta" */ 585 /** set the "listViewPos" variable of "dta" */
584 void setListViewPos(unsigned int category, unsigned int index, 586 void setListViewPos(unsigned int category, unsigned int index,
585 int pos); 587 int pos);
586 /** get the "listViewPos" variable of "dta" */ 588 /** get the "listViewPos" variable of "dta" */
587 int getListViewPos(const QString &category, unsigned int index); 589 int getListViewPos(const QString &category, unsigned int index);
588 /** set the maximum number of entries allowed */ 590 /** set the maximum number of entries allowed */
589 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES) 591 void setMaxNumEntries(unsigned int num = DEFAULT_MAX_ENTRIES)
590 { maxEntries = num; } 592 { maxEntries = num; }
591 /** get the maximum number of entries allowed */ 593 /** get the maximum number of entries allowed */
592 unsigned int getMaxNumEntries() 594 unsigned int getMaxNumEntries()
593 { return maxEntries; } 595 { return maxEntries; }
594 /** ensure all listViewPos of all dta items are set. (are ! -1). 596 /** ensure all listViewPos of all dta items are set. (are ! -1).
595 * If there are some undefined entries, add them to the end of 597 * If there are some undefined entries, add them to the end of
596 * the listViewPos(itions). */ 598 * the listViewPos(itions). */
597 void ensureLvp(); 599 void ensureLvp();
598 /** execute the "launcher" of this entry */ 600 /** execute the "launcher" of this entry */
599 bool execLauncher(const QString &category, unsigned int entryIndex); 601 bool execLauncher(const QString &category, unsigned int entryIndex);
600 /** see above */ 602 /** see above */
601 bool execLauncher(unsigned int category, unsigned int entryIndex); 603 bool execLauncher(unsigned int category, unsigned int entryIndex);
602 /** open a browser with the URL-section of the given entry */ 604 /** open a browser with the URL-section of the given entry */
603 bool goToURL(const QString &category, unsigned int entryIndex); 605 bool goToURL(const QString &category, unsigned int entryIndex);
604 /** see above */ 606 /** see above */
605 bool goToURL(unsigned int category, unsigned int entryIndex); 607 bool goToURL(unsigned int category, unsigned int entryIndex);
606 /** returns true if there is no entry present in the document. 608 /** returns true if there is no entry present in the document.
607 * Note: The "default" Category is present everytime, so 609 * Note: The "default" Category is present everytime, so
608 * it's checked for it's entries. 610 * it's checked for it's entries.
609 */ 611 */
610 bool isDocEmpty() 612 bool isDocEmpty()
611 { 613 {
612 if (numCategories() > 1) 614 if (numCategories() > 1)
613 return false; 615 return false;
614 if (numEntries(0)) 616 if (numEntries(0))
615 return false; 617 return false;
616 return true; 618 return true;
617 } 619 }
618 /** returns the filename of this doc */ 620 /** returns the filename of this doc */
619 const QString& getFilename() 621 const QString& getFilename()
620 { return filename; } 622 { return filename; }
621 /** returns the title of the doc */ 623 /** returns the title of the doc */
622 QString getTitle(); 624 QString getTitle();
623 /** sets the list-view-pointer hold in the doc */ 625 /** sets the list-view-pointer hold in the doc */
624 void setListViewPointer(PwMView *_listView) 626 void setListViewPointer(PwMView *_listView)
625 { listView = _listView; } 627 { listView = _listView; }
626 /** returns the list-view-pointer */ 628 /** returns the list-view-pointer */
627 PwMView * getListViewPointer() 629 PwMView * getListViewPointer()
628 { return listView; } 630 { return listView; }
629 /** try to delete the doc. The user may be asked to save 631 /** try to delete the doc. The user may be asked to save
630 * the data. The user may cancel the whole operation. 632 * the data. The user may cancel the whole operation.
631 * false is returned, then. 633 * false is returned, then.
632 */ 634 */
633 bool tryDelete(); 635 bool tryDelete();
634 /** is the doc deleted? (with tryDelete() ) */ 636 /** is the doc deleted? (with tryDelete() ) */
635 bool isDeleted() 637 bool isDeleted()
636 { return deleted; } 638 { return deleted; }
637 /** returns the document timer object */ 639 /** returns the document timer object */
638 DocTimer * timer() 640 DocTimer * timer()
639 { return _timer; } 641 { return _timer; }
640 /** get a lock on the dataChanged signal. 642 /** get a lock on the dataChanged signal.
641 * If someone is holding a lock, the signal is not emitted. 643 * If someone is holding a lock, the signal is not emitted.
642 */ 644 */
643 void getDataChangedLock() 645 void getDataChangedLock()
644 { ++dataChangedLock; } 646 { ++dataChangedLock; }
645 /** put the dataChanged lock */ 647 /** put the dataChanged lock */
646 void putDataChangedLock() 648 void putDataChangedLock()
647 { --dataChangedLock; } 649 { --dataChangedLock; }
648 /** returns the revision count of the item at cat/index */ 650 /** returns the revision count of the item at cat/index */
649 unsigned int getEntryRevCnt(unsigned int category, unsigned int index) 651 unsigned int getEntryRevCnt(unsigned int category, unsigned int index)
650 { return dti.dta[category].d[index].rev; } 652 { return dti.dta[category].d[index].rev; }
651 /** returns a const pointer to the entries meta */ 653 /** returns a const pointer to the entries meta */
652 const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index) 654 const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index)
653 { return &(dti.dta[category].d[index].meta); } 655 { return &(dti.dta[category].d[index].meta); }
654 /** is the entry at "category" "index" a binary entry? */ 656 /** is the entry at "category" "index" a binary entry? */
655 bool isBinEntry(unsigned int category, unsigned int index) 657 bool isBinEntry(unsigned int category, unsigned int index)
656 { return dti.dta[category].d[index].binary; } 658 { return dti.dta[category].d[index].binary; }
657 659
658public slots: 660public slots:
659 /** wrapper for PwMTray */ 661 /** wrapper for PwMTray */
660 void _deepUnlock(); 662 void _deepUnlock();
661 663
662signals: 664signals:
663 /** the data of the document has changed and must be updated 665 /** the data of the document has changed and must be updated
664 * in all views. 666 * in all views.
665 * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal! 667 * NOTE: use emitDataChanged(PwMDoc *document) to emit this signal!
666 */ 668 */
667 void dataChanged(PwMDoc *document); 669 void dataChanged(PwMDoc *document);
668 /** the document class is going to close. This signal may be 670 /** the document class is going to close. This signal may be
669 * used to nofify all views, that the user closed the document, 671 * used to nofify all views, that the user closed the document,
670 * so the views can go down, too. 672 * so the views can go down, too.
671 */ 673 */
672 void docClosed(PwMDoc *document); 674 void docClosed(PwMDoc *document);
673 /** somebody just opened the document */ 675 /** somebody just opened the document */
674 void docOpened(PwMDoc *document); 676 void docOpened(PwMDoc *document);
675 /** this document object just got created */ 677 /** this document object just got created */
676 void docCreated(PwMDoc *document); 678 void docCreated(PwMDoc *document);
677 679
678public: 680public:
679 /** emit the dataChanged signal after checking for a lock */ 681 /** emit the dataChanged signal after checking for a lock */
680 void emitDataChanged(PwMDoc *document) 682 void emitDataChanged(PwMDoc *document)
681 { 683 {
682 if (!dataChangedLock) 684 if (!dataChangedLock)
683 emit dataChanged(document); 685 emit dataChanged(document);
684 } 686 }
685 687
686protected: 688protected:
687 /** current file for this doc */ 689 /** current file for this doc */
688 QString filename; 690 QString filename;
689//US ENH: we need a place where we keep the syncentries. So I invented 691//US ENH: we need a place where we keep the syncentries. So I invented
690// struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem 692// struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem
691 /** holds all data */ 693 /** holds all data */
692 PwMItem dti; 694 PwMItem dti;
693 /** maximum number of entries */ 695 /** maximum number of entries */
694 unsigned int maxEntries; 696 unsigned int maxEntries;
695 /** currently used password to encrypt data */ 697 /** currently used password to encrypt data */
696 QString currentPw; 698 QString currentPw;
697 /** current global document status flags */ 699 /** current global document status flags */
698 unsigned int curDocStat; 700 unsigned int curDocStat;
699 /** browser process for goToURL() */ 701 /** browser process for goToURL() */
700 KProcess browserProc; 702 KProcess browserProc;
701 /** pointer to the list-view, using this document. 703 /** pointer to the list-view, using this document.
702 * As there can only be one list-view per doc, we 704 * As there can only be one list-view per doc, we
703 * don't need a list here. 705 * don't need a list here.
704 */ 706 */
705 PwMView *listView; 707 PwMView *listView;
706 /** unnamedNum is used to store the "unnamed counter" 708 /** unnamedNum is used to store the "unnamed counter"
707 * for this document, while it's unnamed. If it's 0, 709 * for this document, while it's unnamed. If it's 0,
708 * we have to get a new unique one. 710 * we have to get a new unique one.
709 */ 711 */
710 unsigned int unnamedNum; 712 unsigned int unnamedNum;
711 /** is this doc going to be deleted (executing in destructor context) */ 713 /** is this doc going to be deleted (executing in destructor context) */
712 bool deleted; 714 bool deleted;
713 /** document timer */ 715 /** document timer */
714 DocTimer *_timer; 716 DocTimer *_timer;
715 /** lock counter for the "dataChanged" signal */ 717 /** lock counter for the "dataChanged" signal */
716 unsigned int dataChangedLock; 718 unsigned int dataChangedLock;
717 719
718 /** list of all open documents */ 720 /** list of all open documents */
719 static PwMDocList openDocList; 721 static PwMDocList openDocList;
720 722
721protected: 723protected:
722 /** serialize "dta" and return it in "d". */ 724 /** serialize "dta" and return it in "d". */
723 bool serializeDta(string *d); 725 bool serializeDta(string *d);
724 /** de-serialize "d" and overwrite "dta" */ 726 /** de-serialize "d" and overwrite "dta" */
725 bool deSerializeDta(const string *d, bool entriesLocked); 727 bool deSerializeDta(const string *d, bool entriesLocked);
726 /** write header to file */ 728 /** write header to file */
727 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress, 729 PwMerror writeFileHeader(char keyHash, char dataHash, char crypt, char compress,
728 QString *pw, QFile *f); 730 QString *pw, QFile *f);
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index 7f7dd6f..0092692 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -1,306 +1,306 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "pwmview.h" 20#include "pwmview.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "globalstuff.h" 22#include "globalstuff.h"
23#include "pwm.h" 23#include "pwm.h"
24#include "rencatwnd.h" 24#include "rencatwnd.h"
25#ifndef PWM_EMBEDDED 25#ifndef PWM_EMBEDDED
26#include "configuration.h" 26#include "configuration.h"
27#else 27#else
28#include "pwmprefs.h" 28#include "pwmprefs.h"
29#endif 29#endif
30#include "commentbox.h" 30#include "commentbox.h"
31 31
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qpoint.h> 36#include <qpoint.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qlayout.h> 38#include <qlayout.h>
39 39
40//US ENH: wouldn't it be a good idea if we could use this consts everywhere else. 40//US ENH: wouldn't it be a good idea if we could use this consts everywhere else.
41//US ENH: for examle in listviewpwm.cpp 41//US ENH: for examle in listviewpwm.cpp
42//US ENH: Because of that I transfer them into the headerfile. 42//US ENH: Because of that I transfer them into the headerfile.
43/* 43/*
44 #define COLUMN_DESC 0 44 #define COLUMN_DESC 0
45 #define COLUMN_NAME 1 45 #define COLUMN_NAME 1
46 #define COLUMN_PW 2 46 #define COLUMN_PW 2
47 #define COLUMN_URL 3 47 #define COLUMN_URL 3
48 #define COLUMN_LAUNCHER 4 48 #define COLUMN_LAUNCHER 4
49*/ 49*/
50 50
51PwMView::PwMView(PwM *_mainClass, 51PwMView::PwMView(PwM *_mainClass,
52 QWidget *parent, PwMDoc *_doc, 52 QWidget *parent, PwMDoc *_doc,
53 const char *name) 53 const char *name)
54 : PwMViewStyle(parent, name) 54 : PwMViewStyle(parent, name)
55{ 55{
56 PWM_ASSERT(_mainClass); 56 PWM_ASSERT(_mainClass);
57 PWM_ASSERT(parent); 57 PWM_ASSERT(parent);
58 PWM_ASSERT(_doc); 58 PWM_ASSERT(_doc);
59 setView(this); 59 setView(this);
60 doc = _doc; 60 doc = _doc;
61 doc->setListViewPointer(this); 61 doc->setListViewPointer(this);
62 mainClass = _mainClass; 62 mainClass = _mainClass;
63 resize(_mainClass->size()); 63 resize(_mainClass->size());
64 initStyle(conf()->confWndMainViewStyle()); 64 initStyle(conf()->confWndMainViewStyle());
65 initCtxMenu(); 65 initCtxMenu();
66 doc->setCurrentView(this); 66 doc->setCurrentView(this);
67 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); 67 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView()));
68 connect(this, SIGNAL(editPW()), mainClass, SLOT(editPwd_slot())); 68 connect(this, SIGNAL(editPW()), mainClass, SLOT(editPwd_slot()));
69} 69}
70 70
71PwMView::~PwMView() 71PwMView::~PwMView()
72{ 72{
73} 73}
74 74
75void PwMView::initCtxMenu() 75void PwMView::initCtxMenu()
76{ 76{
77 ctxMenu = new QPopupMenu(this); 77 ctxMenu = new QPopupMenu(this);
78 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); 78 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot()));
79 ctxMenu->insertSeparator(); 79 ctxMenu->insertSeparator();
80 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); 80 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot()));
81 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); 81 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot()));
82 ctxMenu->insertSeparator(); 82 ctxMenu->insertSeparator();
83 ctxMenu->insertItem(i18n("copy password to clipboard"), 83 ctxMenu->insertItem(i18n("copy password to clipboard"),
84 this, SLOT(copyPwToClip())); 84 this, SLOT(copyPwToClip()));
85 ctxMenu->insertItem(i18n("copy username to clipboard"), 85 ctxMenu->insertItem(i18n("copy username to clipboard"),
86 this, SLOT(copyNameToClip())); 86 this, SLOT(copyNameToClip()));
87 ctxMenu->insertItem(i18n("copy description to clipboard"), 87 ctxMenu->insertItem(i18n("copy description to clipboard"),
88 this, SLOT(copyDescToClip())); 88 this, SLOT(copyDescToClip()));
89 ctxMenu->insertItem(i18n("copy url to clipboard"), 89 ctxMenu->insertItem(i18n("copy url to clipboard"),
90 this, SLOT(copyUrlToClip())); 90 this, SLOT(copyUrlToClip()));
91 ctxMenu->insertItem(i18n("copy launcher to clipboard"), 91 ctxMenu->insertItem(i18n("copy launcher to clipboard"),
92 this, SLOT(copyLauncherToClip())); 92 this, SLOT(copyLauncherToClip()));
93 ctxMenu->insertItem(i18n("copy comment to clipboard"), 93 ctxMenu->insertItem(i18n("copy comment to clipboard"),
94 this, SLOT(copyCommentToClip())); 94 this, SLOT(copyCommentToClip()));
95 ctxMenu->insertSeparator(); 95 ctxMenu->insertSeparator();
96 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, 96 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass,
97 SLOT(execLauncher_slot())); 97 SLOT(execLauncher_slot()));
98 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, 98 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass,
99 SLOT(goToURL_slot())); 99 SLOT(goToURL_slot()));
100} 100}
101 101
102void PwMView::resizeEvent(QResizeEvent *) 102void PwMView::resizeEvent(QResizeEvent *)
103{ 103{
104 resizeView(size()); 104 resizeView(size());
105} 105}
106 106
107void PwMView::refreshCommentTextEdit(QListViewItem *curItem) 107void PwMView::refreshCommentTextEdit(QListViewItem *curItem)
108{ 108{
109 PWM_ASSERT(commentBox); 109 PWM_ASSERT(commentBox);
110 if (!curItem) 110 if (!curItem)
111 return; 111 return;
112 string comment; 112 string comment;
113 PwMerror ret; 113 PwMerror ret;
114 ret = document()->getCommentByLvp(getCurrentCategory(), 114 ret = document()->getCommentByLvp_long(getCurrentCategory(),
115 lv->childCount() - lv->itemIndex(curItem) - 1, 115 lv->childCount() - lv->itemIndex(curItem) - 1,
116 &comment); 116 &comment);
117 if (ret == e_binEntry) { 117 if (ret == e_binEntry) {
118 commentBox->setContent(i18n("This is a binary entry.\n" 118 commentBox->setContent(i18n("This is a binary entry.\n"
119 "It is not a normal password-entry, as it contains " 119 "It is not a normal password-entry, as it contains "
120 "binary data, which PwManager can't display here.")); 120 "binary data, which PwManager can't display here."));
121 } else if (ret == e_normalEntry) { 121 } else if (ret == e_normalEntry) {
122 commentBox->setContent(comment.c_str()); 122 commentBox->setContent(comment.c_str());
123 } else { 123 } else {
124 BUG(); 124 BUG();
125 return; 125 return;
126 } 126 }
127 lv->ensureItemVisible(curItem); 127 lv->ensureItemVisible(curItem);
128} 128}
129 129
130void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) 130void PwMView::keyReleaseEvent(QKeyEvent * /*e*/)
131{ 131{
132 refreshCommentTextEdit(lv->currentItem()); 132 refreshCommentTextEdit(lv->currentItem());
133} 133}
134 134
135bool PwMView::getCurEntryIndex(unsigned int *index) 135bool PwMView::getCurEntryIndex(unsigned int *index)
136{ 136{
137 QListViewItem *current = lv->currentItem(); 137 QListViewItem *current = lv->currentItem();
138 if (!current) 138 if (!current)
139 return false; 139 return false;
140 return getDocEntryIndex(index, current); 140 return getDocEntryIndex(index, current);
141} 141}
142 142
143bool PwMView::getDocEntryIndex(unsigned int *index, 143bool PwMView::getDocEntryIndex(unsigned int *index,
144 const QListViewItem *item) 144 const QListViewItem *item)
145{ 145{
146 vector<unsigned int> foundPositions; 146 vector<unsigned int> foundPositions;
147 PwMDataItem curItem; 147 PwMDataItem curItem;
148 curItem.desc = item->text(COLUMN_DESC).latin1(); 148 curItem.desc = item->text(COLUMN_DESC).latin1();
149 curItem.name = item->text(COLUMN_NAME).latin1(); 149 curItem.name = item->text(COLUMN_NAME).latin1();
150 document()->getCommentByLvp(getCurrentCategory(), 150 document()->getCommentByLvp(getCurrentCategory(),
151 lv->childCount() - lv->itemIndex(item) - 1, 151 lv->childCount() - lv->itemIndex(item) - 1,
152 &curItem.comment); 152 &curItem.comment);
153 curItem.url = item->text(COLUMN_URL).latin1(); 153 curItem.url = item->text(COLUMN_URL).latin1();
154 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1(); 154 curItem.launcher = item->text(COLUMN_LAUNCHER).latin1();
155 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC | 155 document()->findEntry(getCurrentCategory(), curItem, SEARCH_IN_DESC |
156 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL | 156 SEARCH_IN_NAME | SEARCH_IN_COMMENT | SEARCH_IN_URL |
157 SEARCH_IN_LAUNCHER, 157 SEARCH_IN_LAUNCHER,
158 &foundPositions, true); 158 &foundPositions, true);
159 if (foundPositions.size()) { 159 if (foundPositions.size()) {
160 *index = foundPositions[0]; 160 *index = foundPositions[0];
161 return true; 161 return true;
162 } 162 }
163 163
164 return false; 164 return false;
165} 165}
166 166
167void PwMView::handleToggle(QListViewItem *item) 167void PwMView::handleToggle(QListViewItem *item)
168{ 168{
169 PWM_ASSERT(doc); 169 PWM_ASSERT(doc);
170 if (!item) 170 if (!item)
171 return; 171 return;
172 QCheckListItem *clItem = (QCheckListItem *)item; 172 QCheckListItem *clItem = (QCheckListItem *)item;
173 QString curCat(getCurrentCategory()); 173 QString curCat(getCurrentCategory());
174 174
175 // find document position of this entry. 175 // find document position of this entry.
176 unsigned int curEntryDocIndex; 176 unsigned int curEntryDocIndex;
177 if (!getDocEntryIndex(&curEntryDocIndex, item)) 177 if (!getDocEntryIndex(&curEntryDocIndex, item))
178 return; 178 return;
179 179
180 // hack to refresh the comment, if only one item is present 180 // hack to refresh the comment, if only one item is present
181 if (lv->childCount() == 1) 181 if (lv->childCount() == 1)
182 refreshCommentTextEdit(lv->currentItem()); 182 refreshCommentTextEdit(lv->currentItem());
183 183
184 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn()) 184 if (doc->isLocked(curCat, curEntryDocIndex) != clItem->isOn())
185 return; // this is just a click somewhere on the entry 185 return; // this is just a click somewhere on the entry
186 if (doc->isDeepLocked()) { 186 if (doc->isDeepLocked()) {
187 PwMerror ret; 187 PwMerror ret;
188 ret = doc->deepLock(false); 188 ret = doc->deepLock(false);
189 if (ret != e_success) 189 if (ret != e_success)
190 clItem->setOn(false); 190 clItem->setOn(false);
191 return; 191 return;
192 } 192 }
193 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); 193 doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn());
194} 194}
195 195
196void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) 196void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int)
197{ 197{
198 if (!item) 198 if (!item)
199 return; 199 return;
200 ctxMenu->move(point); 200 ctxMenu->move(point);
201 /* don't use ctxMenu->exec() here, as it generates race conditions 201 /* don't use ctxMenu->exec() here, as it generates race conditions
202 * with the card interface code. Believe it or not. :) 202 * with the card interface code. Believe it or not. :)
203 */ 203 */
204 ctxMenu->show(); 204 ctxMenu->show();
205} 205}
206 206
207void PwMView::updateCategories() 207void PwMView::updateCategories()
208{ 208{
209 //qDebug("PwMView::updateCategories() "); 209 //qDebug("PwMView::updateCategories() ");
210 QString oldSel(getCurrentCategory()); 210 QString oldSel(getCurrentCategory());
211 delAllCategories(); 211 delAllCategories();
212 QStringList catList; 212 QStringList catList;
213 document()->getCategoryList(&catList); 213 document()->getCategoryList(&catList);
214 catList.sort(); 214 catList.sort();
215#ifndef PWM_EMBEDDED 215#ifndef PWM_EMBEDDED
216 QStringList::iterator i = catList.begin(), 216 QStringList::iterator i = catList.begin(),
217 end = catList.end(); 217 end = catList.end();
218#else 218#else
219 QStringList::Iterator i = catList.begin(), 219 QStringList::Iterator i = catList.begin(),
220 end = catList.end(); 220 end = catList.end();
221#endif 221#endif
222 while (i != end) { 222 while (i != end) {
223 addCategory(*i); 223 addCategory(*i);
224 ++i; 224 ++i;
225 } 225 }
226 selectCategory(oldSel); 226 selectCategory(oldSel);
227} 227}
228 228
229void PwMView::shiftToView() 229void PwMView::shiftToView()
230{ 230{
231 int cX = lv->contentsX(); 231 int cX = lv->contentsX();
232 int cY = lv->contentsY(); 232 int cY = lv->contentsY();
233 commentBox->clear(); 233 commentBox->clear();
234 234
235 unsigned int catDocIndex; 235 unsigned int catDocIndex;
236 if (unlikely( 236 if (unlikely(
237 !(document()->findCategory(getCurrentCategory(), 237 !(document()->findCategory(getCurrentCategory(),
238 &catDocIndex)))) { 238 &catDocIndex)))) {
239 BUG(); 239 BUG();
240 } 240 }
241 241
242 // ensure all listViewPos are set 242 // ensure all listViewPos are set
243 doc->ensureLvp(); 243 doc->ensureLvp();
244 244
245 // clear all tmp-data vectors 245 // clear all tmp-data vectors
246 unsigned int i, entries = doc->numEntries(catDocIndex); 246 unsigned int i, entries = doc->numEntries(catDocIndex);
247 if (entries) { 247 if (entries) {
248 mainClass->setVirgin(false); 248 mainClass->setVirgin(false);
249 } 249 }
250 vector<PwMDataItem> tmpSorted; 250 vector<PwMDataItem> tmpSorted;
251 PwMDataItem currItem; 251 PwMDataItem currItem;
252 currItem.clear(); 252 currItem.clear();
253 tmpSorted.insert(tmpSorted.begin(), entries, currItem); 253 tmpSorted.insert(tmpSorted.begin(), entries, currItem);
254 254
255 // Sort items and store them in tempoary tmpSorted. 255 // Sort items and store them in tempoary tmpSorted.
256 for (i = 0; i < entries; ++i) { 256 for (i = 0; i < entries; ++i) {
257 doc->getEntry(catDocIndex, i, &currItem); 257 doc->getEntry(catDocIndex, i, &currItem);
258 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos); 258 //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos);
259 tmpSorted[currItem.listViewPos] = currItem; 259 tmpSorted[currItem.listViewPos] = currItem;
260 } 260 }
261 261
262 // shift tempoary data to ListView. 262 // shift tempoary data to ListView.
263 tmpDisableSort(); 263 tmpDisableSort();
264 lv->clear(); 264 lv->clear();
265 265
266 //US ENH: adjust the headers of the table according the category texts 266 //US ENH: adjust the headers of the table according the category texts
267 { 267 {
268 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex); 268 PwMCategoryItem* catItem = doc->getCategoryEntry(catDocIndex);
269 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str()); 269 // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str());
270 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str()); 270 lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str());
271 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str()); 271 lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str());
272 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str()); 272 lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str());
273 } 273 }
274 274
275 QCheckListItem *newItem; 275 QCheckListItem *newItem;
276 vector<PwMDataItem>::iterator it = tmpSorted.begin(), 276 vector<PwMDataItem>::iterator it = tmpSorted.begin(),
277 end = tmpSorted.end(); 277 end = tmpSorted.end();
278 while (it != end) { 278 while (it != end) {
279 newItem = new ListViewItemPwM(lv); 279 newItem = new ListViewItemPwM(lv);
280 newItem->setText(COLUMN_DESC, (*it).desc.c_str()); 280 newItem->setText(COLUMN_DESC, (*it).desc.c_str());
281 if ((*it).binary) { 281 if ((*it).binary) {
282 newItem->setText(COLUMN_NAME, ""); 282 newItem->setText(COLUMN_NAME, "");
283 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); 283 newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>"));
284 newItem->setText(COLUMN_URL, ""); 284 newItem->setText(COLUMN_URL, "");
285 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 285 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
286 } else { 286 } else {
287 newItem->setText(COLUMN_NAME, (*it).name.c_str()); 287 newItem->setText(COLUMN_NAME, (*it).name.c_str());
288 if ((*it).lockStat) { 288 if ((*it).lockStat) {
289 newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) 289 newItem->setText(COLUMN_PW, QString((*it).pw.c_str())
290 + " " 290 + " "
291 + i18n("To unlock click the icon on the left.")); 291 + i18n("To unlock click the icon on the left."));
292 } else { 292 } else {
293 newItem->setText(COLUMN_PW, (*it).pw.c_str()); 293 newItem->setText(COLUMN_PW, (*it).pw.c_str());
294 } 294 }
295 newItem->setText(COLUMN_URL, (*it).url.c_str()); 295 newItem->setText(COLUMN_URL, (*it).url.c_str());
296 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 296 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
297 } 297 }
298 newItem->setOn(!((*it).lockStat)); 298 newItem->setOn(!((*it).lockStat));
299 lv->insertItem(newItem); 299 lv->insertItem(newItem);
300 ++it; 300 ++it;
301 } 301 }
302 tmpReEnableSort(); 302 tmpReEnableSort();
303 303
304 if (cY || cX) 304 if (cY || cX)
305 lv->setContentsPos(cX, cY); 305 lv->setContentsPos(cX, cY);
306} 306}
diff --git a/pwmanager/pwmanager/pwmviewstyle_0.cpp b/pwmanager/pwmanager/pwmviewstyle_0.cpp
index 1fc8a34..d82eb15 100644
--- a/pwmanager/pwmanager/pwmviewstyle_0.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle_0.cpp
@@ -1,112 +1,132 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "pwmviewstyle_0.h" 20#include "pwmviewstyle_0.h"
21#include "pwmview.h" 21#include "pwmview.h"
22#include "listviewpwm.h" 22#include "listviewpwm.h"
23#include "commentbox.h" 23#include "commentbox.h"
24 24
25#include <klocale.h> 25#include <klocale.h>
26#include "pwmprefs.h" 26#include "pwmprefs.h"
27 27
28PwMViewStyle_0::PwMViewStyle_0(PwMView *view) 28PwMViewStyle_0::PwMViewStyle_0(PwMView *view)
29 : QObject() 29 : QObject()
30{ 30{
31 vbox1 = new QVBox(view); 31 vbox1 = new QVBox(view);
32 vbox1->setSpacing(3); 32 vbox1->setSpacing(3);
33 hbox1 = new QHBox(vbox1); 33 hbox1 = new QHBox(vbox1);
34 hbox1->setSpacing(3); 34 hbox1->setSpacing(3);
35 categoriesTitle = new QLabel(hbox1); 35 categoriesTitle = new QLabel(hbox1);
36 categoriesTitle->setText(i18n("Categories:")); 36 categoriesTitle->setText(i18n("Categories:"));
37 categoriesCombo = new QComboBox(hbox1); 37 categoriesCombo = new QComboBox(hbox1);
38 renCatButton = new QPushButton(i18n("&Rename"), hbox1); 38 renCatButton = new QPushButton(i18n("&Rename"), hbox1);
39 delCatButton = new QPushButton(i18n("&Delete"), hbox1); 39 delCatButton = new QPushButton(i18n("&Delete"), hbox1);
40#ifndef PWM_EMBEDDED 40#ifndef PWM_EMBEDDED
41 splitter1 = new QSplitter(vbox1); 41 splitter1 = new QSplitter(vbox1);
42 splitter1->setOrientation(Qt::Vertical); 42 splitter1->setOrientation(Qt::Vertical);
43#else 43#else
44 splitter1 = new KDGanttMinimizeSplitter( Qt::Vertical, vbox1); 44 splitter1 = new KDGanttMinimizeSplitter( Qt::Vertical, vbox1);
45 splitter1->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 45 splitter1->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
46 46
47 //US topLayout->addWidget(mMiniSplitter ); 47 //US topLayout->addWidget(mMiniSplitter );
48#endif 48#endif
49 lv = new ListViewPwM(splitter1); 49 lv = new ListViewPwM(splitter1);
50 commentBox = new CommentBox(splitter1); 50 commentBox = new CommentBox(splitter1);
51 // set sizes and styles 51 // set sizes and styles
52 commentBox->resize(commentBox->size().width(), 60); 52 commentBox->resize(commentBox->size().width(), 60);
53 categoriesTitle->setAlignment(Qt::AlignVCenter | Qt::AlignRight); 53 categoriesTitle->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
54 // connections 54 // connections
55 connect(categoriesCombo, SIGNAL(activated(int)), 55 connect(categoriesCombo, SIGNAL(activated(int)),
56 view, SLOT(shiftToView())); 56 view, SLOT(shiftToView()));
57 connect(renCatButton, SIGNAL(clicked()), 57 connect(renCatButton, SIGNAL(clicked()),
58 view, SLOT(renCatButton_slot())); 58 view, SLOT(renCatButton_slot()));
59 connect(delCatButton, SIGNAL(clicked()), 59 connect(delCatButton, SIGNAL(clicked()),
60 view, SLOT(delCatButton_slot())); 60 view, SLOT(delCatButton_slot()));
61 connect(lv, SIGNAL(toggleOverview()),
62 this, SLOT(toggleSplitter()));
61} 63}
62 64
63PwMViewStyle_0::~PwMViewStyle_0() 65PwMViewStyle_0::~PwMViewStyle_0()
64{ 66{
65 delete vbox1; 67 delete vbox1;
66} 68}
69void PwMViewStyle_0::toggleSplitter()
70{
71
72 QValueList<int> si = splitter1->sizes();
73 splitter1->toggle();
74 QValueList<int> si2 = splitter1->sizes();
75 //qDebug("PwMViewStyle_0::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] );
76 if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) {
77 int diff = si[0]/2;
78 if ( diff > 200 )
79 diff = 200;
80 si[0] -= diff;
81 si[1] += diff;
82 splitter1->toggle();
83 splitter1->setSizes( si );
84 }
85
86}
67 87
68void PwMViewStyle_0::delCategory(const QString &cat) 88void PwMViewStyle_0::delCategory(const QString &cat)
69{ 89{
70 PWM_ASSERT(categoriesCombo); 90 PWM_ASSERT(categoriesCombo);
71 int i, count = categoriesCombo->count(); 91 int i, count = categoriesCombo->count();
72 for (i = 0; i < count; ++i) { 92 for (i = 0; i < count; ++i) {
73 if (categoriesCombo->text(i) == cat) { 93 if (categoriesCombo->text(i) == cat) {
74 categoriesCombo->removeItem(i); 94 categoriesCombo->removeItem(i);
75 return; 95 return;
76 } 96 }
77 } 97 }
78 BUG(); 98 BUG();
79} 99}
80 100
81void PwMViewStyle_0::selectCategory(const QString &cat) 101void PwMViewStyle_0::selectCategory(const QString &cat)
82{ 102{
83 PWM_ASSERT(categoriesCombo); 103 PWM_ASSERT(categoriesCombo);
84 int i, count = categoriesCombo->count(); 104 int i, count = categoriesCombo->count();
85 for (i = 0; i < count; ++i) { 105 for (i = 0; i < count; ++i) {
86 if (categoriesCombo->text(i) == cat) { 106 if (categoriesCombo->text(i) == cat) {
87 categoriesCombo->setCurrentItem(i); 107 categoriesCombo->setCurrentItem(i);
88 return; 108 return;
89 } 109 }
90 } 110 }
91 // fall back to 0 111 // fall back to 0
92 categoriesCombo->setCurrentItem(0); 112 categoriesCombo->setCurrentItem(0);
93} 113}
94 114
95 115
96//US ENH: I need a place to load the view dependend settings. Eg. splittersize 116//US ENH: I need a place to load the view dependend settings. Eg. splittersize
97void PwMViewStyle_0::restoreSettings(PWMPrefs* prefs) 117void PwMViewStyle_0::restoreSettings(PWMPrefs* prefs)
98{ 118{
99 //load and store the size of the listviewcolumns 119 //load and store the size of the listviewcolumns
100 lv->restoreLayout(prefs->getConfig(), "listview"); 120 lv->restoreLayout(prefs->getConfig(), "listview");
101 splitter1->setSizes( prefs->mCommentSplitter ); 121 splitter1->setSizes( prefs->mCommentSplitter );
102 commentBox->setFont( prefs->mViewFont ); 122 commentBox->setFont( prefs->mViewFont );
103} 123}
104 124
105//US ENH: I need a place to load the view dependend settings. Eg. splittersize 125//US ENH: I need a place to load the view dependend settings. Eg. splittersize
106void PwMViewStyle_0::saveSettings(PWMPrefs* prefs) 126void PwMViewStyle_0::saveSettings(PWMPrefs* prefs)
107{ 127{
108 //store the size of the listviewcolumns 128 //store the size of the listviewcolumns
109 lv->saveLayout(prefs->getConfig(), "listview"); 129 lv->saveLayout(prefs->getConfig(), "listview");
110 prefs->mCommentSplitter = splitter1->sizes(); 130 prefs->mCommentSplitter = splitter1->sizes();
111 131
112} 132}
diff --git a/pwmanager/pwmanager/pwmviewstyle_0.h b/pwmanager/pwmanager/pwmviewstyle_0.h
index bd93c06..6d3c1d1 100644
--- a/pwmanager/pwmanager/pwmviewstyle_0.h
+++ b/pwmanager/pwmanager/pwmviewstyle_0.h
@@ -1,105 +1,107 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef PWMVIEWSTYLE_0_H 20#ifndef PWMVIEWSTYLE_0_H
21#define PWMVIEWSTYLE_0_H 21#define PWMVIEWSTYLE_0_H
22 22
23#include <qhbox.h> 23#include <qhbox.h>
24#include <qvbox.h> 24#include <qvbox.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#ifndef PWM_EMBEDDED 26#ifndef PWM_EMBEDDED
27#include <qtextedit.h> 27#include <qtextedit.h>
28#include <qsplitter.h> 28#include <qsplitter.h>
29#else 29#else
30#include <qmultilineedit.h> 30#include <qmultilineedit.h>
31#include <KDGanttMinimizeSplitter.h> 31#include <KDGanttMinimizeSplitter.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35 35
36class PwMView; 36class PwMView;
37class ListViewPwM; 37class ListViewPwM;
38class CommentBox; 38class CommentBox;
39class PWMPrefs; 39class PWMPrefs;
40 40
41class PwMViewStyle_0 : public QObject 41class PwMViewStyle_0 : public QObject
42{ 42{
43 Q_OBJECT
43public: 44public:
44 PwMViewStyle_0(PwMView *view); 45 PwMViewStyle_0(PwMView *view);
45 ~PwMViewStyle_0(); 46 ~PwMViewStyle_0();
46 47
47 ListViewPwM * getLv() 48 ListViewPwM * getLv()
48 { return lv; } 49 { return lv; }
49 CommentBox * getCommentBox() 50 CommentBox * getCommentBox()
50 { return commentBox; } 51 { return commentBox; }
51 52
52 /** returns the currently selected category */ 53 /** returns the currently selected category */
53 QString getCurrentCategory() 54 QString getCurrentCategory()
54 { return categoriesCombo->currentText(); } 55 { return categoriesCombo->currentText(); }
55 /** add Category to the view */ 56 /** add Category to the view */
56 void addCategory(const QString &cat) 57 void addCategory(const QString &cat)
57 { categoriesCombo->insertItem(cat); } 58 { categoriesCombo->insertItem(cat); }
58 /** delete Category from view */ 59 /** delete Category from view */
59 void delCategory(const QString &cat); 60 void delCategory(const QString &cat);
60 /** delete all categories from view */ 61 /** delete all categories from view */
61 void delAllCategories() 62 void delAllCategories()
62 { categoriesCombo->clear(); } 63 { categoriesCombo->clear(); }
63 /** select the specified category */ 64 /** select the specified category */
64 void selectCategory(const QString &cat); 65 void selectCategory(const QString &cat);
65 /** returns the number of categories in this view. 66 /** returns the number of categories in this view.
66 * This value dosn't say anything about the number of 67 * This value dosn't say anything about the number of
67 * categories in the document. 68 * categories in the document.
68 */ 69 */
69 int numCategories() 70 int numCategories()
70 { return categoriesCombo->count(); } 71 { return categoriesCombo->count(); }
71 /** resize the view */ 72 /** resize the view */
72 void resize(const QSize &size) 73 void resize(const QSize &size)
73 { vbox1->resize(size); } 74 { vbox1->resize(size); }
74 75
75 //US ENH: I need a place to load the view dependend settings. Eg. splittersize 76 //US ENH: I need a place to load the view dependend settings. Eg. splittersize
76 void restoreSettings(PWMPrefs* prefs); 77 void restoreSettings(PWMPrefs* prefs);
77 void saveSettings(PWMPrefs* prefs); 78 void saveSettings(PWMPrefs* prefs);
78 79
79 80public slots:
81 void toggleSplitter();
80protected: 82protected:
81 /** main list view */ 83 /** main list view */
82 ListViewPwM *lv; 84 ListViewPwM *lv;
83 /** categories combo-box */ 85 /** categories combo-box */
84 QComboBox *categoriesCombo; 86 QComboBox *categoriesCombo;
85 /** title string for the categories combo or list box */ 87 /** title string for the categories combo or list box */
86 QLabel *categoriesTitle; 88 QLabel *categoriesTitle;
87 /** hbox1 for widget style */ 89 /** hbox1 for widget style */
88 QHBox *hbox1; 90 QHBox *hbox1;
89 /** vbox1 for widget style */ 91 /** vbox1 for widget style */
90 QVBox *vbox1; 92 QVBox *vbox1;
91 /** splitter for commentTextEdit */ 93 /** splitter for commentTextEdit */
92 #ifndef PWM_EMBEDDED 94 #ifndef PWM_EMBEDDED
93 QSplitter *splitter1; 95 QSplitter *splitter1;
94#else 96#else
95 KDGanttMinimizeSplitter * splitter1; 97 KDGanttMinimizeSplitter * splitter1;
96#endif 98#endif
97 /** push button to change the category name */ 99 /** push button to change the category name */
98 QPushButton *renCatButton; 100 QPushButton *renCatButton;
99 /** push button to delete the category */ 101 /** push button to delete the category */
100 QPushButton *delCatButton; 102 QPushButton *delCatButton;
101 /** comment box */ 103 /** comment box */
102 CommentBox *commentBox; 104 CommentBox *commentBox;
103}; 105};
104 106
105#endif 107#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle_1.cpp b/pwmanager/pwmanager/pwmviewstyle_1.cpp
index 4a7ffd7..7294f34 100644
--- a/pwmanager/pwmanager/pwmviewstyle_1.cpp
+++ b/pwmanager/pwmanager/pwmviewstyle_1.cpp
@@ -1,173 +1,192 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "pwmviewstyle_1.h" 20#include "pwmviewstyle_1.h"
21#include "pwmview.h" 21#include "pwmview.h"
22#include "listviewpwm.h" 22#include "listviewpwm.h"
23#include "commentbox.h" 23#include "commentbox.h"
24 24
25#include <klocale.h> 25#include <klocale.h>
26#include "pwmprefs.h" 26#include "pwmprefs.h"
27 27
28#ifndef DESKTOP_VERSION 28#ifndef DESKTOP_VERSION
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#endif 32#endif
33 #define INITIAL_CATEGORIES_WIDTH100 33 #define INITIAL_CATEGORIES_WIDTH100
34 34
35PwMViewStyle_1::PwMViewStyle_1(PwMView *view) 35PwMViewStyle_1::PwMViewStyle_1(PwMView *view)
36 : QObject() 36 : QObject()
37{ 37{
38#ifndef PWM_EMBEDDED 38#ifndef PWM_EMBEDDED
39 splitter = new QSplitter(view); 39 splitter = new QSplitter(view);
40#else 40#else
41 if ( QApplication::desktop()->width() > 240 ) { 41 if ( QApplication::desktop()->width() > 240 ) {
42 splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view); 42 splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view);
43 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); 43 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
44 // topLayout = new QHBoxLayout( this ); 44 // topLayout = new QHBoxLayout( this );
45 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 45 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
46 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 46 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
47 } else { 47 } else {
48 splitter = new KDGanttMinimizeSplitter( Qt::Vertical, view); 48 splitter = new KDGanttMinimizeSplitter( Qt::Vertical, view);
49 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 49 splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
50 // topLayout = new QHBoxLayout( this ); 50 // topLayout = new QHBoxLayout( this );
51 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 51 // mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
52 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 52 // mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
53 } 53 }
54 //US topLayout->addWidget(mMiniSplitter ); 54 //US topLayout->addWidget(mMiniSplitter );
55#endif 55#endif
56 56
57 vbox1 = new QVBox(splitter); 57 vbox1 = new QVBox(splitter);
58 categoriesTitle = new QLabel(vbox1); 58 categoriesTitle = new QLabel(vbox1);
59 categoriesList = new QListBox(vbox1); 59 categoriesList = new QListBox(vbox1);
60#ifndef PWM_EMBEDDED 60#ifndef PWM_EMBEDDED
61 splitter2 = new QSplitter(splitter); 61 splitter2 = new QSplitter(splitter);
62 splitter2->setOrientation(Qt::Vertical); 62 splitter2->setOrientation(Qt::Vertical);
63#else 63#else
64 splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter); 64 splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter);
65 splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 65 splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
66 66
67 //US topLayout->addWidget(mMiniSplitter ); 67 //US topLayout->addWidget(mMiniSplitter );
68#endif 68#endif
69 lv = new ListViewPwM(splitter2); 69 lv = new ListViewPwM(splitter2);
70 commentBox = new CommentBox(splitter2); 70 commentBox = new CommentBox(splitter2);
71 // set sizes and styles 71 // set sizes and styles
72 //UScommentBox->resize(commentBox->size().width(), 60); 72 //UScommentBox->resize(commentBox->size().width(), 60);
73 QValueList<int> sizes; 73 QValueList<int> sizes;
74#ifndef PWM_EMBEDDED 74#ifndef PWM_EMBEDDED
75 sizes.push_back(INITIAL_CATEGORIES_WIDTH); 75 sizes.push_back(INITIAL_CATEGORIES_WIDTH);
76 sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH); 76 sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH);
77#else 77#else
78 sizes.append(INITIAL_CATEGORIES_WIDTH); 78 sizes.append(INITIAL_CATEGORIES_WIDTH);
79 sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH); 79 sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH);
80#endif 80#endif
81 //USsplitter->setSizes(sizes); 81 //USsplitter->setSizes(sizes);
82 categoriesTitle->setAlignment(Qt::AlignHCenter); 82 categoriesTitle->setAlignment(Qt::AlignHCenter);
83#ifndef PWM_EMBEDDED 83#ifndef PWM_EMBEDDED
84 categoriesTitle->setFrameShape(QFrame::MenuBarPanel); 84 categoriesTitle->setFrameShape(QFrame::MenuBarPanel);
85#else 85#else
86 categoriesTitle->setFrameShape(QFrame::StyledPanel); 86 categoriesTitle->setFrameShape(QFrame::StyledPanel);
87#endif 87#endif
88 categoriesTitle->setText(i18n("Categories:")); 88 categoriesTitle->setText(i18n("Categories:"));
89 catCtxMenu = new QPopupMenu(view); 89 catCtxMenu = new QPopupMenu(view);
90 catCtxMenu->insertItem(i18n("&Rename"), 90 catCtxMenu->insertItem(i18n("&Rename"),
91 view, SLOT(renCatButton_slot())); 91 view, SLOT(renCatButton_slot()));
92 catCtxMenu->insertItem(i18n("&Delete"), 92 catCtxMenu->insertItem(i18n("&Delete"),
93 view, SLOT(delCatButton_slot())); 93 view, SLOT(delCatButton_slot()));
94 94
95#ifndef DESKTOP_VERSION 95#ifndef DESKTOP_VERSION
96 QPEApplication::setStylusOperation( categoriesList->viewport(), QPEApplication::RightOnHold ); 96 QPEApplication::setStylusOperation( categoriesList->viewport(), QPEApplication::RightOnHold );
97#endif 97#endif
98 98
99 // connections 99 // connections
100 connect(categoriesList, SIGNAL(highlighted(int)), 100 connect(categoriesList, SIGNAL(highlighted(int)),
101 view, SLOT(shiftToView())); 101 view, SLOT(shiftToView()));
102 connect(categoriesList, 102 connect(categoriesList,
103 SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), 103 SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)),
104 this, 104 this,
105 SLOT(catRightClick(QListBoxItem *, const QPoint &))); 105 SLOT(catRightClick(QListBoxItem *, const QPoint &)));
106
107 connect(lv, SIGNAL(toggleOverview()),
108 this, SLOT(toggleSplitter()));
106} 109}
107 110
108PwMViewStyle_1::~PwMViewStyle_1() 111PwMViewStyle_1::~PwMViewStyle_1()
109{ 112{
110 delete catCtxMenu; 113 delete catCtxMenu;
111 delete splitter; 114 delete splitter;
112} 115}
116void PwMViewStyle_1::toggleSplitter()
117{
118 QValueList<int> si = splitter2->sizes();
119 splitter2->toggle();
120 QValueList<int> si2 = splitter2->sizes();
121 //qDebug("PwMViewStyle_1::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] );
122 if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) {
123 int diff = si[0]/2;
124 if ( diff > 200 )
125 diff = 200;
126 si[0] -= diff;
127 si[1] += diff;
128 splitter2->toggle();
129 splitter2->setSizes( si );
130 }
131}
113 132
114void PwMViewStyle_1::catRightClick(QListBoxItem *item, const QPoint &point) 133void PwMViewStyle_1::catRightClick(QListBoxItem *item, const QPoint &point)
115{ 134{
116 if (!item) 135 if (!item)
117 return; 136 return;
118 catCtxMenu->move(point); 137 catCtxMenu->move(point);
119 catCtxMenu->show(); 138 catCtxMenu->show();
120} 139}
121 140
122void PwMViewStyle_1::delCategory(const QString &cat) 141void PwMViewStyle_1::delCategory(const QString &cat)
123{ 142{
124 PWM_ASSERT(categoriesList); 143 PWM_ASSERT(categoriesList);
125 int i, count = categoriesList->count(); 144 int i, count = categoriesList->count();
126 for (i = 0; i < count; ++i) { 145 for (i = 0; i < count; ++i) {
127 if (categoriesList->text(i) == cat) { 146 if (categoriesList->text(i) == cat) {
128 categoriesList->removeItem(i); 147 categoriesList->removeItem(i);
129 return; 148 return;
130 } 149 }
131 } 150 }
132 BUG(); 151 BUG();
133} 152}
134 153
135void PwMViewStyle_1::selectCategory(const QString &cat) 154void PwMViewStyle_1::selectCategory(const QString &cat)
136{ 155{
137 PWM_ASSERT(categoriesList); 156 PWM_ASSERT(categoriesList);
138 int i, count = categoriesList->count(); 157 int i, count = categoriesList->count();
139 for (i = 0; i < count; ++i) { 158 for (i = 0; i < count; ++i) {
140 if (categoriesList->text(i) == cat) { 159 if (categoriesList->text(i) == cat) {
141 categoriesList->setCurrentItem(i); 160 categoriesList->setCurrentItem(i);
142 return; 161 return;
143 } 162 }
144 } 163 }
145 // fall back to 0 164 // fall back to 0
146 categoriesList->setCurrentItem(0); 165 categoriesList->setCurrentItem(0);
147} 166}
148 167
149//US ENH: I need a place to load the view dependend settings. Eg. splittersize 168//US ENH: I need a place to load the view dependend settings. Eg. splittersize
150void PwMViewStyle_1::restoreSettings(PWMPrefs* prefs) 169void PwMViewStyle_1::restoreSettings(PWMPrefs* prefs)
151{ 170{
152 //load and store the size of the listviewcolumns 171 //load and store the size of the listviewcolumns
153 lv->restoreLayout(prefs->getConfig(), "listview"); 172 lv->restoreLayout(prefs->getConfig(), "listview");
154 splitter->setSizes( prefs->mCategorySplitter ); 173 splitter->setSizes( prefs->mCategorySplitter );
155 splitter2->setSizes( prefs->mCommentSplitter ); 174 splitter2->setSizes( prefs->mCommentSplitter );
156 commentBox->setFont( prefs->mViewFont ); 175 commentBox->setFont( prefs->mViewFont );
157 176
158} 177}
159 178
160//US ENH: I need a place to load the view dependend settings. Eg. splittersize 179//US ENH: I need a place to load the view dependend settings. Eg. splittersize
161void PwMViewStyle_1::saveSettings(PWMPrefs* prefs) 180void PwMViewStyle_1::saveSettings(PWMPrefs* prefs)
162{ 181{
163 //store the size of the listviewcolumns 182 //store the size of the listviewcolumns
164 lv->saveLayout(prefs->getConfig(), "listview"); 183 lv->saveLayout(prefs->getConfig(), "listview");
165 prefs->mCategorySplitter = splitter->sizes(); 184 prefs->mCategorySplitter = splitter->sizes();
166 prefs->mCommentSplitter = splitter2->sizes(); 185 prefs->mCommentSplitter = splitter2->sizes();
167 186
168} 187}
169 188
170 189
171#ifndef PWM_EMBEDDED 190#ifndef PWM_EMBEDDED
172#include "pwmviewstyle_1.moc" 191#include "pwmviewstyle_1.moc"
173#endif 192#endif
diff --git a/pwmanager/pwmanager/pwmviewstyle_1.h b/pwmanager/pwmanager/pwmviewstyle_1.h
index a7f100c..4f7a256 100644
--- a/pwmanager/pwmanager/pwmviewstyle_1.h
+++ b/pwmanager/pwmanager/pwmviewstyle_1.h
@@ -1,112 +1,114 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef PWMVIEWSTYLE_1_H 20#ifndef PWMVIEWSTYLE_1_H
21#define PWMVIEWSTYLE_1_H 21#define PWMVIEWSTYLE_1_H
22 22
23#include <qvbox.h> 23#include <qvbox.h>
24 24
25#ifndef PWM_EMBEDDED 25#ifndef PWM_EMBEDDED
26#include <qtextedit.h> 26#include <qtextedit.h>
27#include <qsplitter.h> 27#include <qsplitter.h>
28#else 28#else
29#include <qmultilineedit.h> 29#include <qmultilineedit.h>
30#include <KDGanttMinimizeSplitter.h> 30#include <KDGanttMinimizeSplitter.h>
31#endif 31#endif
32 32
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlistbox.h> 34#include <qlistbox.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36 36
37class PwMView; 37class PwMView;
38class ListViewPwM; 38class ListViewPwM;
39class CommentBox; 39class CommentBox;
40class PWMPrefs; 40class PWMPrefs;
41 41
42class PwMViewStyle_1 : public QObject 42class PwMViewStyle_1 : public QObject
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45public: 45public:
46 PwMViewStyle_1(PwMView *view); 46 PwMViewStyle_1(PwMView *view);
47 ~PwMViewStyle_1(); 47 ~PwMViewStyle_1();
48 48
49 ListViewPwM * getLv() 49 ListViewPwM * getLv()
50 { return lv; } 50 { return lv; }
51 CommentBox * getCommentBox() 51 CommentBox * getCommentBox()
52 { return commentBox; } 52 { return commentBox; }
53 53
54 /** returns the currently selected category */ 54 /** returns the currently selected category */
55 QString getCurrentCategory() 55 QString getCurrentCategory()
56 { return categoriesList->currentText(); } 56 { return categoriesList->currentText(); }
57 /** add Category to the view */ 57 /** add Category to the view */
58 void addCategory(const QString &cat) 58 void addCategory(const QString &cat)
59 { categoriesList->insertItem(cat); } 59 { categoriesList->insertItem(cat); }
60 /** delete Category from view */ 60 /** delete Category from view */
61 void delCategory(const QString &cat); 61 void delCategory(const QString &cat);
62 /** delete all categories from view */ 62 /** delete all categories from view */
63 void delAllCategories() 63 void delAllCategories()
64 { categoriesList->clear(); } 64 { categoriesList->clear(); }
65 /** select the specified category */ 65 /** select the specified category */
66 void selectCategory(const QString &cat); 66 void selectCategory(const QString &cat);
67 /** returns the number of categories in this view. 67 /** returns the number of categories in this view.
68 * This value dosn't say anything about the number of 68 * This value dosn't say anything about the number of
69 * categories in the document. 69 * categories in the document.
70 */ 70 */
71 int numCategories() 71 int numCategories()
72 { return categoriesList->count(); } 72 { return categoriesList->count(); }
73 /** resize the view */ 73 /** resize the view */
74 void resize(const QSize &size) 74 void resize(const QSize &size)
75 { splitter->resize(size); } 75 { splitter->resize(size); }
76 76
77 //US ENH: I need a place to load the view dependend settings. Eg. splittersize 77 //US ENH: I need a place to load the view dependend settings. Eg. splittersize
78 void restoreSettings(PWMPrefs* prefs); 78 void restoreSettings(PWMPrefs* prefs);
79 void saveSettings(PWMPrefs* prefs); 79 void saveSettings(PWMPrefs* prefs);
80 80
81public slots:
82 void toggleSplitter();
81protected slots: 83protected slots:
82 /** user clicked right button in category list */ 84 /** user clicked right button in category list */
83 void catRightClick(QListBoxItem *item, const QPoint &point); 85 void catRightClick(QListBoxItem *item, const QPoint &point);
84 86
85protected: 87protected:
86 /** main list view */ 88 /** main list view */
87 ListViewPwM *lv; 89 ListViewPwM *lv;
88#ifndef PWM_EMBEDDED 90#ifndef PWM_EMBEDDED
89 /** main splitter widget */ 91 /** main splitter widget */
90 QSplitter *splitter; 92 QSplitter *splitter;
91 /** commentTextEdit splitter */ 93 /** commentTextEdit splitter */
92 QSplitter *splitter2; 94 QSplitter *splitter2;
93#else 95#else
94 /** main splitter widget */ 96 /** main splitter widget */
95 KDGanttMinimizeSplitter *splitter; 97 KDGanttMinimizeSplitter *splitter;
96 /** commentTextEdit splitter */ 98 /** commentTextEdit splitter */
97 KDGanttMinimizeSplitter *splitter2; 99 KDGanttMinimizeSplitter *splitter2;
98#endif 100#endif
99 101
100 /** categories list-box */ 102 /** categories list-box */
101 QListBox *categoriesList; 103 QListBox *categoriesList;
102 /** title string for the categories combo or list box */ 104 /** title string for the categories combo or list box */
103 QLabel *categoriesTitle; 105 QLabel *categoriesTitle;
104 /** hbox1 for widget style */ 106 /** hbox1 for widget style */
105 QVBox *vbox1; 107 QVBox *vbox1;
106 /** text-edit to display the comment */ 108 /** text-edit to display the comment */
107 CommentBox *commentBox; 109 CommentBox *commentBox;
108 /** category list context menu */ 110 /** category list context menu */
109 QPopupMenu *catCtxMenu; 111 QPopupMenu *catCtxMenu;
110}; 112};
111 113
112#endif 114#endif