QLabel (parent),
mySession (session),
myTag (-1),
- myPath (path),
myTimer (this)
{
myTimer.setSingleShot (false);
connect (&mySession, SIGNAL(executed(int64_t, const QString&, struct tr_variant*)),
this, SLOT(onSessionExecuted(int64_t, const QString&, struct tr_variant*)));
- onTimer ();
+ setPath (path);
+}
+
+void
+FreespaceLabel :: setPath (const QString& path)
+{
+ if (myPath != path)
+ {
+ setText (tr("<i>Counting Free Space...</i>"));
+ myPath = path;
+ onTimer ();
+ }
}
void
* $Id$
*/
-#include <cstdio>
-
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
myDestinationButton( 0 ),
myVerifyButton( 0 ),
myVerifyFile( 0 ),
- myVerifyHash( QCryptographicHash::Sha1 )
-
+ myVerifyHash( QCryptographicHash::Sha1 ),
+ myEditTimer (this)
{
setWindowTitle( tr( "Open Torrent" ) );
QFontMetrics fontMetrics( font( ) );
QGridLayout * layout = new QGridLayout( this );
int row = 0;
+ myEditTimer.setInterval (2000);
+ myEditTimer.setSingleShot (true);
+ connect (&myEditTimer, SIGNAL(timeout()), this, SLOT(onDestinationEditedIdle()));
+
const int iconSize( style( )->pixelMetric( QStyle :: PM_SmallIconSize ) );
QIcon fileIcon = style( )->standardIcon( QStyle::SP_FileIcon );
const QPixmap filePixmap = fileIcon.pixmap( iconSize );
l = new QLabel( tr( "&Destination folder:" ) );
layout->addWidget( l, ++row, 0, Qt::AlignLeft );
const QString downloadDir (prefs.getString (Prefs::DOWNLOAD_DIR));
+ myFreespaceLabel = new FreespaceLabel (mySession, downloadDir, this);
if( session.isLocal( ) )
{
e->setText (downloadDir);
layout->addWidget( e, row, 1 );
l->setBuddy( e );
+ connect (e, SIGNAL(textEdited(const QString&)), this, SLOT(onDestinationEdited(const QString&)));
}
- l = myFreespaceLabel = new FreespaceLabel (mySession, downloadDir, this);
+ l = myFreespaceLabel;
layout->addWidget (l, ++row, 0, 1, 2, Qt::Alignment (Qt::AlignRight | Qt::AlignTop));
layout->setRowMinimumHeight (row, l->height() + HIG::PAD);
}
}
+void
+Options :: onDestinationEdited (const QString& text)
+{
+ Q_UNUSED (text);
+
+ myEditTimer.start ();
+}
+
+void
+Options :: onDestinationEditedIdle ()
+{
+ myFreespaceLabel->setPath (myDestinationEdit->text());
+}
+
/***
****
**** VERIFY
void onDestinationClicked( );
void onFilesSelected( const QStringList& );
void onDestinationsSelected( const QStringList& );
+ void onDestinationEdited (const QString&);
+ void onDestinationEditedIdle ();
private:
bool eventFilter( QObject *, QEvent * );
QCryptographicHash myVerifyHash;
typedef QMap<uint32_t,int32_t> mybins_t;
mybins_t myVerifyBins;
+ QTimer myEditTimer;
};