2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2009-2015 Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2014-12-29 04:03:56 +00:00
|
|
|
#include <QCryptographicHash>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QDir>
|
2014-12-29 04:03:56 +00:00
|
|
|
#include <QFile>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QMap>
|
2010-08-01 18:55:04 +00:00
|
|
|
#include <QString>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QTimer>
|
2014-12-29 04:03:56 +00:00
|
|
|
#include <QVector>
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "AddData.h" // AddData
|
2015-09-01 20:19:26 +00:00
|
|
|
#include "BaseDialog.h"
|
2020-08-11 18:11:55 +00:00
|
|
|
#include "Macros.h"
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "Torrent.h" // FileList
|
|
|
|
#include "ui_OptionsDialog.h"
|
2013-02-09 04:05:03 +00:00
|
|
|
|
|
|
|
class Prefs;
|
2009-04-09 18:55:47 +00:00
|
|
|
class Session;
|
|
|
|
|
2013-08-24 19:26:21 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
struct tr_variant;
|
2013-08-24 19:26:21 +00:00
|
|
|
}
|
2009-05-15 02:05:07 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
class OptionsDialog : public BaseDialog
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-02-09 21:47:42 +00:00
|
|
|
Q_OBJECT
|
2020-08-11 18:11:55 +00:00
|
|
|
TR_DISABLE_COPY_MOVE(OptionsDialog)
|
2013-02-09 21:47:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2020-06-05 19:02:11 +00:00
|
|
|
OptionsDialog(Session& session, Prefs const& prefs, AddData addme, QWidget* parent = nullptr);
|
2020-09-09 14:24:39 +00:00
|
|
|
~OptionsDialog() override;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private slots:
|
|
|
|
void onAccepted();
|
2020-05-27 21:53:12 +00:00
|
|
|
void onPriorityChanged(QSet<int> const& file_indices, int);
|
|
|
|
void onWantedChanged(QSet<int> const& file_indices, bool);
|
2017-04-19 12:04:45 +00:00
|
|
|
void onVerify();
|
|
|
|
void onTimeout();
|
2014-12-29 04:03:56 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void onSourceChanged();
|
|
|
|
void onDestinationChanged();
|
2013-02-09 21:47:42 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void onSessionUpdated();
|
2016-10-03 18:26:28 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private:
|
2020-11-05 22:46:21 +00:00
|
|
|
using mybins_t = QMap<uint32_t, int32_t>;
|
|
|
|
|
|
|
|
void reload();
|
|
|
|
void updateWidgetsLocality();
|
|
|
|
void clearInfo();
|
|
|
|
void clearVerify();
|
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
AddData add_;
|
|
|
|
FileList files_;
|
2020-11-02 01:13:32 +00:00
|
|
|
QCryptographicHash verify_hash_ = QCryptographicHash(QCryptographicHash::Sha1);
|
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
QDir local_destination_;
|
|
|
|
QFile verify_file_;
|
|
|
|
QPushButton* verify_button_ = {};
|
|
|
|
QTimer edit_timer_;
|
|
|
|
QTimer verify_timer_;
|
|
|
|
QVector<bool> verify_flags_;
|
|
|
|
QVector<bool> wanted_;
|
|
|
|
QVector<int> priorities_;
|
|
|
|
Session& session_;
|
2020-06-05 19:02:11 +00:00
|
|
|
Ui::OptionsDialog ui_ = {};
|
2020-05-27 21:53:12 +00:00
|
|
|
mybins_t verify_bins_;
|
2020-06-05 19:02:11 +00:00
|
|
|
tr_info info_ = {};
|
2020-05-27 21:53:12 +00:00
|
|
|
uint64_t verify_file_pos_ = {};
|
|
|
|
uint32_t verify_piece_index_ = {};
|
|
|
|
uint32_t verify_piece_pos_ = {};
|
|
|
|
int verify_file_index_ = {};
|
|
|
|
char verify_buf_[2048 * 4] = {};
|
|
|
|
bool have_info_ = {};
|
|
|
|
bool is_local_ = {};
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|