mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-20 23:10:39 -04:00
Beautified RsCollectionDialog.
Fixed german language. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4670 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e181127a30
commit
f952bc267b
10 changed files with 337 additions and 284 deletions
|
@ -24,6 +24,7 @@
|
|||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
#include <QDir>
|
||||
#include <QKeyEvent>
|
||||
#include "RsCollectionDialog.h"
|
||||
#include "RsCollectionFile.h"
|
||||
|
||||
|
@ -32,7 +33,8 @@ RsCollectionDialog::RsCollectionDialog(const QString& CollectionFileName,const s
|
|||
{
|
||||
setupUi(this) ;
|
||||
|
||||
setWindowTitle(CollectionFileName) ;
|
||||
setWindowTitle(QString("%1 - %2").arg(windowTitle()).arg(QFileInfo(_filename).baseName()));
|
||||
|
||||
// 1 - add all elements to the list.
|
||||
|
||||
int row = 0;
|
||||
|
@ -43,6 +45,11 @@ RsCollectionDialog::RsCollectionDialog(const QString& CollectionFileName,const s
|
|||
_fileEntriesTW->setHorizontalHeaderItem(2,new QTableWidgetItem(tr("Size"))) ;
|
||||
_fileEntriesTW->setHorizontalHeaderItem(3,new QTableWidgetItem(tr("Hash"))) ;
|
||||
|
||||
QHeaderView *header = _fileEntriesTW->horizontalHeader();
|
||||
header->setResizeMode(0, QHeaderView::Fixed);
|
||||
|
||||
header->setHighlightSections(false);
|
||||
|
||||
_cboxes.clear() ;
|
||||
_cboxes.resize(dlinfos.size(),NULL) ;
|
||||
uint64_t total_size ;
|
||||
|
@ -52,14 +59,22 @@ RsCollectionDialog::RsCollectionDialog(const QString& CollectionFileName,const s
|
|||
{
|
||||
_fileEntriesTW->insertRow(row) ;
|
||||
|
||||
QCheckBox *cb = new QCheckBox ;
|
||||
QWidget *widget = new QWidget;
|
||||
|
||||
QCheckBox *cb = new QCheckBox(widget);
|
||||
cb->setChecked(true) ;
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(widget);
|
||||
layout->addWidget(cb, 0, Qt::AlignCenter);
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(10, 0, 0, 0); // to be centered
|
||||
widget->setLayout(layout);
|
||||
|
||||
connect(cb,SIGNAL(toggled(bool)),this,SLOT(updateSizes())) ;
|
||||
|
||||
_cboxes[i] = cb ;
|
||||
|
||||
_fileEntriesTW->setCellWidget(row,0,cb) ;
|
||||
_fileEntriesTW->setCellWidget(row,0,widget) ;
|
||||
_fileEntriesTW->setItem(row,1,new QTableWidgetItem(dlinfos[i].path + "/" + dlinfos[i].name)) ;
|
||||
_fileEntriesTW->setItem(row,2,new QTableWidgetItem(QString::number(dlinfos[i].size))) ;
|
||||
_fileEntriesTW->setItem(row,3,new QTableWidgetItem(dlinfos[i].hash)) ;
|
||||
|
@ -81,9 +96,36 @@ RsCollectionDialog::RsCollectionDialog(const QString& CollectionFileName,const s
|
|||
connect(_deselectAll_PB,SIGNAL(clicked()),this,SLOT(deselectAll())) ;
|
||||
connect(_cancel_PB,SIGNAL(clicked()),this,SLOT(cancel())) ;
|
||||
connect(_download_PB,SIGNAL(clicked()),this,SLOT(download())) ;
|
||||
|
||||
_fileEntriesTW->installEventFilter(this);
|
||||
}
|
||||
|
||||
void RsCollectionDialog::updateSizes()
|
||||
bool RsCollectionDialog::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == _fileEntriesTW) {
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent && keyEvent->key() == Qt::Key_Space) {
|
||||
// Space pressed
|
||||
QModelIndex currentIndex = _fileEntriesTW->currentIndex();
|
||||
QModelIndex index = _fileEntriesTW->model()->index(currentIndex.row(), 0, currentIndex.parent());
|
||||
QWidget *widget = dynamic_cast<QWidget*>(_fileEntriesTW->indexWidget(index));
|
||||
if (widget) {
|
||||
QCheckBox *cb = dynamic_cast<QCheckBox*>(widget->children().front());
|
||||
if (cb) {
|
||||
cb->toggle();
|
||||
}
|
||||
}
|
||||
|
||||
return true; // eat event
|
||||
}
|
||||
}
|
||||
}
|
||||
// pass the event on to the parent class
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void RsCollectionDialog::updateSizes()
|
||||
{
|
||||
uint64_t total_size = 0 ;
|
||||
uint32_t total_files = 0 ;
|
||||
|
@ -102,14 +144,14 @@ void RsCollectionDialog::selectAll() const
|
|||
{
|
||||
std::cerr << "Selecting all !" << std::endl;
|
||||
for(int i=0;i<_dlinfos.size();++i)
|
||||
dynamic_cast<QCheckBox*>(_fileEntriesTW->cellWidget(i,0))->setChecked(true) ;
|
||||
_cboxes[i]->setChecked(true) ;
|
||||
}
|
||||
|
||||
void RsCollectionDialog::deselectAll() const
|
||||
{
|
||||
std::cerr << "Deselecting all !" << std::endl;
|
||||
for(int i=0;i<_dlinfos.size();++i)
|
||||
dynamic_cast<QCheckBox*>(_fileEntriesTW->cellWidget(i,0))->setChecked(false) ;
|
||||
_cboxes[i]->setChecked(false) ;
|
||||
}
|
||||
|
||||
void RsCollectionDialog::cancel()
|
||||
|
@ -143,5 +185,3 @@ void RsCollectionDialog::download()
|
|||
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue