delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / plasma / applets / folderview / folderview.h
blob8b92a4f1250f6153469f031652d027e720035b31
1 /*
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.
21 #ifndef FOLDERVIEW_H
22 #define FOLDERVIEW_H
24 #include <QCache>
25 #include <QPersistentModelIndex>
26 #include <QSortFilterProxyModel>
27 #include <QListView>
28 #include <QStyleOption>
29 #include <QPointer>
30 #include <QBasicTimer>
32 #include <KActionCollection>
33 #include <KMimeType>
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"
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;
58 class FolderView : public Plasma::Containment
60 Q_OBJECT
62 public:
63 FolderView(QObject *parent, const QVariantList &args);
64 ~FolderView();
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&);
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);
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();
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);
109 void themeChanged();
110 void networkStatusChanged(Solid::Networking::Status status);
111 void clipboardDataChanged();
112 void updateScreenRegion();
113 void showPreviewConfigDialog();
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);
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;
171 // ---------------------------------------------------------------------------
175 class MimeModel : public QStringListModel
177 public:
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);
186 private:
187 KMimeType::List m_mimetypes;
188 QMap<KMimeType*, Qt::CheckState> m_state;
193 // ---------------------------------------------------------------------------
197 class ProxyMimeModel : public QSortFilterProxyModel
199 Q_OBJECT
201 public:
202 ProxyMimeModel(QObject *parent = 0);
204 virtual void setSourceModel(QAbstractItemModel *sourceModel);
206 public slots:
207 void setFilter(const QString &filter);
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;
213 private:
214 QString m_filter;
217 #endif