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;
36
* Grants auto expanding functionality to the provided item view.
37
* Qt has its own auto expand mechanism, but this works only
38
* for QTreeView. Auto expanding of folders is turned on
41
* If the provided view is an instance of the class QTreeView, the
42
* expansion of the directory is automatically done on hover. Otherwise
43
* the enterDir() signal is emitted and the caller needs to ensure that
44
* the requested directory is entered.
46
* The FolderExpander becomes a child of the provided view.
48
class LIBDOLPHINPRIVATE_EXPORT FolderExpander : public QObject
53
FolderExpander(QAbstractItemView* view, QSortFilterProxyModel* proxyModel);
54
virtual ~FolderExpander();
56
void setEnabled(bool enabled);
61
* Is emitted if the directory \a dirModelIndex should be entered. The
62
* signal is not emitted when a QTreeView is used, as the entering of
63
* the directory is already provided by expanding the tree node.
65
void enterDir(const QModelIndex& dirModelIndex);
70
void autoExpandTimeout();
75
QAbstractItemView* m_view;
76
QSortFilterProxyModel* m_proxyModel;
78
QTimer* m_autoExpandTriggerTimer;
79
QPoint m_autoExpandPos;
81
static const int AUTO_EXPAND_DELAY = 700;
84
* Watchs the drag/move events for the view to decide
85
* whether auto expanding of a folder should be triggered.
87
bool eventFilter(QObject* watched, QEvent* event);