mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-04 12:24:24 -04:00
moved to cpp files some column defines that otherwise collapsed in .h files
This commit is contained in:
parent
a0ac041582
commit
dd653e5462
9 changed files with 174 additions and 179 deletions
|
@ -32,6 +32,29 @@
|
|||
|
||||
Q_DECLARE_METATYPE(FileProgressInfo)
|
||||
|
||||
// Defines for download list list columns
|
||||
#define DLLISTDELEGATE_COLUMN_NAME 0
|
||||
#define DLLISTDELEGATE_COLUMN_SIZE 1
|
||||
#define DLLISTDELEGATE_COLUMN_COMPLETED 2
|
||||
#define DLLISTDELEGATE_COLUMN_DLSPEED 3
|
||||
#define DLLISTDELEGATE_COLUMN_PROGRESS 4
|
||||
#define DLLISTDELEGATE_COLUMN_SOURCES 5
|
||||
#define DLLISTDELEGATE_COLUMN_STATUS 6
|
||||
#define DLLISTDELEGATE_COLUMN_PRIORITY 7
|
||||
#define DLLISTDELEGATE_COLUMN_REMAINING 8
|
||||
#define DLLISTDELEGATE_COLUMN_DOWNLOADTIME 9
|
||||
#define DLLISTDELEGATE_COLUMN_ID 10
|
||||
#define DLLISTDELEGATE_COLUMN_LASTDL 11
|
||||
#define DLLISTDELEGATE_COLUMN_PATH 12
|
||||
#define DLLISTDELEGATE_COLUMN_COUNT 13
|
||||
|
||||
#define PRIORITY_NULL 0.0
|
||||
#define PRIORITY_FASTER 0.1
|
||||
#define PRIORITY_AVERAGE 0.2
|
||||
#define PRIORITY_SLOWER 0.3
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
DLListDelegate::DLListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
@ -69,7 +92,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
|
||||
// draw the background color if not the progress column or if progress is not displayed
|
||||
if(index.column() != COLUMN_PROGRESS) {
|
||||
if(index.column() != DLLISTDELEGATE_COLUMN_PROGRESS) {
|
||||
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
|
||||
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
|
||||
cg = QPalette::Inactive;
|
||||
|
@ -83,7 +106,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
}
|
||||
switch(index.column()) {
|
||||
case COLUMN_SIZE:
|
||||
case DLLISTDELEGATE_COLUMN_SIZE:
|
||||
fileSize = index.data().toLongLong();
|
||||
if(fileSize <= 0){
|
||||
temp = "";
|
||||
|
@ -102,7 +125,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_REMAINING:
|
||||
case DLLISTDELEGATE_COLUMN_REMAINING:
|
||||
remaining = index.data().toLongLong();
|
||||
if(remaining <= 0){
|
||||
temp = "";
|
||||
|
@ -121,7 +144,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_COMPLETED:
|
||||
case DLLISTDELEGATE_COLUMN_COMPLETED:
|
||||
completed = index.data().toLongLong();
|
||||
if(completed <= 0){
|
||||
temp = "";
|
||||
|
@ -140,7 +163,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_DLSPEED:
|
||||
case DLLISTDELEGATE_COLUMN_DLSPEED:
|
||||
dlspeed = index.data().toDouble();
|
||||
if (dlspeed <= 0) {
|
||||
temp = "";
|
||||
|
@ -151,7 +174,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_PROGRESS:
|
||||
case DLLISTDELEGATE_COLUMN_PROGRESS:
|
||||
{
|
||||
// create a xProgressBar
|
||||
FileProgressInfo pinfo = index.data(Qt::UserRole).value<FileProgressInfo>() ;
|
||||
|
@ -180,7 +203,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
break;
|
||||
case COLUMN_SOURCES:
|
||||
case DLLISTDELEGATE_COLUMN_SOURCES:
|
||||
{
|
||||
double dblValue = index.data().toDouble();
|
||||
|
||||
|
@ -188,7 +211,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
||||
}
|
||||
break;
|
||||
case COLUMN_PRIORITY:
|
||||
case DLLISTDELEGATE_COLUMN_PRIORITY:
|
||||
{
|
||||
double dblValue = index.data().toDouble();
|
||||
if (dblValue == PRIORITY_NULL)
|
||||
|
@ -205,7 +228,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
||||
}
|
||||
break;
|
||||
case COLUMN_DOWNLOADTIME:
|
||||
case DLLISTDELEGATE_COLUMN_DOWNLOADTIME:
|
||||
downloadtime = index.data().toLongLong();
|
||||
minutes = downloadtime / 60;
|
||||
seconds = downloadtime % 60;
|
||||
|
@ -225,7 +248,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
temp = "" ;
|
||||
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
||||
break;
|
||||
case COLUMN_NAME:
|
||||
case DLLISTDELEGATE_COLUMN_NAME:
|
||||
{
|
||||
// decoration
|
||||
int pixOffset = 0;
|
||||
|
@ -254,7 +277,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
painter->drawText(option.rect.translated(pixOffset, 0), Qt::AlignLeft, temp);
|
||||
}
|
||||
break;
|
||||
case COLUMN_LASTDL:
|
||||
case DLLISTDELEGATE_COLUMN_LASTDL:
|
||||
if (index.data().value<QString>().isEmpty())
|
||||
break;
|
||||
qi64Value = index.data().value<qint64>();
|
||||
|
|
|
@ -24,30 +24,6 @@
|
|||
#include <QAbstractItemDelegate>
|
||||
#include "xprogressbar.h"
|
||||
|
||||
|
||||
// Defines for download list list columns
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_SIZE 1
|
||||
#define COLUMN_COMPLETED 2
|
||||
#define COLUMN_DLSPEED 3
|
||||
#define COLUMN_PROGRESS 4
|
||||
#define COLUMN_SOURCES 5
|
||||
#define COLUMN_STATUS 6
|
||||
#define COLUMN_PRIORITY 7
|
||||
#define COLUMN_REMAINING 8
|
||||
#define COLUMN_DOWNLOADTIME 9
|
||||
#define COLUMN_ID 10
|
||||
#define COLUMN_LASTDL 11
|
||||
#define COLUMN_PATH 12
|
||||
#define COLUMN_COUNT 13
|
||||
|
||||
#define PRIORITY_NULL 0.0
|
||||
#define PRIORITY_FASTER 0.1
|
||||
#define PRIORITY_AVERAGE 0.2
|
||||
#define PRIORITY_SLOWER 0.3
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
class QModelIndex;
|
||||
class QPainter;
|
||||
|
||||
|
|
|
@ -25,6 +25,18 @@
|
|||
|
||||
Q_DECLARE_METATYPE(FileProgressInfo)
|
||||
|
||||
// Defines for upload list list columns
|
||||
#define ULLISTDELEGATE_COLUMN_UNAME 0
|
||||
#define ULLISTDELEGATE_COLUMN_UPEER 1
|
||||
#define ULLISTDELEGATE_COLUMN_USIZE 2
|
||||
#define ULLISTDELEGATE_COLUMN_UTRANSFERRED 3
|
||||
#define ULLISTDELEGATE_COLUMN_ULSPEED 4
|
||||
#define ULLISTDELEGATE_COLUMN_UPROGRESS 5
|
||||
#define ULLISTDELEGATE_COLUMN_UHASH 6
|
||||
#define ULLISTDELEGATE_COLUMN_UCOUNT 7
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
ULListDelegate::ULListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
|
||||
{
|
||||
;
|
||||
|
@ -65,7 +77,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
|
||||
// draw the background color
|
||||
bool bDrawBackground = true;
|
||||
if(index.column() == COLUMN_UPROGRESS) {
|
||||
if(index.column() == ULLISTDELEGATE_COLUMN_UPROGRESS) {
|
||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||
bDrawBackground = (pinfo.type == FileProgressInfo::UNINIT);
|
||||
}
|
||||
|
@ -84,7 +96,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
|
||||
switch(index.column()) {
|
||||
case COLUMN_USIZE:
|
||||
case ULLISTDELEGATE_COLUMN_USIZE:
|
||||
fileSize = index.data().toLongLong();
|
||||
if(fileSize <= 0){
|
||||
temp = "";
|
||||
|
@ -103,7 +115,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_UTRANSFERRED:
|
||||
case ULLISTDELEGATE_COLUMN_UTRANSFERRED:
|
||||
transferred = index.data().toLongLong();
|
||||
if(transferred <= 0){
|
||||
temp = "";
|
||||
|
@ -122,7 +134,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_ULSPEED:
|
||||
case ULLISTDELEGATE_COLUMN_ULSPEED:
|
||||
ulspeed = index.data().toDouble();
|
||||
if (ulspeed <= 0) {
|
||||
temp = "";
|
||||
|
@ -133,7 +145,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case COLUMN_UPROGRESS:
|
||||
case ULLISTDELEGATE_COLUMN_UPROGRESS:
|
||||
{
|
||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||
if (pinfo.type == FileProgressInfo::UNINIT)
|
||||
|
@ -143,7 +155,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
painter->save() ;
|
||||
xProgressBar progressBar(pinfo,option.rect,painter,0);// the 3rd param is the color schema (0 is the default value)
|
||||
|
||||
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), COLUMN_UNAME).data().toString().toStdString())).suffix();;
|
||||
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), ULLISTDELEGATE_COLUMN_UNAME).data().toString().toStdString())).suffix();;
|
||||
if (ext == "rsfc" || ext == "rsrl" || ext == "dist" || ext == "rsfb")
|
||||
progressBar.setColorSchema( 9);
|
||||
else
|
||||
|
@ -157,8 +169,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||
}
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
break;
|
||||
case COLUMN_UNAME:
|
||||
case COLUMN_UPEER:
|
||||
case ULLISTDELEGATE_COLUMN_UNAME:
|
||||
case ULLISTDELEGATE_COLUMN_UPEER:
|
||||
// decoration
|
||||
value = index.data(Qt::DecorationRole);
|
||||
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);
|
||||
|
|
|
@ -23,19 +23,6 @@
|
|||
|
||||
#include <QAbstractItemDelegate>
|
||||
|
||||
// Defines for upload list list columns
|
||||
#define COLUMN_UNAME 0
|
||||
#define COLUMN_UPEER 1
|
||||
#define COLUMN_USIZE 2
|
||||
#define COLUMN_UTRANSFERRED 3
|
||||
#define COLUMN_ULSPEED 4
|
||||
#define COLUMN_UPROGRESS 5
|
||||
#define COLUMN_UHASH 6
|
||||
#define COLUMN_UCOUNT 7
|
||||
|
||||
|
||||
#define MAX_CHAR_TMP 128
|
||||
|
||||
class QModelIndex;
|
||||
class QPainter;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue