summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/findwndimpl.cpp
authorulf69 <ulf69>2004-09-15 17:53:22 (UTC)
committer ulf69 <ulf69>2004-09-15 17:53:22 (UTC)
commitd3925ba5bd25224bc4a60d3d6a107c464994a1ea (patch) (side-by-side diff)
tree60f69da1d2b79ee3081e7ef5c09a46470ca6eda0 /pwmanager/pwmanager/findwndimpl.cpp
parentce83a3479d23b9e8a59c745ccd0a0b14f64ef4e8 (diff)
downloadkdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.zip
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.gz
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.bz2
initial revision
Diffstat (limited to 'pwmanager/pwmanager/findwndimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/findwndimpl.cpp125
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 @@
+/***************************************************************************
+ * *
+ * copyright (C) 2003 by Michael Buesch *
+ * email: mbuesch@freenet.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License version 2 *
+ * as published by the Free Software Foundation. *
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * copyright (C) 2004 by Ulf Schenk
+ * This file is originaly based on version 1.0.1 of pwmanager
+ * and was modified to run on embedded devices that run microkde
+ *
+ * $Id$
+ **************************************************************************/
+
+#include "findwndimpl.h"
+#include "pwmexception.h"
+#include "pwmdoc.h"
+#include "pwmview.h"
+
+#include <qradiobutton.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+
+#include <kmessagebox.h>
+#include <klocale.h>
+
+FindWndImpl::FindWndImpl(PwMView * _parent)
+ : findWnd()
+{
+ parent = _parent;
+ fAt = 0;
+ refVal = 0;
+ currFoundPos = -1;
+ numEntries = parent->document()->numEntries(parent->getCurrentCategory());
+ connect(this, SIGNAL(foundAt(int)), parent, SLOT(selAt(int)));
+}
+
+FindWndImpl::~FindWndImpl()
+{
+}
+
+void FindWndImpl::findButton_slot()
+{
+ if (findLineEdit->text() == "")
+ return;
+ static vector<unsigned int> foundPositions;
+ PwMDoc *doc = parent->document();
+
+ if (currFoundPos < 0) {
+ bool unlockedTempoary = false;
+ foundPositions.clear();
+ PwMDataItem findThis;
+ unsigned int searchIn = 0;
+
+ if (descRadioButton->isChecked()) {
+ searchIn = SEARCH_IN_DESC;
+ findThis.desc = findLineEdit->text().latin1();
+ } else if (nameRadioButton->isChecked()) {
+ searchIn = SEARCH_IN_NAME;
+ findThis.name = findLineEdit->text().latin1();
+ } else if (pwRadioButton->isChecked()) {
+ searchIn = SEARCH_IN_PW;
+ findThis.pw = findLineEdit->text().latin1();
+ } else if (commentRadioButton->isChecked()) {
+ searchIn = SEARCH_IN_COMMENT;
+ findThis.comment = findLineEdit->text().latin1();
+ } else if (urlRadioButton->isChecked()) {
+ searchIn = SEARCH_IN_URL;
+ findThis.url = findLineEdit->text().latin1();
+ } else if (launcherRadioButton->isChecked()) {
+ searchIn = SEARCH_IN_LAUNCHER;
+ findThis.launcher = findLineEdit->text().latin1();
+ }
+
+ if (pwRadioButton->isChecked()) {
+ if (!doc->unlockAll_tempoary())
+ return;
+ unlockedTempoary = true;
+ }
+ doc->findEntry(parent->getCurrentCategory(), findThis,
+ searchIn, &foundPositions, false,
+ caseSensCheckBox->isChecked(),
+ exactCheckBox->isChecked(),
+ true);
+ if (unlockedTempoary) {
+ doc->unlockAll_tempoary(true);
+ }
+
+ if (!foundPositions.size()) {
+ KMessageBox::information(this,
+ i18n("No entry found."),
+ i18n("not found"));
+ return;
+ }
+ currFoundPos = 0;
+ }
+
+ int lvp = doc->getListViewPos(parent->getCurrentCategory(),
+ foundPositions[currFoundPos++]);
+ emit foundAt(numEntries - 1 - lvp);
+
+ if (currFoundPos + 1 > static_cast<int>(foundPositions.size()))
+ currFoundPos = 0;
+}
+
+void FindWndImpl::closeButton_slot()
+{
+ done(0);
+}
+
+void FindWndImpl::selectionChanged_slot()
+{
+ fAt = 0;
+ refVal = 0;
+ currFoundPos = -1;
+}
+
+#ifndef PWM_EMBEDDED
+#include "findwndimpl.moc"
+#endif