#ifndef FOLDERVIEW_H
#define FOLDERVIEW_H
-#include "filetablemodel.h"
-#include "history.h"
+#include "abstractview.h"
+#include "foldermodel.h"
#include <QTableView>
class MainWindow;
-class FolderView : public QTableView
+class FolderView : public QTableView, public AbstractView
{
Q_OBJECT
+ Q_PROPERTY(bool dragging MEMBER m_dragging READ isDragging())
+
public:
explicit FolderView(QWidget *parent = 0);
- QString side() const;
-
- // actions
- void initialize(MainWindow *mainWnd, bool left);
- void updateAppearance(bool darker = false);
- void refresh();
-
- void searchItem(const QString &text);
- void searchNext(const QString &text);
- void searchPrev(const QString &text);
-
- void setCheckStateAll(Qt::CheckState state);
- void setCheckStateAllFiles();
- void invertCheckState();
- void toggleCheckState(const QModelIndex &index);
-
- bool historyBack();
- bool historyForward();
-
- // getter
- QFileInfo currentItem() const;
- QString dir() const { return m_model.absolutePath(); }
- QFileInfoList checkedItems() const;
- QFileInfoList selectedItems() const;
- const History* history() const { return &m_history; }
- QStringList nameFilters() const { return m_model.nameFilters(); }
-
- // setter
- void setPath(const QString &path, bool addHistory);
- void setFilter(QDir::Filters filter, bool enable);
- void setHistoryIndexAt(int index);
- void setNameFilters(const QStringList &list);
- void setSorting();
+ void initialize(MainWindow *w);
+ bool isDragging();
+ FolderModel* folderModel() const;
+ QFileInfoList selectedItems() const;
private:
- MainWindow *m_mainWnd;
- FileTableModel m_model;
- History m_history;
- QPoint m_dragStartPos;
- bool m_dragging;
+ QPoint m_dragStartPos;
+ bool m_dragging;
+ int m_saveRow;
+ QString m_savePath;
+ QString m_saveName;
signals:
- void currentChanged(const QFileInfo &info);
- void dataChanged();
- void dropAccepted(const QFileInfoList &list);
- void itemFound();
- void itemNotFound();
- void retrieveStarted(const QString &path);
- void requestContextMenu(QContextMenuEvent *event);
-// void keyPressed(QKeyEvent *event);
-public slots:
-
- // QAbstractItemView interface
-protected slots:
- void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
+private slots:
+ void model_PreReset();
+ void model_PostReset();
// QWidget interface
protected:
- void keyPressEvent(QKeyEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
- void dropEvent(QDropEvent *event);
- void contextMenuEvent(QContextMenuEvent *event);
- void focusInEvent(QFocusEvent *event);
- void focusOutEvent(QFocusEvent *event);
+
+ // QAbstractItemView interface
+public:
+ void setModel(QAbstractItemModel *model);
+
+ // AbstractView interface
+public:
+ void scaleUp();
+ void scaleDown();
};
+inline bool FolderView::isDragging()
+{
+ return m_dragging;
+}
+
+inline FolderModel *FolderView::folderModel() const
+{
+ return static_cast<FolderModel*>(model());
+}
+
#endif // FOLDERVIEW_H