Merge pull request #1033 from PhenomRetroShare/Add_UploadExpColAll

Add Expand/Collapse All in Upload List
This commit is contained in:
csoler 2017-09-14 22:06:01 +02:00 committed by GitHub
commit d5eac2c1d9
2 changed files with 75 additions and 36 deletions

View File

@ -412,10 +412,14 @@ TransfersDialog::TransfersDialog(QWidget *parent)
connect(renameFileAct, SIGNAL(triggered()), this, SLOT(renameFile())); connect(renameFileAct, SIGNAL(triggered()), this, SLOT(renameFile()));
specifyDestinationDirectoryAct = new QAction(QIcon(IMAGE_SEARCH),tr("Specify..."),this) ; specifyDestinationDirectoryAct = new QAction(QIcon(IMAGE_SEARCH),tr("Specify..."),this) ;
connect(specifyDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(chooseDestinationDirectory())); connect(specifyDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(chooseDestinationDirectory()));
expandAllAct= new QAction(QIcon(IMAGE_EXPAND),tr("Expand all"),this); expandAllDLAct= new QAction(QIcon(IMAGE_EXPAND),tr("Expand all"),this);
connect(expandAllAct,SIGNAL(triggered()),this,SLOT(expandAll())); connect(expandAllDLAct,SIGNAL(triggered()),this,SLOT(expandAllDL()));
collapseAllAct= new QAction(QIcon(IMAGE_COLLAPSE),tr("Collapse all"),this); collapseAllDLAct= new QAction(QIcon(IMAGE_COLLAPSE),tr("Collapse all"),this);
connect(collapseAllAct,SIGNAL(triggered()),this,SLOT(collapseAll())); connect(collapseAllDLAct,SIGNAL(triggered()),this,SLOT(collapseAllDL()));
expandAllULAct= new QAction(QIcon(IMAGE_EXPAND),tr("Expand all"),this);
connect(expandAllULAct,SIGNAL(triggered()),this,SLOT(expandAllUL()));
collapseAllULAct= new QAction(QIcon(IMAGE_COLLAPSE),tr("Collapse all"),this);
connect(collapseAllULAct,SIGNAL(triggered()),this,SLOT(collapseAllUL()));
collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this); collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this);
connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())); connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate()));
collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this); collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this);
@ -777,8 +781,8 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
}//if (add_CopyLink || add_PasteLink) }//if (add_CopyLink || add_PasteLink)
if (DLLFilterModel->rowCount()>0 ) { if (DLLFilterModel->rowCount()>0 ) {
contextMnu.addAction( expandAllAct ) ; contextMnu.addAction( expandAllDLAct ) ;
contextMnu.addAction( collapseAllAct ) ; contextMnu.addAction( collapseAllDLAct ) ;
} }
contextMnu.addSeparator() ;//----------------------------------------------- contextMnu.addSeparator() ;//-----------------------------------------------
@ -844,6 +848,14 @@ void TransfersDialog::uploadsListCustomPopupMenu( QPoint /*point*/ )
if (add_CopyLink) if (add_CopyLink)
contextMnu.addAction( ulCopyLinkAct); contextMnu.addAction( ulCopyLinkAct);
if (ULListModel->rowCount()>0 ) {
if(single || add_CopyLink)
contextMnu.addSeparator() ;//-----------------------------------------------
contextMnu.addAction( expandAllULAct ) ;
contextMnu.addAction( collapseAllULAct ) ;
}
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }
@ -1176,9 +1188,15 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize)); ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize));
//Reset Parent info if child present
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), QVariant(QString()), Qt::ToolTipRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant());
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant());
QStandardItem *ulItem = ULListModel->item(row); QStandardItem *ulItem = ULListModel->item(row);
std::set<int> used_rows ; std::set<int> used_rows ;
double peerULSpeedTotal = 0; double peerULSpeedTotal = 0;
bool bOnlyOne = ( fileInfo.peers.size() == 1 );
for(std::list<TransferInfo>::const_iterator pit = fileInfo.peers.begin() for(std::list<TransferInfo>::const_iterator pit = fileInfo.peers.begin()
; pit != fileInfo.peers.end(); ++pit) ; pit != fileInfo.peers.end(); ++pit)
@ -1219,9 +1237,17 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
peerpinfo.progress = (fileInfo.size>0)?((transferInfo.transfered % chunk_size)*100.0/fileInfo.size):0 ; peerpinfo.progress = (fileInfo.size>0)?((transferInfo.transfered % chunk_size)*100.0/fileInfo.size):0 ;
} }
if (bOnlyOne)
{
//Only one peer so update parent
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), QVariant(getPeerName(transferInfo.peerId)), Qt::ToolTipRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant(completed));
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant::fromValue(peerpinfo));
} else {
int row_id = addPeerToULItem(ulItem, transferInfo.peerId, hashFileAndPeerId, completed, peerULSpeed, peerpinfo); int row_id = addPeerToULItem(ulItem, transferInfo.peerId, hashFileAndPeerId, completed, peerULSpeed, peerpinfo);
used_rows.insert(row_id); used_rows.insert(row_id);
}
peerULSpeedTotal += peerULSpeed; peerULSpeedTotal += peerULSpeed;
} }
@ -2280,15 +2306,24 @@ void TransfersDialog::setShowDLPath(bool show)
} }
} }
void TransfersDialog::expandAll() void TransfersDialog::expandAllDL()
{ {
ui.downloadList->expandAll(); ui.downloadList->expandAll();
} }
void TransfersDialog::collapseAll() void TransfersDialog::collapseAllDL()
{ {
ui.downloadList->collapseAll(); ui.downloadList->collapseAll();
} }
void TransfersDialog::expandAllUL()
{
ui.uploadsList->expandAll();
}
void TransfersDialog::collapseAllUL()
{
ui.uploadsList->collapseAll();
}
void TransfersDialog::filterChanged(const QString& /*text*/) void TransfersDialog::filterChanged(const QString& /*text*/)
{ {
int filterColumn = ui.filterLineEdit->currentFilter(); int filterColumn = ui.filterLineEdit->currentFilter();

View File

@ -101,8 +101,10 @@ private slots:
void setDestinationDirectory(); void setDestinationDirectory();
void chooseDestinationDirectory(); void chooseDestinationDirectory();
void expandAll(); void expandAllDL();
void collapseAll(); void collapseAllDL();
void expandAllUL();
void collapseAllUL();
// void rootdecorated(); // void rootdecorated();
// void rootisnotdecorated(); // void rootisnotdecorated();
@ -207,8 +209,10 @@ private:
QAction *detailsFileAct; QAction *detailsFileAct;
QAction *renameFileAct; QAction *renameFileAct;
QAction *specifyDestinationDirectoryAct; QAction *specifyDestinationDirectoryAct;
QAction *expandAllAct; QAction *expandAllDLAct;
QAction *collapseAllAct; QAction *collapseAllDLAct;
QAction *expandAllULAct;
QAction *collapseAllULAct;
QAction *collCreateAct; QAction *collCreateAct;
QAction *collModifAct; QAction *collModifAct;
QAction *collViewAct; QAction *collViewAct;