(trunk qt) tweak qt "set torrent location" a little

This commit is contained in:
Charles Kerr 2009-05-13 19:16:31 +00:00
parent b2a6def953
commit e2a9a0f263
3 changed files with 17 additions and 12 deletions

View File

@ -622,8 +622,7 @@ TrMainWindow :: openProperties( )
void
TrMainWindow :: setLocation( )
{
const int torrentId( *getSelectedTorrents().begin() );
QDialog * d = new RelocateDialog( mySession, torrentId, this );
QDialog * d = new RelocateDialog( mySession, getSelectedTorrents(), this );
d->show( );
}
@ -744,10 +743,10 @@ TrMainWindow :: refreshActionSensitivity( )
ui.action_Delete->setEnabled( haveSelection );
ui.action_Properties->setEnabled( haveSelection );
ui.action_DeselectAll->setEnabled( haveSelection );
ui.action_SetLocation->setEnabled( haveSelection );
const bool oneSelection( selected == 1 );
ui.action_OpenFolder->setEnabled( oneSelection && mySession.isLocal( ) );
ui.action_SetLocation->setEnabled( oneSelection );
ui.action_SelectAll->setEnabled( selected < rowCount );
ui.action_StartAll->setEnabled( paused > 0 );

View File

@ -19,10 +19,13 @@
#include <QSet>
#include <QDialogButtonBox>
#include <QWidget>
#include <QApplication>
#include <QStyle>
#include "hig.h"
#include "relocate.h"
#include "session.h"
#include "qticonloader.h"
QString RelocateDialog :: myPath;
@ -31,9 +34,7 @@ bool RelocateDialog :: myMoveFlag = true;
void
RelocateDialog :: onSetLocation( )
{
QSet<int> ids;
ids << myTorrentId;
mySession.torrentSetLocation( ids, myPath, myMoveFlag );
mySession.torrentSetLocation( myIds, myPath, myMoveFlag );
deleteLater( );
}
@ -60,11 +61,15 @@ RelocateDialog :: onMoveToggled( bool b )
myMoveFlag = b;
}
RelocateDialog :: RelocateDialog( Session& session, int torrentId, QWidget * parent ):
RelocateDialog :: RelocateDialog( Session& session, const QSet<int>& ids, QWidget * parent ):
QDialog( parent ),
mySession( session ),
myTorrentId( torrentId )
myIds( ids )
{
const int iconSize( style( )->pixelMetric( QStyle :: PM_SmallIconSize ) );
const QIcon folderIcon = QtIconLoader :: icon( "folder", style()->standardIcon( QStyle::SP_DirIcon ) );
const QPixmap folderPixmap = folderIcon.pixmap( iconSize );
QRadioButton * find_rb;
setWindowTitle( tr( "Set Torrent Location" ) );
@ -72,8 +77,8 @@ RelocateDialog :: RelocateDialog( Session& session, int torrentId, QWidget * par
myPath = QDir::homePath( );
HIG * hig = new HIG( );
hig->addSectionTitle( tr( "Location" ) );
hig->addRow( tr( "Torrent &location:" ), myDirButton = new QPushButton( myPath ) );
hig->addSectionTitle( tr( "Set Location" ) );
hig->addRow( tr( "New &location:" ), myDirButton = new QPushButton( folderPixmap, myPath ) );
hig->addWideControl( myMoveRadio = new QRadioButton( tr( "&Move from the current folder" ), this ) );
hig->addWideControl( find_rb = new QRadioButton( tr( "Local data is &already there" ), this ) );
hig->finish( );

View File

@ -14,6 +14,7 @@
#define RELOCATE_DIALOG_H
#include <QDialog>
#include <QSet>
#include <QString>
class QPushButton;
@ -30,7 +31,7 @@ class RelocateDialog: public QDialog
private:
Session & mySession;
const int myTorrentId;
QSet<int> myIds;
QPushButton * myDirButton;
QRadioButton * myMoveRadio;
@ -41,7 +42,7 @@ class RelocateDialog: public QDialog
void onMoveToggled( bool );
public:
RelocateDialog( Session&, int torrentId, QWidget * parent = 0 );
RelocateDialog( Session&, const QSet<int>& ids, QWidget * parent = 0 );
~RelocateDialog( ) { }
};