1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
Copyright (C) 2000, 2001, 2002 David Faure <david@mandrakesoft.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __konq_iconviewwidget_h__
#define __konq_iconviewwidget_h__
#include <kiconloader.h>
#include <kiconview.h>
#include <kurl.h>
#include <tqguardedptr.h>
#include <kfileitem.h>
#include <kio/jobclasses.h>
#include <libkonq_export.h>
class KonqFMSettings;
class KFileIVI;
class KonqIconDrag;
namespace KIO { class Job; }
/**
* A file-aware icon view, implementing drag'n'drop, KDE icon sizes,
* user settings, animated icons...
* Used by kdesktop and konq_iconview.
*
*/
class LIBKONQ_EXPORT KonqIconViewWidget : public KIconView
{
Q_OBJECT
Q_PROPERTY( bool sortDirectoriesFirst READ sortDirectoriesFirst WRITE setSortDirectoriesFirst )
Q_PROPERTY( TQRect iconArea READ iconArea WRITE setIconArea )
Q_PROPERTY( int lineupMode READ lineupMode WRITE setLineupMode )
Q_PROPERTY( TQString url READ urlString WRITE setNewURL )
friend class KFileIVI;
public:
enum LineupMode { LineupHorizontal=1, LineupVertical, LineupBoth };
/**
* Constructor
*/
KonqIconViewWidget( TQWidget *parent = 0L, const char *name = 0L, WFlags f = 0, bool kdesktop = FALSE );
virtual ~KonqIconViewWidget();
/**
* Read the configuration and apply it.
* Call this in the inherited constructor with bInit=true,
* and in some reparseConfiguration() slot with bInit=false.
* Returns true if the font was changed (which means something has to
* be done so that the icon's texts don't run into each other).
* However Konq and KDesktop handle this differently.
*/
bool initConfig( bool bInit );
/**
* Set the area that will be occupied by icons. It is still possible to
* drag icons outside this area; this only applies to automatically placed
* icons.
*/
void setIconArea( const TQRect &rect );
/**
* Reimplemented to make the slotOnItem highlighting work.
*/
virtual void focusOutEvent( TQFocusEvent * /* ev */ );
/**
* Returns the icon area.
*/
TQRect iconArea() const;
/**
* Set the lineup mode. This determines in which direction(s) icons are
* moved when lineing them up.
*/
void setLineupMode(int mode);
/**
* Returns the lineup mode.
*/
int lineupMode() const;
/**
* Line up the icons to a regular grid. The outline of the grid is
* specified by iconArea. The two length parameters are
* gridX and gridY.
*/
void lineupIcons();
/**
* Line up the icons to a regular grid horizontally or vertically.
*
* @param arrangement the arrangement to use (TQIconView::LeftToRight
* for a horizontal arrangement and TQIconView::TopToBottom
* for vertical)
*/
void lineupIcons( TQIconView::Arrangement arrangement );
/**
* Sets the icons of all items, and stores the @p size
* This doesn't touch thumbnails, except if @p stopImagePreviewFor is set.
* Takes care of the grid, when changing the size.
*
* @param size size to use for the icons
* @param stopImagePreviewFor set to a list of mimetypes which should be made normal again.
* For instance "text/plain,image/wmf".
* Can be set to "*" for "all mimetypes" and to "image/"+"*" for "all images".
*/
void setIcons( int size, const TQStringList& stopImagePreviewFor = TQStringList() );
/**
* Called on databaseChanged
*/
void refreshMimeTypes();
int iconSize() { return m_size; }
void calculateGridX();
/**
* The horizontal distance between two icons
* (whether or not a grid has been given to TQIconView)
*/
int gridXValue() const;
/**
* Calculate the tqgeometry of the fixed grid that is used to line up the
* icons, for example when using the lineupIcons() method.
*
* @param x
* @param y
* @param dx Cell width
* @param dy Cell height
* @param nx Number of columns
* @param ny Number of rows
*/
void gridValues( int* x, int* y, int* dx, int* dy, int* nx, int* ny );
/**
* Start generating the previews.
* @param ignored this parameter is probably ignored
* @param force if true, all files are looked at.
* Otherwise, only those which are not a thumbnail already.
*
* @todo figure out the parameter meanings again
*/
void startImagePreview( const TQStringList &ignored, bool force );
void stopImagePreview();
bool isPreviewRunning() const;
// unused
void setThumbnailPixmap( KFileIVI * item, const TQPixmap & pixmap );
void disableSoundPreviews();
void setURL ( const KURL & kurl );
// ### KDE4: make const
const KURL & url() { return m_url; }
TQString urlString() const { return m_url.url(); }
void setRootItem ( const KFileItem * item ) { m_rootItem = item; }
/**
* Get list of selected KFileItems
*/
KFileItemList selectedFileItems();
void setItemColor( const TQColor &c );
TQColor itemColor() const;
virtual void cutSelection();
virtual void copySelection();
virtual void pasteSelection();
virtual KURL::List selectedUrls(); // KDE4: remove virtual + add const
enum UrlFlags { UserVisibleUrls = 0, MostLocalUrls = 1 };
KURL::List selectedUrls( UrlFlags flags ) const; // KDE4: merge with above, default is == UserVisibleUrls
void paste( const KURL &url );
bool sortDirectoriesFirst() const;
void setSortDirectoriesFirst( bool b );
void setCaseInsensitiveSort( bool b );
bool caseInsensitiveSort() const;
/**
* Cache of the dragged URLs over the icon view, used by KFileIVI
*/
const KURL::List & dragURLs() { return m_lstDragURLs; }
/**
* Reimplemented from QIconView
*/
virtual void clear();
/**
* Reimplemented from QIconView
*/
virtual void takeItem( TQIconViewItem *item );
/**
* Reimplemented from TQIconView to take into account iconArea.
*/
virtual void insertInGrid( TQIconViewItem *item );
/**
* Reimplemented from TQIconView to update the gridX
*/
virtual void setItemTextPos( ItemTextPos pos );
/**
* Give feedback when item is activated.
*/
virtual void visualActivate(TQIconViewItem *);
bool isDesktop() const { return m_bDesktop; }
/**
* Provided for KDesktop.
*/
virtual void setWallpaper(const KURL&) { }
bool maySetWallpaper();
void setMaySetWallpaper(bool b);
void disableIcons( const KURL::List & lst );
TQString iconPositionGroupPrefix() const { return m_iconPositionGroupPrefix; }
TQString dotDirectoryPath() const { return m_dotDirectoryPath; }
void setPreviewSettings(const TQStringList& mimeTypes);
const TQStringList& previewSettings();
void setNewURL( const TQString& url );
public slots:
/**
* Checks the new selection and emits enableAction() signals
*/
virtual void slotSelectionChanged();
void slotSaveIconPositions();
void renameSelectedItem();
void renameCurrentItem();
void slotToolTipPreview( const KFileItem *, const TQPixmap & ); // ### unused - remove for KDE4
void slotToolTipPreviewResult() ; // ### unused - remove for KDE4
signals:
/**
* For cut/copy/paste/move/delete (see kparts/browserextension.h)
*/
void enableAction( const char * name, bool enabled );
void dropped();
void imagePreviewFinished();
void incIconSize();
void decIconSize();
/**
* We need to track drag in icon views for the spring loading folders
*/
void dragEntered( bool accepted );
void dragLeft();
void dragMove( bool accepted );
/**
* Emited after the dropped() event. This way we know when the
* drag'n'drop is really finished.
*/
void dragFinished();
protected slots:
virtual void slotDropped( TQDropEvent *e, const TQValueList<TQIconDragItem> & );
void slotItemRenamed(TQIconViewItem *item, const TQString &name);
void slotIconChanged(int);
void slotOnItem(TQIconViewItem *);
void slotOnViewport();
void slotStartSoundPreview();
void slotPreview(const KFileItem *, const TQPixmap &);
void slotPreviewResult();
void slotMovieUpdate( const TQRect& rect );
void slotMovietqStatus( int status );
void slotReenableAnimation();
void slotAboutToCreate(const TQPoint &pos, const TQValueList<KIO::CopyInfo> &files);
void doubleClickTimeout();
protected:
virtual TQDragObject *dragObject();
KonqIconDrag *konqDragObject( TQWidget * dragSource = 0L );
bool mimeTypeMatch( const TQString& mimeType, const TQStringList& mimeList ) const;
virtual void drawBackground( TQPainter *p, const TQRect &r );
/**
* r is the rectangle which you want to paint from the background.
* pt is the upper left point in the painter device where you want to paint
* the rectangle r.
*/
virtual void drawBackground( TQPainter *p, const TQRect &r,
const TQPoint &pt );
virtual void contentsDragEnterEvent( TQDragEnterEvent *e );
virtual void contentsDragLeaveEvent( TQDragLeaveEvent *e );
virtual void contentsDragMoveEvent( TQDragMoveEvent *e );
virtual void contentsDropEvent( TQDropEvent *e );
virtual void contentsMousePressEvent( TQMouseEvent *e );
virtual void contentsMouseReleaseEvent ( TQMouseEvent * e );
virtual void contentsMouseMoveEvent( TQMouseEvent *e );
virtual void backgroundPixmapChange( const TQPixmap & );
virtual void wheelEvent( TQWheelEvent* );
virtual void leaveEvent( TQEvent *e );
void readAnimatedIconsConfig();
void mousePressChangeValue();
bool boostPreview() const;
int previewIconSize( int size ) const;
int largestPreviewIconSize( int size ) const;
bool canPreview( KFileItem* item );
void updatePreviewMimeTypes();
private:
KURL m_url;
const KFileItem * m_rootItem;
KURL::List m_lstDragURLs;
int m_size;
/** Konqueror settings */
KonqFMSettings * m_pSettings;
bool m_bMousePressed;
TQPoint m_mousePos;
TQColor iColor;
bool m_bSortDirsFirst;
TQString m_iconPositionGroupPrefix;
TQString m_dotDirectoryPath;
int m_LineupMode;
TQRect m_IconRect;
bool m_bDesktop;
bool m_bSetGridX;
private:
struct KonqIconViewWidgetPrivate *d;
};
#endif
|