1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "dolphindetailsview.h"
26 #include <qclipboard.h>
29 #include <Q3ValueList>
31 #include <QDragMoveEvent>
33 #include <QResizeEvent>
34 #include <QMouseEvent>
36 #include <QPaintEvent>
37 #include <QStyleOptionFocusRect>
39 #include <kglobalsettings.h>
40 #include <kicontheme.h>
41 #include <qscrollbar.h>
46 #include "dolphinview.h"
47 #include "viewproperties.h"
49 #include "kiconeffect.h"
50 #include "dolphinsettings.h"
51 #include "dolphinstatusbar.h"
52 #include "detailsmodesettings.h"
54 DolphinDetailsView::DolphinDetailsView(DolphinView
* parent
) :
55 KFileDetailView(parent
),
56 m_dolphinView(parent
),
61 m_resizeTimer
= new QTimer(this);
62 connect(m_resizeTimer
, SIGNAL(timeout()),
63 this, SLOT(updateColumnsWidth()));
66 setSelectionMode(KFile::Extended
);
67 setHScrollBarMode(Q3ScrollView::AlwaysOff
);
69 setColumnAlignment(SizeColumn
, Qt::AlignRight
);
70 for (int i
= DateColumn
; i
<= GroupColumn
; ++i
) {
71 setColumnAlignment(i
, Qt::AlignHCenter
);
74 Dolphin
& dolphin
= Dolphin::mainWin();
76 connect(this, SIGNAL(onItem(Q3ListViewItem
*)),
77 this, SLOT(slotOnItem(Q3ListViewItem
*)));
78 connect(this, SIGNAL(onViewport()),
79 this, SLOT(slotOnViewport()));
80 connect(this, SIGNAL(contextMenuRequested(Q3ListViewItem
*, const QPoint
&, int)),
81 this, SLOT(slotContextMenuRequested(Q3ListViewItem
*, const QPoint
&, int)));
82 connect(this, SIGNAL(selectionChanged()),
83 &dolphin
, SLOT(slotSelectionChanged()));
84 connect(&dolphin
, SIGNAL(activeViewChanged()),
85 this, SLOT(slotActivationUpdate()));
86 connect(this, SIGNAL(itemRenamed(Q3ListViewItem
*, const QString
&, int)),
87 this, SLOT(slotItemRenamed(Q3ListViewItem
*, const QString
&, int)));
88 connect(this, SIGNAL(dropped(QDropEvent
*, const KUrl::List
&, const KUrl
&)),
89 parent
, SLOT(slotURLListDropped(QDropEvent
*, const KUrl::List
&, const KUrl
&)));
91 QClipboard
* clipboard
= QApplication::clipboard();
92 connect(clipboard
, SIGNAL(dataChanged()),
93 this, SLOT(slotUpdateDisabledItems()));
95 Q3Header
* viewHeader
= header();
96 viewHeader
->setResizeEnabled(false);
97 viewHeader
->setMovingEnabled(false);
98 connect(viewHeader
, SIGNAL(clicked(int)),
99 this, SLOT(slotHeaderClicked(int)));
101 setMouseTracking(true);
102 setDefaultRenameAction(Q3ListView::Accept
);
107 DolphinDetailsView::~DolphinDetailsView()
113 void DolphinDetailsView::beginItemUpdates()
117 void DolphinDetailsView::endItemUpdates()
119 updateDisabledItems();
121 // Restore the current item. Use the information stored in the history if
122 // available. Otherwise use the first item as current item.
124 const KFileListViewItem
* item
= static_cast<const KFileListViewItem
*>(firstChild());
126 setCurrentItem(item
->fileInfo());
130 const Q3ValueList
<URLNavigator::HistoryElem
> history
= m_dolphinView
->urlHistory(index
);
131 if (!history
.isEmpty()) {
132 KFileView
* fileView
= static_cast<KFileView
*>(this);
133 fileView
->setCurrentItem(history
[index
].currentFileName());
134 setContentsPos(history
[index
].contentsX(), history
[index
].contentsY());
137 updateColumnsWidth();
140 void DolphinDetailsView::insertItem(KFileItem
* fileItem
)
142 KFileView::insertItem(fileItem
);
144 DolphinListViewItem
* item
= new DolphinListViewItem(static_cast<Q3ListView
*>(this), fileItem
);
146 QDir::SortFlags spec
= KFileView::sorting();
147 if (spec
& QDir::Time
) {
148 item
->setKey(sortingKey(fileItem
->time(KIO::UDS_MODIFICATION_TIME
),
152 else if (spec
& QDir::Size
) {
153 item
->setKey(sortingKey(fileItem
->size(), fileItem
->isDir(), spec
));
156 item
->setKey(sortingKey(fileItem
->text(), fileItem
->isDir(), spec
));
159 fileItem
->setExtraData(this, item
);
162 bool DolphinDetailsView::isOnFilename(const Q3ListViewItem
* item
, const QPoint
& pos
) const
164 const QPoint
absPos(mapToGlobal(QPoint(0, 0)));
165 return (pos
.x() - absPos
.x()) <= filenameWidth(item
);
168 void DolphinDetailsView::refreshSettings()
170 const DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
171 assert(settings
!= 0);
173 if (!settings
->showGroup()) {
174 removeColumn(GroupColumn
);
176 if (!settings
->showOwner()) {
177 removeColumn(OwnerColumn
);
179 if (!settings
->showPermissions()) {
180 removeColumn(PermissionsColumn
);
182 if (!settings
->showDate()) {
183 removeColumn(DateColumn
);
186 QFont
adjustedFont(font());
187 adjustedFont
.setFamily(settings
->fontFamily());
188 adjustedFont
.setPointSize(settings
->fontSize());
189 setFont(adjustedFont
);
194 void DolphinDetailsView::zoomIn()
196 if (isZoomInPossible()) {
197 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
198 switch (settings
->iconSize()) {
199 case K3Icon::SizeSmall
: settings
->setIconSize(K3Icon::SizeMedium
); break;
200 case K3Icon::SizeMedium
: settings
->setIconSize(K3Icon::SizeLarge
); break;
201 default: assert(false); break;
203 ItemEffectsManager::zoomIn();
207 void DolphinDetailsView::zoomOut()
209 if (isZoomOutPossible()) {
210 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
211 switch (settings
->iconSize()) {
212 case K3Icon::SizeLarge
: settings
->setIconSize(K3Icon::SizeMedium
); break;
213 case K3Icon::SizeMedium
: settings
->setIconSize(K3Icon::SizeSmall
); break;
214 default: assert(false); break;
216 ItemEffectsManager::zoomOut();
220 bool DolphinDetailsView::isZoomInPossible() const
222 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
223 return settings
->iconSize() < K3Icon::SizeLarge
;
226 bool DolphinDetailsView::isZoomOutPossible() const
228 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
229 return settings
->iconSize() > K3Icon::SizeSmall
;
232 void DolphinDetailsView::resizeContents(int width
, int height
)
234 KFileDetailView::resizeContents(width
, height
);
236 // When loading several 1000 items a punch of resize events
237 // drops in. As updating the column width is a quite expensive
238 // operation, this operation will be postponed until there is
239 // no resize event for at least 50 milliseconds.
240 m_resizeTimer
->stop();
241 m_resizeTimer
->start(50, true);
244 void DolphinDetailsView::slotOnItem(Q3ListViewItem
* item
)
246 if (isOnFilename(item
, QCursor::pos())) {
248 KFileItem
* fileItem
= static_cast<KFileListViewItem
*>(item
)->fileInfo();
249 m_dolphinView
->requestItemInfo(fileItem
->url());
252 resetActivatedItem();
256 void DolphinDetailsView::slotOnViewport()
258 resetActivatedItem();
259 m_dolphinView
->requestItemInfo(KUrl());
262 void DolphinDetailsView::setContextPixmap(void* context
,
263 const QPixmap
& pixmap
)
265 reinterpret_cast<KFileListViewItem
*>(context
)->setPixmap(0, pixmap
);
268 const QPixmap
* DolphinDetailsView::contextPixmap(void* context
)
270 return reinterpret_cast<KFileListViewItem
*>(context
)->pixmap(0);
273 void* DolphinDetailsView::firstContext()
275 return reinterpret_cast<void*>(firstChild());
278 void* DolphinDetailsView::nextContext(void* context
)
280 KFileListViewItem
* listViewItem
= reinterpret_cast<KFileListViewItem
*>(context
);
281 return reinterpret_cast<void*>(listViewItem
->nextSibling());
284 KFileItem
* DolphinDetailsView::contextFileInfo(void* context
)
286 return reinterpret_cast<KFileListViewItem
*>(context
)->fileInfo();
290 void DolphinDetailsView::contentsDragMoveEvent(QDragMoveEvent
* event
)
292 KFileDetailView::contentsDragMoveEvent(event
);
294 // If a dragging is done above a directory, show the icon as 'active' for
296 KFileListViewItem
* item
= static_cast<KFileListViewItem
*>(itemAt(event
->pos()));
298 bool showActive
= false;
300 const KFileItem
* fileInfo
= item
->fileInfo();
301 showActive
= (fileInfo
!= 0) && fileInfo
->isDir();
312 void DolphinDetailsView::resizeEvent(QResizeEvent
* event
)
314 KFileDetailView::resizeEvent(event
);
316 // When loading several 1000 items a punch of resize events
317 // drops in. As updating the column width is a quite expensive
318 // operation, this operation will be postponed until there is
319 // no resize event for at least 50 milliseconds.
320 m_resizeTimer
->stop();
321 m_resizeTimer
->start(50, true);
324 bool DolphinDetailsView::acceptDrag(QDropEvent
* event
) const
326 KUrl::List uriList
= KUrl::List::fromMimeData( event
->mimeData() );
327 bool accept
= !uriList
.isEmpty() &&
328 (event
->action() == QDropEvent::Copy
||
329 event
->action() == QDropEvent::Move
||
330 event
->action() == QDropEvent::Link
);
332 if (static_cast<const QWidget
*>(event
->source()) == this) {
333 KFileListViewItem
* item
= static_cast<KFileListViewItem
*>(itemAt(event
->pos()));
334 accept
= (item
!= 0);
336 KFileItem
* fileItem
= item
->fileInfo();
337 accept
= fileItem
->isDir();
345 void DolphinDetailsView::contentsDropEvent(QDropEvent
* event
)
347 // KFileDetailView::contentsDropEvent does not care whether the mouse
348 // cursor is above a filename or not, the destination URL is always
349 // the URL of the item. This is fixed here in a way that the destination
350 // URL is only the URL of the item if the cursor is above the filename.
351 const QPoint
pos(QCursor::pos());
352 const QPoint
viewportPos(viewport()->mapToGlobal(QPoint(0, 0)));
353 Q3ListViewItem
* item
= itemAt(QPoint(pos
.x() - viewportPos
.x(), pos
.y() - viewportPos
.y()));
354 if ((item
== 0) || ((item
!= 0) && isOnFilename(item
, pos
))) {
355 // dropping is done on the viewport or directly above a filename
356 KFileDetailView::contentsDropEvent(event
);
360 // Dropping is done above an item, but the mouse cursor is not above the file name.
361 // In this case the signals of the base implementation will be blocked and send
362 // in a corrected manner afterwards.
364 const bool block
= signalsBlocked();
366 KFileDetailView::contentsDropEvent(event
);
369 if (!acceptDrag(event
)) {
373 emit
dropped(event
, 0);
374 KUrl::List urls
= KUrl::List::fromMimeData( event
->mimeData() );
375 if (!urls
.isEmpty()) {
376 emit
dropped(event
, urls
, KUrl());
377 sig
->dropURLs(0, event
, urls
);
381 void DolphinDetailsView::contentsMousePressEvent(QMouseEvent
* event
)
389 // Swallow the base implementation of the mouse press event
390 // if the mouse cursor is not above the filename. This prevents
391 // that the item gets selected and simulates an equal usability
392 // like in the icon view.
393 const QPoint
pos(QCursor::pos());
394 const QPoint
viewportPos(viewport()->mapToGlobal(QPoint(0, 0)));
395 Q3ListViewItem
* item
= itemAt(QPoint(pos
.x() - viewportPos
.x(), pos
.y() - viewportPos
.y()));
396 if ((item
!= 0) && isOnFilename(item
, pos
)) {
397 KFileDetailView::contentsMousePressEvent(event
);
399 else if (event
->button() == Qt::LeftButton
) {
400 const Qt::KeyboardModifiers keyboardState
= QApplication::keyboardModifiers();
401 const bool isSelectionActive
= (keyboardState
& Qt::ShiftModifier
) ||
402 (keyboardState
& Qt::ControlModifier
);
403 if (!isSelectionActive
) {
407 assert(m_rubber
== 0);
408 m_rubber
= new QRect(event
->x(), event
->y(), 0, 0);
411 resetActivatedItem();
412 emit
signalRequestActivation();
414 m_dolphinView
->statusBar()->clear();
417 void DolphinDetailsView::contentsMouseMoveEvent(QMouseEvent
* event
)
424 KFileDetailView::contentsMouseMoveEvent(event
);
426 const QPoint
& pos
= event
->globalPos();
427 const QPoint viewportPos
= viewport()->mapToGlobal(QPoint(0, 0));
428 Q3ListViewItem
* item
= itemAt(QPoint(pos
.x() - viewportPos
.x(), pos
.y() - viewportPos
.y()));
429 if ((item
!= 0) && isOnFilename(item
, pos
)) {
433 resetActivatedItem();
437 void DolphinDetailsView::contentsMouseReleaseEvent(QMouseEvent
* event
)
445 if (m_scrollTimer
!= 0) {
446 disconnect(m_scrollTimer
, SIGNAL(timeout()),
447 this, SLOT(slotAutoScroll()));
448 m_scrollTimer
->stop();
449 delete m_scrollTimer
;
453 KFileDetailView::contentsMouseReleaseEvent(event
);
456 void DolphinDetailsView::paintEmptyArea(QPainter
* painter
, const QRect
& rect
)
458 if (m_dolphinView
->isActive()) {
459 KFileDetailView::paintEmptyArea(painter
, rect
);
462 const QBrush
brush(colorGroup().background());
463 painter
->fillRect(rect
, brush
);
467 void DolphinDetailsView::drawRubber()
469 // Parts of the following code have been taken
470 // from the class KonqBaseListViewWidget located in
471 // konqueror/listview/konq_listviewwidget.h of Konqueror.
472 // (Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
473 // 2001, 2002, 2004 Michael Brade <brade@kde.org>)
480 //p.setRasterOp(NotROP);
481 p
.setPen(QPen(Qt::color0
, 1));
482 p
.setBrush(Qt::NoBrush
);
484 QPoint
point(m_rubber
->x(), m_rubber
->y());
485 point
= contentsToViewport(point
);
486 QStyleOptionFocusRect option
;
487 option
.initFrom(this);
488 option
.rect
= QRect(point
.x(), point
.y(), m_rubber
->width(), m_rubber
->height());
489 style()->drawPrimitive(QStyle::PE_FrameFocusRect
, &option
, &p
);
493 void DolphinDetailsView::viewportPaintEvent(QPaintEvent
* paintEvent
)
496 KFileDetailView::viewportPaintEvent(paintEvent
);
500 void DolphinDetailsView::leaveEvent(QEvent
* event
)
502 KFileDetailView::leaveEvent(event
);
506 void DolphinDetailsView::slotActivationUpdate()
510 // TODO: there must be a simpler way to say
511 // "update all children"
512 const QList
<QObject
*> list
= children();
513 if (list
.isEmpty()) {
517 QListIterator
<QObject
*> it(list
);
519 while (it
.hasNext()) {
521 if (object
->inherits("QWidget")) {
522 QWidget
* widget
= static_cast<QWidget
*>(object
);
528 void DolphinDetailsView::slotContextMenuRequested(Q3ListViewItem
* item
,
532 KFileItem
* fileInfo
= 0;
533 if ((item
!= 0) && isOnFilename(item
, pos
)) {
534 fileInfo
= static_cast<KFileListViewItem
*>(item
)->fileInfo();
536 m_dolphinView
->openContextMenu(fileInfo
, pos
);
540 void DolphinDetailsView::slotUpdateDisabledItems()
542 updateDisabledItems();
545 void DolphinDetailsView::slotAutoScroll()
547 // Parts of the following code have been taken
548 // from the class KonqBaseListViewWidget located in
549 // konqueror/listview/konq_listviewwidget.h of Konqueror.
550 // (Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
551 // 2001, 2002, 2004 Michael Brade <brade@kde.org>)
553 const QPoint
pos(viewport()->mapFromGlobal(QCursor::pos()));
554 const QPoint
vc(viewportToContents(pos
));
556 if (vc
== m_rubber
->bottomRight()) {
562 m_rubber
->setBottomRight(vc
);
564 Q3ListViewItem
* item
= itemAt(QPoint(0,0));
566 const bool block
= signalsBlocked();
569 const QRect
rubber(m_rubber
->normalize());
570 const int bottom
= contentsY() + visibleHeight() - 1;
572 // select all items which intersect with the rubber, deselect all others
573 bool bottomReached
= false;
574 while ((item
!= 0) && !bottomReached
) {
575 QRect
rect(itemRect(item
));
576 rect
.setWidth(filenameWidth(item
));
577 rect
= QRect(viewportToContents(rect
.topLeft()),
578 viewportToContents(rect
.bottomRight()));
579 if (rect
.isValid() && (rect
.top() <= bottom
)) {
580 const KFileItem
* fileItem
= static_cast<KFileListViewItem
*>(item
)->fileInfo();
581 setSelected(fileItem
, rect
.intersects(rubber
));
582 item
= item
->itemBelow();
585 bottomReached
= true;
590 emit
selectionChanged();
594 // scroll the viewport if the top or bottom margin is reached
595 const int scrollMargin
= 40;
596 ensureVisible(vc
.x(), vc
.y(), scrollMargin
, scrollMargin
);
597 const bool scroll
= !QRect(scrollMargin
,
599 viewport()->width() - 2 * scrollMargin
,
600 viewport()->height() - 2 * scrollMargin
).contains(pos
);
602 if (m_scrollTimer
== 0) {
603 m_scrollTimer
= new QTimer( this );
604 connect(m_scrollTimer
, SIGNAL(timeout()),
605 this, SLOT(slotAutoScroll()));
606 m_scrollTimer
->start(100, false);
609 else if (m_scrollTimer
!= 0) {
610 disconnect(m_scrollTimer
, SIGNAL(timeout()),
611 this, SLOT(slotAutoScroll()));
612 m_scrollTimer
->stop();
613 delete m_scrollTimer
;
618 void DolphinDetailsView::updateColumnsWidth()
620 const int columnCount
= columns();
621 int requiredWidth
= 0;
622 for (int i
= 1; i
< columnCount
; ++i
) {
623 // When a directory contains no items, a minimum width for
624 // the column must be available, so that the header is readable.
625 // TODO: use header data instead of the hardcoded 64 value...
626 int columnWidth
= 64;
627 QFontMetrics
fontMetrics(font());
628 for (Q3ListViewItem
* item
= firstChild(); item
!= 0; item
= item
->nextSibling()) {
629 const int width
= item
->width(fontMetrics
, this, i
);
630 if (width
> columnWidth
) {
634 columnWidth
+= 16; // add custom margin
635 setColumnWidth(i
, columnWidth
);
636 requiredWidth
+= columnWidth
;
639 // resize the first column in a way that the
640 // whole available width is used
641 int firstColumnWidth
= visibleWidth() - requiredWidth
;
642 if (firstColumnWidth
< 128) {
643 firstColumnWidth
= 128;
645 setColumnWidth(0, firstColumnWidth
);
648 void DolphinDetailsView::slotItemRenamed(Q3ListViewItem
* item
,
652 KFileItem
* fileInfo
= static_cast<KFileListViewItem
*>(item
)->fileInfo();
653 m_dolphinView
->rename(KUrl(fileInfo
->url()), name
);
656 void DolphinDetailsView::slotHeaderClicked(int /* section */)
658 // The sorting has already been changed in QListView if this slot is
659 // invoked, but Dolphin was not informed about this (no signal is available
660 // which indicates a change of the sorting). This is bypassed by changing
661 // the sorting and sort order to a temporary other value and readjust it again.
662 const int column
= sortColumn();
663 if (column
<= DateColumn
) {
664 DolphinView::Sorting sorting
= DolphinView::SortByName
;
666 case SizeColumn
: sorting
= DolphinView::SortBySize
; break;
667 case DateColumn
: sorting
= DolphinView::SortByDate
; break;
672 const Qt::SortOrder currSortOrder
= sortOrder();
674 // temporary adjust the sorting and sort order to different values...
675 const DolphinView::Sorting tempSorting
= (sorting
== DolphinView::SortByName
) ?
676 DolphinView::SortBySize
:
677 DolphinView::SortByName
;
678 m_dolphinView
->setSorting(tempSorting
);
679 const Qt::SortOrder tempSortOrder
= (currSortOrder
== Qt::Ascending
) ?
680 Qt::Descending
: Qt::Ascending
;
681 m_dolphinView
->setSortOrder(tempSortOrder
);
683 // ... so that setting them again results in storing the new setting.
684 m_dolphinView
->setSorting(sorting
);
685 m_dolphinView
->setSortOrder(currSortOrder
);
689 DolphinDetailsView::DolphinListViewItem::DolphinListViewItem(Q3ListView
* parent
,
690 KFileItem
* fileItem
) :
691 KFileListViewItem(parent
, fileItem
)
693 const int iconSize
= DolphinSettings::instance().detailsModeSettings()->iconSize();
694 KFileItem
* info
= fileInfo();
695 setPixmap(DolphinDetailsView::NameColumn
, info
->pixmap(iconSize
));
697 // The base class KFileListViewItem represents the column 'Size' only as byte values.
698 // Adjust those values in a way that a mapping to GBytes, MBytes, KBytes and Bytes
699 // is done. As the file size for directories is useless (only the size of the directory i-node
700 // is given), it is removed completely.
701 if (fileItem
->isDir()) {
702 setText(SizeColumn
, " - ");
705 QString
sizeText(KIO::convertSize(fileItem
->size()));
706 sizeText
.append(" ");
707 setText(SizeColumn
, sizeText
);
710 // Dolphin allows to remove specific columns, but the base class KFileListViewItem
711 // is not aware about this (or at least the class KFileDetailView does not react on
712 // QListView::remove()). Therefore the columns are rearranged here.
713 const DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
714 assert(settings
!= 0);
716 int column_idx
= DateColumn
; // the columns for 'name' and 'size' cannot get removed
717 for (int i
= DolphinDetailsView::DateColumn
; i
<= DolphinDetailsView::GroupColumn
; ++i
) {
718 if (column_idx
< i
) {
719 setText(column_idx
, text(i
));
724 case DateColumn
: inc
= settings
->showDate(); break;
725 case PermissionsColumn
: inc
= settings
->showPermissions(); break;
726 case OwnerColumn
: inc
= settings
->showOwner(); break;
727 case GroupColumn
: inc
= settings
->showGroup(); break;
737 DolphinDetailsView::DolphinListViewItem::~DolphinListViewItem()
741 void DolphinDetailsView::DolphinListViewItem::paintCell(QPainter
* painter
,
742 const QColorGroup
& colorGroup
,
747 const Q3ListView
* view
= listView();
748 const bool isActive
= view
->parent() == Dolphin::mainWin().activeView();
750 // Per default the selection is drawn above the whole width of the item. As a consistent
751 // behavior with the icon view is wanted, only the the column containing the file name
752 // should be shown as selected.
753 QColorGroup
defaultColorGroup(colorGroup
);
754 const QColor
highlightColor(isActive
? backgroundColor(column
) : view
->colorGroup().background());
755 defaultColorGroup
.setColor(QColorGroup::Highlight
, highlightColor
);
756 defaultColorGroup
.setColor(QColorGroup::HighlightedText
, colorGroup
.color(QColorGroup::Text
));
757 KFileListViewItem::paintCell(painter
, defaultColorGroup
, column
, cellWidth
, alignment
);
760 // draw the selection only on the first column
761 Q3ListView
* parent
= listView();
762 const int itemWidth
= width(parent
->fontMetrics(), parent
, 0);
764 KFileListViewItem::paintCell(painter
, colorGroup
, column
, itemWidth
, alignment
);
767 Q3ListViewItem::paintCell(painter
, colorGroup
, column
, itemWidth
, alignment
);
773 KFileListViewItem::paintCell(painter
, colorGroup
, column
, cellWidth
, alignment
);
776 Q3ListViewItem::paintCell(painter
, colorGroup
, column
, cellWidth
, alignment
);
780 if (column
< listView()->columns() - 1) {
781 // draw a separator between columns
782 painter
->setPen(KGlobalSettings::buttonBackground());
783 painter
->drawLine(cellWidth
- 1, 0, cellWidth
- 1, height() - 1);
787 void DolphinDetailsView::DolphinListViewItem::paintFocus(QPainter
* painter
,
788 const QColorGroup
& colorGroup
,
791 // draw the focus consistently with the selection (see implementation notes
792 // in DolphinListViewItem::paintCell)
793 Q3ListView
* parent
= listView();
794 int visibleWidth
= width(parent
->fontMetrics(), parent
, 0);
795 const int colWidth
= parent
->columnWidth(0);
796 if (visibleWidth
> colWidth
) {
797 visibleWidth
= colWidth
;
800 QRect
focusRect(rect
);
801 focusRect
.setWidth(visibleWidth
);
803 KFileListViewItem::paintFocus(painter
, colorGroup
, focusRect
);
806 int DolphinDetailsView::filenameWidth(const Q3ListViewItem
* item
) const
810 int visibleWidth
= item
->width(fontMetrics(), this, 0);
811 const int colWidth
= columnWidth(0);
812 if (visibleWidth
> colWidth
) {
813 visibleWidth
= colWidth
;
818 #include "dolphindetailsview.moc"