]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphiniconsview.h
commited initial version of Dolphin
[dolphin.git] / src / dolphiniconsview.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #ifndef DOLPHINICONSVIEW_H
22 #define DOLPHINICONSVIEW_H
23
24 #include <kfileiconview.h>
25 #include <qpixmap.h>
26 //Added by qt3to4:
27 #include <QDragEnterEvent>
28 #include <QDropEvent>
29 #include <QMouseEvent>
30 #include <QDragMoveEvent>
31 #include <kurl.h>
32 #include <itemeffectsmanager.h>
33
34 class DolphinView;
35
36 /**
37 * @brief Represents the view, where each item is shown as an icon.
38 *
39 * It is also possible that instead of the icon a preview of the item
40 * content is shown.
41 *
42 * @author Peter Penz
43 */
44 class DolphinIconsView : public KFileIconView, public ItemEffectsManager
45 {
46 Q_OBJECT
47
48 public:
49 enum LayoutMode {
50 Icons,
51 Previews
52 };
53
54 DolphinIconsView(DolphinView *parent, LayoutMode layoutMode);
55
56 virtual ~DolphinIconsView();
57
58 void setLayoutMode(LayoutMode mode);
59 LayoutMode layoutMode() const { return m_layoutMode; }
60
61 /** @see ItemEffectsManager::updateItems */
62 virtual void beginItemUpdates();
63
64 /** @see ItemEffectsManager::updateItems */
65 virtual void endItemUpdates();
66
67 /**
68 * Reads out the dolphin settings for the icons view and refreshs
69 * the details view.
70 */
71 // TODO: Other view implementations use a similar interface. When using
72 // Interview in Qt4 this method should be moved to a base class (currently
73 // not possible due to having different base classes for the views).
74 void refreshSettings();
75
76 /** @see ItemEffectsManager::zoomIn() */
77 virtual void zoomIn();
78
79 /** @see ItemEffectsManager::zoomOut() */
80 virtual void zoomOut();
81
82 /** @see ItemEffectsManager::isZoomInPossible() */
83 virtual bool isZoomInPossible() const;
84
85 /** @see ItemEffectsManager::isZoomOutPossible() */
86 virtual bool isZoomOutPossible() const;
87
88 public slots:
89 /**
90 * Bypass a layout issue in KFileIconView in combination with previews.
91 * @see KFileIconView::arrangeItemsInGrid
92 */
93 virtual void arrangeItemsInGrid(bool updated = true);
94
95 signals:
96 /**
97 * Is send, if the details view should be activated. Usually an activation
98 * is triggered by a mouse click.
99 */
100 void signalRequestActivation();
101
102 protected:
103 /** @see ItemEffectsManager::setContextPixmap */
104 virtual void setContextPixmap(void* context,
105 const QPixmap& pixmap);
106
107 /** @see ItemEffectsManager::contextPixmap */
108 virtual const QPixmap* contextPixmap(void* context);
109
110 /** @see ItemEffectsManager::firstContext */
111 virtual void* firstContext();
112
113 /** @see ItemEffectsManager::nextContext */
114 virtual void* nextContext(void* context);
115
116 /** @see ItemEffectsManager::contextFileInfo */
117 virtual KFileItem* contextFileInfo(void* context);
118
119 /** @see KFileIconView::contentsMousePressEvent */
120 virtual void contentsMousePressEvent(QMouseEvent* event);
121
122 /** @see KFileIconView::contentsMouseReleaseEvent */
123 virtual void contentsMouseReleaseEvent(QMouseEvent* event);
124
125 /** @see KFileIconView::drawBackground */
126 virtual void drawBackground(QPainter* painter, const QRect& rect);
127
128 /** @see KFileIconView::dragObject */
129 virtual Q3DragObject* dragObject();
130
131 /** @see KFileIconView::contentsDragEnterEvent */
132 virtual void contentsDragEnterEvent(QDragEnterEvent* event);
133
134 /** @see KFileIconView::contentsDragMoveEvent */
135 virtual void contentsDragMoveEvent(QDragMoveEvent* event);
136
137 /** @see KFileIconView::contentsDropEvent */
138 virtual void contentsDropEvent(QDropEvent* event);
139
140 private slots:
141 /** Is connected to the onItem-signal from KFileIconView. */
142 void slotOnItem(Q3IconViewItem* item);
143
144 /** Is connected to the onViewport-signal from KFileIconView. */
145 void slotOnViewport();
146
147 /**
148 * Opens the context menu for the item \a item on the given
149 * position \a pos.
150 */
151 void slotContextMenuRequested(Q3IconViewItem* item,
152 const QPoint& pos);
153
154 /** Renames the item \a item to the name \a name. */
155 void slotItemRenamed(Q3IconViewItem* item,
156 const QString& name);
157
158 void slotActivationUpdate();
159 void slotUpdateDisabledItems();
160
161 private:
162 int m_previewIconSize;
163 LayoutMode m_layoutMode;
164 DolphinView* m_dolphinView;
165
166 /** Returns the increased icon size for the size \a size. */
167 int increasedIconSize(int size) const;
168
169 /** Returns the decreased icon size for the size \a size. */
170 int decreasedIconSize(int size) const;
171 };
172
173 #endif