Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kdiroperator.cpp
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 84 | public: | |||
---|---|---|---|---|---|
142 | void _k_assureVisibleSelection(); | 142 | void _k_assureVisibleSelection(); | ||
143 | void _k_synchronizeSortingState(int, Qt::SortOrder); | 143 | void _k_synchronizeSortingState(int, Qt::SortOrder); | ||
144 | void _k_slotChangeDecorationPosition(); | 144 | void _k_slotChangeDecorationPosition(); | ||
145 | void _k_slotExpandToUrl(const QModelIndex &); | 145 | void _k_slotExpandToUrl(const QModelIndex &); | ||
146 | void _k_slotItemsChanged(); | 146 | void _k_slotItemsChanged(); | ||
147 | void _k_slotDirectoryCreated(const QUrl &); | 147 | void _k_slotDirectoryCreated(const QUrl &); | ||
148 | 148 | | |||
149 | int iconSizeForViewType(QAbstractItemView *itemView) const; | 149 | int iconSizeForViewType(QAbstractItemView *itemView) const; | ||
150 | void writeIconZoomSettings(KConfigGroup &configGroup); | ||||
150 | 151 | | |||
151 | // private members | 152 | // private members | ||
152 | KDirOperator * const parent; | 153 | KDirOperator * const parent; | ||
153 | QStack<QUrl *> backStack; ///< Contains all URLs you can reach with the back button. | 154 | QStack<QUrl *> backStack; ///< Contains all URLs you can reach with the back button. | ||
154 | QStack<QUrl *> forwardStack; ///< Contains all URLs you can reach with the forward button. | 155 | QStack<QUrl *> forwardStack; ///< Contains all URLs you can reach with the forward button. | ||
155 | 156 | | |||
156 | QModelIndex lastHoveredIndex; | 157 | QModelIndex lastHoveredIndex; | ||
157 | 158 | | |||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Line(s) | |||||
505 | 506 | | |||
506 | KFile::FileView KDirOperator::Private::allViews() | 507 | KFile::FileView KDirOperator::Private::allViews() | ||
507 | { | 508 | { | ||
508 | return static_cast<KFile::FileView>(KFile::Simple | KFile::Detail | KFile::Tree | KFile::DetailTree); | 509 | return static_cast<KFile::FileView>(KFile::Simple | KFile::Detail | KFile::Tree | KFile::DetailTree); | ||
509 | } | 510 | } | ||
510 | 511 | | |||
511 | void KDirOperator::Private::_k_slotDetailedView() | 512 | void KDirOperator::Private::_k_slotDetailedView() | ||
512 | { | 513 | { | ||
514 | if (configGroup && itemView) { | ||||
515 | // save old zoom settings | ||||
516 | writeIconZoomSettings(*configGroup); | ||||
517 | } | ||||
518 | | ||||
513 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | 519 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | ||
514 | parent->setView(view); | 520 | parent->setView(view); | ||
515 | } | 521 | } | ||
516 | 522 | | |||
517 | void KDirOperator::Private::_k_slotSimpleView() | 523 | void KDirOperator::Private::_k_slotSimpleView() | ||
518 | { | 524 | { | ||
525 | if (configGroup && itemView) { | ||||
526 | // save old zoom settings | ||||
527 | writeIconZoomSettings(*configGroup); | ||||
528 | } | ||||
529 | | ||||
519 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 530 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
520 | parent->setView(view); | 531 | parent->setView(view); | ||
521 | } | 532 | } | ||
522 | 533 | | |||
523 | void KDirOperator::Private::_k_slotTreeView() | 534 | void KDirOperator::Private::_k_slotTreeView() | ||
524 | { | 535 | { | ||
536 | if (configGroup && itemView) { | ||||
537 | // save old zoom settings | ||||
538 | writeIconZoomSettings(*configGroup); | ||||
539 | } | ||||
540 | | ||||
525 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Tree); | 541 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Tree); | ||
526 | parent->setView(view); | 542 | parent->setView(view); | ||
527 | } | 543 | } | ||
528 | 544 | | |||
529 | void KDirOperator::Private::_k_slotDetailedTreeView() | 545 | void KDirOperator::Private::_k_slotDetailedTreeView() | ||
530 | { | 546 | { | ||
547 | if (configGroup && itemView) { | ||||
548 | // save old zoom settings | ||||
549 | writeIconZoomSettings(*configGroup); | ||||
550 | } | ||||
551 | | ||||
531 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | 552 | KFile::FileView view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | ||
532 | parent->setView(view); | 553 | parent->setView(view); | ||
533 | } | 554 | } | ||
534 | 555 | | |||
535 | void KDirOperator::Private::_k_slotToggleAllowExpansion(bool allow) { | 556 | void KDirOperator::Private::_k_slotToggleAllowExpansion(bool allow) { | ||
536 | KFile::FileView view = KFile::Detail; | 557 | KFile::FileView view = KFile::Detail; | ||
537 | if (allow) { | 558 | if (allow) { | ||
538 | view = KFile::DetailTree; | 559 | view = KFile::DetailTree; | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
629 | void KDirOperator::Private::_k_slotToggleDirsFirst() | 650 | void KDirOperator::Private::_k_slotToggleDirsFirst() | ||
630 | { | 651 | { | ||
631 | QDir::SortFlags s = (sorting ^ QDir::DirsFirst); | 652 | QDir::SortFlags s = (sorting ^ QDir::DirsFirst); | ||
632 | updateSorting(s); | 653 | updateSorting(s); | ||
633 | } | 654 | } | ||
634 | 655 | | |||
635 | void KDirOperator::Private::_k_slotToggleIconsView() | 656 | void KDirOperator::Private::_k_slotToggleIconsView() | ||
636 | { | 657 | { | ||
658 | if (configGroup && itemView) { | ||||
659 | // save old zoom settings | ||||
660 | writeIconZoomSettings(*configGroup); | ||||
661 | } | ||||
662 | | ||||
637 | // Put the icons on top | 663 | // Put the icons on top | ||
638 | actionCollection->action(QStringLiteral("decorationAtTop"))->setChecked(true); | 664 | actionCollection->action(QStringLiteral("decorationAtTop"))->setChecked(true); | ||
639 | decorationPosition = QStyleOptionViewItem::Top; | 665 | decorationPosition = QStyleOptionViewItem::Top; | ||
640 | 666 | | |||
641 | // Switch to simple view | 667 | // Switch to simple view | ||
642 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 668 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
643 | parent->setView(fileView); | 669 | parent->setView(fileView); | ||
644 | } | 670 | } | ||
645 | 671 | | |||
646 | void KDirOperator::Private::_k_slotToggleCompactView() | 672 | void KDirOperator::Private::_k_slotToggleCompactView() | ||
647 | { | 673 | { | ||
674 | if (configGroup && itemView) { | ||||
675 | // save old zoom settings | ||||
676 | writeIconZoomSettings(*configGroup); | ||||
677 | } | ||||
678 | | ||||
648 | // Put the icons on the side | 679 | // Put the icons on the side | ||
649 | actionCollection->action(QStringLiteral("decorationAtLeft"))->setChecked(true); | 680 | actionCollection->action(QStringLiteral("decorationAtLeft"))->setChecked(true); | ||
650 | decorationPosition = QStyleOptionViewItem::Left; | 681 | decorationPosition = QStyleOptionViewItem::Left; | ||
651 | 682 | | |||
652 | // Switch to simple view | 683 | // Switch to simple view | ||
653 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | 684 | KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple); | ||
654 | parent->setView(fileView); | 685 | parent->setView(fileView); | ||
655 | } | 686 | } | ||
656 | 687 | | |||
657 | void KDirOperator::Private::_k_slotToggleDetailsView() | 688 | void KDirOperator::Private::_k_slotToggleDetailsView() | ||
658 | { | 689 | { | ||
690 | if (configGroup && itemView) { | ||||
691 | // save old zoom settings | ||||
692 | writeIconZoomSettings(*configGroup); | ||||
693 | } | ||||
694 | | ||||
659 | KFile::FileView view; | 695 | KFile::FileView view; | ||
660 | if (actionCollection->action(QStringLiteral("allow expansion"))->isChecked()) { | 696 | if (actionCollection->action(QStringLiteral("allow expansion"))->isChecked()) { | ||
661 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | 697 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree); | ||
662 | } else { | 698 | } else { | ||
663 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | 699 | view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail); | ||
664 | } | 700 | } | ||
665 | parent->setView(view); | 701 | parent->setView(view); | ||
666 | } | 702 | } | ||
▲ Show 20 Lines • Show All 1619 Lines • ▼ Show 20 Line(s) | 2321 | } else if (KFile::isTreeView(fv)) { | |||
2286 | style = QStringLiteral("Tree"); | 2322 | style = QStringLiteral("Tree"); | ||
2287 | } else if (KFile::isDetailTreeView(fv)) { | 2323 | } else if (KFile::isDetailTreeView(fv)) { | ||
2288 | style = QStringLiteral("DetailTree"); | 2324 | style = QStringLiteral("DetailTree"); | ||
2289 | } | 2325 | } | ||
2290 | configGroup.writeEntry(QStringLiteral("View Style"), style); | 2326 | configGroup.writeEntry(QStringLiteral("View Style"), style); | ||
2291 | 2327 | | |||
2292 | if (d->inlinePreviewState == Private::NotForced) { | 2328 | if (d->inlinePreviewState == Private::NotForced) { | ||
2293 | configGroup.writeEntry(QStringLiteral("Show Inline Previews"), d->showPreviews); | 2329 | configGroup.writeEntry(QStringLiteral("Show Inline Previews"), d->showPreviews); | ||
2294 | if (qobject_cast<QListView *>(d->itemView)) { | 2330 | d->writeIconZoomSettings(configGroup); | ||
2295 | configGroup.writeEntry(QStringLiteral("listViewIconSize"), d->iconsZoom); | | |||
2296 | } else { | | |||
2297 | configGroup.writeEntry(QStringLiteral("detailedViewIconSize"), d->iconsZoom); | | |||
2298 | } | | |||
2299 | } | 2331 | } | ||
2300 | 2332 | | |||
2301 | configGroup.writeEntry(QStringLiteral("Decoration position"), (int) d->decorationPosition); | 2333 | configGroup.writeEntry(QStringLiteral("Decoration position"), (int) d->decorationPosition); | ||
2302 | } | 2334 | } | ||
2303 | 2335 | | |||
2336 | void KDirOperator::Private::writeIconZoomSettings(KConfigGroup &configGroup) { | ||||
2337 | // must match behavior of iconSizeForViewType | ||||
2338 | KFile::FileView fv = static_cast<KFile::FileView>(viewKind); | ||||
2339 | | ||||
2340 | if (KFile::isSimpleView(fv)) { | ||||
2341 | if (decorationPosition == QStyleOptionViewItem::Top){ | ||||
2342 | // Simple view decoration above, aka Icons View | ||||
2343 | configGroup.writeEntry("iconViewIconSize", iconsZoom); | ||||
2344 | } else { | ||||
2345 | // Simple view decoration left, aka compact view | ||||
2346 | configGroup.writeEntry("listViewIconSize", iconsZoom); | ||||
2347 | } | ||||
2348 | } else { | ||||
2349 | if (KFile::isTreeView(fv)) { | ||||
2350 | configGroup.writeEntry(QStringLiteral("treeViewIconSize"), iconsZoom); | ||||
2351 | } else if (KFile::isDetailTreeView(fv) || KFile::isDetailView(fv)) { | ||||
2352 | configGroup.writeEntry(QStringLiteral("detailViewIconSize"), iconsZoom); | ||||
2353 | } | ||||
2354 | } | ||||
2355 | } | ||||
2304 | 2356 | | |||
2305 | void KDirOperator::resizeEvent(QResizeEvent *) | 2357 | void KDirOperator::resizeEvent(QResizeEvent *) | ||
2306 | { | 2358 | { | ||
2307 | // resize the splitter and assure that the width of | 2359 | // resize the splitter and assure that the width of | ||
2308 | // the preview widget is restored | 2360 | // the preview widget is restored | ||
2309 | QList<int> sizes = d->splitter->sizes(); | 2361 | QList<int> sizes = d->splitter->sizes(); | ||
2310 | const bool hasPreview = (sizes.count() == 2); | 2362 | const bool hasPreview = (sizes.count() == 2); | ||
2311 | 2363 | | |||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Line(s) | |||||
2632 | 2684 | | |||
2633 | void KDirOperator::Private::_k_slotItemsChanged() | 2685 | void KDirOperator::Private::_k_slotItemsChanged() | ||
2634 | { | 2686 | { | ||
2635 | completeListDirty = true; | 2687 | completeListDirty = true; | ||
2636 | } | 2688 | } | ||
2637 | 2689 | | |||
2638 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | 2690 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | ||
2639 | { | 2691 | { | ||
2692 | // must match behavior of writeIconZoomSettings | ||||
2640 | if (!itemView || !configGroup) { | 2693 | if (!itemView || !configGroup) { | ||
2641 | return 0; | 2694 | return 0; | ||
2642 | } | 2695 | } | ||
2643 | 2696 | | |||
2644 | if (qobject_cast<QListView *>(itemView)) { | 2697 | KFile::FileView fv = static_cast<KFile::FileView>(viewKind); | ||
2698 | | ||||
2699 | if (KFile::isSimpleView(fv)) { | ||||
2700 | if (decorationPosition == QStyleOptionViewItem::Top){ | ||||
2701 | // Simple view decoration above, aka Icons View | ||||
2702 | // default to 43% aka 64px | ||||
2703 | return configGroup->readEntry("iconViewIconSize", 43); | ||||
2704 | } else { | ||||
2705 | // Simple view decoration left, aka compact view | ||||
2645 | return configGroup->readEntry("listViewIconSize", 0); | 2706 | return configGroup->readEntry("listViewIconSize", 0); | ||
2707 | } | ||||
2646 | } else { | 2708 | } else { | ||
2647 | return configGroup->readEntry("detailedViewIconSize", 0); | 2709 | if (KFile::isTreeView(fv)) { | ||
2710 | return configGroup->readEntry(QStringLiteral("treeViewIconSize"), 0); | ||||
2711 | } else if (KFile::isDetailView(fv) || KFile::isDetailTreeView(fv)) { | ||||
meven: Perhaps we could use a more sensible default value for ColumnView.
What would you say about… | |||||
ngraham: That sounds like a good default size. | |||||
2712 | return configGroup->readEntry(QStringLiteral("detailViewIconSize"), 0); | ||||
2648 | } | 2713 | } | ||
2649 | } | 2714 | } | ||
2650 | 2715 | | |||
2716 | return 0; | ||||
2717 | } | ||||
2718 | | ||||
2651 | void KDirOperator::setViewConfig(KConfigGroup &configGroup) | 2719 | void KDirOperator::setViewConfig(KConfigGroup &configGroup) | ||
2652 | { | 2720 | { | ||
2653 | delete d->configGroup; | 2721 | delete d->configGroup; | ||
2654 | d->configGroup = new KConfigGroup(configGroup); | 2722 | d->configGroup = new KConfigGroup(configGroup); | ||
2655 | } | 2723 | } | ||
2656 | 2724 | | |||
2657 | KConfigGroup *KDirOperator::viewConfigGroup() const | 2725 | KConfigGroup *KDirOperator::viewConfigGroup() const | ||
2658 | { | 2726 | { | ||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |
Perhaps we could use a more sensible default value for ColumnView.
What would you say about 32px ?