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()));
141 viewport()->installEventFilter(this);
143 connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
144 this, SLOT(slotGlobalSettingsChanged(int)));
146 m_expandableFoldersAction
= new QAction(i18nc("@option:check", "Expandable Folders"), this);
147 m_expandableFoldersAction
->setCheckable(true);
148 connect(m_expandableFoldersAction
, SIGNAL(toggled(bool)),
149 this, SLOT(setFoldersExpandable(bool)));
151 connect(this, SIGNAL(expanded(const QModelIndex
&)), this, SLOT(slotExpanded(const QModelIndex
&)));
152 connect(this, SIGNAL(collapsed(const QModelIndex
&)), this, SLOT(slotCollapsed(const QModelIndex
&)));
154 updateDecorationSize(view
->showPreview());
156 m_extensionsFactory
= new ViewExtensionsFactory(this, dolphinViewController
, viewModeController
);
157 m_extensionsFactory
->fileItemDelegate()->setMinimizedNameColumn(true);
159 KDirLister
*dirLister
= qobject_cast
<KDirModel
*>(proxyModel
->sourceModel())->dirLister();
160 connect(dirLister
, SIGNAL(newItems(KFileItemList
)), this, SLOT(resizeColumns()));
162 // setFocus() must be called after m_extensionsFactory is initialised (see bug 240374).
166 DolphinDetailsView::~DolphinDetailsView()
170 QSet
<KUrl
> DolphinDetailsView::expandedUrls() const
172 return m_expandedUrls
;
175 bool DolphinDetailsView::event(QEvent
* event
)
177 if (event
->type() == QEvent::Polish
) {
178 header()->setResizeMode(QHeaderView::Interactive
);
179 updateColumnVisibility();
182 return DolphinTreeView::event(event
);
185 QStyleOptionViewItem
DolphinDetailsView::viewOptions() const
187 QStyleOptionViewItem viewOptions
= DolphinTreeView::viewOptions();
188 viewOptions
.font
= m_font
;
189 viewOptions
.fontMetrics
= QFontMetrics(m_font
);
190 viewOptions
.showDecorationSelected
= true;
191 viewOptions
.decorationSize
= m_decorationSize
;
195 void DolphinDetailsView::contextMenuEvent(QContextMenuEvent
* event
)
197 DolphinTreeView::contextMenuEvent(event
);
199 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
200 m_expandableFoldersAction
->setChecked(settings
->expandableFolders());
201 m_dolphinViewController
->triggerContextMenuRequest(event
->pos(),
202 QList
<QAction
*>() << m_expandableFoldersAction
);
205 void DolphinDetailsView::mousePressEvent(QMouseEvent
* event
)
207 m_dolphinViewController
->requestActivation();
209 DolphinTreeView::mousePressEvent(event
);
211 const QModelIndex index
= indexAt(event
->pos());
212 if (!index
.isValid() || (index
.column() != DolphinModel::Name
)) {
213 // The mouse press is done somewhere outside the filename column
214 if (QApplication::mouseButtons() & Qt::MidButton
) {
215 m_dolphinViewController
->replaceUrlByClipboard();
220 void DolphinDetailsView::startDrag(Qt::DropActions supportedActions
)
222 DragAndDropHelper::instance().startDrag(this, supportedActions
, m_dolphinViewController
);
223 DolphinTreeView::startDrag(supportedActions
);
226 void DolphinDetailsView::dragEnterEvent(QDragEnterEvent
* event
)
228 event
->acceptProposedAction();
229 DolphinTreeView::dragEnterEvent(event
);
232 void DolphinDetailsView::dragMoveEvent(QDragMoveEvent
* event
)
234 DolphinTreeView::dragMoveEvent(event
);
235 event
->acceptProposedAction();
238 void DolphinDetailsView::dropEvent(QDropEvent
* event
)
240 const QModelIndex index
= indexAt(event
->pos());
242 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
243 item
= m_dolphinViewController
->itemForIndex(index
);
245 m_dolphinViewController
->indicateDroppedUrls(item
, m_viewModeController
->url(), event
);
246 DolphinTreeView::dropEvent(event
);
249 void DolphinDetailsView::keyPressEvent(QKeyEvent
* event
)
251 DolphinTreeView::keyPressEvent(event
);
252 m_dolphinViewController
->handleKeyPressEvent(event
);
255 void DolphinDetailsView::resizeEvent(QResizeEvent
* event
)
257 DolphinTreeView::resizeEvent(event
);
263 void DolphinDetailsView::wheelEvent(QWheelEvent
* event
)
265 const int step
= m_decorationSize
.height();
266 verticalScrollBar()->setSingleStep(step
);
267 DolphinTreeView::wheelEvent(event
);
270 void DolphinDetailsView::currentChanged(const QModelIndex
& current
, const QModelIndex
& previous
)
272 m_extensionsFactory
->handleCurrentIndexChange(current
, previous
);
273 DolphinTreeView::currentChanged(current
, previous
);
275 // If folders are expanded, the width which is available for editing may have changed
276 // because it depends on the level of the current item in the folder hierarchy.
277 adjustMaximumSizeForEditing(current
);
280 bool DolphinDetailsView::eventFilter(QObject
* watched
, QEvent
* event
)
282 if ((watched
== viewport()) && (event
->type() == QEvent::Leave
)) {
283 // If the mouse is above an item and moved very fast outside the widget,
284 // no viewportEntered() signal might be emitted although the mouse has been moved
285 // above the viewport.
286 m_dolphinViewController
->emitViewportEntered();
289 return DolphinTreeView::eventFilter(watched
, event
);
292 QRect
DolphinDetailsView::visualRect(const QModelIndex
& index
) const
294 QRect rect
= DolphinTreeView::visualRect(index
);
295 const KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
296 if (!item
.isNull()) {
297 const int width
= DolphinFileItemDelegate::nameColumnWidth(item
.text(), viewOptions());
299 if (width
< rect
.width()) {
300 rect
.setWidth(width
);
307 bool DolphinDetailsView::acceptsDrop(const QModelIndex
& index
) const
309 if (index
.isValid() && (index
.column() == DolphinModel::Name
)) {
310 // Accept drops above directories
311 const KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
312 return !item
.isNull() && item
.isDir();
318 void DolphinDetailsView::rowsAboutToBeRemoved(const QModelIndex
&parent
, int start
, int end
)
320 removeExpandedIndexes(parent
, start
, end
);
321 DolphinTreeView::rowsAboutToBeRemoved(parent
, start
, end
);
324 void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting
)
326 header()->setSortIndicator(sorting
, header()->sortIndicatorOrder());
329 void DolphinDetailsView::setSortIndicatorOrder(Qt::SortOrder sortOrder
)
331 header()->setSortIndicator(header()->sortIndicatorSection(), sortOrder
);
334 void DolphinDetailsView::synchronizeSortingState(int column
)
336 // The sorting has already been changed in QTreeView if this slot is
337 // invoked, but Dolphin is not informed about this.
338 DolphinView::Sorting sorting
= DolphinSortFilterProxyModel::sortingForColumn(column
);
339 const Qt::SortOrder sortOrder
= header()->sortIndicatorOrder();
340 m_dolphinViewController
->indicateSortingChange(sorting
);
341 m_dolphinViewController
->indicateSortOrderChange(sortOrder
);
344 void DolphinDetailsView::slotEntered(const QModelIndex
& index
)
346 if (index
.column() == DolphinModel::Name
) {
347 m_dolphinViewController
->emitItemEntered(index
);
349 m_dolphinViewController
->emitViewportEntered();
353 void DolphinDetailsView::setZoomLevel(int level
)
355 const int size
= ZoomLevelInfo::iconSizeForZoomLevel(level
);
356 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
358 const bool showPreview
= m_dolphinViewController
->view()->showPreview();
360 settings
->setPreviewSize(size
);
362 settings
->setIconSize(size
);
365 updateDecorationSize(showPreview
);
368 void DolphinDetailsView::slotShowPreviewChanged()
370 const DolphinView
* view
= m_dolphinViewController
->view();
371 updateDecorationSize(view
->showPreview());
374 void DolphinDetailsView::configureSettings(const QPoint
& pos
)
377 popup
.addTitle(i18nc("@title:menu", "Columns"));
379 // Add checkbox items for each column
380 QHeaderView
* headerView
= header();
381 const int columns
= model()->columnCount();
382 for (int i
= 0; i
< columns
; ++i
) {
383 const int logicalIndex
= headerView
->logicalIndex(i
);
384 const QString text
= model()->headerData(logicalIndex
, Qt::Horizontal
).toString();
385 if (!text
.isEmpty()) {
386 QAction
* action
= popup
.addAction(text
);
387 action
->setCheckable(true);
388 action
->setChecked(!headerView
->isSectionHidden(logicalIndex
));
389 action
->setData(logicalIndex
);
390 action
->setEnabled(logicalIndex
!= DolphinModel::Name
);
393 popup
.addSeparator();
395 QAction
* activatedAction
= popup
.exec(header()->mapToGlobal(pos
));
396 if (activatedAction
!= 0) {
397 const bool show
= activatedAction
->isChecked();
398 const int columnIndex
= activatedAction
->data().toInt();
400 KFileItemDelegate::InformationList list
= m_dolphinViewController
->view()->additionalInfo();
401 const KFileItemDelegate::Information info
= infoForColumn(columnIndex
);
403 Q_ASSERT(!list
.contains(info
));
406 Q_ASSERT(list
.contains(info
));
407 const int index
= list
.indexOf(info
);
408 list
.removeAt(index
);
411 m_dolphinViewController
->indicateAdditionalInfoChange(list
);
412 setColumnHidden(columnIndex
, !show
);
417 void DolphinDetailsView::updateColumnVisibility()
419 QHeaderView
* headerView
= header();
420 disconnect(headerView
, SIGNAL(sectionMoved(int, int, int)),
421 this, SLOT(saveColumnPositions()));
423 const DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
424 const QList
<int> columnPositions
= settings
->columnPositions();
426 const KFileItemDelegate::InformationList list
= m_dolphinViewController
->view()->additionalInfo();
427 for (int i
= DolphinModel::Name
; i
< DolphinModel::ExtraColumnCount
; ++i
) {
428 const KFileItemDelegate::Information info
= infoForColumn(i
);
429 const bool hide
= !list
.contains(info
) && (i
!= DolphinModel::Name
);
430 if (isColumnHidden(i
) != hide
) {
431 setColumnHidden(i
, hide
);
434 // If the list columnPositions has been written by an older Dolphin version,
435 // its length might be smaller than DolphinModel::ExtraColumnCount. Therefore,
436 // we have to check if item number i exists before accessing it.
437 if (i
< columnPositions
.length()) {
438 const int position
= columnPositions
[i
];
440 // The position might be outside the correct range if the list columnPositions
441 // has been written by a newer Dolphin version with more columns.
442 if (position
< DolphinModel::ExtraColumnCount
) {
443 const int from
= headerView
->visualIndex(i
);
444 headerView
->moveSection(from
, position
);
451 connect(headerView
, SIGNAL(sectionMoved(int, int, int)),
452 this, SLOT(saveColumnPositions()));
455 void DolphinDetailsView::resizeColumns()
457 // Using the resize mode QHeaderView::ResizeToContents is too slow (it takes
458 // around 3 seconds for each (!) resize operation when having > 10000 items).
459 // This gets a problem especially when opening large directories, where several
460 // resize operations are received for showing the currently available items during
461 // loading (the application hangs around 20 seconds when loading > 10000 items).
463 QHeaderView
* headerView
= header();
464 const int rowCount
= model()->rowCount();
465 QFontMetrics
fontMetrics(viewport()->font());
467 // Define the maximum number of rows, where an exact (but expensive) calculation
468 // of the widths is done.
469 const int maxRowCount
= 200;
471 // Calculate the required with for each column and store it in columnWidth[]
472 int columnWidth
[DolphinModel::ExtraColumnCount
];
474 for (int column
= 0; column
< DolphinModel::ExtraColumnCount
; ++column
) {
475 columnWidth
[column
] = 0;
476 if (!isColumnHidden(column
)) {
477 // Calculate the required width for the current column and consider only
478 // up to maxRowCount columns for performance reasons
480 const QAbstractProxyModel
* proxyModel
= qobject_cast
<const QAbstractProxyModel
*>(model());
481 const KDirModel
* dirModel
= qobject_cast
<const KDirModel
*>(proxyModel
->sourceModel());
483 const int count
= qMin(rowCount
, maxRowCount
);
484 const QStyleOptionViewItem option
= viewOptions();
485 for (int row
= 0; row
< count
; ++row
) {
486 const QModelIndex index
= dirModel
->index(row
, column
);
487 const int width
= itemDelegate()->sizeHint(option
, index
).width();
488 if (width
> columnWidth
[column
]) {
489 columnWidth
[column
] = width
;
494 // Assure that the required width is sufficient for the header too
495 const int logicalIndex
= headerView
->logicalIndex(column
);
496 const QString headline
= model()->headerData(logicalIndex
, Qt::Horizontal
).toString();
497 // TODO: check Qt-sources which left/right-gap is used for the headlines
498 const int headlineWidth
= fontMetrics
.width(headline
) + 20;
500 columnWidth
[column
] = qMax(columnWidth
[column
], headlineWidth
);
504 // Resize all columns except of the name column
505 int requiredWidth
= 0;
506 for (int column
= KDirModel::Size
; column
< DolphinModel::ExtraColumnCount
; ++column
) {
507 if (!isColumnHidden(column
)) {
508 requiredWidth
+= columnWidth
[column
];
509 headerView
->resizeSection(column
, columnWidth
[column
]);
513 // Resize the name column in a way that the whole available width is used
514 columnWidth
[KDirModel::Name
] = viewport()->width() - requiredWidth
;
516 const int minNameWidth
= 300;
517 if (columnWidth
[KDirModel::Name
] < minNameWidth
) {
518 columnWidth
[KDirModel::Name
] = minNameWidth
;
520 if ((rowCount
> 0) && (rowCount
< maxRowCount
)) {
521 // Try to decrease the name column width without clipping any text
522 const int nameWidth
= sizeHintForColumn(DolphinModel::Name
);
523 if (nameWidth
+ requiredWidth
<= viewport()->width()) {
524 columnWidth
[KDirModel::Name
] = viewport()->width() - requiredWidth
;
525 } else if (nameWidth
< minNameWidth
) {
526 columnWidth
[KDirModel::Name
] = nameWidth
;
531 headerView
->resizeSection(KDirModel::Name
, columnWidth
[KDirModel::Name
]);
534 void DolphinDetailsView::saveColumnPositions()
536 QList
<int> columnPositions
;
537 for (int i
= DolphinModel::Name
; i
< DolphinModel::ExtraColumnCount
; ++i
) {
538 columnPositions
.append(header()->visualIndex(i
));
541 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
542 settings
->setColumnPositions(columnPositions
);
545 void DolphinDetailsView::slotHeaderSectionResized(int logicalIndex
, int oldSize
, int newSize
)
547 Q_UNUSED(logicalIndex
);
550 // If the user changes the size of the headers, the autoresize feature should be
551 // turned off. As there is no dedicated interface to find out whether the header
552 // section has been resized by the user or by a resize event, another approach is used.
553 // Attention: Take care when changing the if-condition to verify that there is no
554 // regression in combination with bug 178630 (see fix in comment #8).
555 if ((QApplication::mouseButtons() & Qt::LeftButton
) && header()->underMouse()) {
556 disableAutoResizing();
559 adjustMaximumSizeForEditing(currentIndex());
562 void DolphinDetailsView::slotActivationChanged(bool active
)
564 setAlternatingRowColors(active
);
567 void DolphinDetailsView::disableAutoResizing()
569 m_autoResize
= false;
572 void DolphinDetailsView::requestActivation()
574 m_dolphinViewController
->requestActivation();
577 void DolphinDetailsView::slotGlobalSettingsChanged(int category
)
581 const DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
582 Q_ASSERT(settings
!= 0);
583 if (settings
->useSystemFont()) {
584 m_font
= KGlobalSettings::generalFont();
586 // Disconnect then reconnect, since the settings have been changed, the connection requirements may have also.
587 disconnect(this, SIGNAL(clicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
588 disconnect(this, SIGNAL(doubleClicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
589 if (KGlobalSettings::singleClick()) {
590 connect(this, SIGNAL(clicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
592 connect(this, SIGNAL(doubleClicked(QModelIndex
)), m_dolphinViewController
, SLOT(triggerItem(QModelIndex
)));
597 void DolphinDetailsView::setFoldersExpandable(bool expandable
)
600 // Collapse all expanded folders, as QTreeView::setItemsExpandable(false)
601 // does not do this task
602 const int rowCount
= model()->rowCount();
603 for (int row
= 0; row
< rowCount
; ++row
) {
604 setExpanded(model()->index(row
, 0), false);
607 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
608 settings
->setExpandableFolders(expandable
);
609 setRootIsDecorated(expandable
);
610 setItemsExpandable(expandable
);
612 // The width of the space which is available for editing has changed
613 // because of the (dis)appearance of the expanding toggles
614 adjustMaximumSizeForEditing(currentIndex());
617 void DolphinDetailsView::slotExpanded(const QModelIndex
& index
)
619 KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
620 if (!item
.isNull()) {
621 m_expandedUrls
.insert(item
.url());
625 void DolphinDetailsView::slotCollapsed(const QModelIndex
& index
)
627 KFileItem item
= m_dolphinViewController
->itemForIndex(index
);
628 if (!item
.isNull()) {
629 m_expandedUrls
.remove(item
.url());
633 void DolphinDetailsView::removeExpandedIndexes(const QModelIndex
& parent
, int start
, int end
)
635 if (m_expandedUrls
.isEmpty()) {
639 for (int row
= start
; row
<= end
; row
++) {
640 const QModelIndex index
= model()->index(row
, 0, parent
);
641 if (isExpanded(index
)) {
642 slotCollapsed(index
);
643 removeExpandedIndexes(index
, 0, model()->rowCount(index
) - 1);
648 void DolphinDetailsView::updateDecorationSize(bool showPreview
)
650 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
651 const int iconSize
= showPreview
? settings
->previewSize() : settings
->iconSize();
652 setIconSize(QSize(iconSize
, iconSize
));
653 m_decorationSize
= QSize(iconSize
, iconSize
);
655 if (m_extensionsFactory
) {
656 // The old maximumSize used by KFileItemDelegate is not valid any more after the icon size change.
657 // It must be discarded before doItemsLayout() is called (see bug 234600).
658 m_extensionsFactory
->fileItemDelegate()->setMaximumSize(QSize());
663 // Calculate the new maximumSize for KFileItemDelegate after the icon size change.
664 QModelIndex current
= currentIndex();
665 if (current
.isValid()) {
666 adjustMaximumSizeForEditing(current
);
670 KFileItemDelegate::Information
DolphinDetailsView::infoForColumn(int columnIndex
) const
672 return AdditionalInfoAccessor::instance().keyForColumn(columnIndex
);
675 void DolphinDetailsView::adjustMaximumSizeForEditing(const QModelIndex
& index
)
677 // Make sure that the full width of the "Name" column is available for "Rename Inline".
678 // Before we do that, we have to check if m_extensionsFactory has been initialised because
679 // it is possible that we end up here before the constructor is finished (see bug 257035)
680 if (m_extensionsFactory
) {
681 m_extensionsFactory
->fileItemDelegate()->setMaximumSize(QTreeView::visualRect(index
).size());
685 #include "dolphindetailsview.moc"