2010-05-17 01:44:33 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-05-17 01:44:33 +02:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AUTOEXPANDINGTREEVIEW_H
|
|
|
|
#define AUTOEXPANDINGTREEVIEW_H
|
|
|
|
|
|
|
|
#include <QTreeView>
|
|
|
|
|
|
|
|
class AutoExpandingTreeView : public QTreeView {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
public:
|
2010-05-17 01:44:33 +02:00
|
|
|
AutoExpandingTreeView(QWidget* parent = 0);
|
|
|
|
|
|
|
|
static const int kRowsToShow;
|
|
|
|
|
|
|
|
void SetAutoOpen(bool v) { auto_open_ = v; }
|
|
|
|
void SetExpandOnReset(bool v) { expand_on_reset_ = v; }
|
2012-03-11 00:38:54 +01:00
|
|
|
void SetAddOnDoubleClick(bool v) { add_on_double_click_ = v; }
|
2010-05-17 01:44:33 +02:00
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
public slots:
|
2010-05-17 01:44:33 +02:00
|
|
|
void RecursivelyExpand(const QModelIndex &index);
|
2011-03-13 15:14:16 +01:00
|
|
|
void UpAndFocus();
|
|
|
|
void DownAndFocus();
|
2010-05-17 01:44:33 +02:00
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
signals:
|
|
|
|
void AddToPlaylistSignal(QMimeData* data);
|
2011-03-13 15:14:16 +01:00
|
|
|
void FocusOnFilterSignal(QKeyEvent* event);
|
2011-01-10 23:26:13 +01:00
|
|
|
|
|
|
|
protected:
|
2010-05-17 01:44:33 +02:00
|
|
|
// QAbstractItemView
|
|
|
|
void reset();
|
|
|
|
|
2010-12-26 19:07:57 +01:00
|
|
|
// QWidget
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
2011-03-13 15:14:16 +01:00
|
|
|
void keyPressEvent(QKeyEvent* event);
|
2010-12-26 19:07:57 +01:00
|
|
|
|
2010-09-18 15:55:04 +02:00
|
|
|
virtual bool CanRecursivelyExpand(const QModelIndex& index) const { return true; }
|
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
private slots:
|
2010-05-17 01:44:33 +02:00
|
|
|
void ItemExpanded(const QModelIndex& index);
|
2010-12-07 22:13:40 +01:00
|
|
|
void ItemClicked(const QModelIndex& index);
|
2010-12-11 12:26:47 +01:00
|
|
|
void ItemDoubleClicked(const QModelIndex& index);
|
2010-05-17 01:44:33 +02:00
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
private:
|
2010-05-17 01:44:33 +02:00
|
|
|
bool RecursivelyExpand(const QModelIndex& index, int* count);
|
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
private:
|
2010-05-17 01:44:33 +02:00
|
|
|
bool auto_open_;
|
|
|
|
bool expand_on_reset_;
|
2012-03-11 00:38:54 +01:00
|
|
|
bool add_on_double_click_;
|
2010-12-11 12:26:47 +01:00
|
|
|
|
|
|
|
bool ignore_next_click_;
|
2010-05-17 01:44:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AUTOEXPANDINGTREEVIEW_H
|