delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / dolphin / src / folderexpander.h
blob57b8e9e5505e819b2f13626c9c8159d4d56efc0b
1 /***************************************************************************
2 * Copyright (C) 2008 by Simon St James <kdedevel@etotheipiplusone.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
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 *
12 * GNU 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; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef FOLDEREXPANDER_H
21 #define FOLDEREXPANDER_H
23 // Needs to be exported as FoldersPanel uses it.
24 #include "libdolphin_export.h"
26 #include <QObject>
27 #include <QPoint>
29 class QAbstractItemView;
30 class QTreeView;
31 class QTimer;
32 class QSortFilterProxyModel;
33 class QModelIndex;
34 class KDirModel;
36 /**
37 * Grants auto expanding functionality to the provided item view.
38 * Qt has its own auto expand mechanism, but this works only
39 * for QTreeView. Auto expanding of folders is turned on
40 * per default.
42 * If the provided view is an instance of the class QTreeView, the
43 * expansion of the directory is automatically done on hover. Otherwise
44 * the enterDir() signal is emitted and the caller needs to ensure that
45 * the requested directory is entered.
47 * The FolderExpander becomes a child of the provided view.
49 class LIBDOLPHINPRIVATE_EXPORT FolderExpander : public QObject
51 Q_OBJECT
53 public:
54 FolderExpander(QAbstractItemView* view, QSortFilterProxyModel* proxyModel);
55 virtual ~FolderExpander();
57 void setEnabled(bool enabled);
58 bool enabled() const;
60 signals:
61 /**
62 * Is emitted if the directory \a dirModelIndex should be entered. The
63 * signal is not emitted when a QTreeView is used, as the entering of
64 * the directory is already provided by expanding the tree node.
66 void enterDir(const QModelIndex& dirModelIndex, QAbstractItemView* view);
69 private slots:
70 void viewScrolled();
71 void autoExpandTimeout();
73 private:
74 bool m_enabled;
76 QAbstractItemView* m_view;
77 QSortFilterProxyModel* m_proxyModel;
79 QTimer* m_autoExpandTriggerTimer;
80 QPoint m_autoExpandPos;
82 static const int AUTO_EXPAND_DELAY = 700;
84 /**
85 * Watchs the drag/move events for the view to decide
86 * whether auto expanding of a folder should be triggered.
88 bool eventFilter(QObject* watched, QEvent* event);
90 #endif