summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/addentrywndimpl.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/addentrywndimpl.cpp
parentce83a3479d23b9e8a59c745ccd0a0b14f64ef4e8 (diff)
downloadkdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.zip
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.gz
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.bz2
initial revision
Diffstat (limited to 'pwmanager/pwmanager/addentrywndimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/addentrywndimpl.cpp174
1 files changed, 174 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/addentrywndimpl.cpp b/pwmanager/pwmanager/addentrywndimpl.cpp
new file mode 100644
index 0000000..9e0fde9
--- a/dev/null
+++ b/pwmanager/pwmanager/addentrywndimpl.cpp
@@ -0,0 +1,174 @@
+/***************************************************************************
+ * *
+ * copyright (C) 2003, 2004 by Michael Buesch *
+ * email: mbuesch@freenet.de *
+ * *
+ * Many very good improvements and the original implementations of *
+ * them came from Matt Scifo <mscifo@o1.com> *
+ * *
+ * 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 "addentrywndimpl.h"
+#include "pwmexception.h"
+#include "pwgenwndimpl.h"
+#ifndef PWM_EMBEDDED
+#include "advcommeditimpl.h"
+#endif
+#include "htmlgen.h"
+
+#include <kmessagebox.h>
+#include <klocale.h>
+
+#include <qpushbutton.h>
+#include <qlabel.h>
+
+
+AddEntryWndImpl::AddEntryWndImpl()
+{
+ editAdvCommentButton = 0;
+ commentTextEdit = 0;
+ switchComment(false);
+ pwGen = new PwGenWndImpl(this);
+}
+
+AddEntryWndImpl::~AddEntryWndImpl()
+{
+ delete_ifnot_null(editAdvCommentButton);
+ delete_ifnot_null(commentTextEdit);
+ delete pwGen;
+}
+
+void AddEntryWndImpl::okButton_slot()
+{
+ if (pwLineEdit->text().isEmpty()) {
+ KMessageBox::error(this,
+ i18n("Sorry, you haven't set a password."),
+ i18n("no password"));
+ return;
+ }
+ if (descLineEdit->text().isEmpty()) {
+ KMessageBox::error(this,
+ i18n
+ ("You haven't set a \"Description\"."),
+ i18n("Description not set"));
+ return;
+ }
+ done(1);
+}
+
+void AddEntryWndImpl::cancelButton_slot()
+{
+ done(2);
+}
+
+void AddEntryWndImpl::setCurrCategory(const QString &cat)
+{
+ int i, count = categoryComboBox->count();
+
+ for (i = 0; i < count; ++i) {
+ if (categoryComboBox->text(i) == cat) {
+ categoryComboBox->setCurrentItem(i);
+ return;
+ }
+ }
+ BUG();
+}
+
+void AddEntryWndImpl::revealButton_slot()
+{
+ if (revealButton->isOn()) {
+ pwLineEdit->setEchoMode(QLineEdit::Normal);
+ } else {
+ pwLineEdit->setEchoMode(QLineEdit::Password);
+ }
+}
+
+void AddEntryWndImpl::generateButton_slot()
+{
+ if (!pwGen->exec())
+ return;
+ setPassword(pwGen->getPassword());
+}
+
+QString AddEntryWndImpl::getComment()
+{
+ if (isAdvancedComment()) {
+ return advCommentDta;
+ }
+ return commentTextEdit->text();
+}
+
+void AddEntryWndImpl::setComment(const QString &comm)
+{
+ if (HtmlGen::isHtml(comm)) {
+ advancedCommentButton->setOn(true);
+ advCommentDta = comm;
+ } else {
+ advancedCommentButton->setOn(false);
+ commentTextEdit->setText(comm);
+ }
+}
+
+void AddEntryWndImpl::advancedCommentButton_slot(bool on)
+{
+ switchComment(on);
+}
+
+void AddEntryWndImpl::switchComment(bool toAdvanced)
+{
+ useAdvComment = toAdvanced;
+ if (toAdvanced) {
+ if (commentTextEdit) {
+ savedCommentText = commentTextEdit->text();
+ delete_and_null(commentTextEdit);
+ }
+ if (editAdvCommentButton)
+ return;
+ editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."),
+ commentDummy);
+ editAdvCommentButton->resize(commentDummy->size().width(), 50);
+ connect(editAdvCommentButton, SIGNAL(clicked()),
+ this, SLOT(editAdvCommentButton_slot()));
+ editAdvCommentButton->show();
+ } else {
+ delete_ifnot_null(editAdvCommentButton);
+ if (commentTextEdit)
+ return;
+#ifndef PWM_EMBEDDED
+ commentTextEdit = new QTextEdit(commentDummy);
+ commentTextEdit->setTextFormat(Qt::PlainText);
+#else
+ commentTextEdit = new QMultiLineEdit(commentDummy);
+#endif
+ commentTextEdit->resize(commentDummy->size());
+ commentTextEdit->setText(savedCommentText);
+ commentTextEdit->show();
+ }
+}
+
+void AddEntryWndImpl::editAdvCommentButton_slot()
+{
+#ifndef PWM_EMBEDDED
+ AdvCommEditImpl editor(this);
+ editor.setHtmlDta(advCommentDta);
+ if (editor.exec())
+ return;
+ advCommentDta = editor.getHtmlDta();
+#endif
+}
+
+#ifndef PWM_EMBEDDED
+#include "addentrywndimpl.moc"
+#endif