author | zautrix <zautrix> | 2005-03-01 14:36:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-01 14:36:05 (UTC) |
commit | 611f97f6d17f6c4e1944ffe39cd74d2a4cd1f2ae (patch) (side-by-side diff) | |
tree | beeb9aebeec2d6829f0c7342ed290e16d56c19b3 | |
parent | 81e2fbd0c031a3db209de68c190ddf4c0350d14a (diff) | |
download | kdepimpi-611f97f6d17f6c4e1944ffe39cd74d2a4cd1f2ae.zip kdepimpi-611f97f6d17f6c4e1944ffe39cd74d2a4cd1f2ae.tar.gz kdepimpi-611f97f6d17f6c4e1944ffe39cd74d2a4cd1f2ae.tar.bz2 |
tab fixes
-rw-r--r-- | pwmanager/pwmanager/addentrywnd_emb.cpp | 7 | ||||
-rw-r--r-- | pwmanager/pwmanager/commentbox.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmview.cpp | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle.cpp | 11 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle.h | 11 |
6 files changed, 30 insertions, 3 deletions
diff --git a/pwmanager/pwmanager/addentrywnd_emb.cpp b/pwmanager/pwmanager/addentrywnd_emb.cpp index f065058..c2590f0 100644 --- a/pwmanager/pwmanager/addentrywnd_emb.cpp +++ b/pwmanager/pwmanager/addentrywnd_emb.cpp @@ -124,96 +124,103 @@ addEntryWnd::addEntryWnd( PwMDoc* d, QWidget* parent, const char* name) 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() ) ); + +#if 0 + if ( QApplication::desktop()->width() <= 640 && QApplication::desktop()->width() >= 480 ) { + resize ( 440, 400 ); + } +#endif + } /* * 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" ); } void addEntryWnd::categorySelected ( const QString & string ) { unsigned int idx; bool found = doc->findCategory(string, &idx); if (found == true) { qDebug("addEntryWnd::categorySelected found"); PwMCategoryItem* catitem = doc->getCategoryEntry(idx); descLineLabel->setText(catitem->desc_text.c_str()); usernameLineLabel->setText(catitem->name_text.c_str()); pwLineLabel->setText(catitem->pw_text.c_str()); return; } else { qDebug("addEntryWnd::categorySelected NOT found"); diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp index e2d2d2b..0f32561 100644 --- a/pwmanager/pwmanager/commentbox.cpp +++ b/pwmanager/pwmanager/commentbox.cpp @@ -187,95 +187,96 @@ void CommentBox::hide() } } void CommentBox::resize(const QSize &size) { switch (mode) { case mode_text: PWM_ASSERT(textDta); textDta->resize(size); break; case mode_html: PWM_ASSERT(htmlDta); htmlDta->view()->resize(size); break; default: break; } } QSize CommentBox::size() { switch (mode) { case mode_text: PWM_ASSERT(textDta); return textDta->size(); break; case mode_html: PWM_ASSERT(htmlDta); return htmlDta->view()->size(); break; default: break; } return QSize(); } //////////////////////////////////////////////////////////////////////// #else CommentBox::CommentBox(QWidget *_parentWidget) : QMultiLineEdit(_parentWidget) { this->setReadOnly(true); + setFocusPolicy( QWidget::ClickFocus ); } CommentBox::~CommentBox() { } void CommentBox::clear() { this->hide(); } void CommentBox::setText(const QString &text) { QMultiLineEdit::setText( 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/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index fc6837f..aed8ec0 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp @@ -614,96 +614,97 @@ bool PwM::save() void PwM::saveAs_slot() { saveAs(); } bool PwM::saveAs() { if (!curDoc()->saveAsDocUi(curDoc())) return false; showStatMsg(i18n("Successfully saved data.")); updateCaption(); return true; } //US ENH : changed code to run with older MOC void PwM::addPwd_slot() { addPwd_slot1(0, 0); } void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) { PwMDoc *doc; if (_doc) { doc = _doc; } else { doc = curDoc(); } PWM_ASSERT(doc); doc->timer()->getLock(DocTimer::id_autoLockTimer); #ifndef PWM_EMBEDDED AddEntryWndImpl w; #else AddEntryWndImpl w(doc, this, "addentrywndimpl"); #endif w.setCaption( i18n ("Add new password") ); vector<string> catList; doc->getCategoryList(&catList); unsigned i, size = catList.size(); for (i = 0; i < size; ++i) { w.addCategory(catList[i].c_str()); } w.setCurrCategory(view->getCurrentCategory()); if (pw) w.pwLineEdit->setText(*pw); tryAgain: + w.descLineEdit->setFocus(); if (w.exec() == 1) { PwMDataItem d; //US BUG: to initialize all values of curEntr with meaningfulldata, // we call clear on it. Reason: Metadata will be uninitialized otherwise. // another option would be to create a constructor for PwMDataItem d.clear(true); d.desc = w.getDescription().latin1(); d.name = w.getUsername().latin1(); d.pw = w.getPassword().latin1(); d.comment = w.getComment().latin1(); d.url = w.getUrl().latin1(); d.launcher = w.getLauncher().latin1(); PwMerror ret = doc->addEntry(w.getCategory(), &d); if (ret == e_entryExists) { KMessageBox::error(this, i18n ("An entry with this \"Description\",\n" "does already exist.\n" "Please select another description."), i18n("entry already exists.")); goto tryAgain; } else if (ret == e_maxAllowedEntr) { KMessageBox::error(this, i18n("The maximum possible number of\nentries" "has been reached.\nYou can't add more entries."), i18n("maximum number of entries")); doc->timer()->putLock(DocTimer::id_autoLockTimer); return; } } setVirgin(false); doc->timer()->putLock(DocTimer::id_autoLockTimer); } //US ENH : changed code to run with older MOC void PwM::editPwd_slot() { editPwd_slot3(0,0,0); } void PwM::editPwd_slot1(const QString *category) { editPwd_slot3(category, 0, 0); } void PwM::editPwd_slot3(const QString *category, const int *index, @@ -714,96 +715,97 @@ void PwM::editPwd_slot3(const QString *category, const int *index, doc = _doc; } else { doc = curDoc(); } PWM_ASSERT(doc); if (doc->isDocEmpty()) return; if (doc->isDeepLocked()) return; doc->timer()->getLock(DocTimer::id_autoLockTimer); unsigned int curEntryIndex; if (index) { curEntryIndex = *index; } else { if (!(view->getCurEntryIndex(&curEntryIndex))) { printDebug("couldn't get index. Maybe we have a binary entry here."); doc->timer()->putLock(DocTimer::id_autoLockTimer); return; } } QString curCategory; if (category) { curCategory = *category; } else { curCategory = view->getCurrentCategory(); } PwMDataItem currItem; if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { doc->timer()->putLock(DocTimer::id_autoLockTimer); return; } BUG_ON(currItem.binary); AddEntryWndImpl w(doc); w.setCaption( i18n ("Edit password") ); vector<string> catList; doc->getCategoryList(&catList); unsigned i, size = catList.size(); for (i = 0; i < size; ++i) { w.addCategory(catList[i].c_str()); } w.setCurrCategory(curCategory); w.setDescription(currItem.desc.c_str()); w.setUsername(currItem.name.c_str()); w.setPassword(currItem.pw.c_str()); w.setUrl(currItem.url.c_str()); w.setLauncher(currItem.launcher.c_str()); w.setComment(currItem.comment.c_str()); + w.descLineEdit->setFocus(); if (w.exec() == 1) { currItem.desc = w.getDescription().latin1(); currItem.name = w.getUsername().latin1(); currItem.pw = w.getPassword().latin1(); currItem.comment = w.getComment().latin1(); currItem.url = w.getUrl().latin1(); currItem.launcher = w.getLauncher().latin1(); if (!doc->editEntry(curCategory, w.getCategory(), curEntryIndex, &currItem)) { KMessageBox::error(this, i18n("Couldn't edit the entry.\n" "Maybe you changed the category and\n" "this entry is already present\nin the new " "category?"), i18n("couldn't edit entry.")); doc->timer()->putLock(DocTimer::id_autoLockTimer); return; } } doc->timer()->putLock(DocTimer::id_autoLockTimer); } void PwM::deletePwd_slot() { PWM_ASSERT(curDoc()); if (curDoc()->isDocEmpty()) return; if (curDoc()->isDeepLocked()) return; curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); unsigned int curEntryIndex = 0; if (!(view->getCurEntryIndex(&curEntryIndex))) { printDebug("couldn't get index"); curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); return; } PwMDataItem currItem; QString curCategory = view->getCurrentCategory(); if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { printDebug("couldn't get entry"); curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); return; } if (KMessageBox:: questionYesNo(this, i18n ("Do you really want to delete\nthe selected entry") + diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp index 8c4d9cc..7f7dd6f 100644 --- a/pwmanager/pwmanager/pwmview.cpp +++ b/pwmanager/pwmanager/pwmview.cpp @@ -20,96 +20,97 @@ #include "pwmview.h" #include "pwmexception.h" #include "globalstuff.h" #include "pwm.h" #include "rencatwnd.h" #ifndef PWM_EMBEDDED #include "configuration.h" #else #include "pwmprefs.h" #endif #include "commentbox.h" #include <kmessagebox.h> #include <klocale.h> #include <qlineedit.h> #include <qpoint.h> #include <qapplication.h> #include <qlayout.h> //US ENH: wouldn't it be a good idea if we could use this consts everywhere else. //US ENH: for examle in listviewpwm.cpp //US ENH: Because of that I transfer them into the headerfile. /* #define COLUMN_DESC 0 #define COLUMN_NAME 1 #define COLUMN_PW 2 #define COLUMN_URL 3 #define COLUMN_LAUNCHER 4 */ PwMView::PwMView(PwM *_mainClass, QWidget *parent, PwMDoc *_doc, const char *name) : PwMViewStyle(parent, name) { PWM_ASSERT(_mainClass); PWM_ASSERT(parent); PWM_ASSERT(_doc); setView(this); doc = _doc; doc->setListViewPointer(this); mainClass = _mainClass; resize(_mainClass->size()); initStyle(conf()->confWndMainViewStyle()); initCtxMenu(); doc->setCurrentView(this); connect(doc, SIGNAL(dataChanged(PwMDoc *)), this, SLOT(updateView())); + connect(this, SIGNAL(editPW()), mainClass, SLOT(editPwd_slot())); } PwMView::~PwMView() { } void PwMView::initCtxMenu() { ctxMenu = new QPopupMenu(this); ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); ctxMenu->insertSeparator(); ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); ctxMenu->insertSeparator(); ctxMenu->insertItem(i18n("copy password to clipboard"), this, SLOT(copyPwToClip())); ctxMenu->insertItem(i18n("copy username to clipboard"), this, SLOT(copyNameToClip())); ctxMenu->insertItem(i18n("copy description to clipboard"), this, SLOT(copyDescToClip())); ctxMenu->insertItem(i18n("copy url to clipboard"), this, SLOT(copyUrlToClip())); ctxMenu->insertItem(i18n("copy launcher to clipboard"), this, SLOT(copyLauncherToClip())); ctxMenu->insertItem(i18n("copy comment to clipboard"), this, SLOT(copyCommentToClip())); ctxMenu->insertSeparator(); ctxMenu->insertItem(i18n("Execute \"Launcher\""), mainClass, SLOT(execLauncher_slot())); ctxMenu->insertItem(i18n("Go to \"URL\""), mainClass, SLOT(goToURL_slot())); } void PwMView::resizeEvent(QResizeEvent *) { resizeView(size()); } void PwMView::refreshCommentTextEdit(QListViewItem *curItem) { PWM_ASSERT(commentBox); if (!curItem) return; string comment; PwMerror ret; ret = document()->getCommentByLvp(getCurrentCategory(), lv->childCount() - lv->itemIndex(curItem) - 1, &comment); diff --git a/pwmanager/pwmanager/pwmviewstyle.cpp b/pwmanager/pwmanager/pwmviewstyle.cpp index 0af1473..5f25880 100644 --- a/pwmanager/pwmanager/pwmviewstyle.cpp +++ b/pwmanager/pwmanager/pwmviewstyle.cpp @@ -16,128 +16,139 @@ * 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()->writeConfig(); delete_ifnot_null(s0); delete_ifnot_null(s1); } +void PwMViewStyle::editPassWord( QListViewItem * i ) +{ + if ( !i ) + return; + emit editPW(); +} 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 *))); + connect(lv, SIGNAL(returnPressed(QListViewItem *)), + this, SLOT(editPassWord(QListViewItem *))); + connect(lv, SIGNAL(doubleClicked(QListViewItem *)), + this, SLOT(editPassWord(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 (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() diff --git a/pwmanager/pwmanager/pwmviewstyle.h b/pwmanager/pwmanager/pwmviewstyle.h index bf5ce91..5656cbc 100644 --- a/pwmanager/pwmanager/pwmviewstyle.h +++ b/pwmanager/pwmanager/pwmviewstyle.h @@ -1,108 +1,113 @@ /*************************************************************************** * * * 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 PWMVIEWSTYLE_H #define PWMVIEWSTYLE_H #include <qwidget.h> #include <qsplitter.h> #include <qhbox.h> #include <qvbox.h> #include <qpushbutton.h> #include <qpopupmenu.h> #ifndef PWM_EMBEDDED #include <qtextedit.h> #else #include <qmultilineedit.h> #endif #include <qlabel.h> #include <qlistbox.h> #include <qcombobox.h> #include <qsize.h> class ListViewPwM; class PwMViewStyle_0; class PwMViewStyle_1; class PwMView; +class QListViewItem; class CommentBox; class PwMViewStyle : public QWidget { Q_OBJECT public: enum style_t { style_notset = -1, style_0 = 0, style_1 = 1 }; public: PwMViewStyle(QWidget *parent = 0, const char *name = 0); ~PwMViewStyle(); /** initialize a new style */ void initStyle(style_t style); void initStyle(int style) { initStyle(static_cast<style_t>(style)); } /** returns the currently used style */ style_t getCurStyle() { return curStyle; } void setView(PwMView *view) { v = view; } /** returns the currently selected category */ QString getCurrentCategory(); protected: /** add Category to the view */ void addCategory(const QString &cat); /** delete Category from view */ void delCategory(const QString &cat); /** delete all categories from view */ void delAllCategories(); /** select the specified category */ void selectCategory(const QString &cat); /** returns the number of categories in this view. * This value dosn't say anything about the number of * categories in the document. */ int numCategories(); /** resize the view */ void resizeView(const QSize &size); + ListViewPwM *lv; + CommentBox *commentBox; + +protected slots: + void editPassWord( QListViewItem * ); private: /** which style has the view? * KListBox on the left, * or QComboBox on the top? */ style_t curStyle; PwMViewStyle_0 *s0; PwMViewStyle_1 *s1; PwMView *v; + signals: + void editPW(); -protected: - ListViewPwM *lv; - CommentBox *commentBox; }; #endif |