summaryrefslogtreecommitdiffstats
path: root/torrentwidget.h
blob: 65c11617202e72bdcacd31dec34be5eba140c4a3 (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
#ifndef TORRENTWIDGET_H
#define TORRENTWIDGET_H

#include <QMainWindow>
#include <QItemSelection>
#include <QString>
#include <QContextMenuEvent>
#include <QLineEdit>

class QPushButton;
class QTreeView;
class QStandardItemModel;
class QLabel;
class QToolBar;
class QMenuBar;
class QKeyEvent;
class QProgressBar;
class FileSorter;
class TorrentDisplay;

class TorrentWidget : public QWidget {
    Q_OBJECT
    public:
        enum CustomRoles { PresentRole = Qt::UserRole + 1, FullPathRole = Qt::UserRole + 2, CreatedRole = Qt::UserRole + 3 };
        enum { ColumnCount = 3 };
        enum Columns { IconColumn = 0, NameColumn = 1, CreatedColumn = 2 };
        enum Present { NotPresent = 0, Present = 1 };
        TorrentWidget(QWidget *parent = 0);
        QMenuBar *menuBar() { return mMenuBar; }
        TorrentDisplay *torrentDisplay() { return mTorrentDisplay; }
        QTreeView *torrentFileView() { return mFileView; }
        void setProgressBar(QProgressBar *progressBar) { mProgressBar = progressBar; }
        const QString currentDir() const { return mDir->text(); }
        ~TorrentWidget();

    signals:
        void statusMessage(const QString &msg);
        void selectionCountChanged(const QString &msg);
        void freeSpaceChanged(const QString &dir);

    public slots:
        void selectDir();
        void setDir();
        void copyToClipboard();
        void gatherData();
        void deleteFiles();
        void moveFiles();
        void torrentInfo();
        void searchFile();
        void fileSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
        void selectFirst();
        void guessSubtitle();

    protected:
        virtual void keyPressEvent(QKeyEvent *e);
        virtual void contextMenuEvent(QContextMenuEvent *e);

    private:
        void setupGui();
        void createActions();
        void readHeaderData();
        void writeHeaderData();
        void readSettings();
        void writeSettings();
        void rememberSelection();
        void restoreSelection();
        QAction *createSeparator();
        QLineEdit *mDir;
        QPushButton *mSelDir;
        QLineEdit *mSearchTorrents;
        QPushButton *mDoSearchTorrents;
        QString mExt;
        QStringList mSelection;
        QStandardItemModel *mModel;
        QTreeView *mFileView;
        QToolBar *mToolBar;
        QMenuBar *mMenuBar;
        QProgressBar *mProgressBar;
        QAction *mRefreshA;
        QAction *mDeleteA;
        QAction *mMoveA;
        QAction *mTorrentInfoA;
        QAction *mSelDirA;
        QAction *mCopyFnToClipA;
        QAction *mGuessSubtitleA;
        FileSorter *mProxy;
        TorrentDisplay *mTorrentDisplay;
};

#endif // TORRENTWIDGET_H