author | ulf69 <ulf69> | 2004-09-29 23:57:50 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-29 23:57:50 (UTC) |
commit | 1bcba53b99411b8af139c8c62d2a5b26ba4a4721 (patch) (side-by-side diff) | |
tree | 6bbe50d7df09e0da3cce98d34e0c2894155bf5a4 /pwmanager | |
parent | 21e794339f8988d9c370bebec45f60f2918fb671 (diff) | |
download | kdepimpi-1bcba53b99411b8af139c8c62d2a5b26ba4a4721.zip kdepimpi-1bcba53b99411b8af139c8c62d2a5b26ba4a4721.tar.gz kdepimpi-1bcba53b99411b8af139c8c62d2a5b26ba4a4721.tar.bz2 |
optimization of the commentview. Coordinates are now stored at programend
-rw-r--r-- | pwmanager/pwmanager/addentrywnd_emb.cpp | 20 | ||||
-rw-r--r-- | pwmanager/pwmanager/addentrywnd_emb.h | 5 | ||||
-rw-r--r-- | pwmanager/pwmanager/addentrywndimpl.cpp | 22 | ||||
-rw-r--r-- | pwmanager/pwmanager/addentrywndimpl.h | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/commentbox.cpp | 87 | ||||
-rw-r--r-- | pwmanager/pwmanager/commentbox.h | 40 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmanagerE.pro | 3 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmprefs.cpp | 3 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmprefs.h | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle.cpp | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_1.cpp | 6 |
12 files changed, 132 insertions, 65 deletions
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp index ed02e6d..dd09d13 100644 --- a/pwmanager/pwmanager/addentrywnd_emb.cpp +++ b/pwmanager/pwmanager/addentrywnd_emb.cpp @@ -1,213 +1,199 @@ /* This file is part of PwManager/Platform independent. Copyright (c) 2004 Ulf Schenk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. $Id$ */ #include "addentrywnd_emb.h" #include <qlayout.h> #include <qlabel.h> #include <qtabwidget.h> #include <qgroupbox.h> #include <klocale.h> #include <kcombobox.h> #include <klineedit.h> #include <qpushbutton.h> +#include <qmultilineedit.h> /* * Constructs a addEntryWnd as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ addEntryWnd::addEntryWnd( QWidget* parent, const char* name) : KDialogBase( KDialogBase::Plain, i18n( "edit/add a password entry" ), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, parent, name, true ) { QWidget *page = plainPage(); QVBoxLayout *pageLayout = new QVBoxLayout( page ); QTabWidget* mTabWidget = new QTabWidget( page ); pageLayout->addWidget( mTabWidget ); //////////////////////////////////////////////////////////////////// // This is the Password tab QWidget *tab1 = new QWidget( mTabWidget ); QGridLayout *layout = new QGridLayout( tab1, 3, 1 ); layout->setMargin( KDialogBase::marginHint() ); layout->setSpacing( KDialogBase::spacingHint() ); int i = 0; descLineEdit = new KLineEdit( tab1, "descLineEdit" ); QLabel* label = new QLabel( descLineEdit, i18n("Description:"), tab1 ); layout->addWidget( label, i, 0 ); layout->addWidget( descLineEdit, i, 1 ); i++; categoryComboBox = new KComboBox( tab1 ); label = new QLabel( categoryComboBox, i18n("Category:"), tab1 ); layout->addWidget( label, i, 0 ); layout->addWidget( categoryComboBox, i, 1 ); i++; categoryComboBox->setEditable( TRUE ); categoryComboBox->setSizeLimit( 100 ); categoryComboBox->setAutoCompletion( TRUE ); categoryComboBox->setDuplicatesEnabled( FALSE ); usernameLineEdit = new KLineEdit( tab1, "usernameLineEdit" ); label = new QLabel( usernameLineEdit, i18n("Username:"), tab1 ); layout->addWidget( label, i, 0 ); layout->addWidget( usernameLineEdit, i, 1 ); i++; pwLineEdit = new KLineEdit( tab1, "pwLineEdit" ); pwLineEdit->setEchoMode( QLineEdit::Password ); label = new QLabel( pwLineEdit, i18n("Password:"), tab1 ); layout->addWidget( label, i, 0 ); layout->addWidget( pwLineEdit, i, 1 ); i++; revealButton = new QPushButton( i18n("&Reveal"), tab1, "revealButton" ); revealButton->setToggleButton( TRUE ); layout->addWidget( revealButton, i, 0 ); generateButton = new QPushButton( i18n("&Generate"), tab1, "generateButton" ); layout->addWidget( generateButton, i, 1 ); i++; urlLineEdit = new KLineEdit( tab1, "urlLineEdit" ); label = new QLabel( urlLineEdit, i18n("URL:"), tab1 ); layout->addWidget( label, i, 0 ); layout->addWidget( urlLineEdit, i, 1 ); i++; mTabWidget->addTab( tab1, i18n( "&Password" ) ); //////////////////////////////////////////////////////////////////// // This is the Comment tab QWidget *tab2 = new QWidget( mTabWidget ); layout = new QGridLayout( tab2, 3, 1 ); layout->setMargin( KDialogBase::marginHintSmall() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); i = 0; - - - groupBox1 = new QGroupBox( tab2, "groupBox1" ); - commentDummy = new QLabel( groupBox1, "commentDummy" ); - commentDummy->setText( QString::null ); - - groupBox1->setTitle( i18n( "Comment:" ) ); - - layout->addMultiCellWidget( groupBox1, i, i, 0, 1 ); - i++; - - - advancedCommentButton = new QPushButton( i18n("advanced comment"), groupBox1, "advancedCommentButton" ); - advancedCommentButton->setToggleButton( FALSE ); - layout->addMultiCellWidget( advancedCommentButton, i, i, 0, 1 ); + commentTextEdit = new QMultiLineEdit(tab2); + layout->addMultiCellWidget( commentTextEdit, i, i, 0, 0 ); i++; mTabWidget->addTab( tab2, i18n( "&Comments" ) ); //////////////////////////////////////////////////////////////////// // This is the Launcher tab QWidget *tab3 = new QWidget( mTabWidget ); layout = new QGridLayout( tab3, 3, 1 ); layout->setMargin( KDialogBase::marginHintSmall() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); i = 0; launcherLineEdit = new KLineEdit( tab3, "launcherLineEdit" ); label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); QLabel* label1 = new QLabel( launcherLineEdit, i18n("$d = Description"), tab3 ); QLabel* label2 = new QLabel( launcherLineEdit, i18n("$n = Username"), tab3 ); QLabel* label3 = new QLabel( launcherLineEdit, i18n("$c = Comment"), tab3 ); QLabel* label4 = new QLabel( launcherLineEdit, i18n("$u = URL"), tab3 ); QLabel* label5 = new QLabel( launcherLineEdit, i18n("$p = Password"), tab3 ); label = new QLabel( launcherLineEdit, i18n("Launcher:"), tab3 ); layout->addWidget( label1, i, 0 ); layout->addWidget( label2, i, 1 ); i++; layout->addWidget( label3, i, 0 ); layout->addWidget( label4, i, 1 ); i++; layout->addWidget( label5, i, 0 ); i++; layout->addWidget( label, i, 0 ); layout->addWidget( launcherLineEdit, i, 1 ); i++; mTabWidget->addTab( tab3, i18n( "&Launcher" ) ); // signals and slots connections connect( generateButton, SIGNAL( clicked() ), this, SLOT( generateButton_slot() ) ); connect( revealButton, SIGNAL( toggled(bool) ), this, SLOT( revealButton_slot() ) ); - connect( advancedCommentButton, SIGNAL( toggled(bool) ), this, SLOT( advancedCommentButton_slot(bool) ) ); - } /* * Destroys the object and frees any allocated resources */ addEntryWnd::~addEntryWnd() { // no need to delete child widgets, Qt does it all for us } void addEntryWnd::slotOk() { qWarning( "addEntryWnd::slotOk(): Not implemented yet" ); } void addEntryWnd::revealButton_slot() { qWarning( "addEntryWnd::revealButton_slot(): Not implemented yet" ); } void addEntryWnd::generateButton_slot() { qWarning( "addEntryWnd::generateButton_slot(): Not implemented yet" ); } void addEntryWnd::advancedCommentButton_slot(bool) { qWarning( "addEntryWnd::advancedCommentButton_slot(bool): Not implemented yet" ); } diff --git a/pwmanager/pwmanager/addentrywnd_emb.h b/pwmanager/pwmanager/addentrywnd_emb.h index e368721..83761dc 100644 --- a/pwmanager/pwmanager/addentrywnd_emb.h +++ b/pwmanager/pwmanager/addentrywnd_emb.h @@ -1,73 +1,72 @@ /* This file is part of PwManager/Platform independent. Copyright (c) 2004 Ulf Schenk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. $Id$ */ #ifndef ADDENTRYWND_EMB_H #define ADDENTRYWND_EMB_H #include <qvariant.h> #include <kdialogbase.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QSpacerItem; class KLineEdit; class QPushButton; class KComboBox; class QLabel; class QGroupBox; +class QMultiLineEdit; class addEntryWnd : public KDialogBase { Q_OBJECT public: addEntryWnd( QWidget* parent = 0, const char* name = 0); ~addEntryWnd(); KLineEdit* launcherLineEdit; QPushButton* generateButton; KLineEdit* descLineEdit; KComboBox* categoryComboBox; KLineEdit* usernameLineEdit; KLineEdit* pwLineEdit; KLineEdit* urlLineEdit; QPushButton* revealButton; - QGroupBox* groupBox1; - QLabel* commentDummy; - QPushButton* advancedCommentButton; + QMultiLineEdit* commentTextEdit; public slots: virtual void revealButton_slot(); virtual void generateButton_slot(); virtual void advancedCommentButton_slot(bool on); protected slots: virtual void slotOk(); }; #endif // ADDENTRYWND_H diff --git a/pwmanager/pwmanager/addentrywndimpl.cpp b/pwmanager/pwmanager/addentrywndimpl.cpp index ffd301f..d47f32c 100644 --- a/pwmanager/pwmanager/addentrywndimpl.cpp +++ b/pwmanager/pwmanager/addentrywndimpl.cpp @@ -1,203 +1,217 @@ /*************************************************************************** * * * 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> +#include <qlayout.h> + #ifndef PWM_EMBEDDED AddEntryWndImpl::AddEntryWndImpl() : addEntryWnd( 0, "AddEntryWndImpl", TRUE) #else AddEntryWndImpl::AddEntryWndImpl( QWidget* parent, const char* name) : addEntryWnd( parent, name) #endif { +#ifndef PWM_EMBEDDED editAdvCommentButton = 0; commentTextEdit = 0; +#endif switchComment(false); pwGen = new PwGenWndImpl(this); } AddEntryWndImpl::~AddEntryWndImpl() { +#ifndef PWM_EMBEDDED delete_ifnot_null(editAdvCommentButton); delete_ifnot_null(commentTextEdit); +#endif delete pwGen; } #ifdef PWM_EMBEDDED void AddEntryWndImpl::slotOk() { slotApply(); 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; } KDialogBase::slotOk(); } #else 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); } #endif 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() { +#ifndef PWM_EMBEDDED if (isAdvancedComment()) { return advCommentDta; } +#endif return commentTextEdit->text(); } void AddEntryWndImpl::setComment(const QString &comm) { +#ifndef PWM_EMBEDDED if (HtmlGen::isHtml(comm)) { advancedCommentButton->setOn(true); advCommentDta = comm; } else { advancedCommentButton->setOn(false); commentTextEdit->setText(comm); } +#else + commentTextEdit->setText(comm); +#endif } void AddEntryWndImpl::advancedCommentButton_slot(bool on) { +#ifndef PWM_EMBEDDED switchComment(on); +#endif } void AddEntryWndImpl::switchComment(bool toAdvanced) { +#ifndef PWM_EMBEDDED + 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(); } +#endif } 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 diff --git a/pwmanager/pwmanager/addentrywndimpl.h b/pwmanager/pwmanager/addentrywndimpl.h index 622e9d2..ce9a594 100644 --- a/pwmanager/pwmanager/addentrywndimpl.h +++ b/pwmanager/pwmanager/addentrywndimpl.h @@ -1,127 +1,127 @@ /*************************************************************************** * * * copyright (C) 2003, 2004 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$ **************************************************************************/ #ifndef __ADDENTRYWNDIMPL_H #define __ADDENTRYWNDIMPL_H #ifndef PWM_EMBEDDED #include <qlineedit.h> #include <qtextedit.h> #include <qcombobox.h> #include "addentrywnd.h" #else #include <klineedit.h> #include <kcombobox.h> #include <qmultilineedit.h> #include "addentrywnd_emb.h" #endif #include <qpushbutton.h> class PwGenWndImpl; /** "add/edit" Window */ class AddEntryWndImpl : public addEntryWnd { Q_OBJECT public: #ifndef PWM_EMBEDDED AddEntryWndImpl(); #else AddEntryWndImpl( QWidget* parent = 0, const char* name = 0); #endif ~AddEntryWndImpl(); /* get... functions */ QString getDescription() { return descLineEdit->text(); } QString getCategory() { return categoryComboBox->currentText(); } QString getUsername() { return usernameLineEdit->text(); } QString getPassword() { return pwLineEdit->text(); } QString getUrl() { return urlLineEdit->text(); } QString getLauncher() { return launcherLineEdit->text(); } QString getComment(); /* set... functions */ void setDescription(const QString &desc) { descLineEdit->setText(desc); } void setCurrCategory(const QString &cat); void addCategory(const QString &cat) { categoryComboBox->insertItem(cat); } void setUsername(const QString &name) { usernameLineEdit->setText(name); } void setPassword(const QString &pw) { pwLineEdit->setText(pw); } void setUrl(const QString &url) { urlLineEdit->setText(url); } void setLauncher(const QString launcher) { launcherLineEdit->setText(launcher); } void setComment(const QString &comm); /** are we using an advanced comment */ bool isAdvancedComment() { return useAdvComment; } public slots: #ifndef PWM_EMBEDDED //MOC_SKIP_BEGIN /** OK button pressed */ void okButton_slot(); /** cancel button pressed */ void cancelButton_slot(); //MOC_SKIP_END #else virtual void slotOk(); #endif /** Reveal button pressed */ void revealButton_slot(); /** Generate button pressed */ void generateButton_slot(); /** advanced comment button pressed */ void advancedCommentButton_slot(bool on); /** edit advanced comment button pressed */ void editAdvCommentButton_slot(); protected: void switchComment(bool toAdvanced); protected: QPushButton *editAdvCommentButton; #ifndef PWM_EMBEDDED QTextEdit *commentTextEdit; #else - QMultiLineEdit * commentTextEdit; + //nothing here #endif /** saved data from normal comment text edit box */ QString savedCommentText; /** use an advanced comment? */ bool useAdvComment; /** data of advanced comment (if available) */ QString advCommentDta; /** password generation object */ PwGenWndImpl *pwGen; }; #endif diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp index 280b139..4a76f36 100644 --- a/pwmanager/pwmanager/commentbox.cpp +++ b/pwmanager/pwmanager/commentbox.cpp @@ -1,238 +1,281 @@ /*************************************************************************** * * * copyright (C) 2004 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 "commentbox.h" #include "pwmexception.h" #include "htmlgen.h" #include <klocale.h> #ifndef PWM_EMBEDDED #include <khtml_part.h> #include <khtmlview.h> #include <qtextedit.h> #else #include <qmultilineedit.h> #endif + + +#ifndef PWM_EMBEDDED CommentBox::CommentBox(QWidget *_parentWidget) { PWM_ASSERT(_parentWidget); parentWidget = _parentWidget; textDta = 0; -#ifndef PWM_EMBEDDED htmlDta = 0; -#endif mode = mode_notSet; } CommentBox::~CommentBox() { clearText(); clearHtml(); } void CommentBox::clear() { clearText(); clearHtml(); mode = mode_notSet; + this->hide(); } void CommentBox::clearText() { delete_ifnot_null(textDta); } void CommentBox::clearHtml() { -#ifndef PWM_EMBEDDED delete_ifnot_null(htmlDta); -#endif } void CommentBox::setText(const QString &text) { switchTo(mode_text); PWM_ASSERT(textDta); textDta->setText(i18n("Comment") + ": " + text); if (!textDta->isVisible()) textDta->show(); } bool CommentBox::getText(QString *text) { if (mode != mode_text) return false; PWM_ASSERT(text); if (!textDta) { *text = ""; return true; } *text = textDta->text(); return true; } void CommentBox::setHtml(QString code) { -#ifndef PWM_EMBEDDED switchTo(mode_html); PWM_ASSERT(htmlDta); if (!HtmlGen::replaceSSDummy(&code)) printWarn("CommentBox::setHtml(): replaceSSDummy() failed!"); htmlDta->begin(); htmlDta->write(code); htmlDta->end(); htmlDta->show(); -#endif } void CommentBox::setContent(const QString &dta) { // if there's no data, hide the comment-box if (dta.isEmpty()) { clear(); return; } -#ifndef PWM_EMBEDDED if (HtmlGen::isHtml(dta)) { setHtml(dta); return; } -#endif // we assume it's plain text setText(dta); } void CommentBox::switchTo(commentBoxMode newMode) { if (newMode == mode) return; // cleanup old mode switch (mode) { case mode_text: clearText(); break; case mode_html: clearHtml(); break; default: break; } // setup new mode switch (newMode) { case mode_text: -#ifndef PWM_EMBEDDED textDta = new QTextEdit(parentWidget); textDta->setTextFormat(Qt::PlainText); -#else - textDta = new QMultiLineEdit(parentWidget); -#endif textDta->setReadOnly(true); textDta->show(); break; case mode_html: -#ifndef PWM_EMBEDDED htmlDta = new KHTMLPart(parentWidget, 0, parentWidget); htmlDta->show(); -#endif break; default: BUG(); break; } mode = newMode; } void CommentBox::show() { switch (mode) { case mode_text: PWM_ASSERT(textDta); textDta->show(); break; case mode_html: -#ifndef PWM_EMBEDDED PWM_ASSERT(htmlDta); htmlDta->show(); -#endif break; default: break; } + } void CommentBox::hide() { switch (mode) { case mode_text: PWM_ASSERT(textDta); textDta->hide(); break; case mode_html: -#ifndef PWM_EMBEDDED PWM_ASSERT(htmlDta); htmlDta->hide(); -#endif break; default: break; } } void CommentBox::resize(const QSize &size) { switch (mode) { case mode_text: PWM_ASSERT(textDta); textDta->resize(size); break; case mode_html: -#ifndef PWM_EMBEDDED PWM_ASSERT(htmlDta); htmlDta->view()->resize(size); -#endif break; default: break; } + } QSize CommentBox::size() { switch (mode) { case mode_text: PWM_ASSERT(textDta); return textDta->size(); break; case mode_html: -#ifndef PWM_EMBEDDED PWM_ASSERT(htmlDta); return htmlDta->view()->size(); -#endif break; default: break; } + return QSize(); } + + +//////////////////////////////////////////////////////////////////////// + +#else + +CommentBox::CommentBox(QWidget *_parentWidget) + : QMultiLineEdit(_parentWidget) + +{ + this->setReadOnly(true); +} + +CommentBox::~CommentBox() +{ +} + +void CommentBox::clear() +{ + this->hide(); +} + + +void CommentBox::setText(const QString &text) +{ + QMultiLineEdit::setText(i18n("Comment") + ": " + text); + if (!this->isVisible()) + this->show(); +} + +bool CommentBox::getText(QString *text) +{ + *text = this->text(); + return true; +} + +void CommentBox::setContent(const QString &dta) +{ + // if there's no data, hide the comment-box + if (dta.isEmpty()) { + clear(); + return; + } + + // we assume it's plain text + setText(dta); +} + +#endif + + + + + + + + + diff --git a/pwmanager/pwmanager/commentbox.h b/pwmanager/pwmanager/commentbox.h index a220acd..352867c 100644 --- a/pwmanager/pwmanager/commentbox.h +++ b/pwmanager/pwmanager/commentbox.h @@ -1,100 +1,124 @@ /*************************************************************************** * * * copyright (C) 2004 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$ **************************************************************************/ #ifndef COMMENTBOX_H #define COMMENTBOX_H #include <qstring.h> #include <qsize.h> - class QWidget; class QTextEdit; -class QMultiLineEdit; class KHTMLPart; -/** Implementation of the advanced HTML comment box */ -class CommentBox +#ifndef PWM_EMBEDDED + +class CommentBox { protected: enum commentBoxMode { mode_notSet = 0, mode_text, mode_html }; public: CommentBox(QWidget *_parentWidget); ~CommentBox(); /** clear all data in the comment box */ void clear(); /** show the comment box */ void show(); /** hide the comment box */ void hide(); /** resize the comment box */ void resize(const QSize &size); void resize(int w, int h) { resize(QSize(w, h)); } /** get the size of the comment box */ QSize size(); /** if neccessary switch to text-mode and * insert this text into the comment box */ void setText(const QString &text); /** get the text of the comment box. * If it's not in text-mode it returns false */ bool getText(QString *text); /** if neccessary switch to HTML-mode and * insert this html code into the comment box */ void setHtml(QString code); /** checks "dta" for its type, sets the correct * mode and writes "dta" to the comment box */ void setContent(const QString &dta); protected: /** switch the current mode */ void switchTo(commentBoxMode newMode); /** clear all text data */ void clearText(); /** clear all HTML data */ void clearHtml(); protected: /** parent widget for this comment box */ QWidget *parentWidget; /** current comment box usage type */ commentBoxMode mode; -#ifndef PWM_EMBEDDED /** if the comment box is a normal textbox, data is stored here */ QTextEdit *textDta; /** if the comment box is a HTML box, data is stored here */ KHTMLPart *htmlDta; +}; + #else - /** if the comment box is a normal textbox, data is stored here */ - QMultiLineEdit *textDta; -#endif +#include <qmultilineedit.h> +/** Implementation of the advanced HTML comment box */ +//US ENH: CommentBox must be derived from QWidget, to allow the splitter to set a initial size +// without conflicting with the two display modes + +class CommentBox : public QMultiLineEdit +{ +public: + CommentBox(QWidget *_parentWidget); + ~CommentBox(); + + /** clear all data in the comment box */ + void clear(); + /** if neccessary switch to text-mode and + * insert this text into the comment box + */ + void setText(const QString &text); + /** get the text of the comment box. + * If it's not in text-mode it returns false + */ + bool getText(QString *text); + /** if neccessary switch to HTML-mode and + * insert this html code into the comment box + */ + void setContent(const QString &dta); }; +#endif + #endif diff --git a/pwmanager/pwmanager/pwmanagerE.pro b/pwmanager/pwmanager/pwmanagerE.pro index 3bcf679..4e482ca 100644 --- a/pwmanager/pwmanager/pwmanagerE.pro +++ b/pwmanager/pwmanager/pwmanagerE.pro @@ -1,139 +1,140 @@ TEMPLATE = app CONFIG += qt warn_on TARGET = pwmpi OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR=$(QPEDIR)/bin INCLUDEPATH += . ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include -DEFINES += PWM_EMBEDDED PWM_DEBUG +DEFINES += PWM_EMBEDDED CONFIG_DEBUG + LIBS += -lmicrokde LIBS += -lmicroqtcompat LIBS += -lmicrokdepim LIBS += -L$(QPEDIR)/lib LIBS += -lqpe LIBS += -lbz2 LIBS += $(QTOPIALIB) #INTERFACES = \ #addentrywnd.ui \ #configwnd.ui \ #findwnd.ui \ #getmasterpwwnd.ui \ #pwgenwnd.ui \ #setmasterpwwnd.ui \ #subtbledit.ui #INTERFACES = \ #subtbledit.ui \ #HEADERS = \ #configuration_31compat.h \ #configuration.h \ #configwnd.h \ #configwndimpl.h \ #selftest.h #subtbledit.h \ #subtbleditimpl.h \ HEADERS = \ addentrywnd_emb.h \ addentrywndimpl.h \ base64.h \ binentrygen.h \ blowfish.h \ commentbox.h \ compiler.h \ compressbzip2.h \ compressgzip.h \ findwnd_emb.h \ findwndimpl.h \ genpasswd.h \ getkeycardwnd.h \ getmasterpwwnd_emb.h \ getmasterpwwndimpl.h \ globalstuff.h \ gpasmanfile.h \ htmlgen.h \ htmlparse.h \ ipc.h \ listobjselectwnd.h \ listviewpwm.h \ printtext.h \ pwgenwnd_emb.h \ pwgenwndimpl.h \ pwmdoc.h \ pwmdocui.h \ pwmexception.h \ pwm.h \ pwminit.h \ pwmprefs.h \ pwmprint.h \ pwmtray.h \ pwmview.h \ pwmviewstyle_0.h \ pwmviewstyle_1.h \ pwmviewstyle.h \ randomizer.h \ rc2.h \ rencatwnd.h \ serializer.h \ setmasterpwwnd_emb.h \ setmasterpwwndimpl.h \ sha1.h \ waitwnd.h \ kcmconfigs/kcmpwmconfig.h \ kcmconfigs/pwmconfigwidget.h \ #sources that need not be build #SOURCES = \ #advcommeditimpl.cpp \ #configuration.cpp \ #configwnd.cpp \ #configwndimpl.cpp \ #configuration_31compat.cpp \ #htmlparse.cpp \ #printtext.cpp \ #selftest.cpp \ #pwmprint.cpp \ #spinforsignal.cpp #subtbledit.cpp \ #subtbleditimpl.cpp \ SOURCES = \ addentrywnd_emb.cpp \ addentrywndimpl.cpp \ base64.cpp \ binentrygen.cpp \ blowfish.cpp \ commentbox.cpp \ compressbzip2.cpp \ compressgzip.cpp \ findwnd_emb.cpp \ findwndimpl.cpp \ genpasswd.cpp \ getkeycardwnd.cpp \ getmasterpwwnd_emb.cpp \ getmasterpwwndimpl.cpp \ globalstuff.cpp \ gpasmanfile.cpp \ htmlgen.cpp \ ipc.cpp \ listobjselectwnd.cpp \ listviewpwm.cpp \ main.cpp \ pwgenwnd_emb.cpp \ pwgenwndimpl.cpp \ pwm.cpp \ pwmdoc.cpp \ pwmdocui.cpp \ pwmexception.cpp \ pwminit.cpp \ pwmprefs.cpp \ pwmtray.cpp \ pwmview.cpp \ pwmviewstyle_0.cpp \ diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index c167c2c..1b6d36f 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp @@ -1,176 +1,174 @@ /*************************************************************************** * * * copyright (C) 2003, 2004 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 2.0 of pwmanager * and was modified to run on embedded devices that run microkde * * $Id$ **************************************************************************/ #include "pwmdoc.h" #include "pwmview.h" #include "blowfish.h" #include "sha1.h" #include "globalstuff.h" #include "gpasmanfile.h" #include "serializer.h" #include "compressgzip.h" #include "compressbzip2.h" #include "randomizer.h" #include "pwminit.h" #ifndef PWM_EMBEDDED //US #include "libgryptif.h" #else #include "pwmprefs.h" #include "kglobal.h" #endif #ifdef CONFIG_KWALLETIF # include "kwalletemu.h" #endif // CONFIG_KWALLETIF #include <qdatetime.h> #include <qsize.h> #include <qfileinfo.h> #include <qfile.h> -#define __USE_GNU -#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> //US#include <iostream> #include <algorithm> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdint.h> //TODO: reset to its normal value. #define META_CHECK_TIMER_INTERVAL 10/*300*/ /* sek */ using namespace std; void PwMDocList::add(PwMDoc *doc, const string &id) { #ifdef PWM_DEBUG // check for existance of object in debug mode only. vector<listItem>::iterator begin = docList.begin(), end = docList.end(), i = begin; while (i != end) { if (i->doc == doc) { BUG(); return; } ++i; } #endif listItem newItem; newItem.doc = doc; newItem.docId = id; docList.push_back(newItem); } void PwMDocList::edit(PwMDoc *doc, const string &newId) { vector<listItem>::iterator begin = docList.begin(), end = docList.end(), i = begin; while (i != end) { if (i->doc == doc) { i->docId = newId; return; } ++i; } } void PwMDocList::del(PwMDoc *doc) { vector<listItem>::iterator begin = docList.begin(), end = docList.end(), i = begin; while (i != end) { if (i->doc == doc) { docList.erase(i); return; } ++i; } } bool PwMDocList::find(const string &id, listItem *ret) { vector<listItem>::iterator begin = docList.begin(), end = docList.end(), i = begin; while (i != end) { if (i->docId == id) { if (ret) *ret = *i; return true; } ++i; } return false; } DocTimer::DocTimer(PwMDoc *_doc) : doc (_doc) , mpwLock (0) , autoLockLock (0) , metaCheckLock (0) { mpwTimer = new QTimer; autoLockTimer = new QTimer; metaCheckTimer = new QTimer; connect(mpwTimer, SIGNAL(timeout()), this, SLOT(mpwTimeout())); connect(autoLockTimer, SIGNAL(timeout()), this, SLOT(autoLockTimeout())); connect(metaCheckTimer, SIGNAL(timeout()), this, SLOT(metaCheckTimeout())); } DocTimer::~DocTimer() { delete mpwTimer; delete autoLockTimer; delete metaCheckTimer; } void DocTimer::start(TimerIDs timer) { switch (timer) { case id_mpwTimer: if (mpwTimer->isActive()) mpwTimer->stop(); doc->setDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); mpwTimer->start(conf()->confGlobPwTimeout() * 1000, true); break; case id_autoLockTimer: if (autoLockTimer->isActive()) autoLockTimer->stop(); if (conf()->confGlobLockTimeout() > 0) autoLockTimer->start(conf()->confGlobLockTimeout() * 1000, true); break; case id_metaCheckTimer: if (metaCheckTimer->isActive()) metaCheckTimer->stop(); metaCheckTimer->start(META_CHECK_TIMER_INTERVAL * 1000, true); break; @@ -1046,258 +1044,256 @@ bool PwMDoc::delEntry(const QString &category, unsigned int index, bool dontFlag if (!findCategory(category, &cat)) { BUG(); return false; } return delEntry(cat, index, dontFlagDirty); } bool PwMDoc::delEntry(unsigned int category, unsigned int index, bool dontFlagDirty) { if (isDeepLocked()) return false; if (index > dta[category].d.size() - 1) return false; getDataChangedLock(); if (!lockAt(category, index, false)) { putDataChangedLock(); return false; } putDataChangedLock(); int lvPos = dta[category].d[index].listViewPos; // delete entry dta[category].d.erase(dta[category].d.begin() + index); unsigned int i, entries = numEntries(category); if (!entries) { // no more entries in this category, so // we can delete it, too. BUG_ON(!delCategory(category)); // delCategory() flags it dirty, so we need not to do so. return true; } for (i = 0; i < entries; ++i) { // decrement all listViewPositions that are greater than the deleted. if (dta[category].d[i].listViewPos > lvPos) --dta[category].d[i].listViewPos; } if (!dontFlagDirty) flagDirty(); return true; } bool PwMDoc::editEntry(const QString &oldCategory, const QString &newCategory, unsigned int index, PwMDataItem *d, bool updateMeta) { PWM_ASSERT(d); unsigned int oldCat = 0; if (!findCategory(oldCategory, &oldCat)) { BUG(); return false; } return editEntry(oldCat, newCategory, index, d, updateMeta); } bool PwMDoc::editEntry(unsigned int oldCategory, const QString &newCategory, unsigned int index, PwMDataItem *d, bool updateMeta) { if (isDeepLocked()) return false; if (updateMeta) { d->meta.update = QDateTime::currentDateTime(); if (d->meta.create.isNull()) { d->meta.create = d->meta.update; } } if (dta[oldCategory].name != newCategory.latin1()) { // the user changed the category. PwMerror ret; d->rev = 0; ret = addEntry(newCategory, d, true, false); if (ret != e_success) return false; if (!delEntry(oldCategory, index, true)) return false; } else { d->rev = dta[oldCategory].d[index].rev + 1; // increment revision counter. dta[oldCategory].d[index] = *d; } flagDirty(); return true; } unsigned int PwMDoc::numEntries(const QString &category) { unsigned int cat = 0; if (!findCategory(category, &cat)) { BUG(); return 0; } return numEntries(cat); } bool PwMDoc::serializeDta(string *d) { PWM_ASSERT(d); Serializer ser; if (!ser.serialize(dta)) return false; d->assign(ser.getXml()); if (!d->size()) return false; return true; } bool PwMDoc::deSerializeDta(const string *d, bool entriesLocked) { PWM_ASSERT(d); #ifndef PWM_EMBEDDED try { Serializer ser(d->c_str()); ser.setDefaultLockStat(entriesLocked); if (!ser.deSerialize(&dta)) return false; } catch (PwMException) { return false; } #else Serializer ser(d->c_str()); ser.setDefaultLockStat(entriesLocked); if (!ser.deSerialize(&dta)) return false; - else - return false; #endif emitDataChanged(this); return true; } bool PwMDoc::getEntry(const QString &category, unsigned int index, PwMDataItem * d, bool unlockIfLocked) { PWM_ASSERT(d); unsigned int cat = 0; if (!findCategory(category, &cat)) { BUG(); return false; } return getEntry(cat, index, d, unlockIfLocked); } bool PwMDoc::getEntry(unsigned int category, unsigned int index, PwMDataItem *d, bool unlockIfLocked) { if (index > dta[category].d.size() - 1) return false; bool locked = isLocked(category, index); if (locked) { /* this entry is locked. We don't return a password, * until it's unlocked by the user by inserting * chipcard or entering the mpw */ if (unlockIfLocked) { if (!lockAt(category, index, false)) { return false; } locked = false; } } *d = dta[category].d[index]; if (locked) d->pw = LOCKED_STRING.latin1(); return true; } PwMerror PwMDoc::getCommentByLvp(const QString &category, int listViewPos, string *foundComment) { PWM_ASSERT(foundComment); unsigned int cat = 0; if (!findCategory(category, &cat)) return e_invalidArg; unsigned int i, entries = numEntries(cat); for (i = 0; i < entries; ++i) { if (dta[cat].d[i].listViewPos == listViewPos) { *foundComment = dta[cat].d[i].comment; if (dta[cat].d[i].binary) return e_binEntry; return e_normalEntry; } } BUG(); return e_generic; } bool PwMDoc::compressDta(string *d, char algo) { PWM_ASSERT(d); switch (algo) { case PWM_COMPRESS_GZIP: { CompressGzip comp; return comp.compress(d); } case PWM_COMPRESS_BZIP2: { CompressBzip2 comp; return comp.compress(d); } case PWM_COMPRESS_NONE: { return true; } default: { BUG(); } } return false; } bool PwMDoc::decompressDta(string *d, char algo) { PWM_ASSERT(d); switch (algo) { case PWM_COMPRESS_GZIP: { CompressGzip comp; return comp.decompress(d); } case PWM_COMPRESS_BZIP2: { CompressBzip2 comp; return comp.decompress(d); } case PWM_COMPRESS_NONE: { return true; } } return false; } PwMerror PwMDoc::encrypt(string *d, const QString *pw, QFile *f, char algo) { PWM_ASSERT(d); PWM_ASSERT(pw); PWM_ASSERT(f); size_t encSize; byte *encrypted = 0; switch (algo) { case PWM_CRYPT_BLOWFISH: { Blowfish::padNull(d); encSize = d->length(); encrypted = new byte[encSize]; Blowfish bf; if (bf.bf_setkey((byte *) pw->latin1(), pw->length())) { delete [] encrypted; return e_weakPw; } bf.bf_encrypt((byte *) encrypted, (byte *) d->c_str(), encSize); break; } #ifndef PWM_EMBEDDED diff --git a/pwmanager/pwmanager/pwmprefs.cpp b/pwmanager/pwmanager/pwmprefs.cpp index d3847f6..7fd347f 100644 --- a/pwmanager/pwmanager/pwmprefs.cpp +++ b/pwmanager/pwmanager/pwmprefs.cpp @@ -1,192 +1,193 @@ /* This file is part of PwManager/Pi Copyright (c) 2004 Ulf Schenk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. $Id$ */ #include <kconfig.h> #include <klocale.h> #include <kstaticdeleter.h> #include "pwmprefs.h" PWMPrefs *PWMPrefs::sInstance = 0; static KStaticDeleter<PWMPrefs> staticDeleter; PWMPrefs::PWMPrefs() : KPimPrefs("pwmanagerrc") { KPrefs::setCurrentGroup( "Global" ); addItemString( "autoStart", &mAutoStart, "" ); addItemString( "browserCommand", &mBrowserCommand, "" ); addItemString( "xtermCommand", &mXTermCommand, CONF_DEFAULT_XTERMCOMMAND); addItemFont( "entryFont", &mEntryFont); addItemInt( "pwTimeout", &mPwTimeout, CONF_DEFAULT_PWTIMEOUT ); addItemInt( "lockTimeout", &mLockTimeout, CONF_DEFAULT_LOCKTIMEOUT ); addItemInt( "compression", &mCompression, CONF_DEFAULT_COMPRESSION ); addItemInt( "filePermissions", &mFilePermissions, CONF_DEFAULT_FILEPERMISSIONS ); addItemInt( "minimizeLock", &mMinimizeLock, CONF_DEFAULT_MINIMIZELOCK ); addItemBool( "unlockOnOpen", &mUnlockOnOpen, CONF_DEFAULT_UNLOCKONOPEN ); addItemBool( "tray", &mTray, CONF_DEFAULT_TRAY ); addItemBool( "makeFileBackup", &mMakeFileBackup, CONF_DEFAULT_MAKEFILEBACKUP ); addItemBool( "autostartDeepLocked", &mAutostartDeeplocked, CONF_DEFAULT_AUTOSTART_DEEPL ); addItemBool( "autoDeepLock", &mAutoDeeplock, CONF_DEFAULT_AUTODEEPLOCK ); addItemBool( "kwalletEmu", &mKWalletEmu, CONF_DEFAULT_KWALLETEMU ); addItemBool( "newEntrLockStat", &mNewEntrLockStat, CONF_DEFAULT_NEWENTRLOCKSTAT ); KPrefs::setCurrentGroup( "Wnd" ); addItemSize( "MainWndSize", &mMainWndSize); addItemInt( "MainViewStyle", &mMainViewStyle, CONF_DEFAULT_MAINVIEWSTYLE ); addItemBool( "autoMinimizeOnStart", &mAutoMinimizeOnStart, CONF_DEFAULT_AUTOMINIMIZE ); addItemBool( "close", &mClose, CONF_DEFAULT_WNDCLOSE ); - addItemIntList( "CommentSplitter", &mCommentSplitter ); + addItemIntList( "commentSplitter", &mCommentSplitter ); + addItemIntList( "categorySplitter", &mCategorySplitter ); } PWMPrefs::~PWMPrefs() { } PWMPrefs *PWMPrefs::instance() { if ( !sInstance ) { #ifdef PWM_EMBEDDED sInstance = staticDeleter.setObject( new PWMPrefs() ); #else //PWM_EMBEDDED //US the following line has changed ???. Why staticDeleter.setObject( sInstance, new PWMPrefs() ); #endif //KAB_EMBEDDED sInstance->readConfig(); } return sInstance; } // US introduce a nonconst way to return the config object. KConfig* PWMPrefs::getConfig() { return config(); } /******************************************************************* * functions for reading the configuration settings *******************************************************************/ QString PWMPrefs::confGlobAutoStart() { return mAutoStart; } QString PWMPrefs::confGlobBrowserCommand() { return mBrowserCommand; } QString PWMPrefs::confGlobXtermCommand() { return mXTermCommand; } QFont PWMPrefs::confGlobEntryFont() { return mEntryFont; } int PWMPrefs::confGlobPwTimeout() { return mPwTimeout; } int PWMPrefs::confGlobLockTimeout() { return mLockTimeout; } int PWMPrefs::confGlobCompression() { return mCompression; } int PWMPrefs::confGlobFilePermissions() { return mFilePermissions; } int PWMPrefs::confGlobMinimizeLock() { return mMinimizeLock; } bool PWMPrefs::confGlobUnlockOnOpen() { return mUnlockOnOpen; } bool PWMPrefs::confGlobTray() { return mTray; } bool PWMPrefs::confGlobMakeFileBackup() { return mMakeFileBackup; } bool PWMPrefs::confGlobAutostartDeepLocked() { return mAutostartDeeplocked; } bool PWMPrefs::confGlobAutoDeepLock() { return mAutoDeeplock; } bool PWMPrefs::confGlobKwalletEmu() { return mKWalletEmu; } bool PWMPrefs::confGlobNewEntrLockStat() { return mNewEntrLockStat; } QSize PWMPrefs::confWndMainWndSize() { return mMainWndSize; } int PWMPrefs::confWndMainViewStyle() { return mMainViewStyle; } bool PWMPrefs::confWndAutoMinimizeOnStart() { return mAutoMinimizeOnStart; } bool PWMPrefs::confWndClose() { diff --git a/pwmanager/pwmanager/pwmprefs.h b/pwmanager/pwmanager/pwmprefs.h index 6a89d10..9fed7d2 100644 --- a/pwmanager/pwmanager/pwmprefs.h +++ b/pwmanager/pwmanager/pwmprefs.h @@ -11,140 +11,141 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. $Id$ */ #ifndef PWMPREFS_H #define PWMPREFS_H #include <qstringlist.h> #include <qsize.h> #include <kpimprefs.h> class KConfig; #define conf() PWMPrefs::instance() #define CONF_DEFAULT_PWTIMEOUT 10 /* 10 sec */ #define CONF_DEFAULT_LOCKTIMEOUT 0 /* 0 == disable */ #define CONF_DEFAULT_TRAY true #define CONF_DEFAULT_UNLOCKONOPEN false #define CONF_DEFAULT_MAINVIEWSTYLE 0 #define CONF_DEFAULT_COMPRESSION 0x01 /* gzip */ #define CONF_DEFAULT_AUTOMINIMIZE false #define CONF_DEFAULT_BROWSERCOMMAND "" #define CONF_DEFAULT_XTERMCOMMAND "konsole -e" #define CONF_DEFAULT_FILEPERMISSIONS 0600 #define CONF_DEFAULT_MAKEFILEBACKUP false #define CONF_DEFAULT_AUTOSTART_DEEPL true #define CONF_DEFAULT_AUTODEEPLOCK true #define CONF_DEFAULT_KWALLETEMU true #define CONF_DEFAULT_MINIMIZELOCK 2 /* deep-lock */ #define CONF_DEFAULT_NEWENTRLOCKSTAT true /* locked */ #define CONF_DEFAULT_WNDCLOSE true /* don't minimize to tray */ class PWMPrefs : public KPimPrefs { public: virtual ~PWMPrefs(); static PWMPrefs *instance(); public: /* functions for reading the configuration settings */ /* GLOBAL */ QString confGlobAutoStart(); QString confGlobBrowserCommand(); QString confGlobXtermCommand(); QFont confGlobEntryFont(); int confGlobPwTimeout(); int confGlobLockTimeout(); int confGlobCompression(); int confGlobFilePermissions(); int confGlobMinimizeLock(); bool confGlobUnlockOnOpen(); bool confGlobTray(); bool confGlobMakeFileBackup(); bool confGlobAutostartDeepLocked(); bool confGlobAutoDeepLock(); bool confGlobKwalletEmu(); bool confGlobNewEntrLockStat(); /* WND */ QSize confWndMainWndSize(); int confWndMainViewStyle(); bool confWndAutoMinimizeOnStart(); bool confWndClose(); public: /* functions for writing the configuration settings */ /* GLOBAL */ void confGlobAutoStart(const QString &e); void confGlobBrowserCommand(const QString &e); void confGlobXtermCommand(const QString &e); void confGlobEntryFont(const QFont &e); void confGlobPwTimeout(int e); void confGlobLockTimeout(int e); void confGlobCompression(int e); void confGlobFilePermissions(int e); void confGlobMinimizeLock(int e); void confGlobUnlockOnOpen(bool e); void confGlobTray(bool e); void confGlobMakeFileBackup(bool e); void confGlobAutostartDeepLocked(bool e); void confGlobAutoDeepLock(bool e); void confGlobKwalletEmu(bool e); void confGlobNewEntrLockStat(bool e); /* WND */ void confWndMainWndSize(const QSize &e); void confWndMainViewStyle(int e); void confWndAutoMinimizeOnStart(bool e); void confWndClose(bool e); QString mAutoStart; QString mBrowserCommand; QString mXTermCommand; QFont mEntryFont; int mPwTimeout; int mLockTimeout; int mCompression; int mFilePermissions; int mMinimizeLock; bool mUnlockOnOpen; bool mTray; bool mMakeFileBackup; bool mAutostartDeeplocked; bool mAutoDeeplock; bool mKWalletEmu; bool mNewEntrLockStat; QSize mMainWndSize; int mMainViewStyle; bool mAutoMinimizeOnStart; bool mClose; //US ENH QValueList<int> mCommentSplitter; + QValueList<int> mCategorySplitter; // US introduce a nonconst way to return the config object. KConfig* getConfig(); private: PWMPrefs(); static PWMPrefs *sInstance; }; #endif diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp index 9704615..0af1473 100644 --- a/pwmanager/pwmanager/pwmviewstyle.cpp +++ b/pwmanager/pwmanager/pwmviewstyle.cpp @@ -1,232 +1,232 @@ /*************************************************************************** * * * copyright (C) 2004 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 "pwmviewstyle.h" #include "pwmexception.h" #include "pwmviewstyle_0.h" #include "pwmviewstyle_1.h" #include "listviewpwm.h" #include "pwmview.h" #include "commentbox.h" #ifndef PWM_EMBEDDED #include "configuration.h" #else #include "pwmprefs.h" #endif PwMViewStyle::PwMViewStyle(QWidget *parent, const char *name) : QWidget(parent, name) { curStyle = style_notset; s0 = 0; s1 = 0; } PwMViewStyle::~PwMViewStyle() { //US ENH : store the size of the listviewcolumns switch (curStyle) { case style_0: s0->saveSettings(PWMPrefs::instance()); break; case style_1: s1->saveSettings(PWMPrefs::instance()); break; default: BUG(); } - PWMPrefs::instance()->getConfig()->sync(); + PWMPrefs::instance()->writeConfig(); delete_ifnot_null(s0); delete_ifnot_null(s1); } void PwMViewStyle::initStyle(style_t style) { printDebug(string("initializing style ") + tostr(style)); bool wasMaximized = v->isMaximized(); if (v->isVisible()) v->hide(); switch (style) { case style_0: delete_ifnot_null(s0); delete_ifnot_null(s1); s0 = new PwMViewStyle_0(v); lv = s0->getLv(); commentBox = s0->getCommentBox(); break; case style_1: delete_ifnot_null(s0); delete_ifnot_null(s1); s1 = new PwMViewStyle_1(v); lv = s1->getLv(); commentBox = s1->getCommentBox(); break; default: BUG(); return; } curStyle = style; connect(lv, SIGNAL(pressed(QListViewItem *)), v, SLOT(handleToggle(QListViewItem *))); connect(lv, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)), v, SLOT(handleRightClick(QListViewItem *, const QPoint &, int))); connect(lv, SIGNAL(clicked(QListViewItem *)), v, SLOT(refreshCommentTextEdit(QListViewItem *))); lv->addColumn(i18n("Description"), 180); lv->addColumn(i18n("Username"), 150); lv->addColumn(i18n("Password"), 150); lv->addColumn(i18n("URL"), 180); lv->addColumn(i18n("Launcher"), 120); v->tmpReEnableSort(); //US ENH : load the size of the listviewcolumns - switch (style) + switch (curStyle) { case style_0: s0->restoreSettings(PWMPrefs::instance()); break; case style_1: s1->restoreSettings(PWMPrefs::instance()); break; default: BUG(); } resizeView(v->size()); v->updateView(); if (wasMaximized) { v->showMaximized(); } else { v->show(); } connect(lv, SIGNAL(layoutChanged()), v, SLOT(reorgLp())); } void PwMViewStyle::resizeView(const QSize &size) { switch (curStyle) { case style_0: PWM_ASSERT(s0); s0->resize(size); return; case style_1: PWM_ASSERT(s1); s1->resize(size); return; default: BUG(); } } QString PwMViewStyle::getCurrentCategory() { switch (curStyle) { case style_0: PWM_ASSERT(s0); return s0->getCurrentCategory(); case style_1: PWM_ASSERT(s1); return s1->getCurrentCategory(); default: BUG(); } return ""; } void PwMViewStyle::addCategory(const QString &cat) { switch (curStyle) { case style_0: PWM_ASSERT(s0); s0->addCategory(cat); return; case style_1: PWM_ASSERT(s1); s1->addCategory(cat); return; default: BUG(); } } void PwMViewStyle::delCategory(const QString &cat) { switch (curStyle) { case style_0: PWM_ASSERT(s0); s0->delCategory(cat); return; case style_1: PWM_ASSERT(s1); s1->delCategory(cat); return; default: BUG(); } } void PwMViewStyle::delAllCategories() { switch (curStyle) { case style_0: PWM_ASSERT(s0); s0->delAllCategories(); return; case style_1: PWM_ASSERT(s1); s1->delAllCategories(); return; default: BUG(); } } void PwMViewStyle::selectCategory(const QString &cat) { switch (curStyle) { case style_0: PWM_ASSERT(s0); s0->selectCategory(cat); return; case style_1: PWM_ASSERT(s1); s1->selectCategory(cat); return; default: BUG(); } } int PwMViewStyle::numCategories() { switch (curStyle) { case style_0: PWM_ASSERT(s0); return s0->numCategories(); case style_1: PWM_ASSERT(s1); return s1->numCategories(); default: BUG(); diff --git a/pwmanager/pwmanager/pwmviewstyle_1.cpp b/pwmanager/pwmanager/pwmviewstyle_1.cpp index 8b2d6d3..374c698 100644 --- a/pwmanager/pwmanager/pwmviewstyle_1.cpp +++ b/pwmanager/pwmanager/pwmviewstyle_1.cpp @@ -1,150 +1,152 @@ /*************************************************************************** * * * copyright (C) 2004 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 "pwmviewstyle_1.h" #include "pwmview.h" #include "listviewpwm.h" #include "commentbox.h" #include <klocale.h> #include "pwmprefs.h" #define INITIAL_CATEGORIES_WIDTH 100 PwMViewStyle_1::PwMViewStyle_1(PwMView *view) : QObject() { #ifndef PWM_EMBEDDED splitter = new QSplitter(view); #else splitter = new KDGanttMinimizeSplitter( Qt::Horizontal, view); splitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); //US topLayout->addWidget(mMiniSplitter ); #endif vbox1 = new QVBox(splitter); categoriesTitle = new QLabel(vbox1); categoriesList = new QListBox(vbox1); #ifndef PWM_EMBEDDED splitter2 = new QSplitter(splitter); splitter2->setOrientation(Qt::Vertical); #else splitter2 = new KDGanttMinimizeSplitter( Qt::Vertical, splitter); splitter2->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); //US topLayout->addWidget(mMiniSplitter ); #endif lv = new ListViewPwM(splitter2); commentBox = new CommentBox(splitter2); // set sizes and styles - commentBox->resize(commentBox->size().width(), 60); + //US commentBox->resize(commentBox->size().width(), 60); QValueList<int> sizes; #ifndef PWM_EMBEDDED sizes.push_back(INITIAL_CATEGORIES_WIDTH); sizes.push_back(view->height() - INITIAL_CATEGORIES_WIDTH); #else sizes.append(INITIAL_CATEGORIES_WIDTH); sizes.append(view->height() - INITIAL_CATEGORIES_WIDTH); #endif - splitter->setSizes(sizes); + //US splitter->setSizes(sizes); categoriesTitle->setAlignment(Qt::AlignHCenter); #ifndef PWM_EMBEDDED categoriesTitle->setFrameShape(QFrame::MenuBarPanel); #else categoriesTitle->setFrameShape(QFrame::StyledPanel); #endif categoriesTitle->setText(i18n("Categories:")); catCtxMenu = new QPopupMenu(view); catCtxMenu->insertItem(i18n("&Rename"), view, SLOT(renCatButton_slot())); catCtxMenu->insertItem(i18n("&Delete"), view, SLOT(delCatButton_slot())); // connections connect(categoriesList, SIGNAL(highlighted(int)), view, SLOT(shiftToView())); connect(categoriesList, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), this, SLOT(catRightClick(QListBoxItem *, const QPoint &))); } PwMViewStyle_1::~PwMViewStyle_1() { delete catCtxMenu; delete splitter; } void PwMViewStyle_1::catRightClick(QListBoxItem *item, const QPoint &point) { if (!item) return; catCtxMenu->move(point); catCtxMenu->show(); } void PwMViewStyle_1::delCategory(const QString &cat) { PWM_ASSERT(categoriesList); int i, count = categoriesList->count(); for (i = 0; i < count; ++i) { if (categoriesList->text(i) == cat) { categoriesList->removeItem(i); return; } } BUG(); } void PwMViewStyle_1::selectCategory(const QString &cat) { PWM_ASSERT(categoriesList); int i, count = categoriesList->count(); for (i = 0; i < count; ++i) { if (categoriesList->text(i) == cat) { categoriesList->setCurrentItem(i); return; } } // fall back to 0 categoriesList->setCurrentItem(0); } //US ENH: I need a place to load the view dependend settings. Eg. splittersize void PwMViewStyle_1::restoreSettings(PWMPrefs* prefs) { //load and store the size of the listviewcolumns lv->restoreLayout(prefs->getConfig(), "listview"); + splitter->setSizes( prefs->mCategorySplitter ); splitter2->setSizes( prefs->mCommentSplitter ); } //US ENH: I need a place to load the view dependend settings. Eg. splittersize void PwMViewStyle_1::saveSettings(PWMPrefs* prefs) { //store the size of the listviewcolumns lv->saveLayout(prefs->getConfig(), "listview"); + prefs->mCategorySplitter = splitter->sizes(); prefs->mCommentSplitter = splitter2->sizes(); } #ifndef PWM_EMBEDDED #include "pwmviewstyle_1.moc" #endif |