Fixed to get work properly Play and OpenFile when File Transfer is complete, Play action is only visible when its a media file.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2377 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-02-20 01:52:44 +00:00
parent 3ff7635171
commit 76e2f5c9c4
2 changed files with 31 additions and 58 deletions

View File

@ -230,26 +230,40 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
*/
std::cerr << "TransfersDialog::downloadListCostumPopupMenu()" << std::endl;
bool addPlayOption = false;
FileInfo info;
for(int i = 0; i <= DLListModel->rowCount(); i++) {
std::cerr << "Row Status :" << getStatus(i, DLListModel).toStdString() << ":" << std::endl;
if(selection->isRowSelected(i, QModelIndex())) {
std::cerr << "Selected Row Status :" << getStatus(i, DLListModel).toStdString() << ":" << std::endl;
QString qstatus = getStatus(i, DLListModel);
std::string status = (qstatus.trimmed()).toStdString();
if (status == "Complete")
for (it = items.begin(); it != items.end(); it ++) {
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
break;
}
bool addPlayOption = false;
bool addOpenFileOption = false;
if (info.downloadStatus == FT_STATE_COMPLETE)
{
std::cerr << "Add Play Option" << std::endl;
addOpenFileOption = true;
size_t pos = info.fname.find_last_of('.');
if (pos == -1) return; /* can't identify type of file */
/* check if the file is a media file */
if (misc::isPreviewable(info.fname.substr(pos + 1).c_str()))
{
addPlayOption = true;
}
}
}
QAction *playAct = NULL;
if (addPlayOption)
{
playAct = new QAction(QIcon(IMAGE_PLAY), tr( "Play" ), this );
connect( playAct , SIGNAL( triggered() ), this, SLOT( playSelectedTransfer() ) );
connect( playAct , SIGNAL( triggered() ), this, SLOT( openTransfer() ) );
}
QAction *detailsAct = NULL;
@ -377,8 +391,10 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
if(single)
{
#ifndef RS_RELEASE_VERSION
if (addOpenFileOption)
contextMnu.addAction( openfileAct);
#ifndef RS_RELEASE_VERSION
contextMnu.addAction( previewfileAct);
#endif
contextMnu.addAction( openfolderAct);
@ -400,36 +416,6 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
contextMnu.exec( mevent->globalPos() );
}
void TransfersDialog::playSelectedTransfer()
{
std::cerr << "TransfersDialog::playSelectedTransfer()" << std::endl;
/* get the shared directories */
std::string incomingdir = rsFiles->getDownloadDirectory();
/* create the List of Files */
QStringList playList;
for(int i = 0; i <= DLListModel->rowCount(); i++) {
if(selection->isRowSelected(i, QModelIndex())) {
QString qstatus = getStatus(i, DLListModel);
std::string status = (qstatus.trimmed()).toStdString();
if (status == "Complete")
{
QString qname = getFileName(i, DLListModel);
QString fullpath = QString::fromStdString(incomingdir);
fullpath += "/";
fullpath += qname.trimmed();
playList.push_back(fullpath);
std::cerr << "PlayFile:" << fullpath.toStdString() << std::endl;
}
}
}
playFiles(playList);
}
TransfersDialog::~TransfersDialog()
{
;
@ -1045,18 +1031,6 @@ void TransfersDialog::showDetailsDialog()
}
}
// display properties of selected items
/*void DownloadingTorrents::propertiesSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
foreach(const QModelIndex &index, selectedIndexes){
if(index.column() == NAME){
showProperties(index);
}
}
}*/
void TransfersDialog::pasteLink()
{
QClipboard *clipboard = QApplication::clipboard();

View File

@ -70,7 +70,6 @@ private slots:
void cancel();
/** removes finished Downloads**/
void clearcompleted();
void playSelectedTransfer();
void copyLink();
void pasteLink();