2
* Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
3
* Copyright © 2008 Rafael Fernández López <ereslibre@kde.org>
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.
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.
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.
25
#include <QPersistentModelIndex>
26
#include <QSortFilterProxyModel>
28
#include <QStyleOption>
30
#include <QBasicTimer>
32
#include <KActionCollection>
35
#include <Solid/Networking>
37
#include <plasma/containment.h>
39
#include "ui_folderviewFilterConfig.h"
40
#include "ui_folderviewDisplayConfig.h"
41
#include "ui_folderviewLocationConfig.h"
42
#include "ui_folderviewPreviewConfig.h"
45
class KFileItemDelegate;
46
class KFilePlacesModel;
47
class KFilePreviewGenerator;
49
class QItemSelectionModel;
58
class FolderView : public Plasma::Containment
63
FolderView(QObject *parent, const QVariantList &args);
67
void saveState(KConfigGroup &config) const;
68
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
69
void setPath(const QString&);
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);
81
// These slots are for KonqPopupMenu
87
void moveToTrash(Qt::MouseButtons, Qt::KeyboardModifiers);
88
void deleteSelectedIcons();
89
void renameSelectedIcon();
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();
100
void activated(const QModelIndex &index);
101
void indexesMoved(const QModelIndexList &indexes);
102
void contextMenuRequest(QWidget *widget, const QPoint &screenPos);
104
void configAccepted();
105
void filterChanged(int index);
106
void selectUnselectAll();
107
void fontSettingsChanged();
108
void iconSettingsChanged(int group);
110
void networkStatusChanged(Solid::Networking::Status status);
111
void clipboardDataChanged();
112
void updateScreenRegion();
113
void showPreviewConfigDialog();
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);
130
KFileItemDelegate *m_delegate;
131
QPointer<KFilePreviewGenerator> m_previewGenerator;
132
QItemSelectionModel *m_selectionModel;
134
KDirModel *m_dirModel;
135
KFilePlacesModel *m_placesModel;
136
IconView *m_iconView;
137
ListView *m_listView;
139
IconWidget *m_iconWidget;
146
QString m_filterFiles;
147
QStringList m_filterFilesMimeList;
148
QPointer<KNewMenu> m_newMenu;
149
KActionCollection m_actionCollection;
150
QActionGroup *m_sortingGroup;
152
Ui::folderviewFilterConfig uiFilter;
153
Ui::folderviewDisplayConfig uiDisplay;
154
Ui::folderviewLocationConfig uiLocation;
155
Ui::folderviewPreviewConfig uiPreviewConfig;
156
bool m_sortDirsFirst;
161
QString m_customLabel;
162
QStringList m_previewPlugins;
163
int m_customIconSize;
165
QListView::Flow m_flow;
166
QBasicTimer m_delayedSaveTimer;
171
// ---------------------------------------------------------------------------
175
class MimeModel : public QStringListModel
178
MimeModel(QObject *parent = 0);
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);
187
KMimeType::List m_mimetypes;
188
QMap<KMimeType*, Qt::CheckState> m_state;
193
// ---------------------------------------------------------------------------
197
class ProxyMimeModel : public QSortFilterProxyModel
202
ProxyMimeModel(QObject *parent = 0);
204
virtual void setSourceModel(QAbstractItemModel *sourceModel);
207
void setFilter(const QString &filter);
210
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
211
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;