Diffstat (limited to 'pwmanager/pwmanager/findwndimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/findwndimpl.cpp | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/findwndimpl.cpp b/pwmanager/pwmanager/findwndimpl.cpp new file mode 100644 index 0000000..fec1a6a --- a/dev/null +++ b/pwmanager/pwmanager/findwndimpl.cpp | |||
@@ -0,0 +1,125 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * copyright (C) 2003 by Michael Buesch * | ||
4 | * email: mbuesch@freenet.de * | ||
5 | * * | ||
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 * | ||
8 | * as published by the Free Software Foundation. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
11 | |||
12 | /*************************************************************************** | ||
13 | * copyright (C) 2004 by Ulf Schenk | ||
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 | ||
16 | * | ||
17 | * $Id$ | ||
18 | **************************************************************************/ | ||
19 | |||
20 | #include "findwndimpl.h" | ||
21 | #include "pwmexception.h" | ||
22 | #include "pwmdoc.h" | ||
23 | #include "pwmview.h" | ||
24 | |||
25 | #include <qradiobutton.h> | ||
26 | #include <qlineedit.h> | ||
27 | #include <qcheckbox.h> | ||
28 | |||
29 | #include <kmessagebox.h> | ||
30 | #include <klocale.h> | ||
31 | |||
32 | FindWndImpl::FindWndImpl(PwMView * _parent) | ||
33 | : findWnd() | ||
34 | { | ||
35 | parent = _parent; | ||
36 | fAt = 0; | ||
37 | refVal = 0; | ||
38 | currFoundPos = -1; | ||
39 | numEntries = parent->document()->numEntries(parent->getCurrentCategory()); | ||
40 | connect(this, SIGNAL(foundAt(int)), parent, SLOT(selAt(int))); | ||
41 | } | ||
42 | |||
43 | FindWndImpl::~FindWndImpl() | ||
44 | { | ||
45 | } | ||
46 | |||
47 | void FindWndImpl::findButton_slot() | ||
48 | { | ||
49 | if (findLineEdit->text() == "") | ||
50 | return; | ||
51 | static vector<unsigned int> foundPositions; | ||
52 | PwMDoc *doc = parent->document(); | ||
53 | |||
54 | if (currFoundPos < 0) { | ||
55 | bool unlockedTempoary = false; | ||
56 | foundPositions.clear(); | ||
57 | PwMDataItem findThis; | ||
58 | unsigned int searchIn = 0; | ||
59 | |||
60 | if (descRadioButton->isChecked()) { | ||
61 | searchIn = SEARCH_IN_DESC; | ||
62 | findThis.desc = findLineEdit->text().latin1(); | ||
63 | } else if (nameRadioButton->isChecked()) { | ||
64 | searchIn = SEARCH_IN_NAME; | ||
65 | findThis.name = findLineEdit->text().latin1(); | ||
66 | } else if (pwRadioButton->isChecked()) { | ||
67 | searchIn = SEARCH_IN_PW; | ||
68 | findThis.pw = findLineEdit->text().latin1(); | ||
69 | } else if (commentRadioButton->isChecked()) { | ||
70 | searchIn = SEARCH_IN_COMMENT; | ||
71 | findThis.comment = findLineEdit->text().latin1(); | ||
72 | } else if (urlRadioButton->isChecked()) { | ||
73 | searchIn = SEARCH_IN_URL; | ||
74 | findThis.url = findLineEdit->text().latin1(); | ||
75 | } else if (launcherRadioButton->isChecked()) { | ||
76 | searchIn = SEARCH_IN_LAUNCHER; | ||
77 | findThis.launcher = findLineEdit->text().latin1(); | ||
78 | } | ||
79 | |||
80 | if (pwRadioButton->isChecked()) { | ||
81 | if (!doc->unlockAll_tempoary()) | ||
82 | return; | ||
83 | unlockedTempoary = true; | ||
84 | } | ||
85 | doc->findEntry(parent->getCurrentCategory(), findThis, | ||
86 | searchIn, &foundPositions, false, | ||
87 | caseSensCheckBox->isChecked(), | ||
88 | exactCheckBox->isChecked(), | ||
89 | true); | ||
90 | if (unlockedTempoary) { | ||
91 | doc->unlockAll_tempoary(true); | ||
92 | } | ||
93 | |||
94 | if (!foundPositions.size()) { | ||
95 | KMessageBox::information(this, | ||
96 | i18n("No entry found."), | ||
97 | i18n("not found")); | ||
98 | return; | ||
99 | } | ||
100 | currFoundPos = 0; | ||
101 | } | ||
102 | |||
103 | int lvp = doc->getListViewPos(parent->getCurrentCategory(), | ||
104 | foundPositions[currFoundPos++]); | ||
105 | emit foundAt(numEntries - 1 - lvp); | ||
106 | |||
107 | if (currFoundPos + 1 > static_cast<int>(foundPositions.size())) | ||
108 | currFoundPos = 0; | ||
109 | } | ||
110 | |||
111 | void FindWndImpl::closeButton_slot() | ||
112 | { | ||
113 | done(0); | ||
114 | } | ||
115 | |||
116 | void FindWndImpl::selectionChanged_slot() | ||
117 | { | ||
118 | fAt = 0; | ||
119 | refVal = 0; | ||
120 | currFoundPos = -1; | ||
121 | } | ||
122 | |||
123 | #ifndef PWM_EMBEDDED | ||
124 | #include "findwndimpl.moc" | ||
125 | #endif | ||