fixed download/upload lists issues (backport of commits 1650 and 1653)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.4.x@1657 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-09-16 19:26:07 +00:00
parent 7e596c58bb
commit fade169f30
2 changed files with 69 additions and 0 deletions

View File

@ -98,6 +98,13 @@ TransfersDialog::TransfersDialog(QWidget *parent)
_header->resizeSection ( STATUS, 100 );
_header->resizeSection ( REMAINING, 100 );
connect(_header, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorDwl(int, Qt::SortOrder)));
// set default column and sort order for download
_sortColDwl = 0;
_sortOrderDwl = Qt::AscendingOrder;
// Set Upload list model
ULListModel = new QStandardItemModel(0,7);
ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
@ -114,6 +121,30 @@ TransfersDialog::TransfersDialog(QWidget *parent)
// ui.uploadsList->setAutoScroll(false) ;
ui.uploadsList->setRootIsDecorated(false);
/* Set header resize modes and initial section sizes Uploads TreeView*/
QHeaderView * upheader = ui.uploadsList->header () ;
upheader->setResizeMode (UNAME, QHeaderView::Interactive);
upheader->setResizeMode (USIZE, QHeaderView::Interactive);
upheader->setResizeMode (UTRANSFERRED, QHeaderView::Interactive);
upheader->setResizeMode (ULSPEED, QHeaderView::Interactive);
upheader->setResizeMode (UPROGRESS, QHeaderView::Interactive);
upheader->setResizeMode (USTATUS, QHeaderView::Interactive);
upheader->setResizeMode (USERNAME, QHeaderView::Interactive);
upheader->resizeSection ( UNAME, 170 );
upheader->resizeSection ( USIZE, 70 );
upheader->resizeSection ( UTRANSFERRED, 75 );
upheader->resizeSection ( ULSPEED, 75 );
upheader->resizeSection ( UPROGRESS, 170 );
upheader->resizeSection ( USTATUS, 100 );
upheader->resizeSection ( USERNAME, 75 );
connect(upheader, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorUpl(int, Qt::SortOrder)));
// set default column and sort order for upload
_sortColUpl = 0;
_sortOrderUpl = Qt::AscendingOrder;
//Selection Setup
//selection = ui.uploadsList->selectionModel();
@ -376,6 +407,13 @@ void TransfersDialog::insertTransfers()
delUploadItem(i);
}
ui.downloadList->sortByColumn(_sortColDwl, _sortOrderDwl);
/* disable for performance issues, enable after insert all transfers */
ui.downloadList->setSortingEnabled(false);
QModelIndex firstSelIdx;
/* get the download and upload lists */
std::list<std::string> downHashes;
@ -451,6 +489,8 @@ void TransfersDialog::insertTransfers()
selection->select(DLListModel->index(dlCount, 0),
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
if (!firstSelIdx.isValid())
firstSelIdx = DLListModel->index(dlCount, NAME);
}
dlCount++;
}
@ -497,11 +537,22 @@ void TransfersDialog::insertTransfers()
selection->select(DLListModel->index(dlCount, 0),
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
if (!firstSelIdx.isValid())
firstSelIdx = DLListModel->index(dlCount, NAME);
}
dlCount++;
}
}
if (firstSelIdx.isValid())
ui.downloadList->scrollTo(firstSelIdx);
ui.downloadList->setSortingEnabled(true);
ui.uploadsList->sortByColumn(_sortColUpl, _sortOrderUpl);
/* disable for performance issues, enable after insert all transfers */
ui.uploadsList->setSortingEnabled(false);
for(it = upHashes.begin(); it != upHashes.end(); it++)
{
FileInfo info;
@ -631,6 +682,18 @@ void TransfersDialog::clearcompleted()
rsFiles->FileClearCompleted();
}
void TransfersDialog::saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order)
{
_sortColDwl = logicalIndex;;
_sortOrderDwl = order;
}
void TransfersDialog::saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order)
{
_sortColUpl = logicalIndex;;
_sortOrderUpl = order;
}
double TransfersDialog::getProgress(int row, QStandardItemModel *model)
{
return model->data(model->index(row, PROGRESS), Qt::DisplayRole).toDouble();

View File

@ -62,6 +62,10 @@ class TransfersDialog : public MainPage
void clearcompleted();
void playSelectedTransfer();
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
signals:
void playFiles(QStringList files);
@ -77,6 +81,8 @@ class TransfersDialog : public MainPage
QString status, icon, name;
qlonglong completed, remaining;
int _sortColDwl, _sortColUpl;
Qt::SortOrder _sortOrderDwl, _sortOrderUpl;
/** Create the actions on the tray menu or menubar */
void createActions();