1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "dolphincolumnview.h"
22 #include "dolphinmodel.h"
23 #include "dolphincontroller.h"
24 #include "dolphinsettings.h"
26 #include "dolphin_columnmodesettings.h"
28 #include <kcolorutils.h>
29 #include <kcolorscheme.h>
30 #include <kdirlister.h>
32 #include <QAbstractProxyModel>
33 #include <QApplication>
39 * Represents one column inside the DolphinColumnView and has been
40 * extended to respect view options and hovering information.
42 class ColumnWidget
: public QListView
45 ColumnWidget(QWidget
* parent
,
46 DolphinColumnView
* columnView
,
48 virtual ~ColumnWidget();
50 /** Sets the size of the icons. */
51 void setDecorationSize(const QSize
& size
);
54 * An active column is defined as column, which shows the same URL
55 * as indicated by the URL navigator. The active column is usually
56 * drawn in a lighter color. All operations are applied to this column.
58 void setActive(bool active
);
59 inline bool isActive() const;
62 * Sets the directory URL of the child column that is shown next to
63 * this column. This property is only used for a visual indication
64 * of the shown directory, it does not trigger a loading of the model.
66 inline void setChildUrl(const KUrl
& url
);
67 inline const KUrl
& childUrl() const;
70 * Returns the directory URL that is shown inside the column widget.
72 inline const KUrl
& url() const;
75 virtual QStyleOptionViewItem
viewOptions() const;
76 virtual void dragEnterEvent(QDragEnterEvent
* event
);
77 virtual void dragLeaveEvent(QDragLeaveEvent
* event
);
78 virtual void dragMoveEvent(QDragMoveEvent
* event
);
79 virtual void dropEvent(QDropEvent
* event
);
80 virtual void paintEvent(QPaintEvent
* event
);
81 virtual void mousePressEvent(QMouseEvent
* event
);
82 virtual void keyPressEvent(QKeyEvent
* event
);
83 virtual void contextMenuEvent(QContextMenuEvent
* event
);
84 virtual void selectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
);
87 /** Used by ColumnWidget::setActive(). */
90 /** Used by ColumnWidget::setActive(). */
95 DolphinColumnView
* m_view
;
96 KUrl m_url
; // URL of the directory that is shown
97 KUrl m_childUrl
; // URL of the next column that is shown
98 QStyleOptionViewItem m_viewOptions
;
100 bool m_dragging
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
101 QRect m_dropRect
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
104 ColumnWidget::ColumnWidget(QWidget
* parent
,
105 DolphinColumnView
* columnView
,
115 setMouseTracking(true);
116 viewport()->setAttribute(Qt::WA_Hover
);
117 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff
);
118 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn
);
119 setSelectionBehavior(SelectItems
);
120 setSelectionMode(QAbstractItemView::ExtendedSelection
);
121 setDragDropMode(QAbstractItemView::DragDrop
);
122 setDropIndicatorShown(false);
123 setFocusPolicy(Qt::NoFocus
);
125 // apply the column mode settings to the widget
126 const ColumnModeSettings
* settings
= DolphinSettings::instance().columnModeSettings();
127 Q_ASSERT(settings
!= 0);
129 m_viewOptions
= QListView::viewOptions();
131 QFont
font(settings
->fontFamily(), settings
->fontSize());
132 font
.setItalic(settings
->italicFont());
133 font
.setBold(settings
->boldFont());
134 m_viewOptions
.font
= font
;
136 const int iconSize
= settings
->iconSize();
137 m_viewOptions
.decorationSize
= QSize(iconSize
, iconSize
);
139 KFileItemDelegate
* delegate
= new KFileItemDelegate(this);
140 setItemDelegate(delegate
);
144 connect(this, SIGNAL(entered(const QModelIndex
&)),
145 m_view
->m_controller
, SLOT(emitItemEntered(const QModelIndex
&)));
146 connect(this, SIGNAL(viewportEntered()),
147 m_view
->m_controller
, SLOT(emitViewportEntered()));
150 ColumnWidget::~ColumnWidget()
154 void ColumnWidget::setDecorationSize(const QSize
& size
)
156 m_viewOptions
.decorationSize
= size
;
160 void ColumnWidget::setActive(bool active
)
162 if (m_active
== active
) {
175 inline bool ColumnWidget::isActive() const
180 inline void ColumnWidget::setChildUrl(const KUrl
& url
)
185 inline const KUrl
& ColumnWidget::childUrl() const
190 const KUrl
& ColumnWidget::url() const
195 QStyleOptionViewItem
ColumnWidget::viewOptions() const
197 return m_viewOptions
;
200 void ColumnWidget::dragEnterEvent(QDragEnterEvent
* event
)
202 if (event
->mimeData()->hasUrls()) {
203 event
->acceptProposedAction();
209 void ColumnWidget::dragLeaveEvent(QDragLeaveEvent
* event
)
211 QListView::dragLeaveEvent(event
);
213 // TODO: remove this code when the issue #160611 is solved in Qt 4.4
215 setDirtyRegion(m_dropRect
);
218 void ColumnWidget::dragMoveEvent(QDragMoveEvent
* event
)
220 QListView::dragMoveEvent(event
);
222 // TODO: remove this code when the issue #160611 is solved in Qt 4.4
223 const QModelIndex index
= indexAt(event
->pos());
224 setDirtyRegion(m_dropRect
);
225 m_dropRect
= visualRect(index
);
226 setDirtyRegion(m_dropRect
);
229 void ColumnWidget::dropEvent(QDropEvent
* event
)
231 const KUrl::List urls
= KUrl::List::fromMimeData(event
->mimeData());
232 if (!urls
.isEmpty()) {
233 event
->acceptProposedAction();
234 m_view
->m_controller
->indicateDroppedUrls(urls
,
236 indexAt(event
->pos()),
239 QListView::dropEvent(event
);
243 void ColumnWidget::paintEvent(QPaintEvent
* event
)
245 if (!m_childUrl
.isEmpty()) {
246 // indicate the shown URL of the next column by highlighting the shown folder item
247 const QModelIndex dirIndex
= m_view
->m_dolphinModel
->indexForUrl(m_childUrl
);
248 const QModelIndex proxyIndex
= m_view
->m_proxyModel
->mapFromSource(dirIndex
);
249 if (proxyIndex
.isValid() && !selectionModel()->isSelected(proxyIndex
)) {
250 const QRect itemRect
= visualRect(proxyIndex
);
251 QPainter
painter(viewport());
254 QColor color
= KColorScheme(QPalette::Active
, KColorScheme::View
).foreground().color();
256 painter
.setPen(Qt::NoPen
);
257 painter
.setBrush(color
);
258 painter
.drawRect(itemRect
);
264 QListView::paintEvent(event
);
266 // TODO: remove this code when the issue #160611 is solved in Qt 4.4
268 const QBrush
& brush
= m_viewOptions
.palette
.brush(QPalette::Normal
, QPalette::Highlight
);
269 DolphinController::drawHoverIndication(viewport(), m_dropRect
, brush
);
273 void ColumnWidget::mousePressEvent(QMouseEvent
* event
)
276 m_view
->requestActivation(this);
279 QListView::mousePressEvent(event
);
282 void ColumnWidget::keyPressEvent(QKeyEvent
* event
)
284 QListView::keyPressEvent(event
);
286 const QItemSelectionModel
* selModel
= selectionModel();
287 const QModelIndex currentIndex
= selModel
->currentIndex();
288 const bool triggerItem
= currentIndex
.isValid()
289 && (event
->key() == Qt::Key_Return
)
290 && (selModel
->selectedIndexes().count() <= 1);
292 m_view
->triggerItem(currentIndex
);
296 void ColumnWidget::contextMenuEvent(QContextMenuEvent
* event
)
299 m_view
->requestActivation(this);
302 QListView::contextMenuEvent(event
);
304 const QModelIndex index
= indexAt(event
->pos());
305 if (index
.isValid() || m_active
) {
306 // Only open a context menu above an item or if the mouse is above
307 // the active column.
308 const QPoint pos
= m_view
->viewport()->mapFromGlobal(event
->globalPos());
309 m_view
->m_controller
->triggerContextMenuRequest(pos
);
313 void ColumnWidget::selectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
)
315 QListView::selectionChanged(selected
, deselected
);
317 QItemSelectionModel
* selModel
= m_view
->selectionModel();
318 selModel
->select(selected
, QItemSelectionModel::Select
);
319 selModel
->select(deselected
, QItemSelectionModel::Deselect
);
322 void ColumnWidget::activate()
324 if (m_view
->hasFocus()) {
325 setFocus(Qt::OtherFocusReason
);
327 m_view
->setFocusProxy(this);
329 // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
330 // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
331 // necessary connecting the signal 'singleClick()' or 'doubleClick'.
332 if (KGlobalSettings::singleClick()) {
333 connect(this, SIGNAL(clicked(const QModelIndex
&)),
334 m_view
, SLOT(triggerItem(const QModelIndex
&)));
336 connect(this, SIGNAL(doubleClicked(const QModelIndex
&)),
337 m_view
, SLOT(triggerItem(const QModelIndex
&)));
340 const QColor bgColor
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
341 QPalette palette
= viewport()->palette();
342 palette
.setColor(viewport()->backgroundRole(), bgColor
);
343 viewport()->setPalette(palette
);
345 if (!m_childUrl
.isEmpty()) {
346 // assure that the current index is set on the index that represents
348 const QModelIndex dirIndex
= m_view
->m_dolphinModel
->indexForUrl(m_childUrl
);
349 const QModelIndex proxyIndex
= m_view
->m_proxyModel
->mapFromSource(dirIndex
);
350 selectionModel()->setCurrentIndex(proxyIndex
, QItemSelectionModel::Current
);
356 void ColumnWidget::deactivate()
358 // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
359 // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
360 // necessary connecting the signal 'singleClick()' or 'doubleClick'.
361 if (KGlobalSettings::singleClick()) {
362 disconnect(this, SIGNAL(clicked(const QModelIndex
&)),
363 m_view
, SLOT(triggerItem(const QModelIndex
&)));
365 disconnect(this, SIGNAL(doubleClicked(const QModelIndex
&)),
366 m_view
, SLOT(triggerItem(const QModelIndex
&)));
369 QColor bgColor
= KColorScheme(QPalette::Active
, KColorScheme::View
).background().color();
370 const QColor fgColor
= KColorScheme(QPalette::Active
, KColorScheme::View
).foreground().color();
371 bgColor
= KColorUtils::mix(bgColor
, fgColor
, 0.04);
373 QPalette palette
= viewport()->palette();
374 palette
.setColor(viewport()->backgroundRole(), bgColor
);
375 viewport()->setPalette(palette
);
377 selectionModel()->clear();
384 DolphinColumnView::DolphinColumnView(QWidget
* parent
, DolphinController
* controller
) :
385 QAbstractItemView(parent
),
386 m_controller(controller
),
387 m_restoreActiveColumnFocus(false),
395 Q_ASSERT(controller
!= 0);
397 setAcceptDrops(true);
398 setDragDropMode(QAbstractItemView::DragDrop
);
399 setDropIndicatorShown(false);
400 setSelectionMode(ExtendedSelection
);
402 connect(this, SIGNAL(entered(const QModelIndex
&)),
403 controller
, SLOT(emitItemEntered(const QModelIndex
&)));
404 connect(this, SIGNAL(viewportEntered()),
405 controller
, SLOT(emitViewportEntered()));
406 connect(controller
, SIGNAL(zoomIn()),
407 this, SLOT(zoomIn()));
408 connect(controller
, SIGNAL(zoomOut()),
409 this, SLOT(zoomOut()));
410 connect(controller
, SIGNAL(urlChanged(const KUrl
&)),
411 this, SLOT(showColumn(const KUrl
&)));
413 connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
414 this, SLOT(moveContentHorizontally(int)));
416 ColumnWidget
* column
= new ColumnWidget(viewport(), this, m_controller
->url());
417 m_columns
.append(column
);
418 setActiveColumnIndex(0);
420 updateDecorationSize();
422 m_animation
= new QTimeLine(500, this);
423 connect(m_animation
, SIGNAL(frameChanged(int)), horizontalScrollBar(), SLOT(setValue(int)));
426 DolphinColumnView::~DolphinColumnView()
430 QModelIndex
DolphinColumnView::indexAt(const QPoint
& point
) const
432 foreach (ColumnWidget
* column
, m_columns
) {
433 const QPoint topLeft
= column
->frameGeometry().topLeft();
434 const QPoint
adjustedPoint(point
.x() - topLeft
.x(), point
.y() - topLeft
.y());
435 const QModelIndex index
= column
->indexAt(adjustedPoint
);
436 if (index
.isValid()) {
441 return QModelIndex();
444 void DolphinColumnView::scrollTo(const QModelIndex
& index
, ScrollHint hint
)
446 activeColumn()->scrollTo(index
, hint
);
449 QRect
DolphinColumnView::visualRect(const QModelIndex
& index
) const
451 return activeColumn()->visualRect(index
);
454 void DolphinColumnView::setModel(QAbstractItemModel
* model
)
456 if (m_dolphinModel
!= 0) {
457 m_dolphinModel
->disconnect(this);
460 m_proxyModel
= static_cast<const QAbstractProxyModel
*>(model
);
461 m_dolphinModel
= static_cast<const DolphinModel
*>(m_proxyModel
->sourceModel());
462 connect(m_dolphinModel
, SIGNAL(expand(const QModelIndex
&)),
463 this, SLOT(triggerReloadColumns(const QModelIndex
&)));
465 activeColumn()->setModel(model
);
466 QAbstractItemView::setModel(model
);
469 void DolphinColumnView::reload()
471 deleteInactiveChildColumns();
473 // Due to the reloading of the model all columns will be reset to show
474 // the same content as the first column. As this is not wanted, all columns
475 // except of the first column are temporary hidden until the root index can
477 m_restoreActiveColumnFocus
= false;
478 QList
<ColumnWidget
*>::iterator start
= m_columns
.begin() + 1;
479 QList
<ColumnWidget
*>::iterator end
= m_columns
.end();
480 for (QList
<ColumnWidget
*>::iterator it
= start
; it
!= end
; ++it
) {
481 ColumnWidget
* column
= (*it
);
482 if (column
->isActive() && column
->hasFocus()) {
483 // because of hiding the column, it will lose the focus
484 // -> remember that the focus should be restored after reloading
485 m_restoreActiveColumnFocus
= true;
488 column
->setRootIndex(QModelIndex());
491 // all columns are hidden, now reload the directory lister
492 KDirLister
* dirLister
= m_dolphinModel
->dirLister();
493 connect(dirLister
, SIGNAL(completed()),
494 this, SLOT(expandToActiveUrl()));
495 const KUrl baseUrl
= m_columns
[0]->url();
496 dirLister
->openUrl(baseUrl
, false, true);
499 bool DolphinColumnView::isIndexHidden(const QModelIndex
& index
) const
502 return false;//activeColumn()->isIndexHidden(index);
505 QModelIndex
DolphinColumnView::moveCursor(CursorAction cursorAction
, Qt::KeyboardModifiers modifiers
)
507 // Parts of this code have been taken from QColumnView::moveCursor().
508 // Copyright (C) 1992-2007 Trolltech ASA.
512 return QModelIndex();
515 const QModelIndex current
= currentIndex();
516 if (isRightToLeft()) {
517 if (cursorAction
== MoveLeft
) {
518 cursorAction
= MoveRight
;
519 } else if (cursorAction
== MoveRight
) {
520 cursorAction
= MoveLeft
;
524 switch (cursorAction
) {
527 setActiveColumnIndex(m_index
- 1);
532 if (m_index
< m_columns
.count() - 1) {
533 setActiveColumnIndex(m_index
+ 1);
541 return QModelIndex();
544 void DolphinColumnView::setSelection(const QRect
& rect
, QItemSelectionModel::SelectionFlags flags
)
548 //activeColumn()->setSelection(rect, flags);
551 QRegion
DolphinColumnView::visualRegionForSelection(const QItemSelection
& selection
) const
554 return QRegion(); //activeColumn()->visualRegionForSelection(selection);
557 int DolphinColumnView::horizontalOffset() const
562 int DolphinColumnView::verticalOffset() const
567 void DolphinColumnView::mousePressEvent(QMouseEvent
* event
)
569 m_controller
->triggerActivation();
570 QAbstractItemView::mousePressEvent(event
);
573 void DolphinColumnView::resizeEvent(QResizeEvent
* event
)
575 QAbstractItemView::resizeEvent(event
);
580 void DolphinColumnView::zoomIn()
582 if (isZoomInPossible()) {
583 ColumnModeSettings
* settings
= DolphinSettings::instance().columnModeSettings();
584 // TODO: get rid of K3Icon sizes
585 switch (settings
->iconSize()) {
586 case K3Icon::SizeSmall
: settings
->setIconSize(K3Icon::SizeMedium
); break;
587 case K3Icon::SizeMedium
: settings
->setIconSize(K3Icon::SizeLarge
); break;
588 default: Q_ASSERT(false); break;
590 updateDecorationSize();
594 void DolphinColumnView::zoomOut()
596 if (isZoomOutPossible()) {
597 ColumnModeSettings
* settings
= DolphinSettings::instance().columnModeSettings();
598 // TODO: get rid of K3Icon sizes
599 switch (settings
->iconSize()) {
600 case K3Icon::SizeLarge
: settings
->setIconSize(K3Icon::SizeMedium
); break;
601 case K3Icon::SizeMedium
: settings
->setIconSize(K3Icon::SizeSmall
); break;
602 default: Q_ASSERT(false); break;
604 updateDecorationSize();
608 void DolphinColumnView::triggerItem(const QModelIndex
& index
)
610 m_controller
->triggerItem(index
);
612 const Qt::KeyboardModifiers modifiers
= QApplication::keyboardModifiers();
613 if ((modifiers
& Qt::ControlModifier
) || (modifiers
& Qt::ShiftModifier
)) {
617 const KFileItem item
= m_dolphinModel
->itemForIndex(m_proxyModel
->mapToSource(index
));
618 if ((item
.url() != activeColumn()->url()) && item
.isDir()) {
619 deleteInactiveChildColumns();
621 const KUrl
& childUrl
= m_controller
->url();
622 activeColumn()->setChildUrl(childUrl
);
624 ColumnWidget
* column
= new ColumnWidget(viewport(), this, childUrl
);
625 column
->setModel(model());
626 column
->setRootIndex(index
);
628 m_columns
.append(column
);
630 setActiveColumnIndex(m_index
+ 1);
632 // Before invoking layoutColumns() the column must be shown. To prevent
633 // a flickering the initial geometry is set to be invisible.
634 column
->setGeometry(QRect(-1, -1, 1, 1));
639 assureVisibleActiveColumn();
643 void DolphinColumnView::moveContentHorizontally(int x
)
649 void DolphinColumnView::showColumn(const KUrl
& url
)
651 if (!m_columns
[0]->url().isParentOf(url
)) {
652 // the URL is no child URL of the column view, hence do nothing
657 foreach (ColumnWidget
* column
, m_columns
) {
658 if (column
->url() == url
) {
659 // the column represents already the requested URL, hence activate it
660 requestActivation(column
);
662 } else if (!column
->url().isParentOf(url
)) {
663 // the column is no parent of the requested URL, hence it must
664 // be deleted and a new column must be loaded
665 if (columnIndex
> 0) {
666 setActiveColumnIndex(columnIndex
- 1);
667 deleteInactiveChildColumns();
670 const QModelIndex dirIndex
= m_dolphinModel
->indexForUrl(url
);
671 if (dirIndex
.isValid()) {
672 triggerItem(m_proxyModel
->mapFromSource(dirIndex
));
679 // no existing column has been replaced and a new column must be created
680 const QModelIndex dirIndex
= m_dolphinModel
->indexForUrl(url
);
681 if (dirIndex
.isValid()) {
682 triggerItem(m_proxyModel
->mapFromSource(dirIndex
));
686 void DolphinColumnView::updateDecorationSize()
688 ColumnModeSettings
* settings
= DolphinSettings::instance().columnModeSettings();
689 const int iconSize
= settings
->iconSize();
691 foreach (QObject
* object
, viewport()->children()) {
692 if (object
->inherits("QListView")) {
693 ColumnWidget
* widget
= static_cast<ColumnWidget
*>(object
);
694 widget
->setDecorationSize(QSize(iconSize
, iconSize
));
698 m_controller
->setZoomInPossible(isZoomInPossible());
699 m_controller
->setZoomOutPossible(isZoomOutPossible());
704 void DolphinColumnView::expandToActiveUrl()
706 const KUrl
& activeUrl
= m_controller
->url();
707 const KUrl baseUrl
= m_dolphinModel
->dirLister()->url();
708 if (baseUrl
.isParentOf(activeUrl
) && (baseUrl
!= activeUrl
)) {
709 m_dolphinModel
->expandToUrl(activeUrl
);
714 void DolphinColumnView::triggerReloadColumns(const QModelIndex
& index
)
717 disconnect(m_dolphinModel
, SIGNAL(expand(const QModelIndex
&)),
718 this, SLOT(triggerReloadColumns(const QModelIndex
&)));
719 // the reloading of the columns may not be done in the context of this slot
720 QMetaObject::invokeMethod(this, "reloadColumns", Qt::QueuedConnection
);
723 void DolphinColumnView::reloadColumns()
725 const int end
= m_columns
.count() - 2; // next to last column
726 for (int i
= 0; i
<= end
; ++i
) {
727 ColumnWidget
* nextColumn
= m_columns
[i
+ 1];
728 const QModelIndex rootIndex
= nextColumn
->rootIndex();
729 if (!rootIndex
.isValid()) {
730 const QModelIndex dirIndex
= m_dolphinModel
->indexForUrl(m_columns
[i
]->childUrl());
731 const QModelIndex proxyIndex
= m_proxyModel
->mapFromSource(dirIndex
);
732 if (proxyIndex
.isValid()) {
733 nextColumn
->setRootIndex(proxyIndex
);
735 if (nextColumn
->isActive() && m_restoreActiveColumnFocus
) {
736 nextColumn
->setFocus();
737 m_restoreActiveColumnFocus
= false;
744 bool DolphinColumnView::isZoomInPossible() const
746 ColumnModeSettings
* settings
= DolphinSettings::instance().columnModeSettings();
747 return settings
->iconSize() < K3Icon::SizeLarge
;
750 bool DolphinColumnView::isZoomOutPossible() const
752 ColumnModeSettings
* settings
= DolphinSettings::instance().columnModeSettings();
753 return settings
->iconSize() > K3Icon::SizeSmall
;
756 void DolphinColumnView::setActiveColumnIndex(int index
)
758 if (m_index
== index
) {
762 const bool hasActiveColumn
= (m_index
>= 0);
763 if (hasActiveColumn
) {
764 m_columns
[m_index
]->setActive(false);
768 m_columns
[m_index
]->setActive(true);
770 m_controller
->setUrl(m_columns
[m_index
]->url());
773 void DolphinColumnView::layoutColumns()
776 ColumnModeSettings
* settings
= DolphinSettings::instance().columnModeSettings();
777 const int columnWidth
= settings
->columnWidth();
778 foreach (ColumnWidget
* column
, m_columns
) {
779 column
->setGeometry(QRect(x
, 0, columnWidth
, viewport()->height()));
784 void DolphinColumnView::updateScrollBar()
786 int contentWidth
= 0;
787 foreach (ColumnWidget
* column
, m_columns
) {
788 contentWidth
+= column
->width();
791 horizontalScrollBar()->setPageStep(contentWidth
);
792 horizontalScrollBar()->setRange(0, contentWidth
- viewport()->width());
795 void DolphinColumnView::assureVisibleActiveColumn()
797 const int viewportWidth
= viewport()->width();
798 const int x
= activeColumn()->x();
799 const int width
= activeColumn()->width();
800 if (x
+ width
> viewportWidth
) {
801 int newContentX
= m_contentX
- x
- width
+ viewportWidth
;
802 if (newContentX
> 0) {
805 m_animation
->setFrameRange(-m_contentX
, -newContentX
);
806 m_animation
->start();
808 const int newContentX
= m_contentX
- x
;
809 m_animation
->setFrameRange(-m_contentX
, -newContentX
);
810 m_animation
->start();
814 void DolphinColumnView::requestActivation(ColumnWidget
* column
)
816 if (column
->isActive()) {
817 assureVisibleActiveColumn();
820 foreach (ColumnWidget
* currColumn
, m_columns
) {
821 if (currColumn
== column
) {
822 setActiveColumnIndex(index
);
823 assureVisibleActiveColumn();
831 void DolphinColumnView::deleteInactiveChildColumns()
833 QList
<ColumnWidget
*>::iterator start
= m_columns
.begin() + m_index
+ 1;
834 QList
<ColumnWidget
*>::iterator end
= m_columns
.end();
835 for (QList
<ColumnWidget
*>::iterator it
= start
; it
!= end
; ++it
) {
836 (*it
)->deleteLater();
838 m_columns
.erase(start
, end
);
841 #include "dolphincolumnview.moc"