author | zautrix <zautrix> | 2005-03-03 13:42:15 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-03 13:42:15 (UTC) |
commit | 91feaad38e5f81063fa496a4e2988aa791267fd1 (patch) (side-by-side diff) | |
tree | fc408221a6b1a664f3574657a336526726aa9ccc | |
parent | 806a806422872b6f31183267c6b084d425458902 (diff) | |
download | kdepimpi-91feaad38e5f81063fa496a4e2988aa791267fd1.zip kdepimpi-91feaad38e5f81063fa496a4e2988aa791267fd1.tar.gz kdepimpi-91feaad38e5f81063fa496a4e2988aa791267fd1.tar.bz2 |
more pw fixes
-rw-r--r-- | pwmanager/pwmanager/commentbox.cpp | 10 | ||||
-rw-r--r-- | pwmanager/pwmanager/commentbox.h | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/listviewpwm.cpp | 8 | ||||
-rw-r--r-- | pwmanager/pwmanager/listviewpwm.h | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 58 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.h | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmview.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_0.cpp | 20 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_0.h | 4 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_1.cpp | 19 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmviewstyle_1.h | 2 |
12 files changed, 121 insertions, 11 deletions
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp index 51f88b2..5416856 100644 --- a/pwmanager/pwmanager/commentbox.cpp +++ b/pwmanager/pwmanager/commentbox.cpp @@ -216,54 +216,54 @@ QSize CommentBox::size() PWM_ASSERT(htmlDta); return htmlDta->view()->size(); break; default: break; } return QSize(); } //////////////////////////////////////////////////////////////////////// #else CommentBox::CommentBox(QWidget *_parentWidget) - : QMultiLineEdit(_parentWidget) + : QTextBrowser(_parentWidget) { - this->setReadOnly(true); + //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(); + QTextBrowser::setText( text); + if (!isVisible()) + 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; } diff --git a/pwmanager/pwmanager/commentbox.h b/pwmanager/pwmanager/commentbox.h index 352867c..3103353 100644 --- a/pwmanager/pwmanager/commentbox.h +++ b/pwmanager/pwmanager/commentbox.h @@ -78,38 +78,38 @@ protected: void clearText(); /** clear all HTML data */ void clearHtml(); protected: /** parent widget for this comment box */ QWidget *parentWidget; /** current comment box usage type */ commentBoxMode mode; /** 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 -#include <qmultilineedit.h> +#include <qtextbrowser.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 +class CommentBox : public QTextBrowser { 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 diff --git a/pwmanager/pwmanager/listviewpwm.cpp b/pwmanager/pwmanager/listviewpwm.cpp index 85e788c..8d46fff 100644 --- a/pwmanager/pwmanager/listviewpwm.cpp +++ b/pwmanager/pwmanager/listviewpwm.cpp @@ -28,32 +28,40 @@ #ifdef PWM_EMBEDDED #include <kglobal.h> #endif ListViewPwM::ListViewPwM(QWidget *parent, const char *name) : KListView(parent, name) { // setResizeMode(QListView::AllColumns); setAllColumnsShowFocus (true ); } bool ListViewPwM::event(QEvent *e) { if (e->type() == QEvent::LayoutHint) emit layoutChanged(); + if (e->type() == QEvent::KeyPress) { + QKeyEvent* ke = (QKeyEvent*) e; + if ( ke->key() == Qt::Key_Space) { + emit toggleOverview(); + return true; + } + + } return KListView::event(e); } QPixmap * ListViewItemPwM::onPix = 0; QPixmap * ListViewItemPwM::offPix = 0; ListViewItemPwM::ListViewItemPwM(QListView *parent) : QCheckListItem(parent, "", QCheckListItem::CheckBox) { if (!onPix) { PWM_ASSERT(!offPix); KIconLoader* picons; #ifndef PWM_EMBEDDED KIconLoader il; picons = &il; diff --git a/pwmanager/pwmanager/listviewpwm.h b/pwmanager/pwmanager/listviewpwm.h index e6471c6..840ee73 100644 --- a/pwmanager/pwmanager/listviewpwm.h +++ b/pwmanager/pwmanager/listviewpwm.h @@ -20,32 +20,33 @@ #ifndef __LISTVIEW_H #define __LISTVIEW_H #include <klistview.h> /** PwManager implementation of the list view. * Derived from KListView. */ class ListViewPwM : public KListView { Q_OBJECT public: ListViewPwM(QWidget *parent = 0, const char *name = 0); signals: void layoutChanged(); + void toggleOverview(); protected: virtual bool event(QEvent *e); }; class ListViewItemPwM : public QCheckListItem { public: ListViewItemPwM(QListView *parent); protected: void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align); protected: /** pixmap to display for an item with state "on" */ diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index aed8ec0..9187380 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp @@ -714,50 +714,50 @@ void PwM::editPwd_slot3(const QString *category, const int *index, if (_doc) { 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))) { + qDebug("couldn't get index. Maybe we have a binary entry here. "); 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(); diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 1f15ffd..6fbe110 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp @@ -1228,55 +1228,111 @@ bool PwMDoc::getEntry(unsigned int category, unsigned int index, * chipcard or entering the mpw */ if (unlockIfLocked) { if (!lockAt(category, index, false)) { return false; } locked = false; } } *d = dti.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 (dti.dta[cat].d[i].listViewPos == listViewPos) { *foundComment = dti.dta[cat].d[i].comment; if (dti.dta[cat].d[i].binary) return e_binEntry; return e_normalEntry; } } BUG(); return e_generic; } +PwMerror PwMDoc::getCommentByLvp_long(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 (dti.dta[cat].d[i].listViewPos == listViewPos) { + if (dti.dta[cat].d[i].binary) + return e_binEntry; + PwMCategoryItem* catItem = getCategoryEntry(cat); + QString retval; + QString tempval = QString (dti.dta[cat].d[i].desc.c_str()); + if ( !tempval.isEmpty() ) { + retval += "<b>" +QString ( catItem->desc_text.c_str() )+ ":</b> "+ tempval+"<br>" ; + } + tempval = QString (dti.dta[cat].d[i].name.c_str()); + if ( !tempval.isEmpty() ) { + retval += "<b>" +QString ( catItem->name_text.c_str() ) + ":</b> "+ tempval+"<br>" ; + } + tempval = QString (dti.dta[cat].d[i].pw.c_str()); + if ( !tempval.isEmpty() ) { + if ( dti.dta[cat].d[i].lockStat ) + retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + i18n("<LOCKED>") +"<br>" ; + else + retval += "<b>" +QString ( catItem->pw_text.c_str() )+ ":</b> " + tempval+"<br>" ; + } + tempval = QString (dti.dta[cat].d[i].url.c_str()); + if ( !tempval.isEmpty() ) { + retval += "<b>" +i18n("URL:")+ "</b> " + tempval+"<br>" ; + } + tempval = QString (dti.dta[cat].d[i].launcher.c_str()); + if ( !tempval.isEmpty() ) { + retval += "<b>" +i18n("Launcher:")+ "</b> " + tempval+"<br>" ; + } + tempval = QString (dti.dta[cat].d[i].comment.c_str()); + if ( !tempval.isEmpty() ) { + tempval.replace(QRegExp ( "\n" ), "<br>" ); + retval += "<b>" +i18n("Comment:")+ "</b><br>" + tempval+"<br>" ; + } + + string ret ( retval.latin1() ); + + + // *foundComment = dti.dta[cat].d[i].comment; + *foundComment = ret; + 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); } #ifndef PWM_EMBEDDED case PWM_COMPRESS_BZIP2: { CompressBzip2 comp; return comp.compress(d); } #endif case PWM_COMPRESS_NONE: { return true; diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h index 9fcdda7..45dd729 100644 --- a/pwmanager/pwmanager/pwmdoc.h +++ b/pwmanager/pwmanager/pwmdoc.h @@ -521,32 +521,34 @@ public: { return (&(dti.dta[index].name)); } /** returns the data of item at "index". * It unlocks the entry if it's locked and unlockIfLocked is true. * If the entry is locked, but unlockIfLocked is false, it'll not return * the pw. */ bool getEntry(const QString &category, unsigned int index, PwMDataItem *d, bool unlockIfLocked = false); bool getEntry(unsigned int category, unsigned int index, PwMDataItem *d, bool unlockIfLocked = false); /** returns the comment-string by looking at the category * and the listViewPos */ PwMerror getCommentByLvp(const QString &category, int listViewPos, string *foundComment); + PwMerror getCommentByLvp_long(const QString &category, int listViewPos, + string *foundComment); /** checks if a password is already available. (currentPw) */ bool isPwAvailable() { return (currentPw != ""); } /** un/lock entry at "index". If needed, ask for password. */ bool lockAt(const QString &category, unsigned int index, bool lock = true); bool lockAt(unsigned int category, unsigned int index, bool lock = true); /** returns the lock-status at "index" */ bool isLocked(const QString &category, unsigned int index); bool isLocked(unsigned int category, unsigned int index) { return dti.dta[category].d[index].lockStat; } /** returns the deeplock status */ bool isDeepLocked() { return getDocStatFlag(DOC_STAT_DEEPLOCKED); } /** (un)lock all entries */ diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp index 7f7dd6f..0092692 100644 --- a/pwmanager/pwmanager/pwmview.cpp +++ b/pwmanager/pwmanager/pwmview.cpp @@ -98,33 +98,33 @@ void PwMView::initCtxMenu() 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(), + ret = document()->getCommentByLvp_long(getCurrentCategory(), lv->childCount() - lv->itemIndex(curItem) - 1, &comment); if (ret == e_binEntry) { commentBox->setContent(i18n("This is a binary entry.\n" "It is not a normal password-entry, as it contains " "binary data, which PwManager can't display here.")); } else if (ret == e_normalEntry) { commentBox->setContent(comment.c_str()); } else { BUG(); return; } lv->ensureItemVisible(curItem); } void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) diff --git a/pwmanager/pwmanager/pwmviewstyle_0.cpp b/pwmanager/pwmanager/pwmviewstyle_0.cpp index 1fc8a34..d82eb15 100644 --- a/pwmanager/pwmanager/pwmviewstyle_0.cpp +++ b/pwmanager/pwmanager/pwmviewstyle_0.cpp @@ -45,38 +45,58 @@ PwMViewStyle_0::PwMViewStyle_0(PwMView *view) splitter1->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); //US topLayout->addWidget(mMiniSplitter ); #endif lv = new ListViewPwM(splitter1); commentBox = new CommentBox(splitter1); // set sizes and styles commentBox->resize(commentBox->size().width(), 60); categoriesTitle->setAlignment(Qt::AlignVCenter | Qt::AlignRight); // connections connect(categoriesCombo, SIGNAL(activated(int)), view, SLOT(shiftToView())); connect(renCatButton, SIGNAL(clicked()), view, SLOT(renCatButton_slot())); connect(delCatButton, SIGNAL(clicked()), view, SLOT(delCatButton_slot())); + connect(lv, SIGNAL(toggleOverview()), + this, SLOT(toggleSplitter())); } PwMViewStyle_0::~PwMViewStyle_0() { delete vbox1; } +void PwMViewStyle_0::toggleSplitter() +{ + + QValueList<int> si = splitter1->sizes(); + splitter1->toggle(); + QValueList<int> si2 = splitter1->sizes(); + //qDebug("PwMViewStyle_0::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] ); + if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) { + int diff = si[0]/2; + if ( diff > 200 ) + diff = 200; + si[0] -= diff; + si[1] += diff; + splitter1->toggle(); + splitter1->setSizes( si ); + } + +} void PwMViewStyle_0::delCategory(const QString &cat) { PWM_ASSERT(categoriesCombo); int i, count = categoriesCombo->count(); for (i = 0; i < count; ++i) { if (categoriesCombo->text(i) == cat) { categoriesCombo->removeItem(i); return; } } BUG(); } void PwMViewStyle_0::selectCategory(const QString &cat) { diff --git a/pwmanager/pwmanager/pwmviewstyle_0.h b/pwmanager/pwmanager/pwmviewstyle_0.h index bd93c06..6d3c1d1 100644 --- a/pwmanager/pwmanager/pwmviewstyle_0.h +++ b/pwmanager/pwmanager/pwmviewstyle_0.h @@ -27,32 +27,33 @@ #include <qtextedit.h> #include <qsplitter.h> #else #include <qmultilineedit.h> #include <KDGanttMinimizeSplitter.h> #endif #include <qlabel.h> #include <qcombobox.h> class PwMView; class ListViewPwM; class CommentBox; class PWMPrefs; class PwMViewStyle_0 : public QObject { + Q_OBJECT public: PwMViewStyle_0(PwMView *view); ~PwMViewStyle_0(); ListViewPwM * getLv() { return lv; } CommentBox * getCommentBox() { return commentBox; } /** returns the currently selected category */ QString getCurrentCategory() { return categoriesCombo->currentText(); } /** add Category to the view */ void addCategory(const QString &cat) { categoriesCombo->insertItem(cat); } /** delete Category from view */ @@ -63,33 +64,34 @@ public: /** 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() { return categoriesCombo->count(); } /** resize the view */ void resize(const QSize &size) { vbox1->resize(size); } //US ENH: I need a place to load the view dependend settings. Eg. splittersize void restoreSettings(PWMPrefs* prefs); void saveSettings(PWMPrefs* prefs); - +public slots: + void toggleSplitter(); protected: /** main list view */ ListViewPwM *lv; /** categories combo-box */ QComboBox *categoriesCombo; /** title string for the categories combo or list box */ QLabel *categoriesTitle; /** hbox1 for widget style */ QHBox *hbox1; /** vbox1 for widget style */ QVBox *vbox1; /** splitter for commentTextEdit */ #ifndef PWM_EMBEDDED QSplitter *splitter1; #else KDGanttMinimizeSplitter * splitter1; diff --git a/pwmanager/pwmanager/pwmviewstyle_1.cpp b/pwmanager/pwmanager/pwmviewstyle_1.cpp index 4a7ffd7..7294f34 100644 --- a/pwmanager/pwmanager/pwmviewstyle_1.cpp +++ b/pwmanager/pwmanager/pwmviewstyle_1.cpp @@ -90,39 +90,58 @@ PwMViewStyle_1::PwMViewStyle_1(PwMView *view) catCtxMenu->insertItem(i18n("&Rename"), view, SLOT(renCatButton_slot())); catCtxMenu->insertItem(i18n("&Delete"), view, SLOT(delCatButton_slot())); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( categoriesList->viewport(), QPEApplication::RightOnHold ); #endif // connections connect(categoriesList, SIGNAL(highlighted(int)), view, SLOT(shiftToView())); connect(categoriesList, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), this, SLOT(catRightClick(QListBoxItem *, const QPoint &))); + + connect(lv, SIGNAL(toggleOverview()), + this, SLOT(toggleSplitter())); } PwMViewStyle_1::~PwMViewStyle_1() { delete catCtxMenu; delete splitter; } +void PwMViewStyle_1::toggleSplitter() +{ + QValueList<int> si = splitter2->sizes(); + splitter2->toggle(); + QValueList<int> si2 = splitter2->sizes(); + //qDebug("PwMViewStyle_1::toggleSplitter() %d %d %d %d", si[0],si[1],si2[0],si2[1] ); + if ( si[0] == si2[0] && si[1] == si2[1] && si2[1] == 1 ) { + int diff = si[0]/2; + if ( diff > 200 ) + diff = 200; + si[0] -= diff; + si[1] += diff; + splitter2->toggle(); + splitter2->setSizes( si ); + } +} 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); diff --git a/pwmanager/pwmanager/pwmviewstyle_1.h b/pwmanager/pwmanager/pwmviewstyle_1.h index a7f100c..4f7a256 100644 --- a/pwmanager/pwmanager/pwmviewstyle_1.h +++ b/pwmanager/pwmanager/pwmviewstyle_1.h @@ -65,32 +65,34 @@ public: /** 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() { return categoriesList->count(); } /** resize the view */ void resize(const QSize &size) { splitter->resize(size); } //US ENH: I need a place to load the view dependend settings. Eg. splittersize void restoreSettings(PWMPrefs* prefs); void saveSettings(PWMPrefs* prefs); +public slots: + void toggleSplitter(); protected slots: /** user clicked right button in category list */ void catRightClick(QListBoxItem *item, const QPoint &point); protected: /** main list view */ ListViewPwM *lv; #ifndef PWM_EMBEDDED /** main splitter widget */ QSplitter *splitter; /** commentTextEdit splitter */ QSplitter *splitter2; #else /** main splitter widget */ KDGanttMinimizeSplitter *splitter; /** commentTextEdit splitter */ |