summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-24 23:05:56 (UTC)
committer ulf69 <ulf69>2004-09-24 23:05:56 (UTC)
commit1a3db02f855f800898f617e3318f98c8c65d6dbb (patch) (unidiff)
tree1fe5f04e150d3aa62d7e7338000516961d6fd897
parente695903cc49b33e63505b651b13d830e318fc29a (diff)
downloadkdepimpi-1a3db02f855f800898f617e3318f98c8c65d6dbb.zip
kdepimpi-1a3db02f855f800898f617e3318f98c8c65d6dbb.tar.gz
kdepimpi-1a3db02f855f800898f617e3318f98c8c65d6dbb.tar.bz2
mooved column const into the headerfile. So that we can access them from
other files as well.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmview.cpp16
-rw-r--r--pwmanager/pwmanager/pwmview.h10
2 files changed, 20 insertions, 6 deletions
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index 58c2fca..d192119 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -1,140 +1,144 @@
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 38
39//US ENH: wouldn't it be a good idea if we could use this consts everywhere else.
40//US ENH: for examle in listviewpwm.cpp
41//US ENH: Because of that I transfer them into the headerfile.
42/*
39 #define COLUMN_DESC 0 43 #define COLUMN_DESC 0
40 #define COLUMN_NAME 1 44 #define COLUMN_NAME 1
41 #define COLUMN_PW 2 45 #define COLUMN_PW 2
42 #define COLUMN_URL 3 46 #define COLUMN_URL 3
43 #define COLUMN_LAUNCHER 4 47 #define COLUMN_LAUNCHER 4
44 48*/
45 49
46PwMView::PwMView(PwM *_mainClass, 50PwMView::PwMView(PwM *_mainClass,
47 QWidget *parent, PwMDoc *_doc, 51 QWidget *parent, PwMDoc *_doc,
48 const char *name) 52 const char *name)
49 : PwMViewStyle(parent, name) 53 : PwMViewStyle(parent, name)
50{ 54{
51 PWM_ASSERT(_mainClass); 55 PWM_ASSERT(_mainClass);
52 PWM_ASSERT(parent); 56 PWM_ASSERT(parent);
53 PWM_ASSERT(_doc); 57 PWM_ASSERT(_doc);
54 setView(this); 58 setView(this);
55 doc = _doc; 59 doc = _doc;
56 doc->setListViewPointer(this); 60 doc->setListViewPointer(this);
57 mainClass = _mainClass; 61 mainClass = _mainClass;
58 resize(_mainClass->size()); 62 resize(_mainClass->size());
59 initStyle(conf()->confWndMainViewStyle()); 63 initStyle(conf()->confWndMainViewStyle());
60 initCtxMenu(); 64 initCtxMenu();
61 doc->setCurrentView(this); 65 doc->setCurrentView(this);
62 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); 66 connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView()));
63} 67}
64 68
65PwMView::~PwMView() 69PwMView::~PwMView()
66{ 70{
67} 71}
68 72
69void PwMView::initCtxMenu() 73void PwMView::initCtxMenu()
70{ 74{
71 ctxMenu = new QPopupMenu(this); 75 ctxMenu = new QPopupMenu(this);
72 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); 76 ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot()));
73 ctxMenu->insertSeparator(); 77 ctxMenu->insertSeparator();
74 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); 78 ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot()));
75 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); 79 ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot()));
76 ctxMenu->insertSeparator(); 80 ctxMenu->insertSeparator();
77 ctxMenu->insertItem(i18n("copy password to clipboard"), 81 ctxMenu->insertItem(i18n("copy password to clipboard"),
78 this, SLOT(copyPwToClip())); 82 this, SLOT(copyPwToClip()));
79 ctxMenu->insertItem(i18n("copy username to clipboard"), 83 ctxMenu->insertItem(i18n("copy username to clipboard"),
80 this, SLOT(copyNameToClip())); 84 this, SLOT(copyNameToClip()));
81 ctxMenu->insertItem(i18n("copy description to clipboard"), 85 ctxMenu->insertItem(i18n("copy description to clipboard"),
82 this, SLOT(copyDescToClip())); 86 this, SLOT(copyDescToClip()));
83 ctxMenu->insertItem(i18n("copy url to clipboard"), 87 ctxMenu->insertItem(i18n("copy url to clipboard"),
84 this, SLOT(copyUrlToClip())); 88 this, SLOT(copyUrlToClip()));
85 ctxMenu->insertItem(i18n("copy launcher to clipboard"), 89 ctxMenu->insertItem(i18n("copy launcher to clipboard"),
86 this, SLOT(copyLauncherToClip())); 90 this, SLOT(copyLauncherToClip()));
87 ctxMenu->insertItem(i18n("copy comment to clipboard"), 91 ctxMenu->insertItem(i18n("copy comment to clipboard"),
88 this, SLOT(copyCommentToClip())); 92 this, SLOT(copyCommentToClip()));
89 ctxMenu->insertSeparator(); 93 ctxMenu->insertSeparator();
90 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, 94 ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass,
91 SLOT(execLauncher_slot())); 95 SLOT(execLauncher_slot()));
92 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, 96 ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass,
93 SLOT(goToURL_slot())); 97 SLOT(goToURL_slot()));
94} 98}
95 99
96void PwMView::resizeEvent(QResizeEvent *) 100void PwMView::resizeEvent(QResizeEvent *)
97{ 101{
98 resizeView(size()); 102 resizeView(size());
99} 103}
100 104
101void PwMView::refreshCommentTextEdit(QListViewItem *curItem) 105void PwMView::refreshCommentTextEdit(QListViewItem *curItem)
102{ 106{
103 PWM_ASSERT(commentBox); 107 PWM_ASSERT(commentBox);
104 if (!curItem) 108 if (!curItem)
105 return; 109 return;
106 string comment; 110 string comment;
107 PwMerror ret; 111 PwMerror ret;
108 ret = document()->getCommentByLvp(getCurrentCategory(), 112 ret = document()->getCommentByLvp(getCurrentCategory(),
109 lv->childCount() - lv->itemIndex(curItem) - 1, 113 lv->childCount() - lv->itemIndex(curItem) - 1,
110 &comment); 114 &comment);
111 if (ret == e_binEntry) { 115 if (ret == e_binEntry) {
112 commentBox->setContent(i18n("This is a binary entry.\n" 116 commentBox->setContent(i18n("This is a binary entry.\n"
113 "It is not a normal password-entry, as it contains " 117 "It is not a normal password-entry, as it contains "
114 "binary data, which PwManager can't display here.")); 118 "binary data, which PwManager can't display here."));
115 } else if (ret == e_normalEntry) { 119 } else if (ret == e_normalEntry) {
116 commentBox->setContent(comment.c_str()); 120 commentBox->setContent(comment.c_str());
117 } else { 121 } else {
118 BUG(); 122 BUG();
119 return; 123 return;
120 } 124 }
121 lv->ensureItemVisible(curItem); 125 lv->ensureItemVisible(curItem);
122} 126}
123 127
124void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) 128void PwMView::keyReleaseEvent(QKeyEvent * /*e*/)
125{ 129{
126 refreshCommentTextEdit(lv->currentItem()); 130 refreshCommentTextEdit(lv->currentItem());
127} 131}
128 132
129bool PwMView::getCurEntryIndex(unsigned int *index) 133bool PwMView::getCurEntryIndex(unsigned int *index)
130{ 134{
131 QListViewItem *current = lv->currentItem(); 135 QListViewItem *current = lv->currentItem();
132 if (!current) 136 if (!current)
133 return false; 137 return false;
134 return getDocEntryIndex(index, current); 138 return getDocEntryIndex(index, current);
135} 139}
136 140
137bool PwMView::getDocEntryIndex(unsigned int *index, 141bool PwMView::getDocEntryIndex(unsigned int *index,
138 const QListViewItem *item) 142 const QListViewItem *item)
139{ 143{
140 vector<unsigned int> foundPositions; 144 vector<unsigned int> foundPositions;
@@ -272,185 +276,185 @@ void PwMView::shiftToView()
272 + " " 276 + " "
273 + i18n("To unlock click the icon on the left.")); 277 + i18n("To unlock click the icon on the left."));
274 } else { 278 } else {
275 newItem->setText(COLUMN_PW, (*it).pw.c_str()); 279 newItem->setText(COLUMN_PW, (*it).pw.c_str());
276 } 280 }
277 newItem->setText(COLUMN_URL, (*it).url.c_str()); 281 newItem->setText(COLUMN_URL, (*it).url.c_str());
278 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); 282 newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str());
279 } 283 }
280 newItem->setOn(!((*it).lockStat)); 284 newItem->setOn(!((*it).lockStat));
281 lv->insertItem(newItem); 285 lv->insertItem(newItem);
282 ++it; 286 ++it;
283 } 287 }
284 tmpReEnableSort(); 288 tmpReEnableSort();
285 289
286 if (cY || cX) 290 if (cY || cX)
287 lv->setContentsPos(cX, cY); 291 lv->setContentsPos(cX, cY);
288} 292}
289 293
290void PwMView::reorgLp() 294void PwMView::reorgLp()
291{ 295{
292 if (!lv->childCount()) 296 if (!lv->childCount())
293 return; 297 return;
294 PWM_ASSERT(doc); 298 PWM_ASSERT(doc);
295 PWM_ASSERT(!doc->isDocEmpty()); 299 PWM_ASSERT(!doc->isDocEmpty());
296 QListViewItem *currItem; 300 QListViewItem *currItem;
297 vector<unsigned int> foundPos; 301 vector<unsigned int> foundPos;
298 /* This searchIn _should_ be: 302 /* This searchIn _should_ be:
299 *const unsigned int searchIn = SEARCH_IN_DESC; 303 *const unsigned int searchIn = SEARCH_IN_DESC;
300 * But we want backward compatibility (see comment in PwMDoc::addEntry()). 304 * But we want backward compatibility (see comment in PwMDoc::addEntry()).
301 * So we need to search again, if we don't find the entry. (see below) 305 * So we need to search again, if we don't find the entry. (see below)
302 */ 306 */
303 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | 307 const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME |
304 SEARCH_IN_URL | SEARCH_IN_LAUNCHER; 308 SEARCH_IN_URL | SEARCH_IN_LAUNCHER;
305 QString curCat(getCurrentCategory()); 309 QString curCat(getCurrentCategory());
306 PwMDataItem findThis; 310 PwMDataItem findThis;
307 unsigned int i, cnt = lv->childCount(); 311 unsigned int i, cnt = lv->childCount();
308 for (i = 0; i < cnt; ++i) { 312 for (i = 0; i < cnt; ++i) {
309 currItem = lv->itemAtIndex(i); 313 currItem = lv->itemAtIndex(i);
310 findThis.desc = currItem->text(COLUMN_DESC).latin1(); 314 findThis.desc = currItem->text(COLUMN_DESC).latin1();
311 findThis.name = currItem->text(COLUMN_NAME).latin1(); 315 findThis.name = currItem->text(COLUMN_NAME).latin1();
312 findThis.url = currItem->text(COLUMN_URL).latin1(); 316 findThis.url = currItem->text(COLUMN_URL).latin1();
313 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); 317 findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1();
314 doc->findEntry(curCat, findThis, searchIn, 318 doc->findEntry(curCat, findThis, searchIn,
315 &foundPos, true); 319 &foundPos, true);
316 if (!foundPos.size()) { 320 if (!foundPos.size()) {
317 /* Did not find the entry. We seem to have a binary 321 /* Did not find the entry. We seem to have a binary
318 * entry here (pray for it!). So search again with 322 * entry here (pray for it!). So search again with
319 * the "correct" searchIn flags. 323 * the "correct" searchIn flags.
320 */ 324 */
321 const unsigned int searchIn2 = SEARCH_IN_DESC; 325 const unsigned int searchIn2 = SEARCH_IN_DESC;
322 doc->findEntry(curCat, findThis, searchIn2, 326 doc->findEntry(curCat, findThis, searchIn2,
323 &foundPos, true); 327 &foundPos, true);
324 if (unlikely(!foundPos.size())) { 328 if (unlikely(!foundPos.size())) {
325 BUG(); 329 BUG();
326 continue; 330 continue;
327 } 331 }
328 /* We assert that it's a binary entry, now. 332 /* We assert that it's a binary entry, now.
329 * No chance to efficiently verify it here. 333 * No chance to efficiently verify it here.
330 */ 334 */
331 } 335 }
332 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); 336 doc->setListViewPos(curCat, foundPos[0], cnt - i - 1);
333 } 337 }
334} 338}
335 339
336void PwMView::selAt(int index) 340void PwMView::selAt(int index)
337{ 341{
338 QListViewItem *item = lv->itemAtIndex(index); 342 QListViewItem *item = lv->itemAtIndex(index);
339 if (!item) 343 if (!item)
340 return; 344 return;
341 lv->setCurrentItem(item); 345 lv->setCurrentItem(item);
342 lv->ensureItemVisible(item); 346 lv->ensureItemVisible(item);
343} 347}
344 348
345void PwMView::renCatButton_slot() 349void PwMView::renCatButton_slot()
346{ 350{
347 if (doc->isDeepLocked()) 351 if (doc->isDeepLocked())
348 return; 352 return;
349 RenCatWnd wnd(this); 353 RenCatWnd wnd(this);
350 if (wnd.exec() == 1) { 354 if (wnd.exec() == 1) {
351 QString newName(wnd.getNewName()); 355 QString newName(wnd.getNewName());
352 if (newName == "") 356 if (newName == "")
353 return; 357 return;
354 document()->renameCategory(getCurrentCategory(), 358 document()->renameCategory(getCurrentCategory(),
355 newName); 359 newName);
356 } 360 }
357} 361}
358 362
359void PwMView::delCatButton_slot() 363void PwMView::delCatButton_slot()
360{ 364{
361 if (doc->isDeepLocked()) 365 if (doc->isDeepLocked())
362 return; 366 return;
363 if (numCategories() <= 1) { 367 if (numCategories() <= 1) {
364 mainClass->showStatMsg(i18n("Can't remove the last category.")); 368 mainClass->showStatMsg(i18n("Can't remove the last category."));
365 return; 369 return;
366 } 370 }
367 if (KMessageBox::questionYesNo(this, 371 if (KMessageBox::questionYesNo(this,
368 i18n("Do you really want to " 372 i18n("Do you really want to\n"
369 "delete the selected " 373 "delete the selected\n"
370 "category? All password-" 374 "category? All password-\n"
371 "entries will be lost in " 375 "entries will be lost in\n"
372 "this category!"), 376 "this category!\n"),
373 i18n("Delete category?")) 377 i18n("Delete category?"))
374 == KMessageBox::No) { 378 == KMessageBox::No) {
375 return; 379 return;
376 } 380 }
377 document()->delCategory(getCurrentCategory()); 381 document()->delCategory(getCurrentCategory());
378} 382}
379 383
380void PwMView::copyPwToClip() 384void PwMView::copyPwToClip()
381{ 385{
382 if (doc->isDeepLocked()) 386 if (doc->isDeepLocked())
383 return; 387 return;
384 unsigned int curIndex = 0; 388 unsigned int curIndex = 0;
385 if (!getCurEntryIndex(&curIndex)) 389 if (!getCurEntryIndex(&curIndex))
386 return; 390 return;
387 PwMDataItem d; 391 PwMDataItem d;
388 document()->getDataChangedLock(); 392 document()->getDataChangedLock();
389 document()->getEntry(getCurrentCategory(), curIndex, &d, true); 393 document()->getEntry(getCurrentCategory(), curIndex, &d, true);
390 document()->putDataChangedLock(); 394 document()->putDataChangedLock();
391 PwM::copyToClipboard(d.pw.c_str()); 395 PwM::copyToClipboard(d.pw.c_str());
392} 396}
393 397
394void PwMView::copyNameToClip() 398void PwMView::copyNameToClip()
395{ 399{
396 if (doc->isDeepLocked()) 400 if (doc->isDeepLocked())
397 return; 401 return;
398 unsigned int curIndex = 0; 402 unsigned int curIndex = 0;
399 if (!getCurEntryIndex(&curIndex)) 403 if (!getCurEntryIndex(&curIndex))
400 return; 404 return;
401 PwMDataItem d; 405 PwMDataItem d;
402 document()->getEntry(getCurrentCategory(), curIndex, &d); 406 document()->getEntry(getCurrentCategory(), curIndex, &d);
403 PwM::copyToClipboard(d.name.c_str()); 407 PwM::copyToClipboard(d.name.c_str());
404} 408}
405 409
406void PwMView::copyDescToClip() 410void PwMView::copyDescToClip()
407{ 411{
408 if (doc->isDeepLocked()) 412 if (doc->isDeepLocked())
409 return; 413 return;
410 unsigned int curIndex = 0; 414 unsigned int curIndex = 0;
411 if (!getCurEntryIndex(&curIndex)) 415 if (!getCurEntryIndex(&curIndex))
412 return; 416 return;
413 PwMDataItem d; 417 PwMDataItem d;
414 document()->getEntry(getCurrentCategory(), curIndex, &d); 418 document()->getEntry(getCurrentCategory(), curIndex, &d);
415 PwM::copyToClipboard(d.desc.c_str()); 419 PwM::copyToClipboard(d.desc.c_str());
416} 420}
417 421
418void PwMView::copyUrlToClip() 422void PwMView::copyUrlToClip()
419{ 423{
420 if (doc->isDeepLocked()) 424 if (doc->isDeepLocked())
421 return; 425 return;
422 unsigned int curIndex = 0; 426 unsigned int curIndex = 0;
423 if (!getCurEntryIndex(&curIndex)) 427 if (!getCurEntryIndex(&curIndex))
424 return; 428 return;
425 PwMDataItem d; 429 PwMDataItem d;
426 document()->getEntry(getCurrentCategory(), curIndex, &d); 430 document()->getEntry(getCurrentCategory(), curIndex, &d);
427 PwM::copyToClipboard(d.url.c_str()); 431 PwM::copyToClipboard(d.url.c_str());
428} 432}
429 433
430void PwMView::copyLauncherToClip() 434void PwMView::copyLauncherToClip()
431{ 435{
432 if (doc->isDeepLocked()) 436 if (doc->isDeepLocked())
433 return; 437 return;
434 unsigned int curIndex = 0; 438 unsigned int curIndex = 0;
435 if (!getCurEntryIndex(&curIndex)) 439 if (!getCurEntryIndex(&curIndex))
436 return; 440 return;
437 PwMDataItem d; 441 PwMDataItem d;
438 document()->getEntry(getCurrentCategory(), curIndex, &d); 442 document()->getEntry(getCurrentCategory(), curIndex, &d);
439 PwM::copyToClipboard(d.launcher.c_str()); 443 PwM::copyToClipboard(d.launcher.c_str());
440} 444}
441 445
442void PwMView::copyCommentToClip() 446void PwMView::copyCommentToClip()
443{ 447{
444 if (doc->isDeepLocked()) 448 if (doc->isDeepLocked())
445 return; 449 return;
446 unsigned int curIndex = 0; 450 unsigned int curIndex = 0;
447 if (!getCurEntryIndex(&curIndex)) 451 if (!getCurEntryIndex(&curIndex))
448 return; 452 return;
449 PwMDataItem d; 453 PwMDataItem d;
450 document()->getEntry(getCurrentCategory(), curIndex, &d); 454 document()->getEntry(getCurrentCategory(), curIndex, &d);
451 PwM::copyToClipboard(d.comment.c_str()); 455 PwM::copyToClipboard(d.comment.c_str());
452} 456}
453 457
454#ifndef PWM_EMBEDDED 458#ifndef PWM_EMBEDDED
455#include "pwmview.moc" 459#include "pwmview.moc"
456#endif 460#endif
diff --git a/pwmanager/pwmanager/pwmview.h b/pwmanager/pwmanager/pwmview.h
index b4cec65..5a326d3 100644
--- a/pwmanager/pwmanager/pwmview.h
+++ b/pwmanager/pwmanager/pwmview.h
@@ -1,118 +1,128 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#ifndef PWMVIEW_H 20#ifndef PWMVIEW_H
21#define PWMVIEW_H 21#define PWMVIEW_H
22 22
23//US ENH: wouldn't it be a good idea if we could use this consts everywhere else.
24//US ENH: for examle in listviewpwm.cpp
25//US ENH: Because of that I transfer them into the headerfile.
26 #define COLUMN_DESC 0
27 #define COLUMN_NAME 1
28 #define COLUMN_PW 2
29 #define COLUMN_URL 3
30 #define COLUMN_LAUNCHER 4
31
32
23#include "listviewpwm.h" 33#include "listviewpwm.h"
24#include "pwmdoc.h" 34#include "pwmdoc.h"
25#include "pwmviewstyle.h" 35#include "pwmviewstyle.h"
26 36
27#include <kconfig.h> 37#include <kconfig.h>
28#include <klocale.h> 38#include <klocale.h>
29 39
30#include <qevent.h> 40#include <qevent.h>
31#include <qfont.h> 41#include <qfont.h>
32#include <qobject.h> 42#include <qobject.h>
33 43
34#include <vector> 44#include <vector>
35#include <string> 45#include <string>
36 46
37using std::string; 47using std::string;
38using std::vector; 48using std::vector;
39 49
40class PwM; 50class PwM;
41class ConfFile; 51class ConfFile;
42class PwMStatusBar; 52class PwMStatusBar;
43 53
44 54
45/** View class for PwM */ 55/** View class for PwM */
46class PwMView : public PwMViewStyle 56class PwMView : public PwMViewStyle
47{ 57{
48 Q_OBJECT 58 Q_OBJECT
49 friend class PwMViewStyle; 59 friend class PwMViewStyle;
50public: 60public:
51 /** construtor */ 61 /** construtor */
52 PwMView(PwM *_mainClass, QWidget* parent, PwMDoc *_doc, 62 PwMView(PwM *_mainClass, QWidget* parent, PwMDoc *_doc,
53 const char *name = 0); 63 const char *name = 0);
54 /** destructor */ 64 /** destructor */
55 ~PwMView(); 65 ~PwMView();
56 66
57 /** returns pointer to the document */ 67 /** returns pointer to the document */
58 PwMDoc* document() 68 PwMDoc* document()
59 { return doc; } 69 { return doc; }
60 /** returns the index of the currently selected entry. 70 /** returns the index of the currently selected entry.
61 * (index as represented in PwMDoc !) 71 * (index as represented in PwMDoc !)
62 */ 72 */
63 bool getCurEntryIndex(unsigned int *index); 73 bool getCurEntryIndex(unsigned int *index);
64 /** returns the position of the given item in the document 74 /** returns the position of the given item in the document
65 * Note: This func only serches in the current category. 75 * Note: This func only serches in the current category.
66 */ 76 */
67 bool getDocEntryIndex(unsigned int *index, 77 bool getDocEntryIndex(unsigned int *index,
68 const QListViewItem *item); 78 const QListViewItem *item);
69 79
70public slots: 80public slots:
71 /** update the view (call if dirty) */ 81 /** update the view (call if dirty) */
72 void updateView() 82 void updateView()
73 { 83 {
74 updateCategories(); 84 updateCategories();
75 shiftToView(); 85 shiftToView();
76 } 86 }
77 /** (re)sort all items and (re)shift them to listView. */ 87 /** (re)sort all items and (re)shift them to listView. */
78 void shiftToView(); 88 void shiftToView();
79 /** handle clicking on an item */ 89 /** handle clicking on an item */
80 void handleToggle(QListViewItem *item); 90 void handleToggle(QListViewItem *item);
81 /** handle right-clicking on an item */ 91 /** handle right-clicking on an item */
82 void handleRightClick(QListViewItem *item, const QPoint &point, int); 92 void handleRightClick(QListViewItem *item, const QPoint &point, int);
83 /** selects the item at "index" */ 93 /** selects the item at "index" */
84 void selAt(int index); 94 void selAt(int index);
85 /** rename category button pressed */ 95 /** rename category button pressed */
86 void renCatButton_slot(); 96 void renCatButton_slot();
87 /** delete category button pressed */ 97 /** delete category button pressed */
88 void delCatButton_slot(); 98 void delCatButton_slot();
89 99
90protected: 100protected:
91 /** right-click context-menu */ 101 /** right-click context-menu */
92 QPopupMenu *ctxMenu; 102 QPopupMenu *ctxMenu;
93 103
94protected: 104protected:
95 /** update the categories from document */ 105 /** update the categories from document */
96 void updateCategories(); 106 void updateCategories();
97 /** widget resize event */ 107 /** widget resize event */
98 void resizeEvent(QResizeEvent *); 108 void resizeEvent(QResizeEvent *);
99 /** initialize context-menu */ 109 /** initialize context-menu */
100 void initCtxMenu(); 110 void initCtxMenu();
101 /** tempoarly disable auto-sorting and user-sorting */ 111 /** tempoarly disable auto-sorting and user-sorting */
102 void tmpDisableSort() 112 void tmpDisableSort()
103 { lv->setSorting(-1); } 113 { lv->setSorting(-1); }
104 /** re-enable tempoarly disabled sorting */ 114 /** re-enable tempoarly disabled sorting */
105 void tmpReEnableSort() 115 void tmpReEnableSort()
106 { 116 {
107 lv->setSorting(lv->columns() + 1, 117 lv->setSorting(lv->columns() + 1,
108 true/*lv->sortOrder() == Qt::Ascending*/); 118 true/*lv->sortOrder() == Qt::Ascending*/);
109 } 119 }
110 /** The user pressed and released a key. */ 120 /** The user pressed and released a key. */
111 void keyReleaseEvent(QKeyEvent *e); 121 void keyReleaseEvent(QKeyEvent *e);
112 122
113protected slots: 123protected slots:
114 /** changes the comment text-edit, because a new item has been selected */ 124 /** changes the comment text-edit, because a new item has been selected */
115 void refreshCommentTextEdit(QListViewItem *curItem); 125 void refreshCommentTextEdit(QListViewItem *curItem);
116 /** copy pw to clipboard */ 126 /** copy pw to clipboard */
117 void copyPwToClip(); 127 void copyPwToClip();
118 /** copy name to clipboard */ 128 /** copy name to clipboard */