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
;
35 class DolphinDirLister
;
36 class DolphinViewAutoScroller
;
37 class KFilePreviewGenerator
;
41 class SelectionManager
;
45 * Represents one column inside the DolphinColumnView and has been
46 * extended to respect view options and hovering information.
48 class DolphinColumnWidget
: public QListView
53 DolphinColumnWidget(QWidget
* parent
,
54 DolphinColumnView
* columnView
,
56 virtual ~DolphinColumnWidget();
58 /** Sets the size of the icons. */
59 void setDecorationSize(const QSize
& size
);
62 * An active column is defined as column, which shows the same URL
63 * as indicated by the URL navigator. The active column is usually
64 * drawn in a lighter color. All operations are applied to this column.
66 void setActive(bool active
);
67 bool isActive() const;
70 * Sets the directory URL of the child column that is shown next to
71 * this column. This property is only used for a visual indication
72 * of the shown directory, it does not trigger a loading of the model.
74 void setChildUrl(const KUrl
& url
);
75 const KUrl
& childUrl() const;
77 /** Sets the directory URL that is shown inside the column widget. */
78 void setUrl(const KUrl
& url
);
80 /** Returns the directory URL that is shown inside the column widget. */
81 const KUrl
& url() const;
83 /** Reloads the directory DolphinColumnWidget::url(). */
86 void setSorting(DolphinView::Sorting sorting
);
87 void setSortOrder(Qt::SortOrder order
);
88 void setShowHiddenFiles(bool show
);
89 void setShowPreview(bool show
);
92 * Updates the background color dependent from the activation state
93 * \a isViewActive of the column view.
95 void updateBackground();
98 * Filters the currently shown items by \a nameFilter. All items
99 * which contain the given filter string will be shown.
101 void setNameFilter(const QString
& nameFilter
);
104 * Does an inline editing for the item \a item.
106 void editItem(const KFileItem
& item
);
109 * Returns the item on the position \a pos. The KFileItem instance
110 * is null if no item is below the position.
112 KFileItem
itemAt(const QPoint
& pos
) const;
114 KFileItemList
selectedItems() const;
117 * Returns the MIME data for the selected items.
119 QMimeData
* selectionMimeData() const;
122 virtual QStyleOptionViewItem
viewOptions() const;
123 virtual void startDrag(Qt::DropActions supportedActions
);
124 virtual void dragEnterEvent(QDragEnterEvent
* event
);
125 virtual void dragLeaveEvent(QDragLeaveEvent
* event
);
126 virtual void dragMoveEvent(QDragMoveEvent
* event
);
127 virtual void dropEvent(QDropEvent
* event
);
128 virtual void paintEvent(QPaintEvent
* event
);
129 virtual void mousePressEvent(QMouseEvent
* event
);
130 virtual void keyPressEvent(QKeyEvent
* event
);
131 virtual void contextMenuEvent(QContextMenuEvent
* event
);
132 virtual void wheelEvent(QWheelEvent
* event
);
133 virtual void leaveEvent(QEvent
* event
);
134 virtual void selectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
);
135 virtual void currentChanged(const QModelIndex
& current
, const QModelIndex
& previous
);
138 void slotEntered(const QModelIndex
& index
);
139 void requestActivation();
143 /** Used by DolphinColumnWidget::setActive(). */
146 /** Used by DolphinColumnWidget::setActive(). */
151 DolphinColumnView
* m_view
;
152 SelectionManager
* m_selectionManager
;
153 DolphinViewAutoScroller
* m_autoScroller
;
154 KUrl m_url
; // URL of the directory that is shown
155 KUrl m_childUrl
; // URL of the next column that is shown
158 QSize m_decorationSize
;
160 DolphinDirLister
* m_dirLister
;
161 DolphinModel
* m_dolphinModel
;
162 DolphinSortFilterProxyModel
* m_proxyModel
;
164 KFilePreviewGenerator
* m_previewGenerator
;
168 friend class DolphinColumnView
;
171 inline bool DolphinColumnWidget::isActive() const
176 inline void DolphinColumnWidget::setChildUrl(const KUrl
& url
)
181 inline const KUrl
& DolphinColumnWidget::childUrl() const
186 inline void DolphinColumnWidget::setUrl(const KUrl
& url
)
194 inline const KUrl
& DolphinColumnWidget::url() const