~ubuntu-branches/ubuntu/warty/kdebase/warty

« back to all changes in this revision

Viewing changes to kdesktop/kdiconview.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-09-16 04:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040916045145-9vr63kith3k1cpza
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
4
 
 
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.
 
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 GNU
 
12
    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; 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.
 
18
*/
 
19
 
 
20
#ifndef kdiconview_h
 
21
#define kdiconview_h
 
22
 
 
23
#include <konq_iconviewwidget.h>
 
24
#include <kaction.h>
 
25
#include <kfileitem.h>
 
26
 
 
27
class KDirLister;
 
28
class KonqSettings;
 
29
class KSimpleConfig;
 
30
class KAccel;
 
31
class KShadowEngine;
 
32
class KDesktopShadowSettings;
 
33
 
 
34
/**
 
35
 * This class is KDesktop's icon view.
 
36
 * The icon view is a child widget of the KDesktop widget.
 
37
 *
 
38
 * Added shadow capability by Laur Ivan (C) 2003
 
39
 * The shadow is supported by the new KFileIVIDesktop objects
 
40
 * which replace KFileIVI objects.
 
41
 */
 
42
class KDIconView : public KonqIconViewWidget
 
43
{
 
44
    Q_OBJECT
 
45
public:
 
46
    KDIconView( QWidget *parent, const char* name = 0L );
 
47
    ~KDIconView();
 
48
 
 
49
    virtual void initConfig( bool init );
 
50
    void configureDevices();
 
51
    /**
 
52
     * Start listing
 
53
     */
 
54
    void start();
 
55
 
 
56
    KActionCollection *actionCollection() { return &m_actionCollection; }
 
57
 
 
58
    enum SortCriterion { NameCaseSensitive = 0, NameCaseInsensitive, Size, Type };
 
59
 
 
60
    void rearrangeIcons( SortCriterion sc, bool bSortDirectoriesFirst);
 
61
 
 
62
    /**
 
63
     * Re-arrange the desktop icons without confirmation.
 
64
     */
 
65
    void rearrangeIcons();
 
66
 
 
67
    void lineupIcons(QIconView::Arrangement);
 
68
 
 
69
    void refreshIcons();
 
70
    QStringList selectedURLs();
 
71
 
 
72
    /**
 
73
     * Save the icon positions
 
74
     */
 
75
    void saveIconPositions();
 
76
 
 
77
    /**
 
78
     * Check if the URL to the desktop has changed
 
79
     */
 
80
    void recheckDesktopURL();
 
81
 
 
82
    /**
 
83
     * Called when the work area has changed
 
84
     */
 
85
    void updateWorkArea( const QRect &wr );
 
86
 
 
87
    /**
 
88
     * Reimplemented from KonqIconViewWidget (for image drops)
 
89
     */
 
90
    virtual void setWallpaper(const KURL &url) { emit newWallpaper( url ); }
 
91
    void setLastIconPosition( const QPoint & );
 
92
protected slots:
 
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);
 
101
 
 
102
    void slotItemRenamed(QIconViewItem*, const QString &name);
 
103
 
 
104
    // slots connected to the directory lister
 
105
    void slotClear();
 
106
    void slotStarted( const KURL& url );
 
107
    void slotCompleted();
 
108
    void slotNewItems( const KFileItemList& );
 
109
    void slotDeleteItem( KFileItem * );
 
110
    void slotRefreshItems( const KFileItemList& );
 
111
 
 
112
    // slots connected to the popupmenu (actions)
 
113
    void slotCut();
 
114
    void slotCopy();
 
115
    void slotTrash();
 
116
    void slotDelete();
 
117
    void slotShred();
 
118
    void slotPopupPasteTo();
 
119
 
 
120
    void slotClipboardDataChanged();
 
121
 
 
122
    void slotNewMenuActivated();
 
123
 
 
124
    // For communication with KDesktop
 
125
signals:
 
126
    void colorDropEvent( QDropEvent *e );
 
127
    void imageDropEvent( QDropEvent *e );
 
128
    void newWallpaper( const KURL & );
 
129
    void iconMoved();
 
130
 
 
131
public slots:
 
132
    /**
 
133
     * Lineup the desktop icons.
 
134
     */
 
135
    void lineupIcons();
 
136
    void slotPaste(); // for krootwm
 
137
protected:
 
138
    void createActions();
 
139
    void setupSortKeys();
 
140
    KURL desktopURL();
 
141
    void initDotDirectories();
 
142
 
 
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 );
 
149
    
 
150
    bool deleteGlobalDesktopFiles();
 
151
 
 
152
    static void renameDesktopFile(const QString &path, const QString &name);
 
153
 
 
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 );
 
161
 
 
162
private slots:
 
163
    void desktopResized();
 
164
 
 
165
private:
 
166
    /** Our action collection, parent of all our actions */
 
167
    KActionCollection m_actionCollection;
 
168
 
 
169
    /** KAccel object, to make the actions shortcuts work */
 
170
    KAccel *m_accel;
 
171
 
 
172
    bool m_bNeedRepaint;
 
173
    bool m_bNeedSave;
 
174
 
 
175
    /** true if even one icon has an icon-position entry in the .directory */
 
176
    bool m_hasExistingPos;
 
177
 
 
178
    /** Show dot files ? */
 
179
    bool m_bShowDot;
 
180
 
 
181
    /** Vertical or Horizontal align of icons on desktop */
 
182
    bool m_bVertAlign;
 
183
 
 
184
    /** Wheelbuttons switch workspaces */
 
185
    bool m_bWheelSwitchesWorkspace;
 
186
 
 
187
    /** The directory lister - created only in start() */
 
188
    KDirLister* m_dirLister;
 
189
 
 
190
    /** The list of urls to be merged into the desktop, in addition to desktopURL */
 
191
    KURL::List m_mergeDirs;
 
192
    
 
193
    /** The list of dirs to be merged into the desktop, in addition to desktopURL **/
 
194
    QStringList m_desktopDirs;
 
195
 
 
196
    /** The desktop's .directory, used for storing icon positions */
 
197
    KSimpleConfig *m_dotDirectory;
 
198
 
 
199
    /** Position of last deleted icon - used when renaming a file */
 
200
    QPoint m_lastDeletedIconPos;
 
201
 
 
202
    /** Sorting */
 
203
    SortCriterion m_eSortCriterion;
 
204
    bool m_bSortDirectoriesFirst;
 
205
    QStringList m_itemsAlwaysFirst;
 
206
 
 
207
    /**
 
208
     * The shadow object
 
209
     */
 
210
    KShadowEngine *m_shadowEngine;
 
211
 
 
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;
 
215
 
 
216
    /** Position where the last drop occurred */
 
217
    QPoint m_dropPos;
 
218
 
 
219
    /** Position for the last dropped item */
 
220
    QPoint m_lastDropPos;
 
221
 
 
222
    /** URL of the items which is being RMB'ed - when only one */
 
223
    KURL m_popupURL;
 
224
 
 
225
    /** device list management */
 
226
    bool m_enableDevices;
 
227
    QStringList m_excludedDevices;
 
228
};
 
229
 
 
230
#endif