2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2010-08-01 20:36:13 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2010-08-01 20:36:13 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2009-05-31 19:33:48 +00:00
|
|
|
* $Id$
|
2009-04-09 18:55:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPTIONS_DIALOG_H
|
|
|
|
#define OPTIONS_DIALOG_H
|
|
|
|
|
2010-08-01 18:55:04 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QString>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QPushButton>
|
2010-08-01 18:55:04 +00:00
|
|
|
#include <QString>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QTimer>
|
2012-07-09 23:18:40 +00:00
|
|
|
#include <QLineEdit>
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2010-08-01 18:55:04 +00:00
|
|
|
#include "add-data.h" // AddData
|
|
|
|
#include "file-tree.h" // FileList
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
class FileTreeView;
|
|
|
|
class Prefs;
|
|
|
|
class QCheckBox;
|
2010-02-02 07:52:57 +00:00
|
|
|
class QComboBox;
|
2009-04-09 18:55:47 +00:00
|
|
|
class Session;
|
|
|
|
|
2012-12-14 04:34:42 +00:00
|
|
|
extern "C" { struct tr_variant; };
|
2009-05-15 02:05:07 +00:00
|
|
|
|
|
|
|
class FileAdded: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
const int64_t myTag;
|
2010-08-01 18:55:04 +00:00
|
|
|
QString myName;
|
2009-05-15 02:05:07 +00:00
|
|
|
QString myDelFile;
|
|
|
|
|
|
|
|
public:
|
2010-08-01 18:55:04 +00:00
|
|
|
FileAdded( int tag, const QString& name ): myTag(tag), myName(name) { }
|
2009-05-15 02:05:07 +00:00
|
|
|
~FileAdded( ) { }
|
2010-08-01 18:55:04 +00:00
|
|
|
void setFileToDelete( const QString& file ) { myDelFile = file; }
|
2009-05-15 02:05:07 +00:00
|
|
|
|
|
|
|
public slots:
|
2012-12-14 04:34:42 +00:00
|
|
|
void executed( int64_t tag, const QString& result, struct tr_variant * arguments );
|
2009-05-15 02:05:07 +00:00
|
|
|
};
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
class Options: public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2010-08-01 18:55:04 +00:00
|
|
|
Options( Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent = 0 );
|
2009-04-09 18:55:47 +00:00
|
|
|
~Options( );
|
|
|
|
|
|
|
|
private:
|
|
|
|
void reload( );
|
|
|
|
void clearInfo( );
|
|
|
|
void refreshFileButton( int width=-1 );
|
|
|
|
void refreshDestinationButton( int width=-1 );
|
|
|
|
void refreshButton( QPushButton *, const QString&, int width=-1 );
|
|
|
|
|
|
|
|
private:
|
|
|
|
Session& mySession;
|
2010-08-01 18:55:04 +00:00
|
|
|
AddData myAdd;
|
2009-04-09 18:55:47 +00:00
|
|
|
QDir myDestination;
|
|
|
|
bool myHaveInfo;
|
|
|
|
tr_info myInfo;
|
|
|
|
FileTreeView * myTree;
|
|
|
|
QCheckBox * myStartCheck;
|
|
|
|
QCheckBox * myTrashCheck;
|
2010-02-02 07:52:57 +00:00
|
|
|
QComboBox * myPriorityCombo;
|
2009-04-09 18:55:47 +00:00
|
|
|
QPushButton * myFileButton;
|
|
|
|
QPushButton * myDestinationButton;
|
2012-07-09 23:18:40 +00:00
|
|
|
QLineEdit * myDestinationEdit;
|
2009-04-09 18:55:47 +00:00
|
|
|
QPushButton * myVerifyButton;
|
|
|
|
QVector<int> myPriorities;
|
|
|
|
QVector<bool> myWanted;
|
|
|
|
FileList myFiles;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onAccepted( );
|
|
|
|
void onPriorityChanged( const QSet<int>& fileIndices, int );
|
|
|
|
void onWantedChanged( const QSet<int>& fileIndices, bool );
|
|
|
|
void onVerify( );
|
|
|
|
void onTimeout( );
|
|
|
|
void onFilenameClicked( );
|
|
|
|
void onDestinationClicked( );
|
|
|
|
void onFilesSelected( const QStringList& );
|
|
|
|
void onDestinationsSelected( const QStringList& );
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool eventFilter( QObject *, QEvent * );
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTimer myVerifyTimer;
|
|
|
|
char myVerifyBuf[2048*4];
|
|
|
|
QFile myVerifyFile;
|
|
|
|
uint64_t myVerifyFilePos;
|
|
|
|
int myVerifyFileIndex;
|
|
|
|
uint32_t myVerifyPieceIndex;
|
|
|
|
uint32_t myVerifyPiecePos;
|
|
|
|
void clearVerify( );
|
|
|
|
QVector<bool> myVerifyFlags;
|
|
|
|
QCryptographicHash myVerifyHash;
|
|
|
|
typedef QMap<uint32_t,int32_t> mybins_t;
|
|
|
|
mybins_t myVerifyBins;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|