mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-23 08:11:24 -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
class QCheckBox ;
|
||||
|
||||
class RsCollectionDialog: public QDialog, public Ui::rsCollectionDialog
|
||||
class RsCollectionDialog: public QDialog, public Ui::RsCollectionDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -40,6 +40,9 @@ class RsCollectionDialog: public QDialog, public Ui::rsCollectionDialog
|
|||
void cancel() ;
|
||||
void updateSizes() ;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
|
||||
private:
|
||||
const std::vector<RsCollectionFile::DLinfo>& _dlinfos ;
|
||||
std::vector<QCheckBox*> _cboxes ;
|
||||
|
|
|
@ -1,161 +1,176 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>rsCollectionDialog</class>
|
||||
<widget class="QDialog" name="rsCollectionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>434</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>File name :</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Total size :</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Selected files:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="_filename_TL">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_totalSize_TL">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_selectedFiles_TL">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="_fileEntriesTW">
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::DotLine</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_selectAll_PB">
|
||||
<property name="text">
|
||||
<string>Select all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_deselectAll_PB">
|
||||
<property name="text">
|
||||
<string>Deselect all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_cancel_PB">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_download_PB">
|
||||
<property name="text">
|
||||
<string>Download!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RsCollectionDialog</class>
|
||||
<widget class="QDialog" name="RsCollectionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>434</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Collection</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/mimetypes/rscollection-16.png</normaloff>:/images/mimetypes/rscollection-16.png</iconset>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>File name :</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Total size :</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Selected files:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="_filename_TL">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_totalSize_TL">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_selectedFiles_TL">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="_fileEntriesTW">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::DotLine</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>22</number>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_selectAll_PB">
|
||||
<property name="text">
|
||||
<string>Select all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_deselectAll_PB">
|
||||
<property name="text">
|
||||
<string>Deselect all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_cancel_PB">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_download_PB">
|
||||
<property name="text">
|
||||
<string>Download!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -39,10 +39,7 @@ bool RsUrlHandler::openUrl(const QUrl& url)
|
|||
QMessageBox::warning(NULL,QObject::tr("Treatment of collection file has failed."),QObject::tr("The collection file ") + url.toLocalFile() + QObject::tr(" could not be openned. Reported error is: ") + QString::fromStdString(e.what())) ;
|
||||
return false ;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return QDesktopServices::openUrl(url) ;
|
||||
return QDesktopServices::openUrl(url) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue