Added open folder and copy RS link to upload list (patch fromPhenom)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6601 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-08-23 20:46:11 +00:00
parent 5aedf393b2
commit b73e08d618
3 changed files with 158 additions and 35 deletions

View file

@ -262,6 +262,8 @@ TransfersDialog::TransfersDialog(QWidget *parent)
// set default column and sort order for download // set default column and sort order for download
ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder); ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
connect( ui.uploadsList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( uploadsListCustomPopupMenu( QPoint ) ) );
// Set Upload list model // Set Upload list model
ULListModel = new QStandardItemModel(0,COLUMN_UCOUNT); ULListModel = new QStandardItemModel(0,COLUMN_UCOUNT);
ULListModel->setHeaderData(COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name")); ULListModel->setHeaderData(COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
@ -287,7 +289,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
//Selection Setup //Selection Setup
selectionup = ui.uploadsList->selectionModel(); selectionUp = ui.uploadsList->selectionModel();
ui.uploadsList->setSelectionMode(QAbstractItemView::ExtendedSelection); ui.uploadsList->setSelectionMode(QAbstractItemView::ExtendedSelection);
/* Set header resize modes and initial section sizes Uploads TreeView*/ /* Set header resize modes and initial section sizes Uploads TreeView*/
@ -377,26 +379,26 @@ TransfersDialog::TransfersDialog(QWidget *parent)
cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this ); cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) ); connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this); openFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openFolderTransfer())); connect(openFolderAct, SIGNAL(triggered()), this, SLOT(openFolderTransfer()));
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this); openFileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openTransfer())); connect(openFileAct, SIGNAL(triggered()), this, SLOT(openTransfer()));
previewfileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this); previewFileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this);
connect(previewfileAct, SIGNAL(triggered()), this, SLOT(previewTransfer())); connect(previewFileAct, SIGNAL(triggered()), this, SLOT(previewTransfer()));
detailsfileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this); detailsFileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this);
connect(detailsfileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog())); connect(detailsFileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog()));
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this ); clearCompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) ); connect( clearCompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this ); copyLinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this );
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) ); connect( copyLinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste RetroShare Link" ), this ); pasteLinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste RetroShare Link" ), this );
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) ); connect( pasteLinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
queueDownAct = new QAction(QIcon(":/images/go-down.png"), tr("Down"), this); queueDownAct = new QAction(QIcon(":/images/go-down.png"), tr("Down"), this);
connect(queueDownAct, SIGNAL(triggered()), this, SLOT(priorityQueueDown())); connect(queueDownAct, SIGNAL(triggered()), this, SLOT(priorityQueueDown()));
queueUpAct = new QAction(QIcon(":/images/go-up.png"), tr("Up"), this); queueUpAct = new QAction(QIcon(":/images/go-up.png"), tr("Up"), this);
@ -463,6 +465,12 @@ TransfersDialog::TransfersDialog(QWidget *parent)
showDLLastDLAct->setCheckable(true); showDLLastDLAct->setToolTip(tr("Show Last Time Seen Column")); showDLLastDLAct->setCheckable(true); showDLLastDLAct->setToolTip(tr("Show Last Time Seen Column"));
connect(showDLLastDLAct,SIGNAL(triggered(bool)),this,SLOT(setShowDLLastDLColumn(bool))) ; connect(showDLLastDLAct,SIGNAL(triggered(bool)),this,SLOT(setShowDLLastDLColumn(bool))) ;
/** Setup the actions for the upload context menu */
ulOpenFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
connect(ulOpenFolderAct, SIGNAL(triggered()), this, SLOT(ulOpenFolder()));
ulCopyLinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link" ), this );
connect( ulCopyLinkAct , SIGNAL( triggered() ), this, SLOT( ulCopyLink() ) );
// load settings // load settings
processSettings(true); processSettings(true);
@ -742,26 +750,26 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
if(single) if(single)
{ {
if (addOpenFileOption) if (addOpenFileOption)
contextMnu.addAction( openfileAct); contextMnu.addAction( openFileAct);
contextMnu.addAction( previewfileAct); contextMnu.addAction( previewFileAct);
contextMnu.addAction( openfolderAct); contextMnu.addAction( openFolderAct);
contextMnu.addAction( detailsfileAct); contextMnu.addAction( detailsFileAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
} }
contextMnu.addAction( clearcompletedAct); contextMnu.addAction( clearCompletedAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
if(!items.empty()) if(!items.empty())
contextMnu.addAction( copylinkAct); contextMnu.addAction( copyLinkAct);
if(!RSLinkClipboard::empty(RetroShareLink::TYPE_FILE)) { if(!RSLinkClipboard::empty(RetroShareLink::TYPE_FILE)) {
pastelinkAct->setEnabled(true); pasteLinkAct->setEnabled(true);
} else { } else {
pastelinkAct->setDisabled(true); pasteLinkAct->setDisabled(true);
} }
contextMnu.addAction( pastelinkAct); contextMnu.addAction( pasteLinkAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
@ -815,6 +823,36 @@ void TransfersDialog::downloadListHeaderCustomPopupMenu( QPoint /*point*/ )
} }
void TransfersDialog::uploadsListCustomPopupMenu( QPoint /*point*/ )
{
std::cerr << "TransfersDialog::uploadsListCustomPopupMenu()" << std::endl;
std::set<std::string> items;
getULSelectedItems(&items, NULL);
bool single = (items.size() == 1);
bool add_CopyLink = false;
QMenu contextMnu( this );
if(!items.empty())
{
add_CopyLink = true;
}//if(!items.empty())
if(single)
{
contextMnu.addAction( ulOpenFolderAct);
}
if (add_CopyLink)
contextMnu.addAction( ulCopyLinkAct);
contextMnu.exec(QCursor::pos());
}
void TransfersDialog::chooseDestinationDirectory() void TransfersDialog::chooseDestinationDirectory()
{ {
QString dest_dir = QFileDialog::getExistingDirectory(this,tr("Choose directory")) ; QString dest_dir = QFileDialog::getExistingDirectory(this,tr("Choose directory")) ;
@ -1420,6 +1458,29 @@ void TransfersDialog::copyLink ()
RSLinkClipboard::copyLinks(links) ; RSLinkClipboard::copyLinks(links) ;
} }
void TransfersDialog::ulCopyLink ()
{
QList<RetroShareLink> links ;
std::set<std::string> items;
std::set<std::string>::iterator it;
getULSelectedItems(&items, NULL);
for (it = items.begin(); it != items.end(); it ++) {
FileInfo info;
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) {
continue;
}
RetroShareLink link;
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash))) {
links.push_back(link) ;
}
}
RSLinkClipboard::copyLinks(links) ;
}
DetailsDialog *TransfersDialog::detailsDialog() DetailsDialog *TransfersDialog::detailsDialog()
{ {
static DetailsDialog *detailsdlg = new DetailsDialog ; static DetailsDialog *detailsdlg = new DetailsDialog ;
@ -1499,6 +1560,31 @@ void TransfersDialog::getSelectedItems(std::set<std::string> *ids, std::set<int>
} }
} }
void TransfersDialog::getULSelectedItems(std::set<std::string> *ids, std::set<int> *rows)
{
if (ids == NULL && rows == NULL) {
return;
}
if (ids) ids->clear();
if (rows) rows->clear();
QModelIndexList indexes = selectionUp->selectedIndexes();
QModelIndex index;
foreach(index, indexes) {
if (ids) {
QStandardItem *id = ULListModel->item(index.row(), COLUMN_UHASH);
ids->insert(id->data(Qt::DisplayRole).toString().toStdString());
}
if (rows) {
rows->insert(index.row());
}
}
}
bool TransfersDialog::controlTransferFile(uint32_t flags) bool TransfersDialog::controlTransferFile(uint32_t flags)
{ {
bool result = true; bool result = true;
@ -1559,6 +1645,33 @@ void TransfersDialog::openFolderTransfer()
} }
} }
void TransfersDialog::ulOpenFolder()
{
FileInfo info;
std::set<std::string> items;
std::set<std::string>::iterator it;
getULSelectedItems(&items, NULL);
for (it = items.begin(); it != items.end(); it ++) {
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) continue;
break;
}
/* make path for uploading files */
QFileInfo qinfo;
std::string path;
path = info.path.substr(0,info.path.length()-info.fname.length());
/* open folder with a suitable application */
qinfo.setFile(QString::fromUtf8(path.c_str()));
if (qinfo.exists() && qinfo.isDir()) {
if (!RsUrlHandler::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
std::cerr << "ulOpenFolder(): can't open folder " << path << std::endl;
}
}
}
void TransfersDialog::previewTransfer() void TransfersDialog::previewTransfer()
{ {
FileInfo info; FileInfo info;

View file

@ -79,6 +79,7 @@ private slots:
/** Create the context popup menu and it's submenus */ /** Create the context popup menu and it's submenus */
void downloadListCustomPopupMenu( QPoint point ); void downloadListCustomPopupMenu( QPoint point );
void downloadListHeaderCustomPopupMenu( QPoint point ); void downloadListHeaderCustomPopupMenu( QPoint point );
void uploadsListCustomPopupMenu( QPoint point );
void cancel(); void cancel();
void forceCheck(); void forceCheck();
@ -103,6 +104,8 @@ private slots:
void openTransfer(); void openTransfer();
void previewTransfer(); void previewTransfer();
void ulOpenFolder();
void ulCopyLink();
/** clear download or all queue - for pending dwls */ /** clear download or all queue - for pending dwls */
// void clearQueue(); // void clearQueue();
@ -149,7 +152,7 @@ private:
QStandardItemModel *DLListModel; QStandardItemModel *DLListModel;
QStandardItemModel *ULListModel; QStandardItemModel *ULListModel;
QItemSelectionModel *selection; QItemSelectionModel *selection;
QItemSelectionModel *selectionup; QItemSelectionModel *selectionUp;
DLListDelegate *DLDelegate; DLListDelegate *DLDelegate;
ULListDelegate *ULDelegate; ULListDelegate *ULDelegate;
@ -158,20 +161,20 @@ private:
void createActions(); void createActions();
/** Defines the actions for the context menu */ /** Defines the actions for the context menu */
QAction* showdowninfoAct; QAction* showdownInfoAct;
QAction* playAct; QAction* playAct;
QAction* cancelAct; QAction* cancelAct;
QAction* forceCheckAct; QAction* forceCheckAct;
QAction* clearcompletedAct; QAction* clearCompletedAct;
QAction* copylinkAct; QAction* copyLinkAct;
QAction* pastelinkAct; QAction* pasteLinkAct;
QAction* rootisnotdecoratedAct; QAction* rootIsNotDecoratedAct;
QAction* rootisdecoratedAct; QAction* rootIsDecoratedAct;
QAction *pauseAct; QAction *pauseAct;
QAction *resumeAct; QAction *resumeAct;
QAction *openfolderAct; QAction *openFolderAct;
QAction *openfileAct; QAction *openFileAct;
QAction *previewfileAct; QAction *previewFileAct;
// QAction *clearQueuedDwlAct; // QAction *clearQueuedDwlAct;
// QAction *clearQueueAct; // QAction *clearQueueAct;
QAction *changePriorityAct; QAction *changePriorityAct;
@ -185,7 +188,7 @@ private:
QAction *chunkRandomAct; QAction *chunkRandomAct;
QAction *chunkProgressiveAct; QAction *chunkProgressiveAct;
QAction *chunkStreamingAct; QAction *chunkStreamingAct;
QAction *detailsfileAct; QAction *detailsFileAct;
QAction *toggleShowCacheTransfersAct; QAction *toggleShowCacheTransfersAct;
QAction *openCollectionAct; QAction *openCollectionAct;
QAction *renameFileAct; QAction *renameFileAct;
@ -206,11 +209,15 @@ private:
QAction* showDLIDAct; QAction* showDLIDAct;
QAction* showDLLastDLAct; QAction* showDLLastDLAct;
/** Defines the actions for the upload context menu */
QAction* ulOpenFolderAct;
QAction* ulCopyLinkAct;
bool m_bProcessSettings; bool m_bProcessSettings;
void processSettings(bool bLoad); void processSettings(bool bLoad);
void getSelectedItems(std::set<std::string> *ids, std::set<int> *rows); void getSelectedItems(std::set<std::string> *ids, std::set<int> *rows);
void getULSelectedItems(std::set<std::string> *ids, std::set<int> *rows);
bool controlTransferFile(uint32_t flags); bool controlTransferFile(uint32_t flags);
void changePriority(int priority); void changePriority(int priority);
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ; void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;

View file

@ -193,6 +193,9 @@
<pointsize>9</pointsize> <pointsize>9</pointsize>
</font> </font>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>