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 #ifndef DOLPHINCOLUMNWIDGET_H
21 #define DOLPHINCOLUMNWIDGET_H
23 #include "dolphinview.h"
28 #include <QStyleOption>
32 class DolphinColumnView
;
34 class DolphinSortFilterProxyModel
;
43 * Represents one column inside the DolphinColumnView and has been
44 * extended to respect view options and hovering information.
46 class DolphinColumnWidget
: public QListView
51 DolphinColumnWidget(QWidget
* parent
,
52 DolphinColumnView
* columnView
,
54 virtual ~DolphinColumnWidget();
56 /** Sets the size of the icons. */
57 void setDecorationSize(const QSize
& size
);
60 * An active column is defined as column, which shows the same URL
61 * as indicated by the URL navigator. The active column is usually
62 * drawn in a lighter color. All operations are applied to this column.
64 void setActive(bool active
);
65 bool isActive() const;
68 * Sets the directory URL of the child column that is shown next to
69 * this column. This property is only used for a visual indication
70 * of the shown directory, it does not trigger a loading of the model.
72 void setChildUrl(const KUrl
& url
);
73 const KUrl
& childUrl() const;
75 /** Sets the directory URL that is shown inside the column widget. */
76 void setUrl(const KUrl
& url
);
78 /** Returns the directory URL that is shown inside the column widget. */
79 const KUrl
& url() const;
81 /** Reloads the directory DolphinColumnWidget::url(). */
84 void setSorting(DolphinView::Sorting sorting
);
85 void setSortOrder(Qt::SortOrder order
);
86 void setShowHiddenFiles(bool show
);
87 void setShowPreview(bool show
);
90 * Updates the background color dependent from the activation state
91 * \a isViewActive of the column view.
93 void updateBackground();
96 * Filters the currently shown items by \a nameFilter. All items
97 * which contain the given filter string will be shown.
99 void setNameFilter(const QString
& nameFilter
);
102 virtual QStyleOptionViewItem
viewOptions() const;
103 virtual void startDrag(Qt::DropActions supportedActions
);
104 virtual void dragEnterEvent(QDragEnterEvent
* event
);
105 virtual void dragLeaveEvent(QDragLeaveEvent
* event
);
106 virtual void dragMoveEvent(QDragMoveEvent
* event
);
107 virtual void dropEvent(QDropEvent
* event
);
108 virtual void paintEvent(QPaintEvent
* event
);
109 virtual void mousePressEvent(QMouseEvent
* event
);
110 virtual void keyPressEvent(QKeyEvent
* event
);
111 virtual void contextMenuEvent(QContextMenuEvent
* event
);
112 virtual void wheelEvent(QWheelEvent
* event
);
113 virtual void selectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
);
117 * If the item specified by \a index is a directory, then this
118 * directory will be loaded in a new column. If the item is a
119 * file, the corresponding application will get started.
121 void triggerItem(const QModelIndex
& index
);
123 void slotEntered(const QModelIndex
& index
);
125 void requestActivation();
128 /** Used by DolphinColumnWidget::setActive(). */
131 /** Used by DolphinColumnWidget::setActive(). */
134 KFileItem
itemForIndex(const QModelIndex
& index
) const;
138 DolphinColumnView
* m_view
;
139 KUrl m_url
; // URL of the directory that is shown
140 KUrl m_childUrl
; // URL of the next column that is shown
143 QSize m_decorationSize
;
145 KDirLister
* m_dirLister
;
146 DolphinModel
* m_dolphinModel
;
147 DolphinSortFilterProxyModel
* m_proxyModel
;
149 IconManager
* m_iconManager
;
151 bool m_dragging
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
152 QRect m_dropRect
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
155 inline bool DolphinColumnWidget::isActive() const
160 inline void DolphinColumnWidget::setChildUrl(const KUrl
& url
)
165 inline const KUrl
& DolphinColumnWidget::childUrl() const
170 inline void DolphinColumnWidget::setUrl(const KUrl
& url
)
178 inline const KUrl
& DolphinColumnWidget::url() const