mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
Fixed context menu "Cancel" and "Copy RetroShare Links" in TransfersDialog when a peer is selected.
Fixed DetailsDialog when a peer is selected. Sort peers by name ascending in the download list. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4018 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
dbe0890974
commit
9d76a44890
@ -71,20 +71,65 @@ Q_DECLARE_METATYPE(FileProgressInfo)
|
|||||||
|
|
||||||
DetailsDialog *TransfersDialog::detailsdlg = NULL;
|
DetailsDialog *TransfersDialog::detailsdlg = NULL;
|
||||||
|
|
||||||
class ProgressItem : public QStandardItem
|
class SortByNameItem : public QStandardItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProgressItem() : QStandardItem() {}
|
SortByNameItem(QHeaderView *header) : QStandardItem()
|
||||||
|
{
|
||||||
|
this->header = header;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool operator<(const QStandardItem &other) const
|
virtual bool operator<(const QStandardItem &other) const
|
||||||
{
|
{
|
||||||
const int role = model() ? model()->sortRole() : Qt::DisplayRole;
|
QStandardItemModel *m = model();
|
||||||
|
if (m == NULL) {
|
||||||
|
return QStandardItem::operator<(other);
|
||||||
|
}
|
||||||
|
|
||||||
FileProgressInfo l = data(role).value<FileProgressInfo>();
|
QStandardItem *myParent = parent();
|
||||||
FileProgressInfo r = other.data(role).value<FileProgressInfo>();
|
QStandardItem *otherParent = other.parent();
|
||||||
|
|
||||||
return l < r;
|
if (myParent == NULL || otherParent == NULL) {
|
||||||
}
|
return QStandardItem::operator<(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStandardItem *myName = myParent->child(index().row(), NAME);
|
||||||
|
QStandardItem *otherName = otherParent->child(other.index().row(), NAME);
|
||||||
|
|
||||||
|
if (header == NULL || header->sortIndicatorOrder() == Qt::AscendingOrder) {
|
||||||
|
/* Ascending */
|
||||||
|
return *myName < *otherName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Descending, sort peers in ascending order */
|
||||||
|
return !(*myName < *otherName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHeaderView *header;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProgressItem : public SortByNameItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProgressItem(QHeaderView *header) : SortByNameItem(header) {}
|
||||||
|
|
||||||
|
virtual bool operator<(const QStandardItem &other) const
|
||||||
|
{
|
||||||
|
const int role = model() ? model()->sortRole() : Qt::DisplayRole;
|
||||||
|
|
||||||
|
FileProgressInfo l = data(role).value<FileProgressInfo>();
|
||||||
|
FileProgressInfo r = other.data(role).value<FileProgressInfo>();
|
||||||
|
|
||||||
|
if (l < r) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (l > r) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SortByNameItem::operator<(other);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
@ -350,9 +395,9 @@ void TransfersDialog::processSettings(bool bLoad)
|
|||||||
|
|
||||||
void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
||||||
{
|
{
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
|
|
||||||
bool single = (items.size() == 1) ;
|
bool single = (items.size() == 1) ;
|
||||||
|
|
||||||
@ -364,7 +409,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,7 +546,7 @@ int TransfersDialog::addItem(const QString&, const QString& name, const QString&
|
|||||||
int rowCount = DLListModel->rowCount();
|
int rowCount = DLListModel->rowCount();
|
||||||
int row ;
|
int row ;
|
||||||
for(row=0;row<rowCount;++row)
|
for(row=0;row<rowCount;++row)
|
||||||
if(DLListModel->item(row,ID)->data(Qt::EditRole).toString() == coreID)
|
if(DLListModel->item(row,ID)->data(Qt::DisplayRole).toString() == coreID)
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
if(row >= rowCount )
|
if(row >= rowCount )
|
||||||
@ -510,7 +555,7 @@ int TransfersDialog::addItem(const QString&, const QString& name, const QString&
|
|||||||
DLListModel->insertRow(row);
|
DLListModel->insertRow(row);
|
||||||
|
|
||||||
// change progress column to own class for sorting
|
// change progress column to own class for sorting
|
||||||
DLListModel->setItem(row, PROGRESS, new ProgressItem);
|
DLListModel->setItem(row, PROGRESS, new ProgressItem (NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
||||||
@ -588,17 +633,19 @@ int TransfersDialog::addPeerToItem(int row, const QString& name, const QString&
|
|||||||
//set this false if you want to expand on double click
|
//set this false if you want to expand on double click
|
||||||
dlItem->setEditable(false);
|
dlItem->setEditable(false);
|
||||||
|
|
||||||
|
QHeaderView *header = ui.downloadList->header ();
|
||||||
|
|
||||||
QStandardItem *i1 = new QStandardItem();
|
QStandardItem *i1 = new QStandardItem();
|
||||||
QStandardItem *i2 = new QStandardItem();
|
QStandardItem *i2 = new SortByNameItem(header);
|
||||||
QStandardItem *i3 = new QStandardItem();
|
QStandardItem *i3 = new SortByNameItem(header);
|
||||||
QStandardItem *i4 = new QStandardItem();
|
QStandardItem *i4 = new SortByNameItem(header);
|
||||||
QStandardItem *i5 = new ProgressItem();
|
QStandardItem *i5 = new ProgressItem(header);
|
||||||
QStandardItem *i6 = new QStandardItem();
|
QStandardItem *i6 = new SortByNameItem(header);
|
||||||
QStandardItem *i7 = new QStandardItem();
|
QStandardItem *i7 = new SortByNameItem(header);
|
||||||
QStandardItem *i8 = new QStandardItem();
|
QStandardItem *i8 = new SortByNameItem(header);
|
||||||
QStandardItem *i9 = new QStandardItem();
|
QStandardItem *i9 = new SortByNameItem(header);
|
||||||
QStandardItem *i10 = new QStandardItem();
|
QStandardItem *i10 = new SortByNameItem(header);
|
||||||
QStandardItem *i11 = new QStandardItem();
|
QStandardItem *i11 = new SortByNameItem(header);
|
||||||
|
|
||||||
si1 = i1 ;
|
si1 = i1 ;
|
||||||
si7 = i7 ;
|
si7 = i7 ;
|
||||||
@ -692,7 +739,7 @@ int TransfersDialog::addUploadItem( const QString&, const QString& name, const Q
|
|||||||
ULListModel->insertRow(row);
|
ULListModel->insertRow(row);
|
||||||
|
|
||||||
// change progress column to own class for sorting
|
// change progress column to own class for sorting
|
||||||
ULListModel->setItem(row, UPROGRESS, new ProgressItem);
|
ULListModel->setItem(row, UPROGRESS, new ProgressItem(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
ULListModel->setData(ULListModel->index(row, UNAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
ULListModel->setData(ULListModel->index(row, UNAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
||||||
@ -712,15 +759,15 @@ int TransfersDialog::addUploadItem( const QString&, const QString& name, const Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TransfersDialog::delItem(int row)
|
//void TransfersDialog::delItem(int row)
|
||||||
{
|
//{
|
||||||
DLListModel->removeRow(row, QModelIndex());
|
// DLListModel->removeRow(row, QModelIndex());
|
||||||
}
|
//}
|
||||||
|
|
||||||
void TransfersDialog::delUploadItem(int row)
|
//void TransfersDialog::delUploadItem(int row)
|
||||||
{
|
//{
|
||||||
ULListModel->removeRow(row, QModelIndex());
|
// ULListModel->removeRow(row, QModelIndex());
|
||||||
}
|
//}
|
||||||
|
|
||||||
/* get the list of Transfers from the RsIface. **/
|
/* get the list of Transfers from the RsIface. **/
|
||||||
void TransfersDialog::updateDisplay()
|
void TransfersDialog::updateDisplay()
|
||||||
@ -784,7 +831,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
if(pit->tfRate > 0 && info.downloadStatus==FT_STATE_DOWNLOADING)
|
if(pit->tfRate > 0 && info.downloadStatus==FT_STATE_DOWNLOADING)
|
||||||
active++;
|
active++;
|
||||||
|
|
||||||
QString sources = QString("%1 (%2)").arg(active).arg(info.peers.size());
|
QString sources = QString("%1 (%2)").arg(active).arg(info.peers.size());
|
||||||
|
|
||||||
QString status;
|
QString status;
|
||||||
switch (info.downloadStatus) {
|
switch (info.downloadStatus) {
|
||||||
@ -871,13 +918,14 @@ void TransfersDialog::insertTransfers()
|
|||||||
if(used_rows.find(r) == used_rows.end())
|
if(used_rows.find(r) == used_rows.end())
|
||||||
QListDelete (dlItem->takeRow(r)) ;
|
QListDelete (dlItem->takeRow(r)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove hashes that where not shown
|
// remove hashes that where not shown
|
||||||
//first clean the model in case some files are not download anymore
|
//first clean the model in case some files are not download anymore
|
||||||
//remove items that are not fiends anymore
|
//remove items that are not fiends anymore
|
||||||
int removeIndex = 0;
|
int removeIndex = 0;
|
||||||
while (removeIndex < DLListModel->rowCount())
|
while (removeIndex < DLListModel->rowCount())
|
||||||
{
|
{
|
||||||
std::string hash = DLListModel->item(removeIndex, ID)->data(Qt::EditRole).toString().toStdString();
|
std::string hash = DLListModel->item(removeIndex, ID)->data(Qt::DisplayRole).toString().toStdString();
|
||||||
|
|
||||||
if(used_hashes.find(hash) == used_hashes.end())
|
if(used_hashes.find(hash) == used_hashes.end())
|
||||||
QListDelete (DLListModel->takeRow(removeIndex));
|
QListDelete (DLListModel->takeRow(removeIndex));
|
||||||
@ -1001,27 +1049,28 @@ void TransfersDialog::forceCheck()
|
|||||||
if (!controlTransferFile(RS_FILE_CTRL_FORCE_CHECK))
|
if (!controlTransferFile(RS_FILE_CTRL_FORCE_CHECK))
|
||||||
std::cerr << "resumeFileTransfer(): can't force check file transfer" << std::endl;
|
std::cerr << "resumeFileTransfer(): can't force check file transfer" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::cancel()
|
void TransfersDialog::cancel()
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for(int i = 0; i < DLListModel->rowCount(); i++) {
|
|
||||||
if(selection->isRowSelected(i, QModelIndex())) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
QString queryWrn2;
|
|
||||||
queryWrn2.clear();
|
|
||||||
queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?"));
|
|
||||||
|
|
||||||
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::No) {
|
std::set<std::string> items;
|
||||||
break;
|
std::set<std::string>::iterator it;
|
||||||
}
|
getSelectedItems(&items, NULL);
|
||||||
}
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
QString queryWrn2;
|
||||||
|
queryWrn2.clear();
|
||||||
|
queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?"));
|
||||||
|
|
||||||
std::string id = getID(i, DLListModel).toStdString();
|
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::No) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rsFiles->FileCancel(id); /* hash */
|
rsFiles->FileCancel(*it);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//void TransfersDialog::handleDownloadRequest(const QString& url)
|
//void TransfersDialog::handleDownloadRequest(const QString& url)
|
||||||
@ -1050,20 +1099,22 @@ void TransfersDialog::cancel()
|
|||||||
|
|
||||||
void TransfersDialog::copyLink ()
|
void TransfersDialog::copyLink ()
|
||||||
{
|
{
|
||||||
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
|
||||||
std::vector<RetroShareLink> links ;
|
std::vector<RetroShareLink> links ;
|
||||||
|
|
||||||
for (int i = 0; i < lst.count (); i++)
|
std::set<std::string> items;
|
||||||
if ( lst[i].column() == 0 )
|
std::set<std::string>::iterator it;
|
||||||
{
|
getSelectedItems(&items, NULL);
|
||||||
QModelIndex & ind = lst[i];
|
|
||||||
QString fhash= ind.model ()->data (ind.model ()->index (ind.row (), ID )).toString() ;
|
|
||||||
qulonglong fsize= ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toULongLong() ;
|
|
||||||
QString fname= ind.model ()->data (ind.model ()->index (ind.row (), NAME)).toString() ;
|
|
||||||
|
|
||||||
RetroShareLink link(fname, uint64_t(fsize), fhash);
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
links.push_back(link) ;
|
FileInfo info;
|
||||||
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RetroShareLink link(QString::fromStdString(info.fname), info.size, QString::fromStdString(info.hash));
|
||||||
|
links.push_back(link) ;
|
||||||
|
}
|
||||||
|
|
||||||
RSLinkClipboard::copyLinks(links) ;
|
RSLinkClipboard::copyLinks(links) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1085,8 +1136,6 @@ void TransfersDialog::updateDetailsDialog()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
|
|
||||||
|
|
||||||
std::string file_hash ;
|
std::string file_hash ;
|
||||||
QString fhash;
|
QString fhash;
|
||||||
QString fsize;
|
QString fsize;
|
||||||
@ -1102,39 +1151,38 @@ void TransfersDialog::updateDetailsDialog()
|
|||||||
|
|
||||||
qulonglong fdownloadtime = 0;
|
qulonglong fdownloadtime = 0;
|
||||||
|
|
||||||
for (int i = 0; i < lst.count (); i++)
|
std::set<int> rows;
|
||||||
{
|
std::set<int>::iterator it;
|
||||||
if (lst[i].column () == 0)
|
getSelectedItems(NULL, &rows);
|
||||||
{
|
|
||||||
QModelIndex& ind = lst[i];
|
|
||||||
fhash = ind.model ()->data (ind.model ()->index (ind.row (), ID )).toString() ;
|
|
||||||
fsize = ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toString() ;
|
|
||||||
fname = ind.model ()->data (ind.model ()->index (ind.row (), NAME)).toString() ;
|
|
||||||
fstatus = ind.model ()->data (ind.model ()->index (ind.row (), STATUS)).toString() ;
|
|
||||||
fpriority = ind.model ()->data (ind.model ()->index (ind.row (), PRIORITY)).toString() ;
|
|
||||||
fsources= ind.model ()->data (ind.model ()->index (ind.row (), SOURCES)).toString() ;
|
|
||||||
|
|
||||||
filesize = ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toULongLong() ;
|
if (rows.size()) {
|
||||||
fdatarate = ind.model ()->data (ind.model ()->index (ind.row (), DLSPEED)).toDouble() ;
|
int row = *rows.begin();
|
||||||
fcompleted = ind.model ()->data (ind.model ()->index (ind.row (), COMPLETED)).toULongLong() ;
|
|
||||||
fremaining = ind.model ()->data (ind.model ()->index (ind.row (), REMAINING)).toULongLong() ;
|
|
||||||
|
|
||||||
fdownloadtime = ind.model ()->data (ind.model ()->index (ind.row (), DOWNLOADTIME)).toULongLong() ;
|
fhash = getID(row, DLListModel);
|
||||||
|
fsize = getFileSize(row, DLListModel);
|
||||||
|
fname = getFileName(row, DLListModel);
|
||||||
|
fstatus = getStatus(row, DLListModel);
|
||||||
|
fpriority = getPriority(row, DLListModel);
|
||||||
|
fsources = getSources(row, DLListModel);
|
||||||
|
|
||||||
|
filesize = getFileSize(row, DLListModel);
|
||||||
|
fdatarate = getSpeed(row, DLListModel);
|
||||||
|
fcompleted = getTransfered(row, DLListModel);
|
||||||
|
fremaining = getRemainingTime(row, DLListModel);
|
||||||
|
|
||||||
|
fdownloadtime = getDownloadTime(row, DLListModel);
|
||||||
|
|
||||||
// maybe show all links in retroshare link(s) Tab
|
// maybe show all links in retroshare link(s) Tab
|
||||||
// int nb_select = 0 ;
|
// int nb_select = 0 ;
|
||||||
//
|
//
|
||||||
// for(int i = 0; i <= DLListModel->rowCount(); i++)
|
// for(int i = 0; i <= DLListModel->rowCount(); i++)
|
||||||
// if(selection->isRowSelected(i, QModelIndex()))
|
// if(selection->isRowSelected(i, QModelIndex()))
|
||||||
// {
|
// {
|
||||||
// file_hash = getID(i, DLListModel).toStdString();
|
// file_hash = getID(i, DLListModel).toStdString();
|
||||||
// ++nb_select ;
|
// ++nb_select ;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
file_hash = getID(ind.row(), DLListModel).toStdString();
|
file_hash = getID(row, DLListModel).toStdString();
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detailsdlg->setFileHash(file_hash);
|
detailsdlg->setFileHash(file_hash);
|
||||||
@ -1191,9 +1239,14 @@ void TransfersDialog::pasteLink()
|
|||||||
RSLinkClipboard::process(RetroShareLink::TYPE_FILE, RSLINK_PROCESS_NOTIFY_ERROR);
|
RSLinkClipboard::process(RetroShareLink::TYPE_FILE, RSLINK_PROCESS_NOTIFY_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items)
|
void TransfersDialog::getSelectedItems(std::set<std::string> *ids, std::set<int> *rows)
|
||||||
{
|
{
|
||||||
items.clear();
|
if (ids == NULL && rows == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ids) ids->clear();
|
||||||
|
if (rows) rows->clear();
|
||||||
|
|
||||||
int i, imax = DLListModel->rowCount();
|
int i, imax = DLListModel->rowCount();
|
||||||
for (i = 0; i < imax; i++) {
|
for (i = 0; i < imax; i++) {
|
||||||
@ -1219,8 +1272,13 @@ void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items)
|
|||||||
|
|
||||||
/* if transfered file or it's peers are selected control it*/
|
/* if transfered file or it's peers are selected control it*/
|
||||||
if (isParentSelected || isChildSelected) {
|
if (isParentSelected || isChildSelected) {
|
||||||
QStandardItem *id = DLListModel->item(i, ID);
|
if (ids) {
|
||||||
items.insert(id);
|
QStandardItem *id = DLListModel->item(i, ID);
|
||||||
|
ids->insert(id->data(Qt::DisplayRole).toString().toStdString());
|
||||||
|
}
|
||||||
|
if (rows) {
|
||||||
|
rows->insert(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1229,11 +1287,11 @@ bool TransfersDialog::controlTransferFile(uint32_t flags)
|
|||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
result &= rsFiles->FileControl((*it)->data(Qt::DisplayRole).toString().toStdString(), flags);
|
result &= rsFiles->FileControl(*it, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -1259,11 +1317,11 @@ void TransfersDialog::openFolderTransfer()
|
|||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1289,11 +1347,11 @@ void TransfersDialog::previewTransfer()
|
|||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1350,11 +1408,11 @@ void TransfersDialog::openTransfer()
|
|||||||
{
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
|
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
if (!rsFiles->FileDetails((*it)->data(Qt::DisplayRole).toString().toStdString(), RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1383,7 +1441,7 @@ void TransfersDialog::openTransfer()
|
|||||||
//{
|
//{
|
||||||
// std::set<QStandardItem *> items;
|
// std::set<QStandardItem *> items;
|
||||||
// std::set<QStandardItem *>::iterator it;
|
// std::set<QStandardItem *>::iterator it;
|
||||||
// getIdOfSelectedItems(items);
|
// getSelectedItems(&items, NULL);
|
||||||
//
|
//
|
||||||
// for (it = items.begin(); it != items.end(); it ++) {
|
// for (it = items.begin(); it != items.end(); it ++) {
|
||||||
// std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
// std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
||||||
@ -1405,13 +1463,12 @@ void TransfersDialog::chunkRandom()
|
|||||||
}
|
}
|
||||||
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
||||||
{
|
{
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++) {
|
for (it = items.begin(); it != items.end(); it ++) {
|
||||||
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
rsFiles->setChunkStrategy(*it, s);
|
||||||
rsFiles->setChunkStrategy(hash, s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* modify download priority actions */
|
/* modify download priority actions */
|
||||||
@ -1447,14 +1504,13 @@ void TransfersDialog::priorityQueueBottom()
|
|||||||
|
|
||||||
void TransfersDialog::changeSpeed(int speed)
|
void TransfersDialog::changeSpeed(int speed)
|
||||||
{
|
{
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++)
|
for (it = items.begin(); it != items.end(); it ++)
|
||||||
{
|
{
|
||||||
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
rsFiles->changeDownloadSpeed(*it, speed);
|
||||||
rsFiles->changeDownloadSpeed(hash, speed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1462,21 +1518,20 @@ void TransfersDialog::changeSpeed(int speed)
|
|||||||
void TransfersDialog::changeQueuePosition(QueueMove mv)
|
void TransfersDialog::changeQueuePosition(QueueMove mv)
|
||||||
{
|
{
|
||||||
std::cerr << "In changeQueuePosition (gui)"<< std::endl ;
|
std::cerr << "In changeQueuePosition (gui)"<< std::endl ;
|
||||||
std::set<QStandardItem *> items;
|
std::set<std::string> items;
|
||||||
std::set<QStandardItem *>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
getIdOfSelectedItems(items);
|
getSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); it ++)
|
for (it = items.begin(); it != items.end(); it ++)
|
||||||
{
|
{
|
||||||
std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString();
|
rsFiles->changeQueuePosition(*it, mv);
|
||||||
rsFiles->changeQueuePosition(hash, mv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::clearcompleted()
|
void TransfersDialog::clearcompleted()
|
||||||
{
|
{
|
||||||
std::cerr << "TransfersDialog::clearcompleted()" << std::endl;
|
std::cerr << "TransfersDialog::clearcompleted()" << std::endl;
|
||||||
rsFiles->FileClearCompleted();
|
rsFiles->FileClearCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::showFileDetails()
|
void TransfersDialog::showFileDetails()
|
||||||
@ -1552,3 +1607,13 @@ qlonglong TransfersDialog::getRemainingTime(int row, QStandardItemModel *model)
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
return model->data(model->index(row, REMAINING), Qt::DisplayRole).toULongLong(&ok);
|
return model->data(model->index(row, REMAINING), Qt::DisplayRole).toULongLong(&ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qlonglong TransfersDialog::getDownloadTime(int row, QStandardItemModel *model)
|
||||||
|
{
|
||||||
|
return model->data(model->index(row, DOWNLOADTIME), Qt::DisplayRole).toULongLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TransfersDialog::getSources(int row, QStandardItemModel *model)
|
||||||
|
{
|
||||||
|
return model->data(model->index(row, SOURCES), Qt::DisplayRole).toString();
|
||||||
|
}
|
||||||
|
@ -151,7 +151,7 @@ private:
|
|||||||
bool m_bProcessSettings;
|
bool m_bProcessSettings;
|
||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
|
|
||||||
void getIdOfSelectedItems(std::set<QStandardItem *>& items);
|
void getSelectedItems(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) ;
|
||||||
@ -169,10 +169,10 @@ public slots:
|
|||||||
//
|
//
|
||||||
int addItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining, qlonglong downloadtime);
|
int addItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining, qlonglong downloadtime);
|
||||||
int addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo);
|
int addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo);
|
||||||
void delItem(int row);
|
// void delItem(int row);
|
||||||
|
|
||||||
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources,const QString& source_id, const QString& status, qlonglong completed, qlonglong remaining);
|
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources,const QString& source_id, const QString& status, qlonglong completed, qlonglong remaining);
|
||||||
void delUploadItem(int row);
|
// void delUploadItem(int row);
|
||||||
|
|
||||||
void showFileDetails() ;
|
void showFileDetails() ;
|
||||||
|
|
||||||
@ -185,6 +185,8 @@ public slots:
|
|||||||
qlonglong getFileSize(int row, QStandardItemModel *model);
|
qlonglong getFileSize(int row, QStandardItemModel *model);
|
||||||
qlonglong getTransfered(int row, QStandardItemModel *model);
|
qlonglong getTransfered(int row, QStandardItemModel *model);
|
||||||
qlonglong getRemainingTime(int row, QStandardItemModel *model);
|
qlonglong getRemainingTime(int row, QStandardItemModel *model);
|
||||||
|
qlonglong getDownloadTime(int row, QStandardItemModel *model);
|
||||||
|
QString getSources(int row, QStandardItemModel *model);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,6 +33,11 @@ bool FileProgressInfo::operator<(const FileProgressInfo &other) const
|
|||||||
return progress < other.progress;
|
return progress < other.progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileProgressInfo::operator>(const FileProgressInfo &other) const
|
||||||
|
{
|
||||||
|
return progress > other.progress;
|
||||||
|
}
|
||||||
|
|
||||||
xProgressBar::xProgressBar(const FileProgressInfo& pinfo,QRect rect, QPainter *painter, int schemaIndex)
|
xProgressBar::xProgressBar(const FileProgressInfo& pinfo,QRect rect, QPainter *painter, int schemaIndex)
|
||||||
: _pinfo(pinfo)
|
: _pinfo(pinfo)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ class FileProgressInfo
|
|||||||
std::vector<uint32_t> chunks_in_progress ;
|
std::vector<uint32_t> chunks_in_progress ;
|
||||||
|
|
||||||
bool operator<(const FileProgressInfo &other) const;
|
bool operator<(const FileProgressInfo &other) const;
|
||||||
|
bool operator>(const FileProgressInfo &other) const;
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
class xProgressBar : public QObject
|
class xProgressBar : public QObject
|
||||||
|
Loading…
Reference in New Issue
Block a user