1 /***************************************************************************
2 * Copyright (C) 2007-2009 by Peter Penz <peter.penz19@gmail.com> *
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 #ifndef DOLPHINCOLUMNVIEW_H
21 #define DOLPHINCOLUMNVIEW_H
23 #include "dolphinview.h"
24 #include "dolphintreeview.h"
28 #include <QStyleOption>
32 class DolphinColumnViewContainer
;
34 class DolphinSortFilterProxyModel
;
35 class DolphinDirLister
;
38 class SelectionManager
;
39 class ViewExtensionsFactory
;
42 * Represents one column inside the DolphinColumnViewContainer.
44 class DolphinColumnView
: public DolphinTreeView
49 DolphinColumnView(QWidget
* parent
,
50 DolphinColumnViewContainer
* container
,
52 virtual ~DolphinColumnView();
55 * An active column is defined as column, which shows the same URL
56 * as indicated by the URL navigator. The active column is usually
57 * drawn in a lighter color. All operations are applied to this column.
59 void setActive(bool active
);
60 bool isActive() const;
63 * Sets the directory URL of the child column that is shown next to
64 * this column. This property is only used for a visual indication
65 * of the shown directory, it does not trigger a loading of the model.
67 void setChildUrl(const KUrl
& url
);
68 KUrl
childUrl() const;
70 /** Sets the directory URL that is shown inside the column widget. */
71 void setUrl(const KUrl
& url
);
73 /** Returns the directory URL that is shown inside the column widget. */
77 * Updates the background color dependent from the activation state
78 * \a isViewActive of the column view.
80 void updateBackground();
83 * Returns the item on the position \a pos. The KFileItem instance
84 * is null if no item is below the position.
86 KFileItem
itemAt(const QPoint
& pos
) const;
88 virtual void setSelectionModel(QItemSelectionModel
* model
);
91 virtual QStyleOptionViewItem
viewOptions() const;
92 virtual bool event(QEvent
* event
);
93 virtual void startDrag(Qt::DropActions supportedActions
);
94 virtual void dragEnterEvent(QDragEnterEvent
* event
);
95 virtual void dragMoveEvent(QDragMoveEvent
* event
);
96 virtual void dropEvent(QDropEvent
* event
);
97 virtual void paintEvent(QPaintEvent
* event
);
98 virtual void mousePressEvent(QMouseEvent
* event
);
99 virtual void keyPressEvent(QKeyEvent
* event
);
100 virtual void contextMenuEvent(QContextMenuEvent
* event
);
101 virtual void wheelEvent(QWheelEvent
* event
);
102 virtual void leaveEvent(QEvent
* event
);
103 virtual void currentChanged(const QModelIndex
& current
, const QModelIndex
& previous
);
104 virtual QRect
visualRect(const QModelIndex
& index
) const;
105 virtual bool acceptsDrop(const QModelIndex
& index
) const;
106 virtual bool eventFilter(QObject
* watched
, QEvent
* event
);
109 void setZoomLevel(int level
);
111 void slotEntered(const QModelIndex
& index
);
112 void requestActivation();
115 void slotShowPreviewChanged();
117 void slotDirListerCompleted();
120 /** Used by DolphinColumnView::setActive(). */
123 /** Used by DolphinColumnView::setActive(). */
126 void updateDecorationSize(bool showPreview
);
130 DolphinColumnViewContainer
* m_container
;
131 SelectionManager
* m_selectionManager
;
132 ViewExtensionsFactory
* m_extensionsFactory
;
133 KUrl m_url
; // URL of the directory that is shown
134 KUrl m_childUrl
; // URL of the next column that is shown
137 QSize m_decorationSize
;
139 DolphinDirLister
* m_dirLister
;
140 DolphinModel
* m_dolphinModel
;
141 DolphinSortFilterProxyModel
* m_proxyModel
;
143 QLabel
* m_resizeWidget
;
146 friend class DolphinColumnViewContainer
;