~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to apps/plasma/applets/folderview/folderview.h

  • Committer: Bazaar Package Importer
  • Author(s): Ana Beatriz Guerrero Lopez
  • Date: 2009-04-05 05:22:13 UTC
  • mfrom: (0.4.2 experimental) (0.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 235.
  • Revision ID: james.westby@ubuntu.com-20090405052213-39thr4l6p2ss07uj
Tags: 4:4.2.2-1
* New upstream release:
  - khtml fixes. (Closes: #290285, #359680)
  - Default konsole sessions can be deleted. (Closes: #286342)
  - Tag widget uses standard application palette. (Closes: #444800)
  - ... and surely many more but we have lost track...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
 
3
 *   Copyright © 2008 Rafael Fernández López <ereslibre@kde.org>
 
4
 *
 
5
 *   This library is free software; you can redistribute it and/or
 
6
 *   modify it under the terms of the GNU Library General Public
 
7
 *   License as published by the Free Software Foundation; either
 
8
 *   version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 *   This library 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 GNU
 
13
 *   Library General Public License for more details.
 
14
 *
 
15
 *   You should have received a copy of the GNU Library General Public License
 
16
 *   along with this library; see the file COPYING.LIB.  If not, write to
 
17
 *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 *   Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#ifndef FOLDERVIEW_H
 
22
#define FOLDERVIEW_H
 
23
 
 
24
#include <QCache>
 
25
#include <QPersistentModelIndex>
 
26
#include <QSortFilterProxyModel>
 
27
#include <QListView>
 
28
#include <QStyleOption>
 
29
#include <QPointer>
 
30
#include <QBasicTimer>
 
31
 
 
32
#include <KActionCollection>
 
33
#include <KMimeType>
 
34
 
 
35
#include <Solid/Networking>
 
36
 
 
37
#include <plasma/containment.h>
 
38
 
 
39
#include "ui_folderviewFilterConfig.h"
 
40
#include "ui_folderviewDisplayConfig.h"
 
41
#include "ui_folderviewLocationConfig.h"
 
42
#include "ui_folderviewPreviewConfig.h"
 
43
 
 
44
class KDirModel;
 
45
class KFileItemDelegate;
 
46
class KFilePlacesModel;
 
47
class KFilePreviewGenerator;
 
48
class KNewMenu;
 
49
class QItemSelectionModel;
 
50
class ProxyModel;
 
51
class IconView;
 
52
class IconWidget;
 
53
class ListView;
 
54
class Label;
 
55
class Dialog;
 
56
 
 
57
 
 
58
class FolderView : public Plasma::Containment
 
59
{
 
60
    Q_OBJECT
 
61
 
 
62
public:
 
63
    FolderView(QObject *parent, const QVariantList &args);
 
64
    ~FolderView();
 
65
 
 
66
    void init();
 
67
    void saveState(KConfigGroup &config) const;
 
68
    void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
 
69
    void setPath(const QString&);
 
70
 
 
71
protected:
 
72
    void createConfigurationInterface(KConfigDialog *parent);
 
73
    QList<QAction*> contextualActions();
 
74
    void constraintsEvent(Plasma::Constraints);
 
75
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
 
76
    void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
 
77
    void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
 
78
    void dropEvent(QGraphicsSceneDragDropEvent *event);
 
79
 
 
80
protected slots:
 
81
    // These slots are for KonqPopupMenu
 
82
    void copy();
 
83
    void cut();
 
84
    void paste();
 
85
    void pasteTo();
 
86
    void refreshIcons();
 
87
    void moveToTrash(Qt::MouseButtons, Qt::KeyboardModifiers);
 
88
    void deleteSelectedIcons();
 
89
    void renameSelectedIcon();
 
90
 
 
91
    void undoTextChanged(const QString &text);
 
92
    void toggleIconsLocked(bool locked);
 
93
    void toggleAlignToGrid(bool align);
 
94
    void toggleDirectoriesFirst(bool enable);
 
95
    void sortingChanged(QAction *action);
 
96
    void aboutToShowCreateNew();
 
97
    void updateIconWidget();
 
98
    void iconWidgetClicked();
 
99
 
 
100
    void activated(const QModelIndex &index);
 
101
    void indexesMoved(const QModelIndexList &indexes);
 
102
    void contextMenuRequest(QWidget *widget, const QPoint &screenPos);
 
103
 
 
104
    void configAccepted();
 
105
    void filterChanged(int index);
 
106
    void selectUnselectAll();
 
107
    void fontSettingsChanged();
 
108
    void iconSettingsChanged(int group);
 
109
    void themeChanged();
 
110
    void networkStatusChanged(Solid::Networking::Status status);
 
111
    void clipboardDataChanged();
 
112
    void updateScreenRegion();
 
113
    void showPreviewConfigDialog();
 
114
    
 
115
private:
 
116
    void setupIconView();
 
117
    void setUrl(const KUrl &url);
 
118
    QSize iconSize() const;
 
119
    QSize gridSize() const;
 
120
    void createActions();
 
121
    void updateSortActionsState();
 
122
    void updateListViewState();
 
123
    void updateIconViewState();
 
124
    void saveIconPositions() const;
 
125
    KUrl::List selectedUrls() const;
 
126
    void showContextMenu(QWidget *widget, const QPoint &pos, const QModelIndexList &indexes);
 
127
    void timerEvent(QTimerEvent *event);
 
128
 
 
129
private:
 
130
    KFileItemDelegate *m_delegate;
 
131
    QPointer<KFilePreviewGenerator> m_previewGenerator;
 
132
    QItemSelectionModel *m_selectionModel;
 
133
    ProxyModel *m_model;
 
134
    KDirModel *m_dirModel;
 
135
    KFilePlacesModel *m_placesModel;
 
136
    IconView *m_iconView;
 
137
    ListView *m_listView;
 
138
    Label *m_label;
 
139
    IconWidget *m_iconWidget;
 
140
    Dialog *m_dialog;
 
141
    QIcon m_icon;
 
142
    KUrl m_url;
 
143
    QColor m_textColor;
 
144
    QString m_titleText;
 
145
    int m_filterType;
 
146
    QString m_filterFiles;
 
147
    QStringList m_filterFilesMimeList;
 
148
    QPointer<KNewMenu> m_newMenu;
 
149
    KActionCollection m_actionCollection;
 
150
    QActionGroup *m_sortingGroup;
 
151
    int m_sortColumn;
 
152
    Ui::folderviewFilterConfig uiFilter;
 
153
    Ui::folderviewDisplayConfig uiDisplay;
 
154
    Ui::folderviewLocationConfig uiLocation;
 
155
    Ui::folderviewPreviewConfig uiPreviewConfig;
 
156
    bool m_sortDirsFirst;
 
157
    bool m_showPreviews;
 
158
    bool m_drawShadows;
 
159
    bool m_iconsLocked;
 
160
    bool m_alignToGrid;
 
161
    QString m_customLabel;
 
162
    QStringList m_previewPlugins;
 
163
    int m_customIconSize;
 
164
    int m_numTextLines;
 
165
    QListView::Flow m_flow;
 
166
    QBasicTimer m_delayedSaveTimer;
 
167
};
 
168
 
 
169
 
 
170
 
 
171
// ---------------------------------------------------------------------------
 
172
 
 
173
 
 
174
 
 
175
class MimeModel : public QStringListModel
 
176
{
 
177
public:
 
178
    MimeModel(QObject *parent = 0);
 
179
 
 
180
    virtual QVariant data(const QModelIndex &index, int role) const;
 
181
    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
 
182
    virtual QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
 
183
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
184
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
 
185
 
 
186
private:
 
187
    KMimeType::List m_mimetypes;
 
188
    QMap<KMimeType*, Qt::CheckState> m_state;
 
189
};
 
190
 
 
191
 
 
192
 
 
193
// ---------------------------------------------------------------------------
 
194
 
 
195
 
 
196
 
 
197
class ProxyMimeModel : public QSortFilterProxyModel
 
198
{
 
199
Q_OBJECT
 
200
 
 
201
public:
 
202
    ProxyMimeModel(QObject *parent = 0);
 
203
 
 
204
    virtual void setSourceModel(QAbstractItemModel *sourceModel);
 
205
 
 
206
public slots:
 
207
    void setFilter(const QString &filter);
 
208
 
 
209
protected:
 
210
    virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
 
211
    virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
 
212
 
 
213
private:
 
214
    QString m_filter;
 
215
};
 
216
 
 
217
#endif