delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / dolphin / src / dolphincolumnwidget.h
blobc1bf6a836a6ed15e30d7819a1b1a4c257bcdde37
1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
3 * *
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. *
8 * *
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. *
13 * *
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"
25 #include <QFont>
26 #include <QListView>
27 #include <QSize>
28 #include <QStyleOption>
30 #include <kurl.h>
32 class DolphinColumnView;
33 class DolphinModel;
34 class DolphinSortFilterProxyModel;
35 class DolphinDirLister;
36 class DolphinViewAutoScroller;
37 class KFilePreviewGenerator;
38 class KJob;
39 class KFileItem;
40 class KFileItemList;
41 class SelectionManager;
42 class QPixmap;
44 /**
45 * Represents one column inside the DolphinColumnView and has been
46 * extended to respect view options and hovering information.
48 class DolphinColumnWidget : public QListView
50 Q_OBJECT
52 public:
53 DolphinColumnWidget(QWidget* parent,
54 DolphinColumnView* columnView,
55 const KUrl& url);
56 virtual ~DolphinColumnWidget();
58 /** Sets the size of the icons. */
59 void setDecorationSize(const QSize& size);
61 /**
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;
69 /**
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(). */
84 void reload();
86 void setSorting(DolphinView::Sorting sorting);
87 void setSortOrder(Qt::SortOrder order);
88 void setShowHiddenFiles(bool show);
89 void setShowPreview(bool show);
91 /**
92 * Updates the background color dependent from the activation state
93 * \a isViewActive of the column view.
95 void updateBackground();
97 /**
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;
121 protected:
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);
137 private slots:
138 void slotEntered(const QModelIndex& index);
139 void requestActivation();
140 void updateFont();
142 private:
143 /** Used by DolphinColumnWidget::setActive(). */
144 void activate();
146 /** Used by DolphinColumnWidget::setActive(). */
147 void deactivate();
149 private:
150 bool m_active;
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
157 QFont m_font;
158 QSize m_decorationSize;
160 DolphinDirLister* m_dirLister;
161 DolphinModel* m_dolphinModel;
162 DolphinSortFilterProxyModel* m_proxyModel;
164 KFilePreviewGenerator* m_previewGenerator;
166 QRect m_dropRect;
168 friend class DolphinColumnView;
171 inline bool DolphinColumnWidget::isActive() const
173 return m_active;
176 inline void DolphinColumnWidget::setChildUrl(const KUrl& url)
178 m_childUrl = url;
181 inline const KUrl& DolphinColumnWidget::childUrl() const
183 return m_childUrl;
186 inline void DolphinColumnWidget::setUrl(const KUrl& url)
188 if (url != m_url) {
189 m_url = url;
190 reload();
194 inline const KUrl& DolphinColumnWidget::url() const
196 return m_url;
199 #endif