enabled multiple selections via mouse,keyboard,CTRL + A ...

added feature to can delete files via Qt::Key_Delete
added messagebox when cancel files from Transfers

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1190 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-05-07 22:40:57 +00:00
parent 20593c9de2
commit d201d41736
2 changed files with 65 additions and 35 deletions

View File

@ -75,26 +75,28 @@ TransfersDialog::TransfersDialog(QWidget *parent)
//Selection Setup
selection = ui.downloadList->selectionModel();
ui.downloadList->setSelectionMode(QAbstractItemView::ExtendedSelection);
/* Set header resize modes and initial section sizes Downloads TreeView*/
// QHeaderView * _header = ui.downloadList->header () ;
// _header->setResizeMode (0, QHeaderView::Interactive); /*Name*/
// _header->setResizeMode (1, QHeaderView::Interactive); /*Size*/
// _header->setResizeMode (2, QHeaderView::Interactive); /*Progress*/
// _header->setResizeMode (3, QHeaderView::Interactive); /*Speed*/
// _header->setResizeMode (4, QHeaderView::Interactive); /*Sources*/
// _header->setResizeMode (5, QHeaderView::Interactive); /*Status*/
// _header->setResizeMode (6, QHeaderView::Interactive); /*Completed*/
// _header->setResizeMode (7, QHeaderView::Interactive); /*Remaining */
//
//
// _header->resizeSection ( 0, 100 ); /*Name*/
// _header->resizeSection ( 1, 75 ); /*Size*/
// _header->resizeSection ( 2, 170 ); /*Progress*/
// _header->resizeSection ( 3, 75 ); /*Speed*/
// _header->resizeSection ( 4, 100 ); /*Sources*/
// _header->resizeSection ( 5, 100 ); /*Status*/
// _header->resizeSection ( 6, 75 ); /*Completed*/
// _header->resizeSection ( 7, 100 ); /*Remaining */
QHeaderView * _header = ui.downloadList->header () ;
_header->setResizeMode (NAME, QHeaderView::Interactive);
_header->setResizeMode (SIZE, QHeaderView::Interactive);
_header->setResizeMode (COMPLETED, QHeaderView::Interactive);
_header->setResizeMode (DLSPEED, QHeaderView::Interactive);
_header->setResizeMode (PROGRESS, QHeaderView::Interactive);
_header->setResizeMode (SOURCES, QHeaderView::Interactive);
_header->setResizeMode (STATUS, QHeaderView::Interactive);
_header->setResizeMode (REMAINING, QHeaderView::Interactive);
_header->resizeSection ( NAME, 170 );
_header->resizeSection ( SIZE, 70 );
_header->resizeSection ( COMPLETED, 75 );
_header->resizeSection ( DLSPEED, 75 );
_header->resizeSection ( PROGRESS, 170 );
_header->resizeSection ( SOURCES, 90 );
_header->resizeSection ( STATUS, 100 );
_header->resizeSection ( REMAINING, 100 );
// Set Upload list model
ULListModel = new QStandardItemModel(0,7);
@ -139,6 +141,17 @@ TransfersDialog::TransfersDialog(QWidget *parent)
#endif
}
void TransfersDialog::keyPressEvent(QKeyEvent *e)
{
if(e->key() == Qt::Key_Delete)
{
cancel() ;
e->accept() ;
}
else
MainPage::keyPressEvent(e) ;
}
void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
{
@ -586,8 +599,18 @@ void TransfersDialog::insertTransfers()
void TransfersDialog::cancel()
{
for(int i = 0; i <= DLListModel->rowCount(); i++) {
if(selection->isRowSelected(i, QModelIndex())) {
QString queryWrn2;
queryWrn2.clear();
queryWrn2.append("Are you sure that you want to cancel and delete these files?");
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)
{
for(int i = 0; i <= DLListModel->rowCount(); i++)
{
if(selection->isRowSelected(i, QModelIndex()))
{
std::string id = getID(i, DLListModel).toStdString();
QString qname = getFileName(i, DLListModel);
/* XXX -> Should not have to 'trim' filename ... something wrong here..
@ -595,8 +618,13 @@ void TransfersDialog::cancel()
*/
std::string name = (qname.trimmed()).toStdString();
rsFiles->FileCancel(id); /* hash */
}
}
}
else
return;
}
void TransfersDialog::clearcompleted()

View File

@ -47,6 +47,8 @@ class TransfersDialog : public MainPage
/** Default Destructor */
~TransfersDialog();
virtual void keyPressEvent(QKeyEvent *) ;
public slots:
void insertTransfers();