Diffstat (limited to 'pwmanager/pwmanager/pwmview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/pwmview.cpp | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp index 2533487..68500d0 100644 --- a/pwmanager/pwmanager/pwmview.cpp +++ b/pwmanager/pwmanager/pwmview.cpp | |||
@@ -32,13 +32,21 @@ | |||
32 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qpoint.h> | 36 | #include <qpoint.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <QDesktopWidget> | ||
38 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | //Added by qt3to4: | ||
41 | #include <Q3HBoxLayout> | ||
42 | #include <QKeyEvent> | ||
43 | #include <QLabel> | ||
44 | #include <QResizeEvent> | ||
45 | #include <Q3PopupMenu> | ||
46 | #include <Q3VBoxLayout> | ||
39 | 47 | ||
40 | //US ENH: wouldn't it be a good idea if we could use this consts everywhere else. | 48 | //US ENH: wouldn't it be a good idea if we could use this consts everywhere else. |
41 | //US ENH: for examle in listviewpwm.cpp | 49 | //US ENH: for examle in listviewpwm.cpp |
42 | //US ENH: Because of that I transfer them into the headerfile. | 50 | //US ENH: Because of that I transfer them into the headerfile. |
43 | /* | 51 | /* |
44 | #define COLUMN_DESC 0 | 52 | #define COLUMN_DESC 0 |
@@ -73,13 +81,13 @@ PwMView::PwMView(PwM *_mainClass, | |||
73 | PwMView::~PwMView() | 81 | PwMView::~PwMView() |
74 | { | 82 | { |
75 | } | 83 | } |
76 | 84 | ||
77 | void PwMView::initCtxMenu() | 85 | void PwMView::initCtxMenu() |
78 | { | 86 | { |
79 | ctxMenu = new QPopupMenu(this); | 87 | ctxMenu = new Q3PopupMenu(this); |
80 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); | 88 | ctxMenu->insertItem(i18n("&Add password"), mainClass, SLOT(addPwd_slot())); |
81 | ctxMenu->insertSeparator(); | 89 | ctxMenu->insertSeparator(); |
82 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); | 90 | ctxMenu->insertItem(i18n("&Edit"), mainClass, SLOT(editPwd_slot())); |
83 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); | 91 | ctxMenu->insertItem(i18n("&Delete"), mainClass, SLOT(deletePwd_slot())); |
84 | ctxMenu->insertSeparator(); | 92 | ctxMenu->insertSeparator(); |
85 | ctxMenu->insertItem(i18n("copy password to clipboard"), | 93 | ctxMenu->insertItem(i18n("copy password to clipboard"), |
@@ -103,13 +111,13 @@ void PwMView::initCtxMenu() | |||
103 | 111 | ||
104 | void PwMView::resizeEvent(QResizeEvent *) | 112 | void PwMView::resizeEvent(QResizeEvent *) |
105 | { | 113 | { |
106 | resizeView(size()); | 114 | resizeView(size()); |
107 | } | 115 | } |
108 | 116 | ||
109 | void PwMView::refreshCommentTextEdit(QListViewItem *curItem) | 117 | void PwMView::refreshCommentTextEdit(Q3ListViewItem *curItem) |
110 | { | 118 | { |
111 | PWM_ASSERT(commentBox); | 119 | PWM_ASSERT(commentBox); |
112 | if (!curItem) | 120 | if (!curItem) |
113 | return; | 121 | return; |
114 | string comment; | 122 | string comment; |
115 | PwMerror ret; | 123 | PwMerror ret; |
@@ -133,20 +141,20 @@ void PwMView::keyReleaseEvent(QKeyEvent * /*e*/) | |||
133 | { | 141 | { |
134 | refreshCommentTextEdit(lv->currentItem()); | 142 | refreshCommentTextEdit(lv->currentItem()); |
135 | } | 143 | } |
136 | 144 | ||
137 | bool PwMView::getCurEntryIndex(unsigned int *index) | 145 | bool PwMView::getCurEntryIndex(unsigned int *index) |
138 | { | 146 | { |
139 | QListViewItem *current = lv->currentItem(); | 147 | Q3ListViewItem *current = lv->currentItem(); |
140 | if (!current) | 148 | if (!current) |
141 | return false; | 149 | return false; |
142 | return getDocEntryIndex(index, current); | 150 | return getDocEntryIndex(index, current); |
143 | } | 151 | } |
144 | 152 | ||
145 | bool PwMView::getDocEntryIndex(unsigned int *index, | 153 | bool PwMView::getDocEntryIndex(unsigned int *index, |
146 | const QListViewItem *item) | 154 | const Q3ListViewItem *item) |
147 | { | 155 | { |
148 | vector<unsigned int> foundPositions; | 156 | vector<unsigned int> foundPositions; |
149 | PwMDataItem curItem; | 157 | PwMDataItem curItem; |
150 | curItem.desc = item->text(COLUMN_DESC).latin1(); | 158 | curItem.desc = item->text(COLUMN_DESC).latin1(); |
151 | curItem.name = item->text(COLUMN_NAME).latin1(); | 159 | curItem.name = item->text(COLUMN_NAME).latin1(); |
152 | document()->getCommentByLvp(getCurrentCategory(), | 160 | document()->getCommentByLvp(getCurrentCategory(), |
@@ -163,18 +171,18 @@ bool PwMView::getDocEntryIndex(unsigned int *index, | |||
163 | return true; | 171 | return true; |
164 | } | 172 | } |
165 | 173 | ||
166 | return false; | 174 | return false; |
167 | } | 175 | } |
168 | 176 | ||
169 | void PwMView::handleToggle(QListViewItem *item) | 177 | void PwMView::handleToggle(Q3ListViewItem *item) |
170 | { | 178 | { |
171 | PWM_ASSERT(doc); | 179 | PWM_ASSERT(doc); |
172 | if (!item) | 180 | if (!item) |
173 | return; | 181 | return; |
174 | QCheckListItem *clItem = (QCheckListItem *)item; | 182 | Q3CheckListItem *clItem = (Q3CheckListItem *)item; |
175 | QString curCat(getCurrentCategory()); | 183 | QString curCat(getCurrentCategory()); |
176 | 184 | ||
177 | // find document position of this entry. | 185 | // find document position of this entry. |
178 | unsigned int curEntryDocIndex; | 186 | unsigned int curEntryDocIndex; |
179 | if (!getDocEntryIndex(&curEntryDocIndex, item)) | 187 | if (!getDocEntryIndex(&curEntryDocIndex, item)) |
180 | return; | 188 | return; |
@@ -192,13 +200,13 @@ void PwMView::handleToggle(QListViewItem *item) | |||
192 | clItem->setOn(false); | 200 | clItem->setOn(false); |
193 | return; | 201 | return; |
194 | } | 202 | } |
195 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); | 203 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); |
196 | } | 204 | } |
197 | 205 | ||
198 | void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) | 206 | void PwMView::handleRightClick(Q3ListViewItem *item, const QPoint &point, int) |
199 | { | 207 | { |
200 | if (!item) | 208 | if (!item) |
201 | return; | 209 | return; |
202 | ctxMenu->move(point); | 210 | ctxMenu->move(point); |
203 | /* don't use ctxMenu->exec() here, as it generates race conditions | 211 | /* don't use ctxMenu->exec() here, as it generates race conditions |
204 | * with the card interface code. Believe it or not. :) | 212 | * with the card interface code. Believe it or not. :) |
@@ -271,13 +279,13 @@ void PwMView::shiftToView() | |||
271 | // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str()); | 279 | // qDebug("PwMView::ShiftToView CAT: %i, %s", catDocIndex, catItem->name.c_str()); |
272 | lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str()); | 280 | lv->setColumnText(COLUMN_DESC, catItem->desc_text.c_str()); |
273 | lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str()); | 281 | lv->setColumnText(COLUMN_NAME, catItem->name_text.c_str()); |
274 | lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str()); | 282 | lv->setColumnText(COLUMN_PW, catItem->pw_text.c_str()); |
275 | } | 283 | } |
276 | 284 | ||
277 | QCheckListItem *newItem; | 285 | Q3CheckListItem *newItem; |
278 | vector<PwMDataItem>::iterator it = tmpSorted.begin(), | 286 | vector<PwMDataItem>::iterator it = tmpSorted.begin(), |
279 | end = tmpSorted.end(); | 287 | end = tmpSorted.end(); |
280 | while (it != end) { | 288 | while (it != end) { |
281 | newItem = new ListViewItemPwM(lv); | 289 | newItem = new ListViewItemPwM(lv); |
282 | newItem->setText(COLUMN_DESC, (*it).desc.c_str()); | 290 | newItem->setText(COLUMN_DESC, (*it).desc.c_str()); |
283 | if ((*it).binary) { | 291 | if ((*it).binary) { |
@@ -310,13 +318,13 @@ void PwMView::shiftToView() | |||
310 | void PwMView::reorgLp() | 318 | void PwMView::reorgLp() |
311 | { | 319 | { |
312 | if (!lv->childCount()) | 320 | if (!lv->childCount()) |
313 | return; | 321 | return; |
314 | PWM_ASSERT(doc); | 322 | PWM_ASSERT(doc); |
315 | PWM_ASSERT(!doc->isDocEmpty()); | 323 | PWM_ASSERT(!doc->isDocEmpty()); |
316 | QListViewItem *currItem; | 324 | Q3ListViewItem *currItem; |
317 | vector<unsigned int> foundPos; | 325 | vector<unsigned int> foundPos; |
318 | /* This searchIn _should_ be: | 326 | /* This searchIn _should_ be: |
319 | *const unsigned int searchIn = SEARCH_IN_DESC; | 327 | *const unsigned int searchIn = SEARCH_IN_DESC; |
320 | * But we want backward compatibility (see comment in PwMDoc::addEntry()). | 328 | * But we want backward compatibility (see comment in PwMDoc::addEntry()). |
321 | * So we need to search again, if we don't find the entry. (see below) | 329 | * So we need to search again, if we don't find the entry. (see below) |
322 | */ | 330 | */ |
@@ -352,13 +360,13 @@ void PwMView::reorgLp() | |||
352 | doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); | 360 | doc->setListViewPos(curCat, foundPos[0], cnt - i - 1); |
353 | } | 361 | } |
354 | } | 362 | } |
355 | 363 | ||
356 | void PwMView::selAt(int index) | 364 | void PwMView::selAt(int index) |
357 | { | 365 | { |
358 | QListViewItem *item = lv->itemAtIndex(index); | 366 | Q3ListViewItem *item = lv->itemAtIndex(index); |
359 | if (!item) | 367 | if (!item) |
360 | return; | 368 | return; |
361 | lv->setCurrentItem(item); | 369 | lv->setCurrentItem(item); |
362 | lv->ensureItemVisible(item); | 370 | lv->ensureItemVisible(item); |
363 | } | 371 | } |
364 | 372 | ||
@@ -476,13 +484,13 @@ void PwMView::copyCommentToClip() | |||
476 | * | 484 | * |
477 | * | 485 | * |
478 | ************************************************************************/ | 486 | ************************************************************************/ |
479 | 487 | ||
480 | 488 | ||
481 | PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name ) | 489 | PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name ) |
482 | : QTextBrowser( parent, name ) | 490 | : Q3TextBrowser( parent, name ) |
483 | 491 | ||
484 | 492 | ||
485 | { | 493 | { |
486 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 494 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
487 | setLinkUnderline( false ); | 495 | setLinkUnderline( false ); |
488 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 496 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
@@ -563,30 +571,30 @@ PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool t | |||
563 | { | 571 | { |
564 | findButton( Close )->setText( i18n("Cancel Sync")); | 572 | findButton( Close )->setText( i18n("Cancel Sync")); |
565 | findButton( Ok )->setText( i18n("Remote")); | 573 | findButton( Ok )->setText( i18n("Remote")); |
566 | findButton( User1 )->setText( i18n("Local")); | 574 | findButton( User1 )->setText( i18n("Local")); |
567 | QWidget* topframe = new QWidget( this ); | 575 | QWidget* topframe = new QWidget( this ); |
568 | setMainWidget( topframe ); | 576 | setMainWidget( topframe ); |
569 | QBoxLayout* bl; | 577 | Q3BoxLayout* bl; |
570 | if ( QApplication::desktop()->width() < 640 ) { | 578 | if ( QApplication::desktop()->width() < 640 ) { |
571 | bl = new QVBoxLayout( topframe ); | 579 | bl = new Q3VBoxLayout( topframe ); |
572 | } else { | 580 | } else { |
573 | bl = new QHBoxLayout( topframe ); | 581 | bl = new Q3HBoxLayout( topframe ); |
574 | } | 582 | } |
575 | QVBox* subframe = new QVBox( topframe ); | 583 | Q3VBox* subframe = new Q3VBox( topframe ); |
576 | bl->addWidget(subframe ); | 584 | bl->addWidget(subframe ); |
577 | QLabel* lab = new QLabel( i18n("Local Entry"), subframe ); | 585 | QLabel* lab = new QLabel( i18n("Local Entry"), subframe ); |
578 | if ( takeloc ) | 586 | if ( takeloc ) |
579 | lab->setBackgroundColor(Qt::green.light() ); | 587 | lab->setBackgroundColor(QColor(Qt::green).light() ); |
580 | PwMDataItemView * av = new PwMDataItemView( subframe ); | 588 | PwMDataItemView * av = new PwMDataItemView( subframe ); |
581 | av->setPwMDataItem( loc ); | 589 | av->setPwMDataItem( loc ); |
582 | subframe = new QVBox( topframe ); | 590 | subframe = new Q3VBox( topframe ); |
583 | bl->addWidget(subframe ); | 591 | bl->addWidget(subframe ); |
584 | lab = new QLabel( i18n("Remote Entry"), subframe ); | 592 | lab = new QLabel( i18n("Remote Entry"), subframe ); |
585 | if ( !takeloc ) | 593 | if ( !takeloc ) |
586 | lab->setBackgroundColor(Qt::green.light() ); | 594 | lab->setBackgroundColor(QColor(Qt::green).light() ); |
587 | av = new PwMDataItemView( subframe ); | 595 | av = new PwMDataItemView( subframe ); |
588 | av->setPwMDataItem( rem ); | 596 | av->setPwMDataItem( rem ); |
589 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); | 597 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); |
590 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); | 598 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); |
591 | #ifndef DESKTOP_VERSION | 599 | #ifndef DESKTOP_VERSION |
592 | showMaximized(); | 600 | showMaximized(); |
@@ -615,9 +623,9 @@ void PwMDataItemChooser::slot_local() | |||
615 | mSyncResult = 1; | 623 | mSyncResult = 1; |
616 | accept(); | 624 | accept(); |
617 | } | 625 | } |
618 | 626 | ||
619 | 627 | ||
620 | 628 | ||
621 | #ifndef PWM_EMBEDDED | 629 | #ifndef PWM_EMBEDDED_ |
622 | #include "pwmview.moc" | 630 | #include "moc_pwmview.cpp" |
623 | #endif | 631 | #endif |