2015-06-10 21:27:11 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2009-2015 Mnemosyne LLC
|
|
|
|
*
|
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QTR_FILE_TREE_VIEW_H
|
|
|
|
#define QTR_FILE_TREE_VIEW_H
|
|
|
|
|
|
|
|
#include <QSet>
|
|
|
|
#include <QTreeView>
|
|
|
|
|
|
|
|
#include "Torrent.h" // FileList
|
|
|
|
|
2015-08-10 19:40:58 +00:00
|
|
|
class QAction;
|
|
|
|
class QMenu;
|
2015-06-10 21:27:11 +00:00
|
|
|
class QSortFilterProxyModel;
|
|
|
|
|
|
|
|
class FileTreeDelegate;
|
|
|
|
class FileTreeModel;
|
|
|
|
|
|
|
|
class FileTreeView: public QTreeView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-06-12 22:12:12 +00:00
|
|
|
FileTreeView (QWidget * parent = nullptr, bool editable = true);
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
void clear ();
|
2015-06-12 22:12:12 +00:00
|
|
|
void update (const FileList& files, bool updateProperties = true);
|
2015-06-10 21:27:11 +00:00
|
|
|
|
|
|
|
void setEditable (bool editable);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void priorityChanged (const QSet<int>& fileIndices, int priority);
|
|
|
|
void wantedChanged (const QSet<int>& fileIndices, bool wanted);
|
|
|
|
void pathEdited (const QString& oldpath, const QString& newname);
|
|
|
|
void openRequested (const QString& path);
|
|
|
|
|
|
|
|
protected:
|
2015-06-15 21:07:46 +00:00
|
|
|
// QWidget
|
|
|
|
virtual void resizeEvent (QResizeEvent * event);
|
|
|
|
virtual void keyPressEvent (QKeyEvent * event);
|
2015-08-10 19:40:58 +00:00
|
|
|
virtual void mouseDoubleClickEvent (QMouseEvent * event);
|
|
|
|
virtual void contextMenuEvent (QContextMenuEvent * event);
|
|
|
|
|
|
|
|
// QAbstractItemView
|
|
|
|
virtual bool edit (const QModelIndex& index, EditTrigger trigger, QEvent * event);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onClicked (const QModelIndex& index);
|
|
|
|
|
|
|
|
void checkSelectedItems ();
|
|
|
|
void uncheckSelectedItems ();
|
|
|
|
void onlyCheckSelectedItems ();
|
|
|
|
void setSelectedItemsPriority ();
|
|
|
|
bool openSelectedItem ();
|
|
|
|
void renameSelectedItem ();
|
|
|
|
|
|
|
|
void refreshContextMenuActionsSensitivity ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initContextMenu ();
|
2015-08-16 22:07:09 +00:00
|
|
|
QModelIndexList selectedSourceRows (int column = 0) const;
|
|
|
|
|
|
|
|
static Qt::CheckState getCumulativeCheckState (const QModelIndexList& indices);
|
2015-06-10 21:27:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
FileTreeModel * myModel;
|
|
|
|
QSortFilterProxyModel * myProxy;
|
|
|
|
FileTreeDelegate * myDelegate;
|
2015-08-10 19:40:58 +00:00
|
|
|
|
|
|
|
QMenu * myContextMenu = nullptr;
|
|
|
|
QMenu * myPriorityMenu = nullptr;
|
|
|
|
QAction * myCheckSelectedAction = nullptr;
|
|
|
|
QAction * myUncheckSelectedAction = nullptr;
|
|
|
|
QAction * myOnlyCheckSelectedAction = nullptr;
|
|
|
|
QAction * myHighPriorityAction = nullptr;
|
|
|
|
QAction * myNormalPriorityAction = nullptr;
|
|
|
|
QAction * myLowPriorityAction = nullptr;
|
|
|
|
QAction * myOpenAction = nullptr;
|
|
|
|
QAction * myRenameAction = nullptr;
|
2015-06-10 21:27:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QTR_FILE_TREE_VIEW_H
|