Changeset View
Standalone View
src/filewidgets/kdiroperator.cpp
Show First 20 Lines • Show All 2243 Lines • ▼ Show 20 Line(s) | 2228 | { | |||
---|---|---|---|---|---|
2244 | if (hasPreview) { | 2244 | if (hasPreview) { | ||
2245 | d->previewWidth = sizes[1]; | 2245 | d->previewWidth = sizes[1]; | ||
2246 | } | 2246 | } | ||
2247 | 2247 | | |||
2248 | if (d->progressBar->parent() == this) { | 2248 | if (d->progressBar->parent() == this) { | ||
2249 | // might be reparented into a statusbar | 2249 | // might be reparented into a statusbar | ||
2250 | d->progressBar->move(2, height() - d->progressBar->height() - 2); | 2250 | d->progressBar->move(2, height() - d->progressBar->height() - 2); | ||
2251 | } | 2251 | } | ||
2252 | | ||||
2253 | d->updateListViewGrid(); | ||||
ngraham: Why is this needed? | |||||
Without this the icon grid gets only updated when the zoom slider is moved, and it needs to get updated when the window is resized as well. anemeth: Without this the icon grid gets only updated when the zoom slider is moved, and it needs to get… | |||||
2252 | } | 2254 | } | ||
2253 | 2255 | | |||
2254 | void KDirOperator::setOnlyDoubleClickSelectsFiles(bool enable) | 2256 | void KDirOperator::setOnlyDoubleClickSelectsFiles(bool enable) | ||
2255 | { | 2257 | { | ||
2256 | d->onlyDoubleClickSelectsFiles = enable; | 2258 | d->onlyDoubleClickSelectsFiles = enable; | ||
2257 | // TODO: port to QAbstractItemModel | 2259 | // TODO: port to QAbstractItemModel | ||
2258 | //if (d->itemView != 0) { | 2260 | //if (d->itemView != 0) { | ||
2259 | // d->itemView->setOnlyDoubleClickSelectsFiles(enable); | 2261 | // d->itemView->setOnlyDoubleClickSelectsFiles(enable); | ||
▲ Show 20 Lines • Show All 318 Lines • ▼ Show 20 Line(s) | 2567 | { | |||
2578 | if (leftChecked) { | 2580 | if (leftChecked) { | ||
2579 | view->setGridSize(QSize()); | 2581 | view->setGridSize(QSize()); | ||
2580 | KFileItemDelegate *delegate = qobject_cast<KFileItemDelegate *>(view->itemDelegate()); | 2582 | KFileItemDelegate *delegate = qobject_cast<KFileItemDelegate *>(view->itemDelegate()); | ||
2581 | if (delegate) { | 2583 | if (delegate) { | ||
2582 | delegate->setMaximumSize(QSize()); | 2584 | delegate->setMaximumSize(QSize()); | ||
2583 | } | 2585 | } | ||
2584 | } else { | 2586 | } else { | ||
2585 | const QFontMetrics metrics(itemView->viewport()->font()); | 2587 | const QFontMetrics metrics(itemView->viewport()->font()); | ||
2586 | int size = itemView->iconSize().height() + metrics.height() * 2; | 2588 | | ||
2587 | // some heuristics for good looking. let's guess width = height * (3 / 2) is nice | 2589 | const int height = itemView->iconSize().height() + metrics.height() * 2.5; | ||
2588 | view->setGridSize(QSize(size * (3.0 / 2.0), size + metrics.height())); | 2590 | const int minWidth = qMax(height, metrics.height() * 5); | ||
2591 | | ||||
2592 | // this is needed for a workaround to an issue where the scrollbar area seems to be reserved at all times | ||||
The + 1 looks a bit weird. Taking it out results in much flickering, so I guess we have to keep it. However, it should get a comment and/or possibly be moved elsewhere (as it is not about the scrollBarWidth). rkflx: The `+ 1` looks a bit weird. Taking it out results in much flickering, so I guess we have to… | |||||
2593 | const int scrollBarWidth = itemView->verticalScrollBar()->sizeHint().width() + 1; | ||||
There seems to be an issues with the Oxygen style, where upon resizing the window an additional scrollbar (?) width is added on the right, resulting in the items not being centered anymore. You can look into it, but if there is no easy solution (or there is a bug in Oxygen), I'm also okay with the current state. rkflx: There seems to be an issues with the Oxygen style, where upon resizing the window an additional… | |||||
I tried other widget styles too. anemeth: I tried other widget styles too.
They all share this issue where the space for the scrollbar… | |||||
ngraham: I think it's OK if avoiding it is a nightmare. | |||||
2594 | | ||||
2595 | const int viewPortWidth = itemView->contentsRect().width() - scrollBarWidth; | ||||
rkflx: Thread 1 "kdialog" received signal SIGFPE, Arithmetic exception. | |||||
anemeth: Thanks, fixed. | |||||
You got the reasoning wrong, please see my patch again and switch it around. 1px is against flickering, 4 px against the column problem (and include "Oxygen"!). rkflx: You got the reasoning wrong, please see my patch again and switch it around. 1px is against… | |||||
2596 | const int itemsInRow = qMax(1, viewPortWidth / minWidth); | ||||
2597 | const int remainingWidth = viewPortWidth - (minWidth * itemsInRow); | ||||
2598 | const int width = minWidth + (remainingWidth / itemsInRow); | ||||
2599 | | ||||
2600 | const QSize itemSize(width, height); | ||||
2601 | | ||||
2602 | view->setGridSize(itemSize); | ||||
2589 | KFileItemDelegate *delegate = qobject_cast<KFileItemDelegate *>(view->itemDelegate()); | 2603 | KFileItemDelegate *delegate = qobject_cast<KFileItemDelegate *>(view->itemDelegate()); | ||
2590 | if (delegate) { | 2604 | if (delegate) { | ||
2591 | delegate->setMaximumSize(QSize(size * (3.0 / 2.0), size + metrics.height())); | 2605 | delegate->setMaximumSize(itemSize); | ||
2592 | } | 2606 | } | ||
2593 | } | 2607 | } | ||
2594 | } | 2608 | } | ||
2595 | 2609 | | |||
2596 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | 2610 | int KDirOperator::Private::iconSizeForViewType(QAbstractItemView *itemView) const | ||
2597 | { | 2611 | { | ||
2598 | if (!itemView || !configGroup) { | 2612 | if (!itemView || !configGroup) { | ||
2599 | return 0; | 2613 | return 0; | ||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |
Why is this needed?