OSDN Git Service

42705a83c8d7f06fdbfb76c0f6e7f53fbd809a21
[gefu/Gefu.git] / folderview.h
1 #ifndef FOLDERVIEW_H
2 #define FOLDERVIEW_H
3
4 #include "filetablemodel.h"
5 #include "history.h"
6
7 #include <QTableView>
8 class MainWindow;
9
10 class FolderView : public QTableView
11 {
12     Q_OBJECT
13 public:
14     explicit FolderView(QWidget *parent = 0);
15
16     QString side() const;
17
18     // actions
19     void initialize(MainWindow *mainWnd, bool left);
20     void updateAppearance(bool darker = false);
21     void refresh();
22
23     void searchItem(const QString &text);
24     void searchNext(const QString &text);
25     void searchPrev(const QString &text);
26
27     void setCheckStateAll(Qt::CheckState state);
28     void setCheckStateAllFiles();
29     void invertCheckState();
30     void toggleCheckState(const QModelIndex &index);
31
32     bool historyBack();
33     bool historyForward();
34
35     // getter
36     QFileInfo currentItem() const;
37     QString dir() const { return m_model.absolutePath(); }
38     QFileInfoList checkedItems() const;
39     QFileInfoList selectedItems() const;
40     const History* history() const { return &m_history; }
41     QStringList nameFilters() const { return m_model.nameFilters(); }
42
43     // setter
44     void setPath(const QString &path, bool addHistory);
45     void setFilter(QDir::Filters filter, bool enable);
46     void setHistoryIndexAt(int index);
47     void setNameFilters(const QStringList &list);
48     void setSorting();
49
50 private:
51     MainWindow *m_mainWnd;
52     FileTableModel m_model;
53     History m_history;
54     QPoint m_dragStartPos;
55     bool m_dragging;
56
57 signals:
58     void currentChanged(const QFileInfo &info);
59     void dataChanged();
60     void dropAccepted(const QFileInfoList &list);
61     void itemFound();
62     void itemNotFound();
63     void retrieveStarted(const QString &path);
64     void requestContextMenu(QContextMenuEvent *event);
65 //    void keyPressed(QKeyEvent *event);
66
67 public slots:
68
69     // QAbstractItemView interface
70 protected slots:
71     void currentChanged(const QModelIndex &current, const QModelIndex &previous);
72     void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
73
74     // QWidget interface
75 protected:
76     void keyPressEvent(QKeyEvent *event);
77     void mousePressEvent(QMouseEvent *event);
78     void mouseMoveEvent(QMouseEvent *event);
79     void dragEnterEvent(QDragEnterEvent *event);
80     void dropEvent(QDropEvent *event);
81     void contextMenuEvent(QContextMenuEvent *event);
82     void focusInEvent(QFocusEvent *event);
83     void focusOutEvent(QFocusEvent *event);
84 };
85
86 #endif // FOLDERVIEW_H