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