-rw-r--r-- | pwmanager/pwmanager/pwmview.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp index e53124f..5aaf66e 100644 --- a/pwmanager/pwmanager/pwmview.cpp +++ b/pwmanager/pwmanager/pwmview.cpp | |||
@@ -192,128 +192,129 @@ void PwMView::handleToggle(QListViewItem *item) | |||
192 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); | 192 | doc->lockAt(curCat, curEntryDocIndex, !clItem->isOn()); |
193 | } | 193 | } |
194 | 194 | ||
195 | void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) | 195 | void PwMView::handleRightClick(QListViewItem *item, const QPoint &point, int) |
196 | { | 196 | { |
197 | if (!item) | 197 | if (!item) |
198 | return; | 198 | return; |
199 | ctxMenu->move(point); | 199 | ctxMenu->move(point); |
200 | /* don't use ctxMenu->exec() here, as it generates race conditions | 200 | /* don't use ctxMenu->exec() here, as it generates race conditions |
201 | * with the card interface code. Believe it or not. :) | 201 | * with the card interface code. Believe it or not. :) |
202 | */ | 202 | */ |
203 | ctxMenu->show(); | 203 | ctxMenu->show(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void PwMView::updateCategories() | 206 | void PwMView::updateCategories() |
207 | { | 207 | { |
208 | QString oldSel(getCurrentCategory()); | 208 | QString oldSel(getCurrentCategory()); |
209 | delAllCategories(); | 209 | delAllCategories(); |
210 | QStringList catList; | 210 | QStringList catList; |
211 | document()->getCategoryList(&catList); | 211 | document()->getCategoryList(&catList); |
212 | catList.sort(); | 212 | catList.sort(); |
213 | #ifndef PWM_EMBEDDED | 213 | #ifndef PWM_EMBEDDED |
214 | QStringList::iterator i = catList.begin(), | 214 | QStringList::iterator i = catList.begin(), |
215 | end = catList.end(); | 215 | end = catList.end(); |
216 | #else | 216 | #else |
217 | QStringList::Iterator i = catList.begin(), | 217 | QStringList::Iterator i = catList.begin(), |
218 | end = catList.end(); | 218 | end = catList.end(); |
219 | #endif | 219 | #endif |
220 | while (i != end) { | 220 | while (i != end) { |
221 | addCategory(*i); | 221 | addCategory(*i); |
222 | ++i; | 222 | ++i; |
223 | } | 223 | } |
224 | selectCategory(oldSel); | 224 | selectCategory(oldSel); |
225 | } | 225 | } |
226 | 226 | ||
227 | void PwMView::shiftToView() | 227 | void PwMView::shiftToView() |
228 | { | 228 | { |
229 | int cX = lv->contentsX(); | 229 | int cX = lv->contentsX(); |
230 | int cY = lv->contentsY(); | 230 | int cY = lv->contentsY(); |
231 | commentBox->clear(); | 231 | commentBox->clear(); |
232 | 232 | ||
233 | unsigned int catDocIndex; | 233 | unsigned int catDocIndex; |
234 | if (unlikely( | 234 | if (unlikely( |
235 | !(document()->findCategory(getCurrentCategory(), | 235 | !(document()->findCategory(getCurrentCategory(), |
236 | &catDocIndex)))) { | 236 | &catDocIndex)))) { |
237 | BUG(); | 237 | BUG(); |
238 | } | 238 | } |
239 | 239 | ||
240 | // ensure all listViewPos are set | 240 | // ensure all listViewPos are set |
241 | doc->ensureLvp(); | 241 | doc->ensureLvp(); |
242 | 242 | ||
243 | // clear all tmp-data vectors | 243 | // clear all tmp-data vectors |
244 | unsigned int i, entries = doc->numEntries(catDocIndex); | 244 | unsigned int i, entries = doc->numEntries(catDocIndex); |
245 | if (entries) { | 245 | if (entries) { |
246 | mainClass->setVirgin(false); | 246 | mainClass->setVirgin(false); |
247 | } | 247 | } |
248 | vector<PwMDataItem> tmpSorted; | 248 | vector<PwMDataItem> tmpSorted; |
249 | PwMDataItem currItem; | 249 | PwMDataItem currItem; |
250 | currItem.clear(); | 250 | currItem.clear(); |
251 | tmpSorted.insert(tmpSorted.begin(), entries, currItem); | 251 | tmpSorted.insert(tmpSorted.begin(), entries, currItem); |
252 | 252 | ||
253 | // Sort items and store them in tempoary tmpSorted. | 253 | // Sort items and store them in tempoary tmpSorted. |
254 | for (i = 0; i < entries; ++i) { | 254 | for (i = 0; i < entries; ++i) { |
255 | doc->getEntry(catDocIndex, i, &currItem); | 255 | doc->getEntry(catDocIndex, i, &currItem); |
256 | //qDebug("PwMView::shiftToView: %s, %i", currItem.desc.c_str(), currItem.listViewPos); | ||
256 | tmpSorted[currItem.listViewPos] = currItem; | 257 | tmpSorted[currItem.listViewPos] = currItem; |
257 | } | 258 | } |
258 | 259 | ||
259 | // shift tempoary data to ListView. | 260 | // shift tempoary data to ListView. |
260 | tmpDisableSort(); | 261 | tmpDisableSort(); |
261 | lv->clear(); | 262 | lv->clear(); |
262 | QCheckListItem *newItem; | 263 | QCheckListItem *newItem; |
263 | vector<PwMDataItem>::iterator it = tmpSorted.begin(), | 264 | vector<PwMDataItem>::iterator it = tmpSorted.begin(), |
264 | end = tmpSorted.end(); | 265 | end = tmpSorted.end(); |
265 | while (it != end) { | 266 | while (it != end) { |
266 | newItem = new ListViewItemPwM(lv); | 267 | newItem = new ListViewItemPwM(lv); |
267 | newItem->setText(COLUMN_DESC, (*it).desc.c_str()); | 268 | newItem->setText(COLUMN_DESC, (*it).desc.c_str()); |
268 | if ((*it).binary) { | 269 | if ((*it).binary) { |
269 | newItem->setText(COLUMN_NAME, ""); | 270 | newItem->setText(COLUMN_NAME, ""); |
270 | newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); | 271 | newItem->setText(COLUMN_PW, i18n("<BINARY ENTRY>")); |
271 | newItem->setText(COLUMN_URL, ""); | 272 | newItem->setText(COLUMN_URL, ""); |
272 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); | 273 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); |
273 | } else { | 274 | } else { |
274 | newItem->setText(COLUMN_NAME, (*it).name.c_str()); | 275 | newItem->setText(COLUMN_NAME, (*it).name.c_str()); |
275 | if ((*it).lockStat) { | 276 | if ((*it).lockStat) { |
276 | newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) | 277 | newItem->setText(COLUMN_PW, QString((*it).pw.c_str()) |
277 | + " " | 278 | + " " |
278 | + i18n("To unlock click the icon on the left.")); | 279 | + i18n("To unlock click the icon on the left.")); |
279 | } else { | 280 | } else { |
280 | newItem->setText(COLUMN_PW, (*it).pw.c_str()); | 281 | newItem->setText(COLUMN_PW, (*it).pw.c_str()); |
281 | } | 282 | } |
282 | newItem->setText(COLUMN_URL, (*it).url.c_str()); | 283 | newItem->setText(COLUMN_URL, (*it).url.c_str()); |
283 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); | 284 | newItem->setText(COLUMN_LAUNCHER, (*it).launcher.c_str()); |
284 | } | 285 | } |
285 | newItem->setOn(!((*it).lockStat)); | 286 | newItem->setOn(!((*it).lockStat)); |
286 | lv->insertItem(newItem); | 287 | lv->insertItem(newItem); |
287 | ++it; | 288 | ++it; |
288 | } | 289 | } |
289 | tmpReEnableSort(); | 290 | tmpReEnableSort(); |
290 | 291 | ||
291 | if (cY || cX) | 292 | if (cY || cX) |
292 | lv->setContentsPos(cX, cY); | 293 | lv->setContentsPos(cX, cY); |
293 | } | 294 | } |
294 | 295 | ||
295 | void PwMView::reorgLp() | 296 | void PwMView::reorgLp() |
296 | { | 297 | { |
297 | if (!lv->childCount()) | 298 | if (!lv->childCount()) |
298 | return; | 299 | return; |
299 | PWM_ASSERT(doc); | 300 | PWM_ASSERT(doc); |
300 | PWM_ASSERT(!doc->isDocEmpty()); | 301 | PWM_ASSERT(!doc->isDocEmpty()); |
301 | QListViewItem *currItem; | 302 | QListViewItem *currItem; |
302 | vector<unsigned int> foundPos; | 303 | vector<unsigned int> foundPos; |
303 | /* This searchIn _should_ be: | 304 | /* This searchIn _should_ be: |
304 | *const unsigned int searchIn = SEARCH_IN_DESC; | 305 | *const unsigned int searchIn = SEARCH_IN_DESC; |
305 | * But we want backward compatibility (see comment in PwMDoc::addEntry()). | 306 | * But we want backward compatibility (see comment in PwMDoc::addEntry()). |
306 | * So we need to search again, if we don't find the entry. (see below) | 307 | * So we need to search again, if we don't find the entry. (see below) |
307 | */ | 308 | */ |
308 | const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | | 309 | const unsigned int searchIn = SEARCH_IN_DESC | SEARCH_IN_NAME | |
309 | SEARCH_IN_URL | SEARCH_IN_LAUNCHER; | 310 | SEARCH_IN_URL | SEARCH_IN_LAUNCHER; |
310 | QString curCat(getCurrentCategory()); | 311 | QString curCat(getCurrentCategory()); |
311 | PwMDataItem findThis; | 312 | PwMDataItem findThis; |
312 | unsigned int i, cnt = lv->childCount(); | 313 | unsigned int i, cnt = lv->childCount(); |
313 | for (i = 0; i < cnt; ++i) { | 314 | for (i = 0; i < cnt; ++i) { |
314 | currItem = lv->itemAtIndex(i); | 315 | currItem = lv->itemAtIndex(i); |
315 | findThis.desc = currItem->text(COLUMN_DESC).latin1(); | 316 | findThis.desc = currItem->text(COLUMN_DESC).latin1(); |
316 | findThis.name = currItem->text(COLUMN_NAME).latin1(); | 317 | findThis.name = currItem->text(COLUMN_NAME).latin1(); |
317 | findThis.url = currItem->text(COLUMN_URL).latin1(); | 318 | findThis.url = currItem->text(COLUMN_URL).latin1(); |
318 | findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); | 319 | findThis.launcher = currItem->text(COLUMN_LAUNCHER).latin1(); |
319 | doc->findEntry(curCat, findThis, searchIn, | 320 | doc->findEntry(curCat, findThis, searchIn, |
@@ -431,128 +432,132 @@ void PwMView::copyUrlToClip() | |||
431 | document()->getEntry(getCurrentCategory(), curIndex, &d); | 432 | document()->getEntry(getCurrentCategory(), curIndex, &d); |
432 | PwM::copyToClipboard(d.url.c_str()); | 433 | PwM::copyToClipboard(d.url.c_str()); |
433 | } | 434 | } |
434 | 435 | ||
435 | void PwMView::copyLauncherToClip() | 436 | void PwMView::copyLauncherToClip() |
436 | { | 437 | { |
437 | if (doc->isDeepLocked()) | 438 | if (doc->isDeepLocked()) |
438 | return; | 439 | return; |
439 | unsigned int curIndex = 0; | 440 | unsigned int curIndex = 0; |
440 | if (!getCurEntryIndex(&curIndex)) | 441 | if (!getCurEntryIndex(&curIndex)) |
441 | return; | 442 | return; |
442 | PwMDataItem d; | 443 | PwMDataItem d; |
443 | document()->getEntry(getCurrentCategory(), curIndex, &d); | 444 | document()->getEntry(getCurrentCategory(), curIndex, &d); |
444 | PwM::copyToClipboard(d.launcher.c_str()); | 445 | PwM::copyToClipboard(d.launcher.c_str()); |
445 | } | 446 | } |
446 | 447 | ||
447 | void PwMView::copyCommentToClip() | 448 | void PwMView::copyCommentToClip() |
448 | { | 449 | { |
449 | if (doc->isDeepLocked()) | 450 | if (doc->isDeepLocked()) |
450 | return; | 451 | return; |
451 | unsigned int curIndex = 0; | 452 | unsigned int curIndex = 0; |
452 | if (!getCurEntryIndex(&curIndex)) | 453 | if (!getCurEntryIndex(&curIndex)) |
453 | return; | 454 | return; |
454 | PwMDataItem d; | 455 | PwMDataItem d; |
455 | document()->getEntry(getCurrentCategory(), curIndex, &d); | 456 | document()->getEntry(getCurrentCategory(), curIndex, &d); |
456 | PwM::copyToClipboard(d.comment.c_str()); | 457 | PwM::copyToClipboard(d.comment.c_str()); |
457 | } | 458 | } |
458 | 459 | ||
459 | /************************************************************************ | 460 | /************************************************************************ |
460 | * | 461 | * |
461 | * | 462 | * |
462 | * | 463 | * |
463 | ************************************************************************/ | 464 | ************************************************************************/ |
464 | 465 | ||
465 | 466 | ||
466 | PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name ) | 467 | PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name ) |
467 | : QTextBrowser( parent, name ) | 468 | : QTextBrowser( parent, name ) |
468 | 469 | ||
469 | 470 | ||
470 | { | 471 | { |
471 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 472 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
472 | setLinkUnderline( false ); | 473 | setLinkUnderline( false ); |
473 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 474 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
474 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 475 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
475 | 476 | ||
476 | //US QStyleSheet *sheet = styleSheet(); | 477 | //US QStyleSheet *sheet = styleSheet(); |
477 | //US QStyleSheetItem *link = sheet->item( "a" ); | 478 | //US QStyleSheetItem *link = sheet->item( "a" ); |
478 | //US link->setColor( KGlobalSettings::linkColor() ); | 479 | //US link->setColor( KGlobalSettings::linkColor() ); |
479 | 480 | ||
480 | } | 481 | } |
481 | 482 | ||
482 | void PwMDataItemView::setPwMDataItem( const PwMDataItem& a ) | 483 | void PwMDataItemView::setPwMDataItem( const PwMDataItem& a ) |
483 | 484 | ||
484 | { | 485 | { |
485 | mItem = a; | 486 | mItem = a; |
486 | // clear view | 487 | // clear view |
487 | setText( QString::null ); | 488 | setText( QString::null ); |
488 | 489 | ||
489 | 490 | ||
490 | QString dynamicPart; | 491 | QString dynamicPart; |
491 | QString format = "<tr><td align=\"right\"><b>%1</b></td>" | 492 | QString format = "<tr><td align=\"right\"><b>%1</b></td>" |
492 | "<td align=\"left\">%2</td></tr>"; | 493 | "<td align=\"left\">%2</td></tr>"; |
493 | 494 | ||
494 | dynamicPart += format | 495 | dynamicPart += format |
496 | .arg( i18n("LastUpdate") ) | ||
497 | .arg( mItem.meta.update.toString().latin1() ); | ||
498 | |||
499 | dynamicPart += format | ||
495 | .arg( i18n("Description") ) | 500 | .arg( i18n("Description") ) |
496 | .arg( mItem.desc.c_str() ); | 501 | .arg( mItem.desc.c_str() ); |
497 | 502 | ||
498 | dynamicPart += format | 503 | dynamicPart += format |
499 | .arg( i18n("Name") ) | 504 | .arg( i18n("Name") ) |
500 | .arg( mItem.name.c_str() ); | 505 | .arg( mItem.name.c_str() ); |
501 | 506 | ||
502 | dynamicPart += format | 507 | dynamicPart += format |
503 | .arg( i18n("Password") ) | 508 | .arg( i18n("Password") ) |
504 | .arg( mItem.pw.c_str() ); | 509 | .arg( mItem.pw.c_str() ); |
505 | 510 | ||
506 | QString comment(mItem.pw.c_str()); | 511 | QString comment(mItem.pw.c_str()); |
507 | dynamicPart += format | 512 | dynamicPart += format |
508 | .arg( i18n("Comment") ) | 513 | .arg( i18n("Comment") ) |
509 | .arg( comment.replace( QRegExp("\n"), "<br>" ) ); | 514 | .arg( comment.replace( QRegExp("\n"), "<br>" ) ); |
510 | 515 | ||
511 | dynamicPart += format | 516 | dynamicPart += format |
512 | .arg( i18n("URL") ) | 517 | .arg( i18n("URL") ) |
513 | .arg( mItem.url.c_str() ); | 518 | .arg( mItem.url.c_str() ); |
514 | 519 | ||
515 | dynamicPart += format | 520 | dynamicPart += format |
516 | .arg( i18n("Launcher") ) | 521 | .arg( i18n("Launcher") ) |
517 | .arg( mItem.launcher.c_str() ); | 522 | .arg( mItem.launcher.c_str() ); |
518 | 523 | ||
519 | QString mText = "<table><td colspan=\"2\"> </td>"; | 524 | QString mText = "<table><td colspan=\"2\"> </td>"; |
520 | 525 | ||
521 | mText += dynamicPart; | 526 | mText += dynamicPart; |
522 | mText += "</table>"; | 527 | mText += "</table>"; |
523 | 528 | ||
524 | // at last display it... | 529 | // at last display it... |
525 | setText( mText ); | 530 | setText( mText ); |
526 | 531 | ||
527 | } | 532 | } |
528 | 533 | ||
529 | PwMDataItem PwMDataItemView::pwmdataitem() const | 534 | PwMDataItem PwMDataItemView::pwmdataitem() const |
530 | { | 535 | { |
531 | return mItem; | 536 | return mItem; |
532 | } | 537 | } |
533 | 538 | ||
534 | /************************************************************************ | 539 | /************************************************************************ |
535 | * | 540 | * |
536 | * | 541 | * |
537 | * | 542 | * |
538 | ************************************************************************/ | 543 | ************************************************************************/ |
539 | 544 | ||
540 | 545 | ||
541 | PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name ) | 546 | PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name ) |
542 | : KDialogBase(parent, name, true , | 547 | : KDialogBase(parent, name, true , |
543 | i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false) | 548 | i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false) |
544 | { | 549 | { |
545 | findButton( Close )->setText( i18n("Cancel Sync")); | 550 | findButton( Close )->setText( i18n("Cancel Sync")); |
546 | findButton( Ok )->setText( i18n("Remote")); | 551 | findButton( Ok )->setText( i18n("Remote")); |
547 | findButton( User1 )->setText( i18n("Local")); | 552 | findButton( User1 )->setText( i18n("Local")); |
548 | QWidget* topframe = new QWidget( this ); | 553 | QWidget* topframe = new QWidget( this ); |
549 | setMainWidget( topframe ); | 554 | setMainWidget( topframe ); |
550 | QBoxLayout* bl; | 555 | QBoxLayout* bl; |
551 | if ( QApplication::desktop()->width() < 640 ) { | 556 | if ( QApplication::desktop()->width() < 640 ) { |
552 | bl = new QVBoxLayout( topframe ); | 557 | bl = new QVBoxLayout( topframe ); |
553 | } else { | 558 | } else { |
554 | bl = new QHBoxLayout( topframe ); | 559 | bl = new QHBoxLayout( topframe ); |
555 | } | 560 | } |
556 | QVBox* subframe = new QVBox( topframe ); | 561 | QVBox* subframe = new QVBox( topframe ); |
557 | bl->addWidget(subframe ); | 562 | bl->addWidget(subframe ); |
558 | QLabel* lab = new QLabel( i18n("Local Entry"), subframe ); | 563 | QLabel* lab = new QLabel( i18n("Local Entry"), subframe ); |