1 /***************************************************************************
2 * Copyright (C) 2008 by Simon St James <kdedevel@etotheipiplusone.com> *
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. *
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. *
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"
29 class QAbstractItemView
;
32 class QSortFilterProxyModel
;
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
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
54 FolderExpander(QAbstractItemView
* view
, QSortFilterProxyModel
* proxyModel
);
55 virtual ~FolderExpander();
57 void setEnabled(bool enabled
);
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
);
71 void autoExpandTimeout();
76 QAbstractItemView
* m_view
;
77 QSortFilterProxyModel
* m_proxyModel
;
79 QTimer
* m_autoExpandTriggerTimer
;
80 QPoint m_autoExpandPos
;
82 static const int AUTO_EXPAND_DELAY
= 700;
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
);