]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphindetailsview.cpp
Fixed issue that sometimes the dragging from an inactive view to an active view does...
[dolphin.git] / src / dolphindetailsview.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "dolphindetailsview.h"
22
23 #include "dolphinmodel.h"
24 #include "dolphincontroller.h"
25 #include "dolphinsettings.h"
26 #include "dolphinsortfilterproxymodel.h"
27 #include "draganddrophelper.h"
28 #include "selectionmanager.h"
29 #include "viewproperties.h"
30
31 #include "dolphin_detailsmodesettings.h"
32 #include "dolphin_generalsettings.h"
33
34 #include <kdirmodel.h>
35 #include <klocale.h>
36 #include <kmenu.h>
37
38 #include <QAbstractProxyModel>
39 #include <QAction>
40 #include <QApplication>
41 #include <QHeaderView>
42 #include <QRubberBand>
43 #include <QPainter>
44 #include <QScrollBar>
45
46 DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* controller) :
47 QTreeView(parent),
48 m_autoResize(true),
49 m_controller(controller),
50 m_selectionManager(0),
51 m_font(),
52 m_decorationSize(),
53 m_showElasticBand(false),
54 m_elasticBandOrigin(),
55 m_elasticBandDestination()
56 {
57 const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
58 Q_ASSERT(settings != 0);
59 Q_ASSERT(controller != 0);
60
61 setAcceptDrops(true);
62 setSortingEnabled(true);
63 setUniformRowHeights(true);
64 setSelectionBehavior(SelectItems);
65 setDragDropMode(QAbstractItemView::DragDrop);
66 setDropIndicatorShown(false);
67 setAlternatingRowColors(true);
68 setRootIsDecorated(settings->expandableFolders());
69 setItemsExpandable(settings->expandableFolders());
70 setEditTriggers(QAbstractItemView::NoEditTriggers);
71
72 setMouseTracking(true);
73
74 const ViewProperties props(controller->url());
75 setSortIndicatorSection(props.sorting());
76 setSortIndicatorOrder(props.sortOrder());
77
78 QHeaderView* headerView = header();
79 connect(headerView, SIGNAL(sectionClicked(int)),
80 this, SLOT(synchronizeSortingState(int)));
81 headerView->setContextMenuPolicy(Qt::CustomContextMenu);
82 connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)),
83 this, SLOT(configureColumns(const QPoint&)));
84 connect(headerView, SIGNAL(sectionResized(int, int, int)),
85 this, SLOT(slotHeaderSectionResized(int, int, int)));
86 connect(headerView, SIGNAL(sectionHandleDoubleClicked(int)),
87 this, SLOT(disableAutoResizing()));
88
89 connect(parent, SIGNAL(sortingChanged(DolphinView::Sorting)),
90 this, SLOT(setSortIndicatorSection(DolphinView::Sorting)));
91 connect(parent, SIGNAL(sortOrderChanged(Qt::SortOrder)),
92 this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
93
94 // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
95 // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
96 // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the
97 // RETURN-key in keyPressEvent().
98 if (KGlobalSettings::singleClick()) {
99 connect(this, SIGNAL(clicked(const QModelIndex&)),
100 controller, SLOT(triggerItem(const QModelIndex&)));
101 if (DolphinSettings::instance().generalSettings()->showSelectionToggle()) {
102 m_selectionManager = new SelectionManager(this);
103 connect(m_selectionManager, SIGNAL(selectionChanged()),
104 this, SLOT(requestActivation()));
105 connect(m_controller, SIGNAL(urlChanged(const KUrl&)),
106 m_selectionManager, SLOT(reset()));
107 }
108 } else {
109 connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
110 controller, SLOT(triggerItem(const QModelIndex&)));
111 }
112 connect(this, SIGNAL(entered(const QModelIndex&)),
113 this, SLOT(slotEntered(const QModelIndex&)));
114 connect(this, SIGNAL(viewportEntered()),
115 controller, SLOT(emitViewportEntered()));
116 connect(controller, SIGNAL(zoomIn()),
117 this, SLOT(zoomIn()));
118 connect(controller, SIGNAL(zoomOut()),
119 this, SLOT(zoomOut()));
120 connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()),
121 this, SLOT(updateColumnVisibility()));
122
123 if (settings->useSystemFont()) {
124 m_font = KGlobalSettings::generalFont();
125 } else {
126 m_font = QFont(settings->fontFamily(),
127 settings->fontSize(),
128 settings->fontWeight(),
129 settings->italicFont());
130 }
131
132 setVerticalScrollMode(QTreeView::ScrollPerPixel);
133 setHorizontalScrollMode(QTreeView::ScrollPerPixel);
134
135 updateDecorationSize();
136
137 setFocus();
138 viewport()->installEventFilter(this);
139
140 connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
141 this, SLOT(updateFont()));
142 }
143
144 DolphinDetailsView::~DolphinDetailsView()
145 {
146 }
147
148 bool DolphinDetailsView::event(QEvent* event)
149 {
150 if (event->type() == QEvent::Polish) {
151 QHeaderView* headerView = header();
152 headerView->setResizeMode(QHeaderView::Interactive);
153 headerView->setMovable(false);
154
155 updateColumnVisibility();
156
157 hideColumn(DolphinModel::Rating);
158 hideColumn(DolphinModel::Tags);
159 } else if (event->type() == QEvent::UpdateRequest) {
160 // a wheel movement will scroll 4 items
161 if (model()->rowCount() > 0) {
162 verticalScrollBar()->setSingleStep((sizeHintForRow(0) / 3) * 4);
163 }
164 }
165
166 return QTreeView::event(event);
167 }
168
169 QStyleOptionViewItem DolphinDetailsView::viewOptions() const
170 {
171 QStyleOptionViewItem viewOptions = QTreeView::viewOptions();
172 viewOptions.font = m_font;
173 viewOptions.showDecorationSelected = true;
174 viewOptions.decorationSize = m_decorationSize;
175 return viewOptions;
176 }
177
178 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent* event)
179 {
180 QTreeView::contextMenuEvent(event);
181 m_controller->triggerContextMenuRequest(event->pos());
182 }
183
184 void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
185 {
186 m_controller->requestActivation();
187
188 QTreeView::mousePressEvent(event);
189
190 const QModelIndex index = indexAt(event->pos());
191 if (index.isValid() && (event->button() == Qt::LeftButton)) {
192 // TODO: see comment in DolphinIconsView::mousePressEvent()
193 setState(QAbstractItemView::DraggingState);
194 }
195
196 if (!index.isValid() || (index.column() != DolphinModel::Name)) {
197 const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
198 if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) {
199 clearSelection();
200 }
201 }
202
203 if (event->button() == Qt::LeftButton) {
204 m_showElasticBand = true;
205
206 const QPoint pos(contentsPos());
207 m_elasticBandOrigin = event->pos();
208 m_elasticBandOrigin.setX(m_elasticBandOrigin.x() + pos.x());
209 m_elasticBandOrigin.setY(m_elasticBandOrigin.y() + pos.y());
210 m_elasticBandDestination = event->pos();
211 }
212 }
213
214 void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event)
215 {
216 if (m_showElasticBand) {
217 const QPoint mousePos = event->pos();
218 const QModelIndex index = indexAt(mousePos);
219 if (!index.isValid()) {
220 // the destination of the selection rectangle is above the viewport. In this
221 // case QTreeView does no selection at all, which is not the wanted behavior
222 // in Dolphin -> select all items within the elastic band rectangle
223 clearSelection();
224
225 const int nameColumnWidth = header()->sectionSize(DolphinModel::Name);
226 QRect selRect = QRect(m_elasticBandOrigin, m_elasticBandDestination).normalized();
227 const QRect nameColumnsRect(0, 0, nameColumnWidth, viewport()->height());
228 selRect = nameColumnsRect.intersected(selRect);
229
230 setSelection(selRect, QItemSelectionModel::Select);
231 }
232
233 // TODO: enable QTreeView::mouseMoveEvent(event) again, as soon
234 // as the Qt-issue #199631 has been fixed.
235 // QTreeView::mouseMoveEvent(event);
236 QAbstractItemView::mouseMoveEvent(event);
237 updateElasticBand();
238 } else {
239 // TODO: enable QTreeView::mouseMoveEvent(event) again, as soon
240 // as the Qt-issue #199631 has been fixed.
241 // QTreeView::mouseMoveEvent(event);
242 QAbstractItemView::mouseMoveEvent(event);
243 }
244 }
245
246 void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
247 {
248 QTreeView::mouseReleaseEvent(event);
249 if (m_showElasticBand) {
250 updateElasticBand();
251 m_showElasticBand = false;
252 }
253 }
254
255 void DolphinDetailsView::startDrag(Qt::DropActions supportedActions)
256 {
257 DragAndDropHelper::startDrag(this, supportedActions);
258 m_showElasticBand = false;
259 }
260
261 void DolphinDetailsView::dragEnterEvent(QDragEnterEvent* event)
262 {
263 if (event->mimeData()->hasUrls()) {
264 event->acceptProposedAction();
265 }
266
267 if (m_showElasticBand) {
268 updateElasticBand();
269 m_showElasticBand = false;
270 }
271 }
272
273 void DolphinDetailsView::dragLeaveEvent(QDragLeaveEvent* event)
274 {
275 QTreeView::dragLeaveEvent(event);
276 setDirtyRegion(m_dropRect);
277 }
278
279 void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event)
280 {
281 QTreeView::dragMoveEvent(event);
282
283 // TODO: remove this code when the issue #160611 is solved in Qt 4.4
284 setDirtyRegion(m_dropRect);
285 const QModelIndex index = indexAt(event->pos());
286 if (index.isValid() && (index.column() == DolphinModel::Name)) {
287 const KFileItem item = m_controller->itemForIndex(index);
288 if (!item.isNull() && item.isDir()) {
289 m_dropRect = visualRect(index);
290 } else {
291 m_dropRect.setSize(QSize()); // set as invalid
292 }
293 setDirtyRegion(m_dropRect);
294 }
295
296 if (event->mimeData()->hasUrls()) {
297 // accept url drops, independently from the destination item
298 event->acceptProposedAction();
299 }
300 }
301
302 void DolphinDetailsView::dropEvent(QDropEvent* event)
303 {
304 const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
305 if (!urls.isEmpty()) {
306 event->acceptProposedAction();
307 const QModelIndex index = indexAt(event->pos());
308 KFileItem item;
309 if (index.isValid() && (index.column() == DolphinModel::Name)) {
310 item = m_controller->itemForIndex(index);
311 }
312 m_controller->indicateDroppedUrls(urls,
313 m_controller->url(),
314 item);
315 }
316 QTreeView::dropEvent(event);
317 }
318
319 void DolphinDetailsView::paintEvent(QPaintEvent* event)
320 {
321 QTreeView::paintEvent(event);
322 if (m_showElasticBand) {
323 // The following code has been taken from QListView
324 // and adapted to DolphinDetailsView.
325 // (C) 1992-2007 Trolltech ASA
326 QStyleOptionRubberBand opt;
327 opt.initFrom(this);
328 opt.shape = QRubberBand::Rectangle;
329 opt.opaque = false;
330 opt.rect = elasticBandRect();
331
332 QPainter painter(viewport());
333 painter.save();
334 style()->drawControl(QStyle::CE_RubberBand, &opt, &painter);
335 painter.restore();
336 }
337 }
338
339 void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
340 {
341 QTreeView::keyPressEvent(event);
342 m_controller->handleKeyPressEvent(event);
343 }
344
345 void DolphinDetailsView::resizeEvent(QResizeEvent* event)
346 {
347 if (m_autoResize) {
348 resizeColumns();
349 }
350 QTreeView::resizeEvent(event);
351 }
352
353 void DolphinDetailsView::wheelEvent(QWheelEvent* event)
354 {
355 if (m_selectionManager != 0) {
356 m_selectionManager->reset();
357 }
358
359 // let Ctrl+wheel events propagate to the DolphinView for icon zooming
360 if (event->modifiers() & Qt::ControlModifier) {
361 event->ignore();
362 return;
363 }
364
365 QTreeView::wheelEvent(event);
366 }
367
368 void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
369 {
370 QTreeView::currentChanged(current, previous);
371
372 // Stay consistent with QListView: When changing the current index by key presses,
373 // also change the selection.
374 if (QApplication::mouseButtons() == Qt::NoButton) {
375 selectionModel()->select(current, QItemSelectionModel::ClearAndSelect);
376 }
377 }
378
379 bool DolphinDetailsView::eventFilter(QObject* watched, QEvent* event)
380 {
381 if ((watched == viewport()) && (event->type() == QEvent::Leave)) {
382 // if the mouse is above an item and moved very fast outside the widget,
383 // no viewportEntered() signal might be emitted although the mouse has been moved
384 // above the viewport
385 m_controller->emitViewportEntered();
386 }
387
388 return QTreeView::eventFilter(watched, event);
389 }
390
391 void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
392 {
393 QHeaderView* headerView = header();
394 headerView->setSortIndicator(sorting, headerView->sortIndicatorOrder());
395 }
396
397 void DolphinDetailsView::setSortIndicatorOrder(Qt::SortOrder sortOrder)
398 {
399 QHeaderView* headerView = header();
400 headerView->setSortIndicator(headerView->sortIndicatorSection(), sortOrder);
401 }
402
403 void DolphinDetailsView::synchronizeSortingState(int column)
404 {
405 // The sorting has already been changed in QTreeView if this slot is
406 // invoked, but Dolphin is not informed about this.
407 DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(column);
408 const Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
409 m_controller->indicateSortingChange(sorting);
410 m_controller->indicateSortOrderChange(sortOrder);
411 }
412
413 void DolphinDetailsView::slotEntered(const QModelIndex& index)
414 {
415 const QPoint pos = viewport()->mapFromGlobal(QCursor::pos());
416 const int nameColumnWidth = header()->sectionSize(DolphinModel::Name);
417 if (pos.x() < nameColumnWidth) {
418 m_controller->emitItemEntered(index);
419 }
420 else {
421 m_controller->emitViewportEntered();
422 }
423 }
424
425 void DolphinDetailsView::updateElasticBand()
426 {
427 if (m_showElasticBand) {
428 QRect dirtyRegion(elasticBandRect());
429 m_elasticBandDestination = viewport()->mapFromGlobal(QCursor::pos());
430 dirtyRegion = dirtyRegion.united(elasticBandRect());
431 setDirtyRegion(dirtyRegion);
432 }
433 }
434
435 QRect DolphinDetailsView::elasticBandRect() const
436 {
437 const QPoint pos(contentsPos());
438 const QPoint topLeft(m_elasticBandOrigin.x() - pos.x(), m_elasticBandOrigin.y() - pos.y());
439 return QRect(topLeft, m_elasticBandDestination).normalized();
440 }
441
442 void DolphinDetailsView::zoomIn()
443 {
444 if (isZoomInPossible()) {
445 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
446 switch (settings->iconSize()) {
447 case KIconLoader::SizeSmall: settings->setIconSize(KIconLoader::SizeMedium); break;
448 case KIconLoader::SizeMedium: settings->setIconSize(KIconLoader::SizeLarge); break;
449 default: Q_ASSERT(false); break;
450 }
451 updateDecorationSize();
452 }
453 }
454
455 void DolphinDetailsView::zoomOut()
456 {
457 if (isZoomOutPossible()) {
458 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
459 switch (settings->iconSize()) {
460 case KIconLoader::SizeLarge: settings->setIconSize(KIconLoader::SizeMedium); break;
461 case KIconLoader::SizeMedium: settings->setIconSize(KIconLoader::SizeSmall); break;
462 default: Q_ASSERT(false); break;
463 }
464 updateDecorationSize();
465 }
466 }
467
468 void DolphinDetailsView::configureColumns(const QPoint& pos)
469 {
470 KMenu popup(this);
471 popup.addTitle(i18nc("@title:menu", "Columns"));
472
473 QHeaderView* headerView = header();
474 for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
475 const int logicalIndex = headerView->logicalIndex(i);
476 const QString text = model()->headerData(i, Qt::Horizontal).toString();
477 QAction* action = popup.addAction(text);
478 action->setCheckable(true);
479 action->setChecked(!headerView->isSectionHidden(logicalIndex));
480 action->setData(i);
481 }
482
483 QAction* activatedAction = popup.exec(header()->mapToGlobal(pos));
484 if (activatedAction != 0) {
485 const bool show = activatedAction->isChecked();
486 const int columnIndex = activatedAction->data().toInt();
487
488 KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
489 const KFileItemDelegate::Information info = infoForColumn(columnIndex);
490 if (show) {
491 Q_ASSERT(!list.contains(info));
492 list.append(info);
493 } else {
494 Q_ASSERT(list.contains(info));
495 const int index = list.indexOf(info);
496 list.removeAt(index);
497 }
498
499 m_controller->indicateAdditionalInfoChange(list);
500 setColumnHidden(columnIndex, !show);
501 }
502 }
503
504 void DolphinDetailsView::updateColumnVisibility()
505 {
506 const KFileItemDelegate::InformationList list = m_controller->dolphinView()->additionalInfo();
507 for (int i = DolphinModel::Size; i <= DolphinModel::Type; ++i) {
508 const KFileItemDelegate::Information info = infoForColumn(i);
509 const bool hide = !list.contains(info);
510 if (isColumnHidden(i) != hide) {
511 setColumnHidden(i, hide);
512 }
513 }
514
515 resizeColumns();
516 }
517
518 void DolphinDetailsView::slotHeaderSectionResized(int logicalIndex, int oldSize, int newSize)
519 {
520 Q_UNUSED(logicalIndex);
521 Q_UNUSED(oldSize);
522 Q_UNUSED(newSize);
523 if (QApplication::mouseButtons() & Qt::LeftButton) {
524 disableAutoResizing();
525 }
526 }
527
528 void DolphinDetailsView::disableAutoResizing()
529 {
530 m_autoResize = false;
531 }
532
533 void DolphinDetailsView::requestActivation()
534 {
535 m_controller->requestActivation();
536 }
537
538 void DolphinDetailsView::updateFont()
539 {
540 const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
541 Q_ASSERT(settings != 0);
542
543 if (settings->useSystemFont()) {
544 m_font = KGlobalSettings::generalFont();
545 }
546 }
547
548 bool DolphinDetailsView::isZoomInPossible() const
549 {
550 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
551 return settings->iconSize() < KIconLoader::SizeLarge;
552 }
553
554 bool DolphinDetailsView::isZoomOutPossible() const
555 {
556 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
557 return settings->iconSize() > KIconLoader::SizeSmall;
558 }
559
560 void DolphinDetailsView::updateDecorationSize()
561 {
562 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
563 const int iconSize = settings->iconSize();
564 setIconSize(QSize(iconSize, iconSize));
565 m_decorationSize = QSize(iconSize, iconSize);
566
567 m_controller->setZoomInPossible(isZoomInPossible());
568 m_controller->setZoomOutPossible(isZoomOutPossible());
569
570 if (m_selectionManager != 0) {
571 m_selectionManager->reset();
572 }
573
574 doItemsLayout();
575 }
576
577 QPoint DolphinDetailsView::contentsPos() const
578 {
579 // implementation note: the horizonal position is ignored currently, as no
580 // horizontal scrolling is done anyway during a selection
581 const QScrollBar* scrollbar = verticalScrollBar();
582 Q_ASSERT(scrollbar != 0);
583
584 const int maxHeight = maximumViewportSize().height();
585 const int height = scrollbar->maximum() - scrollbar->minimum() + 1;
586 const int visibleHeight = model()->rowCount() + 1 - height;
587 if (visibleHeight <= 0) {
588 return QPoint(0, 0);
589 }
590
591 const int y = scrollbar->sliderPosition() * maxHeight / visibleHeight;
592 return QPoint(0, y);
593 }
594
595 KFileItemDelegate::Information DolphinDetailsView::infoForColumn(int columnIndex) const
596 {
597 KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
598
599 switch (columnIndex) {
600 case DolphinModel::Size: info = KFileItemDelegate::Size; break;
601 case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
602 case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
603 case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
604 case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
605 case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
606 default: break;
607 }
608
609 return info;
610 }
611
612 void DolphinDetailsView::resizeColumns()
613 {
614 // Using the resize mode QHeaderView::ResizeToContents is too slow (it takes
615 // around 3 seconds for each (!) resize operation when having > 10000 items).
616 // This gets a problem especially when opening large directories, where several
617 // resize operations are received for showing the currently available items during
618 // loading (the application hangs around 20 seconds when loading > 10000 items).
619
620 QHeaderView* headerView = header();
621 QFontMetrics fontMetrics(viewport()->font());
622
623 int columnWidth[KDirModel::ColumnCount];
624 columnWidth[KDirModel::Size] = fontMetrics.width("00000 Items");
625 columnWidth[KDirModel::ModifiedTime] = fontMetrics.width("0000-00-00 00:00");
626 columnWidth[KDirModel::Permissions] = fontMetrics.width("xxxxxxxxxx");
627 columnWidth[KDirModel::Owner] = fontMetrics.width("xxxxxxxxxx");
628 columnWidth[KDirModel::Group] = fontMetrics.width("xxxxxxxxxx");
629 columnWidth[KDirModel::Type] = fontMetrics.width("XXXX Xxxxxxx");
630
631 int requiredWidth = 0;
632 for (int i = KDirModel::Size; i <= KDirModel::Type; ++i) {
633 if (!isColumnHidden(i)) {
634 columnWidth[i] += 20; // provide a default gap
635 requiredWidth += columnWidth[i];
636 headerView->resizeSection(i, columnWidth[i]);
637 }
638 }
639
640 // resize the name column in a way that the whole available width is used
641 columnWidth[KDirModel::Name] = viewport()->width() - requiredWidth;
642 if (columnWidth[KDirModel::Name] < 120) {
643 columnWidth[KDirModel::Name] = 120;
644 }
645 headerView->resizeSection(KDirModel::Name, columnWidth[KDirModel::Name]);
646 }
647
648 #include "dolphindetailsview.moc"