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

@ -66,37 +66,39 @@ TransfersDialog::TransfersDialog(QWidget *parent)
DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining", "i.e: Estimated Time of Arrival / Time left")); DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining", "i.e: Estimated Time of Arrival / Time left"));
DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID")); DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID"));
ui.downloadList->setModel(DLListModel); ui.downloadList->setModel(DLListModel);
ui.downloadList->hideColumn(ID); ui.downloadList->hideColumn(ID);
DLDelegate = new DLListDelegate(); DLDelegate = new DLListDelegate();
ui.downloadList->setItemDelegate(DLDelegate); ui.downloadList->setItemDelegate(DLDelegate);
ui.downloadList->setAutoScroll(false) ; ui.downloadList->setAutoScroll(false) ;
//Selection Setup //Selection Setup
selection = ui.downloadList->selectionModel(); selection = ui.downloadList->selectionModel();
ui.downloadList->setSelectionMode(QAbstractItemView::ExtendedSelection);
/* Set header resize modes and initial section sizes Downloads TreeView*/ /* Set header resize modes and initial section sizes Downloads TreeView*/
// QHeaderView * _header = ui.downloadList->header () ; QHeaderView * _header = ui.downloadList->header () ;
// _header->setResizeMode (0, QHeaderView::Interactive); /*Name*/ _header->setResizeMode (NAME, QHeaderView::Interactive);
// _header->setResizeMode (1, QHeaderView::Interactive); /*Size*/ _header->setResizeMode (SIZE, QHeaderView::Interactive);
// _header->setResizeMode (2, QHeaderView::Interactive); /*Progress*/ _header->setResizeMode (COMPLETED, QHeaderView::Interactive);
// _header->setResizeMode (3, QHeaderView::Interactive); /*Speed*/ _header->setResizeMode (DLSPEED, QHeaderView::Interactive);
// _header->setResizeMode (4, QHeaderView::Interactive); /*Sources*/ _header->setResizeMode (PROGRESS, QHeaderView::Interactive);
// _header->setResizeMode (5, QHeaderView::Interactive); /*Status*/ _header->setResizeMode (SOURCES, QHeaderView::Interactive);
// _header->setResizeMode (6, QHeaderView::Interactive); /*Completed*/ _header->setResizeMode (STATUS, QHeaderView::Interactive);
// _header->setResizeMode (7, QHeaderView::Interactive); /*Remaining */ _header->setResizeMode (REMAINING, QHeaderView::Interactive);
//
// _header->resizeSection ( NAME, 170 );
// _header->resizeSection ( 0, 100 ); /*Name*/ _header->resizeSection ( SIZE, 70 );
// _header->resizeSection ( 1, 75 ); /*Size*/ _header->resizeSection ( COMPLETED, 75 );
// _header->resizeSection ( 2, 170 ); /*Progress*/ _header->resizeSection ( DLSPEED, 75 );
// _header->resizeSection ( 3, 75 ); /*Speed*/ _header->resizeSection ( PROGRESS, 170 );
// _header->resizeSection ( 4, 100 ); /*Sources*/ _header->resizeSection ( SOURCES, 90 );
// _header->resizeSection ( 5, 100 ); /*Status*/ _header->resizeSection ( STATUS, 100 );
// _header->resizeSection ( 6, 75 ); /*Completed*/ _header->resizeSection ( REMAINING, 100 );
// _header->resizeSection ( 7, 100 ); /*Remaining */
// Set Upload list model // Set Upload list model
ULListModel = new QStandardItemModel(0,7); ULListModel = new QStandardItemModel(0,7);
ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name")); ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
ULListModel->setHeaderData(USIZE, Qt::Horizontal, tr("Size", "i.e: file size")); ULListModel->setHeaderData(USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
@ -109,7 +111,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
ULDelegate = new ULListDelegate(); ULDelegate = new ULListDelegate();
ui.uploadsList->setItemDelegate(ULDelegate); ui.uploadsList->setItemDelegate(ULDelegate);
ui.uploadsList->setAutoScroll(false) ; ui.uploadsList->setAutoScroll(false) ;
ui.uploadsList->setRootIsDecorated(false); ui.uploadsList->setRootIsDecorated(false);
//Selection Setup //Selection Setup
@ -139,6 +141,17 @@ TransfersDialog::TransfersDialog(QWidget *parent)
#endif #endif
} }
void TransfersDialog::keyPressEvent(QKeyEvent *e)
{
if(e->key() == Qt::Key_Delete)
{
cancel() ;
e->accept() ;
}
else
MainPage::keyPressEvent(e) ;
}
void TransfersDialog::downloadListCostumPopupMenu( QPoint point ) void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
{ {
@ -586,17 +599,32 @@ void TransfersDialog::insertTransfers()
void TransfersDialog::cancel() void TransfersDialog::cancel()
{ {
for(int i = 0; i <= DLListModel->rowCount(); i++) { QString queryWrn2;
if(selection->isRowSelected(i, QModelIndex())) { queryWrn2.clear();
std::string id = getID(i, DLListModel).toStdString(); queryWrn2.append("Are you sure that you want to cancel and delete these files?");
QString qname = getFileName(i, DLListModel);
/* XXX -> Should not have to 'trim' filename ... something wrong here.. if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)
* but otherwise, not exact filename .... BUG {
*/
std::string name = (qname.trimmed()).toStdString();
rsFiles->FileCancel(id); /* hash */ 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..
* but otherwise, not exact filename .... BUG
*/
std::string name = (qname.trimmed()).toStdString();
rsFiles->FileCancel(id); /* hash */
}
}
}
else
return;
} }
void TransfersDialog::clearcompleted() void TransfersDialog::clearcompleted()

View File

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