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
24 #include <QStyleOption>
28 class DolphinColumnView
;
30 class DolphinSortFilterProxyModel
;
37 * Represents one column inside the DolphinColumnView and has been
38 * extended to respect view options and hovering information.
40 class DolphinColumnWidget
: public QListView
45 DolphinColumnWidget(QWidget
* parent
,
46 DolphinColumnView
* columnView
,
48 virtual ~DolphinColumnWidget();
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 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 void setChildUrl(const KUrl
& url
);
67 const KUrl
& childUrl() const;
69 /** Sets the directory URL that is shown inside the column widget. */
70 void setUrl(const KUrl
& url
);
72 /** Returns the directory URL that is shown inside the column widget. */
73 const KUrl
& url() const;
75 /** Reloads the directory DolphinColumnWidget::url(). */
78 void setShowHiddenFiles(bool show
);
79 void setShowPreview(bool show
);
82 * Updates the background color dependent from the activation state
83 * \a isViewActive of the column view.
85 void updateBackground();
88 * Filters the currently shown items by \a nameFilter. All items
89 * which contain the given filter string will be shown.
91 void setNameFilter(const QString
& nameFilter
);
94 virtual QStyleOptionViewItem
viewOptions() const;
95 virtual void startDrag(Qt::DropActions supportedActions
);
96 virtual void dragEnterEvent(QDragEnterEvent
* event
);
97 virtual void dragLeaveEvent(QDragLeaveEvent
* event
);
98 virtual void dragMoveEvent(QDragMoveEvent
* event
);
99 virtual void dropEvent(QDropEvent
* event
);
100 virtual void paintEvent(QPaintEvent
* event
);
101 virtual void mousePressEvent(QMouseEvent
* event
);
102 virtual void keyPressEvent(QKeyEvent
* event
);
103 virtual void contextMenuEvent(QContextMenuEvent
* event
);
104 virtual void selectionChanged(const QItemSelection
& selected
, const QItemSelection
& deselected
);
108 * If the item specified by \a index is a directory, then this
109 * directory will be loaded in a new column. If the item is a
110 * file, the corresponding application will get started.
112 void triggerItem(const QModelIndex
& index
);
115 * Generates a preview image for each file item in \a items.
116 * The current preview settings (maximum size, 'Show Preview' menu)
119 void generatePreviews(const KFileItemList
& items
);
122 * Replaces the icon of the item \a item by the preview pixmap
125 void showPreview(const KFileItem
& item
, const QPixmap
& pixmap
);
127 void slotEntered(const QModelIndex
& index
);
130 /** Used by DolphinColumnWidget::setActive(). */
133 /** Used by DolphinColumnWidget::setActive(). */
137 * Returns true, if the item \a item has been cut into
140 bool isCutItem(const KFileItem
& item
) const;
142 KFileItem
itemForIndex(const QModelIndex
& index
) const;
147 DolphinColumnView
* m_view
;
148 KUrl m_url
; // URL of the directory that is shown
149 KUrl m_childUrl
; // URL of the next column that is shown
150 QStyleOptionViewItem m_viewOptions
;
151 KDirLister
* m_dirLister
;
152 DolphinModel
* m_dolphinModel
;
153 DolphinSortFilterProxyModel
* m_proxyModel
;
155 bool m_dragging
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
156 QRect m_dropRect
; // TODO: remove this property when the issue #160611 is solved in Qt 4.4
159 inline bool DolphinColumnWidget::isActive() const
164 inline void DolphinColumnWidget::setChildUrl(const KUrl
& url
)
169 inline const KUrl
& DolphinColumnWidget::childUrl() const
174 inline void DolphinColumnWidget::setUrl(const KUrl
& url
)
182 inline const KUrl
& DolphinColumnWidget::url() const
187 inline QStyleOptionViewItem
DolphinColumnWidget::viewOptions() const
189 return m_viewOptions
;