1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) *
3 * Copyright (C) 2008 by Simon St. James (kdedevel@etotheipiplusone.com) *
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. *
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. *
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 ***************************************************************************/
21 #include "dolphindetailsview.h"
23 #include "additionalinfoaccessor.h"
24 #include "dolphinmodel.h"
25 #include "dolphinviewcontroller.h"
26 #include "dolphinfileitemdelegate.h"
27 #include "settings/dolphinsettings.h"
28 #include "dolphinsortfilterproxymodel.h"
29 #include "dolphinviewautoscroller.h"
30 #include "draganddrophelper.h"
31 #include "viewextensionsfactory.h"
32 #include "viewmodecontroller.h"
33 #include "viewproperties.h"
34 #include "zoomlevelinfo.h"
36 #include "dolphin_detailsmodesettings.h"
37 #include "dolphin_generalsettings.h"
39 #include <kdirmodel.h>
40 #include <kdirlister.h>
44 #include <QApplication>
45 #include <QHeaderView>
48 DolphinDetailsView::DolphinDetailsView(QWidget
* parent
,
49 DolphinViewController
* dolphinViewController
,
50 const ViewModeController
* viewModeController
,
51 DolphinSortFilterProxyModel
* proxyModel
) :
52 DolphinTreeView(parent
),
54 m_dolphinViewController(dolphinViewController
),
55 m_viewModeController(viewModeController
),
56 m_extensionsFactory(0),
57 m_expandableFoldersAction(0),
62 const DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
63 Q_ASSERT(settings
!= 0);
64 Q_ASSERT(dolphinViewController
!= 0);
65 Q_ASSERT(viewModeController
!= 0);
67 setLayoutDirection(Qt::LeftToRight
);
69 setSortingEnabled(true);
70 setUniformRowHeights(true);
71 setSelectionBehavior(SelectItems
);
72 setDragDropMode(QAbstractItemView::DragDrop
);
73 setDropIndicatorShown(false);
74 setAlternatingRowColors(true);
75 setRootIsDecorated(settings
->expandableFolders());
76 setItemsExpandable(settings
->expandableFolders());
77 setEditTriggers(QAbstractItemView::NoEditTriggers
);
80 setMouseTracking(true);
82 const ViewProperties
props(viewModeController
->url());
83 setSortIndicatorSection(props
.sorting());
84 setSortIndicatorOrder(props
.sortOrder());
86 QHeaderView
* headerView
= header();
87 connect(headerView
, SIGNAL(sectionClicked(int)),
88 this, SLOT(synchronizeSortingState(int)));
89 headerView
->setContextMenuPolicy(Qt::CustomContextMenu
);
90 connect(headerView
, SIGNAL(customContextMenuRequested(const QPoint
&)),
91 this, SLOT(configureSettings(const QPoint
&)));
92 connect(headerView
, SIGNAL(sectionResized(int, int, int)),
93 this, SLOT(slotHeaderSectionResized(int, int, int)));
94 connect(headerView
, SIGNAL(sectionHandleDoubleClicked(int)),
95 this, SLOT(disableAutoResizing()));
97 connect(parent
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
98 this, SLOT(setSortIndicatorSection(DolphinView::Sorting
)));
99 connect(parent
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
100 this, SLOT(setSortIndicatorOrder(Qt::SortOrder
)));
102 connect(this, SIGNAL(clicked(const QModelIndex
&)),
103 dolphinViewController
, SLOT(requestTab(const QModelIndex
&)));
104 if (KGlobalSettings::singleClick()) {
105 connect(this, SIGNAL(clicked(const QModelIndex
&)),
106 dolphinViewController
, SLOT(triggerItem(const QModelIndex
&)));
108 connect(this, SIGNAL(doubleClicked(const QModelIndex
&)),
109 dolphinViewController
, SLOT(triggerItem(const QModelIndex
&)));
112 connect(this, SIGNAL(entered(const QModelIndex
&)),
113 this, SLOT(slotEntered(const QModelIndex
&)));
114 connect(this, SIGNAL(viewportEntered()),
115 dolphinViewController
, SLOT(emitViewportEntered()));
116 connect(viewModeController
, SIGNAL(zoomLevelChanged(int)),
117 this, SLOT(setZoomLevel(int)));
118 connect(dolphinViewController
->view(), SIGNAL(additionalInfoChanged()),
119 this, SLOT(updateColumnVisibility()));
120 connect(viewModeController
, SIGNAL(activationChanged(bool)),
121 this, SLOT(slotActivationChanged(bool)));
123 if (settings
->useSystemFont()) {
124 m_font
= KGlobalSettings::generalFont();
126 m_font
= QFont(settings
->fontFamily(),
127 qRound(settings
->fontSize()),
128 settings
->fontWeight(),
129 settings
->italicFont());
130 m_font
.setPointSizeF(settings
->fontSize());
133 setVerticalScrollMode(QTreeView::ScrollPerPixel
);
134 setHorizontalScrollMode(QTreeView::ScrollPerPixel
);
136 const DolphinView
* view
= dolphinViewController
->view();
137 connect(view
, SIGNAL(showPreviewChanged()),
138 this, SLOT(slotShowPreviewChanged()));
142 viewport()->installEventFilter(this);
144 connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
145 this, SLOT(slotGlobalSettingsChanged(int)));
147 m_expandableFoldersAction
= new QAction(i18nc("@option:check", "Expandable Folders"), this);
148 m_expandableFoldersAction
->setCheckable(true);
149 connect(m_expandableFoldersAction
, SIGNAL(toggled(bool)),
150 this, SLOT(setFoldersExpandable(bool)));
152 connect(this, SIGNAL(expanded(const QModelIndex
&)), this, SLOT(slotExpanded(const QModelIndex
&)));
153 connect(this, SIGNAL(collapsed(const QModelIndex
&)), this, SLOT(slotCollapsed(const QModelIndex
&)));
155 updateDecorationSize(view
->showPreview());
157 m_extensionsFactory
= new ViewExtensionsFactory(this, dolphinViewController
, viewModeController
);
158 m_extensionsFactory
->fileItemDelegate()->setMinimizedNameColumn(true);
160 KDirLister
*dirLister
= qobject_cast
<KDirModel
*>(proxyModel
->sourceModel())->dirLister();
161 connect(dirLister
, SIGNAL(newItems(KFileItemList
)), this, SLOT(resizeColumns()));
164 DolphinDetailsView::~DolphinDetailsView()
168 QSet
<KUrl
> DolphinDetailsView::expandedUrls() const
170 return m_expandedUrls
;
173 bool DolphinDetailsView::event(QEvent
* event
)
175 if (event
->type() == QEvent::Polish
) {
176 header()->setResizeMode(QHeaderView::Interactive
);
177 updateColumnVisibility();
180 return DolphinTreeView::event(event
);
183 QStyleOptionViewItem
DolphinDetailsView::viewOptions() const
185 QStyleOptionViewItem viewOptions
= DolphinTreeView::viewOptions();
186 viewOptions
.font
= m_font
;
187 viewOptions
.fontMetrics
= QFontMetrics(m_font
);
188 viewOptions
.showDecorationSelected
= true;
189 viewOptions
.decorationSize
= m_decorationSize
;
193 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent
* event
)
195 DolphinTreeView::contextMenuEvent(event
);
197 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
198 m_expandableFoldersAction
->setChecked(settings
->expandableFolders());
199 m_dolphinViewController
->triggerContextMenuRequest(event
->pos(),
200 QList
<QAction
*>() << m_expandableFoldersAction
);
203 void DolphinDetailsView::mousePressEvent(QMouseEvent
* event
)
205 m_dolphinViewController
->requestActivation();
207 DolphinTreeView::mousePressEvent(event
);
209 const QModelIndex index
= indexAt(event
->pos());
210 if (!index
.isValid() || (index
.column() != DolphinModel::Name
)) {
211 // The mouse press is done somewhere outside the filename column
212 if (QApplication::mouseButtons() & Qt::MidButton
) {
213 m_dolphinViewController
->replaceUrlByClipboard();
218 void DolphinDetailsView::startDrag(Qt::DropActions supportedActions
)
220 DragAndDropHelper::instance().startDrag(this, supportedActions
, m_dolphinViewController
);
221 DolphinTreeView::startDrag(supportedActions
);
224 void DolphinDetailsView::dragEnterEvent(QDragEnterEvent
* event
)
226 if (DragAndDropHelper::instance().isMimeDataSupported(event
->mimeData())) {
227 event
->acceptProposedAction();
229 DolphinTreeView::dragEnterEvent(event
);
232 void DolphinDetailsView::dragMoveEvent(QDragMoveEvent
* event
)
234 DolphinTreeView::dragMoveEvent(event
);
236 if (DragAndDropHelper::instance().isMimeDataSupported(event
->mimeData())) {
237 // Accept URL drops, independently from the destination item
238 event
->acceptProposedAction();
242 void DolphinDetailsView::dropEvent(QDropEvent
* event
)
244 const QModelIndex index
= indexAt(event
->pos());
246 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
247 item
= m_dolphinViewController
->itemForIndex(index
);
249 m_dolphinViewController
->indicateDroppedUrls(item
, m_viewModeController
->url(), event
);
250 DolphinTreeView::dropEvent(event
);
253 void DolphinDetailsView::keyPressEvent(QKeyEvent
* event
)
255 DolphinTreeView::keyPressEvent(event
);
256 m_dolphinViewController
->handleKeyPressEvent(event
);
259 void DolphinDetailsView::resizeEvent(QResizeEvent
* event
)
261 DolphinTreeView::resizeEvent(event
);
267 void DolphinDetailsView::wheelEvent(QWheelEvent
* event
)
269 const int step
= m_decorationSize
.height();
270 verticalScrollBar()->setSingleStep(step
);
271 DolphinTreeView::wheelEvent(event
);
274 void DolphinDetailsView::currentChanged(const QModelIndex
& current
, const QModelIndex
& previous
)
276 m_extensionsFactory
->handleCurrentIndexChange(current
, previous
);
277 DolphinTreeView::currentChanged(current
, previous
);
279 // If folders are expanded, the width which is available for editing may have changed
280 // because it depends on the level of the current item in the folder hierarchy.
281 adjustMaximumSizeForEditing(current
);
284 bool DolphinDetailsView::eventFilter(QObject
* watched
, QEvent
* event
)
286 if ((watched
== viewport()) && (event
->type() == QEvent::Leave
)) {
287 // If the mouse is above an item and moved very fast outside the widget,
288 // no viewportEntered() signal might be emitted although the mouse has been moved
289 // above the viewport.
290 m_dolphinViewController
->emitViewportEntered();
293 return DolphinTreeView::eventFilter(watched
, event
);
296 QRect
DolphinDetailsView::visualRect(const QModelIndex
& index
) const
298 QRect rect
= DolphinTreeView::visualRect(index
);
299 const KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
300 if (!item
.isNull()) {
301 const int width
= DolphinFileItemDelegate::nameColumnWidth(item
.text(), viewOptions());
302 rect
.setWidth(width
);
308 bool DolphinDetailsView::acceptsDrop(const QModelIndex
& index
) const
310 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
311 // Accept drops above directories
312 const KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
313 return !item
.isNull() && item
.isDir();
319 void DolphinDetailsView::rowsAboutToBeRemoved(const QModelIndex
&parent
, int start
, int end
)
321 removeExpandedIndexes(parent
, start
, end
);
322 DolphinTreeView::rowsAboutToBeRemoved(parent
, start
, end
);
325 void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting
)
327 header()->setSortIndicator(sorting
, header()->sortIndicatorOrder());
330 void DolphinDetailsView::setSortIndicatorOrder(Qt::SortOrder sortOrder
)
332 header()->setSortIndicator(header()->sortIndicatorSection(), sortOrder
);
335 void DolphinDetailsView::synchronizeSortingState(int column
)
337 // The sorting has already been changed in QTreeView if this slot is
338 // invoked, but Dolphin is not informed about this.
339 DolphinView::Sorting sorting
= DolphinSortFilterProxyModel::sortingForColumn(column
);
340 const Qt::SortOrder sortOrder
= header()->sortIndicatorOrder();
341 m_dolphinViewController
->indicateSortingChange(sorting
);
342 m_dolphinViewController
->indicateSortOrderChange(sortOrder
);
345 void DolphinDetailsView::slotEntered(const QModelIndex
& index
)
347 if (index
.column() == DolphinModel::Name
) {
348 m_dolphinViewController
->emitItemEntered(index
);
350 m_dolphinViewController
->emitViewportEntered();
354 void DolphinDetailsView::setZoomLevel(int level
)
356 const int size
= ZoomLevelInfo::iconSizeForZoomLevel(level
);
357 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
359 const bool showPreview
= m_dolphinViewController
->view()->showPreview();
361 settings
->setPreviewSize(size
);
363 settings
->setIconSize(size
);
366 updateDecorationSize(showPreview
);
369 void DolphinDetailsView::slotShowPreviewChanged()
371 const DolphinView
* view
= m_dolphinViewController
->view();
372 updateDecorationSize(view
->showPreview());
375 void DolphinDetailsView::configureSettings(const QPoint
& pos
)
378 popup
.addTitle(i18nc("@title:menu", "Columns"));
380 // Add checkbox items for each column
381 QHeaderView
* headerView
= header();
382 const int columns
= model()->columnCount();
383 for (int i
= 0; i
< columns
; ++i
) {
384 const int logicalIndex
= headerView
->logicalIndex(i
);
385 const QString text
= model()->headerData(logicalIndex
, Qt::Horizontal
).toString();
386 if (!text
.isEmpty()) {
387 QAction
* action
= popup
.addAction(text
);
388 action
->setCheckable(true);
389 action
->setChecked(!headerView
->isSectionHidden(logicalIndex
));
390 action
->setData(logicalIndex
);
391 action
->setEnabled(logicalIndex
!= DolphinModel::Name
);
394 popup
.addSeparator();
396 QAction
* activatedAction
= popup
.exec(header()->mapToGlobal(pos
));
397 if (activatedAction
!= 0) {
398 const bool show
= activatedAction
->isChecked();
399 const int columnIndex
= activatedAction
->data().toInt();
401 KFileItemDelegate::InformationList list
= m_dolphinViewController
->view()->additionalInfo();
402 const KFileItemDelegate::Information info
= infoForColumn(columnIndex
);
404 Q_ASSERT(!list
.contains(info
));
407 Q_ASSERT(list
.contains(info
));
408 const int index
= list
.indexOf(info
);
409 list
.removeAt(index
);
412 m_dolphinViewController
->indicateAdditionalInfoChange(list
);
413 setColumnHidden(columnIndex
, !show
);
418 void DolphinDetailsView::updateColumnVisibility()
420 QHeaderView
* headerView
= header();
421 disconnect(headerView
, SIGNAL(sectionMoved(int, int, int)),
422 this, SLOT(saveColumnPositions()));
424 const DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
425 const QList
<int> columnPositions
= settings
->columnPositions();
427 const KFileItemDelegate::InformationList list
= m_dolphinViewController
->view()->additionalInfo();
428 for (int i
= DolphinModel::Name
; i
< DolphinModel::ExtraColumnCount
; ++i
) {
429 const KFileItemDelegate::Information info
= infoForColumn(i
);
430 const bool hide
= !list
.contains(info
) && (i
!= DolphinModel::Name
);
431 if (isColumnHidden(i
) != hide
) {
432 setColumnHidden(i
, hide
);
435 // If the list columnPositions has been written by an older Dolphin version,
436 // its length might be smaller than DolphinModel::ExtraColumnCount. Therefore,
437 // we have to check if item number i exists before accessing it.
438 if (i
< columnPositions
.length()) {
439 const int position
= columnPositions
[i
];
441 // The position might be outside the correct range if the list columnPositions
442 // has been written by a newer Dolphin version with more columns.
443 if (position
< DolphinModel::ExtraColumnCount
) {
444 const int from
= headerView
->visualIndex(i
);
445 headerView
->moveSection(from
, position
);
452 connect(headerView
, SIGNAL(sectionMoved(int, int, int)),
453 this, SLOT(saveColumnPositions()));
456 void DolphinDetailsView::resizeColumns()
458 // Using the resize mode QHeaderView::ResizeToContents is too slow (it takes
459 // around 3 seconds for each (!) resize operation when having > 10000 items).
460 // This gets a problem especially when opening large directories, where several
461 // resize operations are received for showing the currently available items during
462 // loading (the application hangs around 20 seconds when loading > 10000 items).
464 QHeaderView
* headerView
= header();
465 const int rowCount
= model()->rowCount();
466 QFontMetrics
fontMetrics(viewport()->font());
468 // Define the maximum number of rows, where an exact (but expensive) calculation
469 // of the widths is done.
470 const int maxRowCount
= 200;
472 // Calculate the required with for each column and store it in columnWidth[]
473 int columnWidth
[DolphinModel::ExtraColumnCount
];
475 for (int column
= 0; column
< DolphinModel::ExtraColumnCount
; ++column
) {
476 columnWidth
[column
] = 0;
477 if (!isColumnHidden(column
)) {
478 // Calculate the required width for the current column and consider only
479 // up to maxRowCount columns for performance reasons
481 const QAbstractProxyModel
* proxyModel
= qobject_cast
<const QAbstractProxyModel
*>(model());
482 const KDirModel
* dirModel
= qobject_cast
<const KDirModel
*>(proxyModel
->sourceModel());
484 const int count
= qMin(rowCount
, maxRowCount
);
485 const QStyleOptionViewItem option
= viewOptions();
486 for (int row
= 0; row
< count
; ++row
) {
487 const QModelIndex index
= dirModel
->index(row
, column
);
488 const int width
= itemDelegate()->sizeHint(option
, index
).width();
489 if (width
> columnWidth
[column
]) {
490 columnWidth
[column
] = width
;
495 // Assure that the required width is sufficient for the header too
496 const int logicalIndex
= headerView
->logicalIndex(column
);
497 const QString headline
= model()->headerData(logicalIndex
, Qt::Horizontal
).toString();
498 // TODO: check Qt-sources which left/right-gap is used for the headlines
499 const int headlineWidth
= fontMetrics
.width(headline
) + 20;
501 columnWidth
[column
] = qMax(columnWidth
[column
], headlineWidth
);
505 // Resize all columns except of the name column
506 int requiredWidth
= 0;
507 for (int column
= KDirModel::Size
; column
< DolphinModel::ExtraColumnCount
; ++column
) {
508 if (!isColumnHidden(column
)) {
509 requiredWidth
+= columnWidth
[column
];
510 headerView
->resizeSection(column
, columnWidth
[column
]);
514 // Resize the name column in a way that the whole available width is used
515 columnWidth
[KDirModel::Name
] = viewport()->width() - requiredWidth
;
517 const int minNameWidth
= 300;
518 if (columnWidth
[KDirModel::Name
] < minNameWidth
) {
519 columnWidth
[KDirModel::Name
] = minNameWidth
;
521 if ((rowCount
> 0) && (rowCount
< maxRowCount
)) {
522 // Try to decrease the name column width without clipping any text
523 const int nameWidth
= sizeHintForColumn(DolphinModel::Name
);
524 if (nameWidth
+ requiredWidth
<= viewport()->width()) {
525 columnWidth
[KDirModel::Name
] = viewport()->width() - requiredWidth
;
526 } else if (nameWidth
< minNameWidth
) {
527 columnWidth
[KDirModel::Name
] = nameWidth
;
532 headerView
->resizeSection(KDirModel::Name
, columnWidth
[KDirModel::Name
]);
535 void DolphinDetailsView::saveColumnPositions()
537 QList
<int> columnPositions
;
538 for (int i
= DolphinModel::Name
; i
< DolphinModel::ExtraColumnCount
; ++i
) {
539 columnPositions
.append(header()->visualIndex(i
));
542 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
543 settings
->setColumnPositions(columnPositions
);
546 void DolphinDetailsView::slotHeaderSectionResized(int logicalIndex
, int oldSize
, int newSize
)
548 Q_UNUSED(logicalIndex
);
551 // If the user changes the size of the headers, the autoresize feature should be
552 // turned off. As there is no dedicated interface to find out whether the header
553 // section has been resized by the user or by a resize event, another approach is used.
554 // Attention: Take care when changing the if-condition to verify that there is no
555 // regression in combination with bug 178630 (see fix in comment #8).
556 if ((QApplication::mouseButtons() & Qt::LeftButton
) && header()->underMouse()) {
557 disableAutoResizing();
560 adjustMaximumSizeForEditing(currentIndex());
563 void DolphinDetailsView::slotActivationChanged(bool active
)
565 setAlternatingRowColors(active
);
568 void DolphinDetailsView::disableAutoResizing()
570 m_autoResize
= false;
573 void DolphinDetailsView::requestActivation()
575 m_dolphinViewController
->requestActivation();
578 void DolphinDetailsView::slotGlobalSettingsChanged(int category
)
582 const DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
583 Q_ASSERT(settings
!= 0);
584 if (settings
->useSystemFont()) {
585 m_font
= KGlobalSettings::generalFont();
587 // Disconnect then reconnect, since the settings have been changed, the connection requirements may have also.
588 disconnect(this, SIGNAL(clicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
589 disconnect(this, SIGNAL(doubleClicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
590 if (KGlobalSettings::singleClick()) {
591 connect(this, SIGNAL(clicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
593 connect(this, SIGNAL(doubleClicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
598 void DolphinDetailsView::setFoldersExpandable(bool expandable
)
601 // Collapse all expanded folders, as QTreeView::setItemsExpandable(false)
602 // does not do this task
603 const int rowCount
= model()->rowCount();
604 for (int row
= 0; row
< rowCount
; ++row
) {
605 setExpanded(model()->index(row
, 0), false);
608 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
609 settings
->setExpandableFolders(expandable
);
610 setRootIsDecorated(expandable
);
611 setItemsExpandable(expandable
);
613 // The width of the space which is available for editing has changed
614 // because of the (dis)appearance of the expanding toggles
615 adjustMaximumSizeForEditing(currentIndex());
618 void DolphinDetailsView::slotExpanded(const QModelIndex
& index
)
620 KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
621 if (!item
.isNull()) {
622 m_expandedUrls
.insert(item
.url());
626 void DolphinDetailsView::slotCollapsed(const QModelIndex
& index
)
628 KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
629 if (!item
.isNull()) {
630 m_expandedUrls
.remove(item
.url());
634 void DolphinDetailsView::removeExpandedIndexes(const QModelIndex
& parent
, int start
, int end
)
636 if (m_expandedUrls
.isEmpty()) {
640 for (int row
= start
; row
<= end
; row
++) {
641 const QModelIndex index
= model()->index(row
, 0, parent
);
642 if (isExpanded(index
)) {
643 slotCollapsed(index
);
644 removeExpandedIndexes(index
, 0, model()->rowCount(index
) - 1);
649 void DolphinDetailsView::updateDecorationSize(bool showPreview
)
651 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
652 const int iconSize
= showPreview
? settings
->previewSize() : settings
->iconSize();
653 setIconSize(QSize(iconSize
, iconSize
));
654 m_decorationSize
= QSize(iconSize
, iconSize
);
656 if (m_extensionsFactory
) {
657 // The old maximumSize used by KFileItemDelegate is not valid any more after the icon size change.
658 // It must be discarded before doItemsLayout() is called (see bug 234600).
659 m_extensionsFactory
->fileItemDelegate()->setMaximumSize(QSize());
664 // Calculate the new maximumSize for KFileItemDelegate after the icon size change.
665 QModelIndex current
= currentIndex();
666 if (current
.isValid()) {
667 adjustMaximumSizeForEditing(current
);
671 KFileItemDelegate::Information
DolphinDetailsView::infoForColumn(int columnIndex
) const
673 return AdditionalInfoAccessor::instance().keyForColumn(columnIndex
);
676 void DolphinDetailsView::adjustMaximumSizeForEditing(const QModelIndex
& index
)
678 // Make sure that the full width of the "Name" column is available for "Rename Inline".
679 // Before we do that, we have to check if m_extensionsFactory has been initialised because
680 // it is possible that we end up here before the constructor is finished (see bug 257035)
681 if (m_extensionsFactory
) {
682 m_extensionsFactory
->fileItemDelegate()->setMaximumSize(QTreeView::visualRect(index
).size());
686 #include "dolphindetailsview.moc"