mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
- Started to improve download & finished list rendering (filename column)
This commit is contained in:
parent
99530728c5
commit
0561206d91
4
TODO
4
TODO
@ -44,9 +44,9 @@
|
|||||||
- Windows port (Chris - Peerkoel)
|
- Windows port (Chris - Peerkoel)
|
||||||
- Add checking icon to documentation
|
- Add checking icon to documentation
|
||||||
* beta3
|
* beta3
|
||||||
- Translations update (IN PROGESS)
|
- Translations update (IN PROGRESS)
|
||||||
- Optimize and cleanup code
|
- Optimize and cleanup code
|
||||||
- add asserts to squash remaining bugs
|
- Improve delegates
|
||||||
- Check that there is no problem with right click menu in torrent content (all files filtered for example)
|
- Check that there is no problem with right click menu in torrent content (all files filtered for example)
|
||||||
- Wait for some bug fixes in libtorrent :
|
- Wait for some bug fixes in libtorrent :
|
||||||
- upload/download limit per torrent
|
- upload/download limit per torrent
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef DLLISTDELEGATE_H
|
#ifndef DLLISTDELEGATE_H
|
||||||
#define DLLISTDELEGATE_H
|
#define DLLISTDELEGATE_H
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QItemDelegate>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionProgressBarV2>
|
#include <QStyleOptionProgressBarV2>
|
||||||
@ -41,11 +41,11 @@
|
|||||||
#define ETA 7
|
#define ETA 7
|
||||||
#define HASH 8
|
#define HASH 8
|
||||||
|
|
||||||
class DLListDelegate: public QAbstractItemDelegate {
|
class DLListDelegate: public QItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DLListDelegate(QObject *parent) : QAbstractItemDelegate(parent){}
|
DLListDelegate(QObject *parent) : QItemDelegate(parent){}
|
||||||
|
|
||||||
~DLListDelegate(){}
|
~DLListDelegate(){}
|
||||||
|
|
||||||
@ -72,15 +72,15 @@ class DLListDelegate: public QAbstractItemDelegate {
|
|||||||
}
|
}
|
||||||
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||||
}else{
|
}else{
|
||||||
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Base));
|
// painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Base));
|
||||||
// The following should work but is broken (retry with future versions of Qt)
|
// The following should work but is broken (retry with future versions of Qt)
|
||||||
// QVariant value = index.data(Qt::BackgroundRole);
|
QVariant value = index.data(Qt::BackgroundRole);
|
||||||
// if (qVariantCanConvert<QBrush>(value)) {
|
if (qVariantCanConvert<QBrush>(value)) {
|
||||||
// QPointF oldBO = painter->brushOrigin();
|
QPointF oldBO = painter->brushOrigin();
|
||||||
// painter->setBrushOrigin(option.rect.topLeft());
|
painter->setBrushOrigin(option.rect.topLeft());
|
||||||
// painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
|
painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
|
||||||
// painter->setBrushOrigin(oldBO);
|
painter->setBrushOrigin(oldBO);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch(index.column()){
|
switch(index.column()){
|
||||||
@ -125,20 +125,8 @@ class DLListDelegate: public QAbstractItemDelegate {
|
|||||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NAME:{
|
|
||||||
// decoration
|
|
||||||
value = index.data(Qt::DecorationRole);
|
|
||||||
QPixmap pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);
|
|
||||||
QRect pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
|
||||||
if (pixmapRect.isValid()){
|
|
||||||
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
|
||||||
painter->drawPixmap(p, pixmap);
|
|
||||||
}
|
|
||||||
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, index.data().toString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
QItemDelegate::paint(painter, option, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,25 +139,6 @@ class DLListDelegate: public QAbstractItemDelegate {
|
|||||||
return textRect.size();
|
return textRect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// QWidget* createEditor(QWidget * parent, const QStyleOptionViewItem& /*option*/, const QModelIndex & index) const{
|
|
||||||
// if(index.column() == PROGRESS){
|
|
||||||
// QProgressBar *progressBar = new QProgressBar(parent);
|
|
||||||
// progressBar->setRange(0,100);
|
|
||||||
// progressBar->installEventFilter(const_cast<DLListDelegate*>(this));
|
|
||||||
// return progressBar;
|
|
||||||
// }
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
// void setEditorData(QWidget *editor, const QModelIndex &index) const{
|
|
||||||
// QProgressBar *progressBar = static_cast<QProgressBar*>(editor);
|
|
||||||
// float progress = index.data().toDouble();
|
|
||||||
// progressBar->setValue((int)(progress*100.));
|
|
||||||
// }
|
|
||||||
// void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & index) const{
|
|
||||||
// if(index.column() == PROGRESS){
|
|
||||||
// editor->setGeometry(option.rect);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef FINISHEDLISTDELEGATE_H
|
#ifndef FINISHEDLISTDELEGATE_H
|
||||||
#define FINISHEDLISTDELEGATE_H
|
#define FINISHEDLISTDELEGATE_H
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QItemDelegate>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionProgressBarV2>
|
#include <QStyleOptionProgressBarV2>
|
||||||
@ -39,11 +39,11 @@
|
|||||||
#define F_RATIO 5
|
#define F_RATIO 5
|
||||||
#define F_HASH 6
|
#define F_HASH 6
|
||||||
|
|
||||||
class FinishedListDelegate: public QAbstractItemDelegate {
|
class FinishedListDelegate: public QItemDelegate {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FinishedListDelegate(QObject *parent) : QAbstractItemDelegate(parent){}
|
FinishedListDelegate(QObject *parent) : QItemDelegate(parent){}
|
||||||
|
|
||||||
~FinishedListDelegate(){}
|
~FinishedListDelegate(){}
|
||||||
|
|
||||||
@ -70,15 +70,15 @@ class FinishedListDelegate: public QAbstractItemDelegate {
|
|||||||
}
|
}
|
||||||
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||||
}else{
|
}else{
|
||||||
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Base));
|
// painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Base));
|
||||||
// The following should work but is broken (retry with future versions of Qt)
|
// The following should work but is broken (retry with future versions of Qt)
|
||||||
// QVariant value = index.data(Qt::BackgroundRole);
|
QVariant value = index.data(Qt::BackgroundRole);
|
||||||
// if (qVariantCanConvert<QBrush>(value)) {
|
if (qVariantCanConvert<QBrush>(value)) {
|
||||||
// QPointF oldBO = painter->brushOrigin();
|
QPointF oldBO = painter->brushOrigin();
|
||||||
// painter->setBrushOrigin(option.rect.topLeft());
|
painter->setBrushOrigin(option.rect.topLeft());
|
||||||
// painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
|
painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
|
||||||
// painter->setBrushOrigin(oldBO);
|
painter->setBrushOrigin(oldBO);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch(index.column()){
|
switch(index.column()){
|
||||||
@ -119,20 +119,8 @@ class FinishedListDelegate: public QAbstractItemDelegate {
|
|||||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case F_NAME:{
|
|
||||||
// decoration
|
|
||||||
value = index.data(Qt::DecorationRole);
|
|
||||||
QPixmap pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);
|
|
||||||
QRect pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
|
||||||
if (pixmapRect.isValid()){
|
|
||||||
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
|
||||||
painter->drawPixmap(p, pixmap);
|
|
||||||
}
|
|
||||||
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, index.data().toString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
QItemDelegate::paint(painter, option, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user