summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sq_diroperator.h
blob: 98ffc9f0675991734269ee7f277a1b683016d6a0 (plain)
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
/***************************************************************************
                          sq_diroperator.h  -  description
                             -------------------
    begin                : Mon Mar 15 2004
    copyright            : (C) 2004 by Baryshev Dmitry
    email                : ksquirrel.iv@gmail.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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef SQ_DIROPERATOR_H
#define SQ_DIROPERATOR_H

#include <tqmap.h>

#include <tdediroperator.h>

class TQTimer;
class TQListViewItem;
class TQIconViewItem;

class KDirLister;
class KFileIconView;
class KFileItem;

class SQ_Downloader;

class SQ_DirOperator : public KDirOperator
{
    TQ_OBJECT
  

    public:
        /*
         *  View type.
         *
         *  - list view with small icons
         *  - icon view with large icons
         *  - detailed view with file details
         *  - thumbnail view with image thumbnails
         */
        enum ViewT {TypeList = 0, TypeIcons, TypeDetailed, TypeThumbs };

        /*
         *  Constructor. Creates diroperator with specified view type. SQ_DirOperatorBase
         *  reimplements createView() to create different custom views.
         *  View type is determined by 'type_'.
         */
        SQ_DirOperator(const KURL &url = KURL(), ViewT type_ = SQ_DirOperator::TypeList,
                                    TQWidget *parent = 0, const char *name = 0);

        ~SQ_DirOperator();

        void stopThumbnailUpdate();

        void enableThumbnailActions(bool enable);

        void fireDiskSize(const KURL &url);

        void setLazy(bool l, int delay, int rows);

        /*
         *  Deselect all items, set current item, select this item,
         *  and ensure it visible.
         */
        void setCurrentItem(KFileItem *item);

        void calcTotalSize();

        /*
         *  Save new view type for future use. It means that SQ_WidgetStack
         *  wants to change view type (for example "list view" => "thumbnail view"),
         *  and will activate an SQ_DirOperator's action, which will change view type.
         *
         *  See SQ_WidgetStack::raiseWidget() for more.
         */
        void prepareView(ViewT);

        KFileView* preparedView();

        void setPreparedView();

        void startOrNotThumbnailUpdate();

        /*
         *  Is current diropertor manages thumbnail view ?
         */
        bool isThumbView() const;

        int viewType() const;

        /*
         *  Smart update. Store all file items, reset view,
         *  and transfer all items back.
         */
        void smartUpdate();

        /*
         *  Remove ".." item from current view
         */
        void removeCdUpItem();

        void stopPreview();

        void setPendingFile(const TQString &p);

        void execute(KFileItem *item);

        void saveConfig();

        void selectOld();

    protected:
        /*
         *  Reimplement createView() to create custom views.
         */
        virtual KFileView* createView(TQWidget *parent, KFile::FileView view);

    private:
        void itemKill(KFileItem *);

        void executePrivate(KFileItem *);

        void disableSpecificActions(KFileIconView *);

        /*
         *  SQ_DirOperator has context menu, derived from KDirOperator.
         *  This method will change this menu, insert new actions.
         */
        void setupActionsMy();

        void clearListers();

    signals:
        /*
         *  If user clicked on item, and it is archive file,
         *  emit this signal. Normally SQ_WidgetStack will catch it.
         */
        void tryUnpack(KFileItem *item);

        /*
         *  Run selected file separately (with default application)
         */
        void runSeparately(KFileItem *item);

    public slots:
        void urlAdded(const KURL &);
        void urlRemoved(const KURL &);

        /*
         *  Invoked, when current directory has been loaded.
         */
        void slotFinishedLoading();

        /*
         *  Change thumbnail size.
         */
        void slotSetThumbSize(const TQString&);

    private slots:

        void slotDownloadPercents(int);

        void slotCopyPath();
        void slotCopyURL();

        void slotEnableFileActions(bool);

        void slotInvokeBrowser();
        /*
         *  Since KDE 3.4 (or 3.5 ?) it is neccessary to reimplement this slot
         *  to insert our own actions in context menu.
         */
        void activatedMenu(const KFileItem *, const TQPoint &pos);

        void slotDownloaderResult(const KURL &);

        void slotSetURL(const KURL &);

        /*
         *  Connected to dirLister()
         */
        void slotNewItems(const KFileItemList &);
        void slotRefreshItems(const KFileItemList &);

        void slotDelayedFinishedLoading();

        void slotFoundMountPoint(const unsigned long&,
                    const unsigned long&,
                    const unsigned long&,
                    const TQString&);

        /*
         *  Edit current item's mimetype (Konqueror-related action).
         */
        void slotEditMime();

        void slotPreview();

        void slotDropped(const KFileItem *, TQDropEvent*, const KURL::List&);
        void slotAddToBasket();
        void slotAddToDirectoryBasket();

        /*
         *  Execute item. If current clicking policy is "Single click",
         *  single click will execute item, and double click otherwise.
         */
        void slotExecutedConst(const KFileItem *item);

        /*
         *  URL entered.
         */
        void slotUrlEntered(const KURL&);

        /*
         *  Invoked, when some item has been deleted. We should
         *  remove appropriate thumbnail from pixmap cache.
         */
        void slotItemDeleted(KFileItem *);

        void slotUpdateInformation(int,int);

        void slotSelectionChanged();

        void slotCurrentChanged(TQListViewItem *);
        void slotCurrentChanged(TQIconViewItem *);

    private:
        typedef TQMap<KURL, KDirLister *> SQ_Listers;
        SQ_Listers listers;

        /*
         *  Pointer to current view. All view types (such as icon view, list view ...)
         *  are derived from KFileView.
         */
        KFileView     *fileview;

        /*
         *  Some additional menus.
         */
        TDEActionMenu     *pADirOperatorMenu, *pAFileActions, *pAImageActions;
        TDEToggleAction   *actionHidden;

        ViewT     type;
        TQTimer    *timer_preview;
        KURL lasturl;
        bool usenew;
        TQString m_pending;
        TDEIO::filesize_t totalSize;
        KFileItemList oldSelected;
        KFileItem     *oldCurrentItem;
        SQ_Downloader *down;
};

inline
int SQ_DirOperator::viewType() const
{
    return static_cast<int>(type);
}

inline
bool SQ_DirOperator::isThumbView() const
{
    return (type == SQ_DirOperator::TypeThumbs);
}

inline
KFileView* SQ_DirOperator::preparedView()
{
    return fileview;
}

inline
KFileView* SQ_DirOperator::createView(TQWidget *, KFile::FileView)
{
    return fileview;
}

inline
void SQ_DirOperator::setPendingFile(const TQString &p)
{
    m_pending = p;
}

#endif