1 | /* |
---|
2 | * This file Copyright (C) 2009-2014 Mnemosyne LLC |
---|
3 | * |
---|
4 | * It may be used under the GNU GPL versions 2 or 3 |
---|
5 | * or any future license endorsed by Mnemosyne LLC. |
---|
6 | * |
---|
7 | * $Id: options.h 14241 2014-01-21 03:10:30Z jordan $ |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef OPTIONS_DIALOG_H |
---|
11 | #define OPTIONS_DIALOG_H |
---|
12 | |
---|
13 | #include <iostream> |
---|
14 | |
---|
15 | #include <QDialog> |
---|
16 | #include <QEvent> |
---|
17 | #include <QString> |
---|
18 | #include <QDir> |
---|
19 | #include <QVector> |
---|
20 | #include <QMap> |
---|
21 | #include <QString> |
---|
22 | #include <QStringList> |
---|
23 | #include <QCryptographicHash> |
---|
24 | #include <QFile> |
---|
25 | #include <QTimer> |
---|
26 | #include <QLineEdit> |
---|
27 | |
---|
28 | #include "add-data.h" // AddData |
---|
29 | #include "file-tree.h" // FileList |
---|
30 | |
---|
31 | class QCheckBox; |
---|
32 | class QComboBox; |
---|
33 | class QPushButton; |
---|
34 | |
---|
35 | class FileTreeView; |
---|
36 | class FreespaceLabel; |
---|
37 | class Prefs; |
---|
38 | class Session; |
---|
39 | |
---|
40 | extern "C" |
---|
41 | { |
---|
42 | struct tr_variant; |
---|
43 | } |
---|
44 | |
---|
45 | class FileAdded: public QObject |
---|
46 | { |
---|
47 | Q_OBJECT |
---|
48 | |
---|
49 | public: |
---|
50 | FileAdded (int tag, const QString& name): myTag (tag), myName (name) {} |
---|
51 | ~FileAdded () {} |
---|
52 | void setFileToDelete (const QString& file) { myDelFile = file; } |
---|
53 | |
---|
54 | public slots: |
---|
55 | void executed (int64_t tag, const QString& result, struct tr_variant * arguments); |
---|
56 | |
---|
57 | private: |
---|
58 | const int64_t myTag; |
---|
59 | QString myName; |
---|
60 | QString myDelFile; |
---|
61 | }; |
---|
62 | |
---|
63 | class Options: public QDialog |
---|
64 | { |
---|
65 | Q_OBJECT |
---|
66 | |
---|
67 | public: |
---|
68 | Options (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent = 0); |
---|
69 | ~Options (); |
---|
70 | |
---|
71 | private: |
---|
72 | void reload (); |
---|
73 | void clearInfo (); |
---|
74 | void refreshSource (int width=-1); |
---|
75 | void refreshDestinationButton (int width=-1); |
---|
76 | void refreshButton (QPushButton *, const QString&, int width=-1); |
---|
77 | bool eventFilter (QObject *, QEvent *); |
---|
78 | |
---|
79 | private slots: |
---|
80 | void onAccepted (); |
---|
81 | void onPriorityChanged (const QSet<int>& fileIndices, int); |
---|
82 | void onWantedChanged (const QSet<int>& fileIndices, bool); |
---|
83 | void onVerify (); |
---|
84 | void onTimeout (); |
---|
85 | void onFilenameClicked (); |
---|
86 | void onDestinationClicked (); |
---|
87 | void onFilesSelected (const QStringList&); |
---|
88 | void onSourceEditingFinished (); |
---|
89 | void onDestinationsSelected (const QStringList&); |
---|
90 | void onDestinationEdited (const QString&); |
---|
91 | void onDestinationEditedIdle (); |
---|
92 | |
---|
93 | private: |
---|
94 | Session& mySession; |
---|
95 | AddData myAdd; |
---|
96 | QDir myLocalDestination; |
---|
97 | bool myHaveInfo; |
---|
98 | tr_info myInfo; |
---|
99 | FileTreeView * myTree; |
---|
100 | FreespaceLabel * myFreespaceLabel; |
---|
101 | QCheckBox * myStartCheck; |
---|
102 | QCheckBox * myTrashCheck; |
---|
103 | QComboBox * myPriorityCombo; |
---|
104 | QPushButton * mySourceButton; |
---|
105 | QLineEdit * mySourceEdit; |
---|
106 | QPushButton * myDestinationButton; |
---|
107 | QLineEdit * myDestinationEdit; |
---|
108 | QPushButton * myVerifyButton; |
---|
109 | QVector<int> myPriorities; |
---|
110 | QVector<bool> myWanted; |
---|
111 | FileList myFiles; |
---|
112 | |
---|
113 | private: |
---|
114 | QTimer myVerifyTimer; |
---|
115 | char myVerifyBuf[2048*4]; |
---|
116 | QFile myVerifyFile; |
---|
117 | uint64_t myVerifyFilePos; |
---|
118 | int myVerifyFileIndex; |
---|
119 | uint32_t myVerifyPieceIndex; |
---|
120 | uint32_t myVerifyPiecePos; |
---|
121 | void clearVerify (); |
---|
122 | QVector<bool> myVerifyFlags; |
---|
123 | QCryptographicHash myVerifyHash; |
---|
124 | typedef QMap<uint32_t,int32_t> mybins_t; |
---|
125 | mybins_t myVerifyBins; |
---|
126 | QTimer myEditTimer; |
---|
127 | }; |
---|
128 | |
---|
129 | #endif |
---|