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