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

View File

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

View File

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