Changeset View
Changeset View
Standalone View
Standalone View
krusader/DiskUsage/dulines.cpp
Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Line(s) | 237 | case QEvent::ToolTip: { | |||
---|---|---|---|---|---|
240 | if (viewport()) { | 240 | if (viewport()) { | ||
241 | QPoint pos = viewport()->mapFromGlobal(he->globalPos()); | 241 | QPoint pos = viewport()->mapFromGlobal(he->globalPos()); | ||
242 | 242 | | |||
243 | QTreeWidgetItem * item = itemAt(pos); | 243 | QTreeWidgetItem * item = itemAt(pos); | ||
244 | 244 | | |||
245 | int column = columnAt(pos.x()); | 245 | int column = columnAt(pos.x()); | ||
246 | 246 | | |||
247 | if (item && column == 1) { | 247 | if (item && column == 1) { | ||
248 | File *fileItem = ((DULinesItem *)item)->getFile(); | 248 | File *fileItem = (dynamic_cast<DULinesItem *>(item))->getFile(); | ||
249 | QToolTip::showText(he->globalPos(), diskUsage->getToolTip(fileItem), this); | 249 | QToolTip::showText(he->globalPos(), diskUsage->getToolTip(fileItem), this); | ||
250 | return true; | 250 | return true; | ||
251 | } | 251 | } | ||
252 | } | 252 | } | ||
253 | } | 253 | } | ||
254 | break; | 254 | break; | ||
255 | default: | 255 | default: | ||
256 | break; | 256 | break; | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 384 | while (*it2) { | |||
396 | it2++; | 396 | it2++; | ||
397 | } | 397 | } | ||
398 | } | 398 | } | ||
399 | 399 | | |||
400 | bool DULines::doubleClicked(QTreeWidgetItem * item) | 400 | bool DULines::doubleClicked(QTreeWidgetItem * item) | ||
401 | { | 401 | { | ||
402 | if (item) { | 402 | if (item) { | ||
403 | if (item->text(0) != "..") { | 403 | if (item->text(0) != "..") { | ||
404 | File *fileItem = ((DULinesItem *)item)->getFile(); | 404 | File *fileItem = (dynamic_cast<DULinesItem *>(item))->getFile(); | ||
405 | if (fileItem->isDir()) | 405 | if (fileItem->isDir()) | ||
406 | diskUsage->changeDirectory(dynamic_cast<Directory *>(fileItem)); | 406 | diskUsage->changeDirectory(dynamic_cast<Directory *>(fileItem)); | ||
407 | return true; | 407 | return true; | ||
408 | } else { | 408 | } else { | ||
409 | auto *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); | 409 | auto *upDir = (Directory *)diskUsage->getCurrentDir()->parent(); | ||
410 | 410 | | |||
411 | if (upDir) | 411 | if (upDir) | ||
412 | diskUsage->changeDirectory(upDir); | 412 | diskUsage->changeDirectory(upDir); | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 434 | { | |||
454 | KrTreeWidget::keyPressEvent(e); | 454 | KrTreeWidget::keyPressEvent(e); | ||
455 | } | 455 | } | ||
456 | 456 | | |||
457 | void DULines::slotRightClicked(QTreeWidgetItem *item, const QPoint &pos) | 457 | void DULines::slotRightClicked(QTreeWidgetItem *item, const QPoint &pos) | ||
458 | { | 458 | { | ||
459 | File * file = nullptr; | 459 | File * file = nullptr; | ||
460 | 460 | | |||
461 | if (item && item->text(0) != "..") | 461 | if (item && item->text(0) != "..") | ||
462 | file = ((DULinesItem *)item)->getFile(); | 462 | file = (dynamic_cast<DULinesItem *>(item))->getFile(); | ||
463 | 463 | | |||
464 | QMenu linesPopup; | 464 | QMenu linesPopup; | ||
465 | QAction *act = linesPopup.addAction(i18n("Show file sizes"), this, SLOT(slotShowFileSizes())); | 465 | QAction *act = linesPopup.addAction(i18n("Show file sizes"), this, SLOT(slotShowFileSizes())); | ||
466 | act->setChecked(showFileSize); | 466 | act->setChecked(showFileSize); | ||
467 | 467 | | |||
468 | diskUsage->rightClickMenu(pos, file, &linesPopup, i18n("Lines")); | 468 | diskUsage->rightClickMenu(pos, file, &linesPopup, i18n("Lines")); | ||
469 | } | 469 | } | ||
470 | 470 | | |||
471 | void DULines::slotShowFileSizes() | 471 | void DULines::slotShowFileSizes() | ||
472 | { | 472 | { | ||
473 | showFileSize = !showFileSize; | 473 | showFileSize = !showFileSize; | ||
474 | slotDirChanged(diskUsage->getCurrentDir()); | 474 | slotDirChanged(diskUsage->getCurrentDir()); | ||
475 | } | 475 | } | ||
476 | 476 | | |||
477 | File * DULines::getCurrentFile() | 477 | File * DULines::getCurrentFile() | ||
478 | { | 478 | { | ||
479 | QTreeWidgetItem *item = currentItem(); | 479 | QTreeWidgetItem *item = currentItem(); | ||
480 | 480 | | |||
481 | if (item == nullptr || item->text(0) == "..") | 481 | if (item == nullptr || item->text(0) == "..") | ||
482 | return nullptr; | 482 | return nullptr; | ||
483 | 483 | | |||
484 | return ((DULinesItem *)item)->getFile(); | 484 | return (dynamic_cast<DULinesItem *>(item))->getFile(); | ||
485 | } | 485 | } | ||
486 | 486 | | |||
487 | void DULines::slotChanged(File * item) | 487 | void DULines::slotChanged(File * item) | ||
488 | { | 488 | { | ||
489 | QTreeWidgetItemIterator it(this); | 489 | QTreeWidgetItemIterator it(this); | ||
490 | while (*it) { | 490 | while (*it) { | ||
491 | QTreeWidgetItem *lvitem = *it; | 491 | QTreeWidgetItem *lvitem = *it; | ||
492 | it++; | 492 | it++; | ||
493 | 493 | | |||
494 | if (lvitem->text(0) != "..") { | 494 | if (lvitem->text(0) != "..") { | ||
495 | auto *duItem = (DULinesItem *)(lvitem); | 495 | auto *duItem = dynamic_cast<DULinesItem *>(lvitem); | ||
496 | if (duItem->getFile() == item) { | 496 | if (duItem->getFile() == item) { | ||
497 | setSortingEnabled(false); | 497 | setSortingEnabled(false); | ||
498 | duItem->setHidden(item->isExcluded()); | 498 | duItem->setHidden(item->isExcluded()); | ||
499 | duItem->setText(1, item->percent()); | 499 | duItem->setText(1, item->percent()); | ||
500 | if (!refreshNeeded) { | 500 | if (!refreshNeeded) { | ||
501 | refreshNeeded = true; | 501 | refreshNeeded = true; | ||
502 | QTimer::singleShot(0, this, &DULines::slotRefresh); | 502 | QTimer::singleShot(0, this, &DULines::slotRefresh); | ||
503 | } | 503 | } | ||
504 | break; | 504 | break; | ||
505 | } | 505 | } | ||
506 | } | 506 | } | ||
507 | } | 507 | } | ||
508 | } | 508 | } | ||
509 | 509 | | |||
510 | void DULines::slotDeleted(File * item) | 510 | void DULines::slotDeleted(File * item) | ||
511 | { | 511 | { | ||
512 | QTreeWidgetItemIterator it(this); | 512 | QTreeWidgetItemIterator it(this); | ||
513 | while (*it) { | 513 | while (*it) { | ||
514 | QTreeWidgetItem *lvitem = *it; | 514 | QTreeWidgetItem *lvitem = *it; | ||
515 | it++; | 515 | it++; | ||
516 | 516 | | |||
517 | if (lvitem->text(0) != "..") { | 517 | if (lvitem->text(0) != "..") { | ||
518 | auto *duItem = (DULinesItem *)(lvitem); | 518 | auto *duItem = dynamic_cast<DULinesItem *>(lvitem); | ||
519 | if (duItem->getFile() == item) { | 519 | if (duItem->getFile() == item) { | ||
520 | delete duItem; | 520 | delete duItem; | ||
521 | break; | 521 | break; | ||
522 | } | 522 | } | ||
523 | } | 523 | } | ||
524 | } | 524 | } | ||
525 | } | 525 | } | ||
526 | 526 | | |||
Show All 9 Lines |