summaryrefslogtreecommitdiffstats
path: root/filestreewidget.h
blob: 4a7e3f322537808222e67afc7b579038e2042199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
  This program 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
  2 of the License, or (at your option) any later version.
*/

#ifndef FILESTREEWIDGET_H
#define FILESTREEWIDGET_H

#include <QWidget>
#include <QTreeView>
#include <QSortFilterProxyModel>

typedef QList<QPersistentModelIndex> PersistenModelIndexList;

class FilesTreeView;
class FilesTreeModel;
class FilesTreeSortModel;
class SeriesTreeModel;
class PictureViewer2;
class HoverWindow;
class QContextMenuEvent;
class QSpinBox;
class QPushButton;
class QEvent;

class FilesTreeWidget : public QWidget {
	Q_OBJECT
	public:
		explicit FilesTreeWidget(QWidget *parent = 0);
		FilesTreeView *filesTree() { return mView; }
		void resetSize();

	public slots:
		void moveToBurn();
		void removeFiles();
		void moveToDirectory();
		void fileProperties();
		void edit(int column);
		void suggest();

	private slots:
        void fileSelectionChanged();
		void itemDoubleClicked(const QModelIndex &index);

	signals:
        void selectedSize(qint64);
        void numSelected(int);
		void statusMessage(QString);

	private:
		FilesTreeView *mView;
		FilesTreeModel *mModel;
		FilesTreeSortModel *mProxy;
		SeriesTreeModel *mSeriesModel;
        PictureViewer2 *mPictureViewer;
		QModelIndexList mSelectedFiles;
		qint64 mSelectedSize;
};

class FilesTreeView : public QTreeView {
	Q_OBJECT
	public:
		explicit FilesTreeView(QWidget *parent = 0);
		virtual void setModel(QAbstractItemModel *model);

	public slots:
		void readSettings();
		void readHeaderConfig();
		void writeHeaderConfig();
		void toggleHeader(QObject *action);

	protected:
		virtual void contextMenuEvent(QContextMenuEvent *event);
		virtual bool event(QEvent *event);

	private:
		bool exitHover(bool exitVal = true);
		void doHover(const QModelIndex &idx);
		const QString fileNameText(const QModelIndex &idx) const;
		const QString metaDataText(const QModelIndex &idx) const;
		const QPixmap annotateHover(const QPixmap &hoverImage, const QString &text) const;
		QModelIndex mCurHover;
		HoverWindow *mHoverWin;
		bool mHoverPics;
		bool mHoverMovies;
		qint16 mCursorOffest;
};

class FilesTreeSortModel : public QSortFilterProxyModel {
	Q_OBJECT
	public:
		FilesTreeSortModel(QObject *parent = 0);
		~FilesTreeSortModel() {}

	protected:
		virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
};
#endif