1
/* This file is part of the KDE project
2
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3
Copyright (C) 2000, 2001 David Faure <faure@kde.org>
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public
7
License version 2 as published by the Free Software Foundation.
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 GNU
12
General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; see the file COPYING. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
23
#include <konq_iconviewwidget.h>
25
#include <kfileitem.h>
32
class KDesktopShadowSettings;
35
* This class is KDesktop's icon view.
36
* The icon view is a child widget of the KDesktop widget.
38
* Added shadow capability by Laur Ivan (C) 2003
39
* The shadow is supported by the new KFileIVIDesktop objects
40
* which replace KFileIVI objects.
42
class KDIconView : public KonqIconViewWidget
46
KDIconView( QWidget *parent, const char* name = 0L );
49
virtual void initConfig( bool init );
50
void configureDevices();
56
KActionCollection *actionCollection() { return &m_actionCollection; }
58
enum SortCriterion { NameCaseSensitive = 0, NameCaseInsensitive, Size, Type };
60
void rearrangeIcons( SortCriterion sc, bool bSortDirectoriesFirst);
63
* Re-arrange the desktop icons without confirmation.
65
void rearrangeIcons();
67
void lineupIcons(QIconView::Arrangement);
70
QStringList selectedURLs();
73
* Save the icon positions
75
void saveIconPositions();
78
* Check if the URL to the desktop has changed
80
void recheckDesktopURL();
83
* Called when the work area has changed
85
void updateWorkArea( const QRect &wr );
88
* Reimplemented from KonqIconViewWidget (for image drops)
90
virtual void setWallpaper(const KURL &url) { emit newWallpaper( url ); }
91
void setLastIconPosition( const QPoint & );
93
// slots connected to the icon view
94
void slotReturnPressed( QIconViewItem *item );
95
void slotExecuted( QIconViewItem *item );
96
void slotMouseButtonPressed(int _button, QIconViewItem* _item, const QPoint& _global);
97
void slotMouseButtonClickedKDesktop(int _button, QIconViewItem* _item, const QPoint& _global);
98
void slotContextMenuRequested(QIconViewItem* _item, const QPoint& _global);
99
void slotEnableAction( const char * name, bool enabled );
100
void slotAboutToCreate(const QPoint &pos, const QValueList<KIO::CopyInfo> &files);
102
void slotItemRenamed(QIconViewItem*, const QString &name);
104
// slots connected to the directory lister
106
void slotStarted( const KURL& url );
107
void slotCompleted();
108
void slotNewItems( const KFileItemList& );
109
void slotDeleteItem( KFileItem * );
110
void slotRefreshItems( const KFileItemList& );
112
// slots connected to the popupmenu (actions)
118
void slotPopupPasteTo();
120
void slotClipboardDataChanged();
122
void slotNewMenuActivated();
124
// For communication with KDesktop
126
void colorDropEvent( QDropEvent *e );
127
void imageDropEvent( QDropEvent *e );
128
void newWallpaper( const KURL & );
133
* Lineup the desktop icons.
136
void slotPaste(); // for krootwm
138
void createActions();
139
void setupSortKeys();
141
void initDotDirectories();
143
bool makeFriendlyText( KFileIVI *fileIVI );
144
static QString stripDesktopExtension( const QString & text );
145
bool isDesktopFile( KFileItem * _item ) const;
146
bool isFreePosition( const QIconViewItem *item ) const;
147
bool isFreePosition( const QIconViewItem *item, const QRect& rect ) const;
148
void moveToFreePosition(QIconViewItem *item );
150
bool deleteGlobalDesktopFiles();
152
static void renameDesktopFile(const QString &path, const QString &name);
154
virtual void popupMenu( const QPoint &_global, KFileItemList _items );
155
virtual void showEvent( QShowEvent *e );
156
virtual void contentsDropEvent( QDropEvent *e );
157
virtual void viewportWheelEvent( QWheelEvent * );
158
virtual void contentsMousePressEvent( QMouseEvent *e );
159
virtual void mousePressEvent( QMouseEvent *e );
160
virtual void wheelEvent( QWheelEvent* e );
163
void desktopResized();
166
/** Our action collection, parent of all our actions */
167
KActionCollection m_actionCollection;
169
/** KAccel object, to make the actions shortcuts work */
175
/** true if even one icon has an icon-position entry in the .directory */
176
bool m_hasExistingPos;
178
/** Show dot files ? */
181
/** Vertical or Horizontal align of icons on desktop */
184
/** Wheelbuttons switch workspaces */
185
bool m_bWheelSwitchesWorkspace;
187
/** The directory lister - created only in start() */
188
KDirLister* m_dirLister;
190
/** The list of urls to be merged into the desktop, in addition to desktopURL */
191
KURL::List m_mergeDirs;
193
/** The list of dirs to be merged into the desktop, in addition to desktopURL **/
194
QStringList m_desktopDirs;
196
/** The desktop's .directory, used for storing icon positions */
197
KSimpleConfig *m_dotDirectory;
199
/** Position of last deleted icon - used when renaming a file */
200
QPoint m_lastDeletedIconPos;
203
SortCriterion m_eSortCriterion;
204
bool m_bSortDirectoriesFirst;
205
QStringList m_itemsAlwaysFirst;
210
KShadowEngine *m_shadowEngine;
212
/** Position where to move the next item.
213
* It is set to the KRootWm position when "new file" is chosen. */
214
QPoint m_nextItemPos;
216
/** Position where the last drop occurred */
219
/** Position for the last dropped item */
220
QPoint m_lastDropPos;
222
/** URL of the items which is being RMB'ed - when only one */
225
/** device list management */
226
bool m_enableDevices;
227
QStringList m_excludedDevices;