fixed naming of columns that colided because of common names

This commit is contained in:
csoler 2022-03-27 19:35:23 +02:00
parent dc32b10ed6
commit 0cc813d093
12 changed files with 331 additions and 361 deletions

View file

@ -32,27 +32,6 @@
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)
@ -92,7 +71,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() != DLLISTDELEGATE_COLUMN_PROGRESS) {
if(index.column() != COLUMN_PROGRESS) {
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
cg = QPalette::Inactive;
@ -106,7 +85,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
}
switch(index.column()) {
case DLLISTDELEGATE_COLUMN_SIZE:
case COLUMN_SIZE:
fileSize = index.data().toLongLong();
if(fileSize <= 0){
temp = "";
@ -125,7 +104,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case DLLISTDELEGATE_COLUMN_REMAINING:
case COLUMN_REMAINING:
remaining = index.data().toLongLong();
if(remaining <= 0){
temp = "";
@ -144,7 +123,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case DLLISTDELEGATE_COLUMN_COMPLETED:
case COLUMN_COMPLETED:
completed = index.data().toLongLong();
if(completed <= 0){
temp = "";
@ -163,7 +142,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case DLLISTDELEGATE_COLUMN_DLSPEED:
case COLUMN_DLSPEED:
dlspeed = index.data().toDouble();
if (dlspeed <= 0) {
temp = "";
@ -174,7 +153,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case DLLISTDELEGATE_COLUMN_PROGRESS:
case COLUMN_PROGRESS:
{
// create a xProgressBar
FileProgressInfo pinfo = index.data(Qt::UserRole).value<FileProgressInfo>() ;
@ -203,7 +182,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;
case DLLISTDELEGATE_COLUMN_SOURCES:
case COLUMN_SOURCES:
{
double dblValue = index.data().toDouble();
@ -211,7 +190,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
painter->drawText(option.rect, Qt::AlignCenter, temp);
}
break;
case DLLISTDELEGATE_COLUMN_PRIORITY:
case COLUMN_PRIORITY:
{
double dblValue = index.data().toDouble();
if (dblValue == PRIORITY_NULL)
@ -228,7 +207,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
painter->drawText(option.rect, Qt::AlignCenter, temp);
}
break;
case DLLISTDELEGATE_COLUMN_DOWNLOADTIME:
case COLUMN_DOWNLOADTIME:
downloadtime = index.data().toLongLong();
minutes = downloadtime / 60;
seconds = downloadtime % 60;
@ -248,7 +227,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
temp = "" ;
painter->drawText(option.rect, Qt::AlignCenter, temp);
break;
case DLLISTDELEGATE_COLUMN_NAME:
case COLUMN_NAME:
{
// decoration
int pixOffset = 0;
@ -277,7 +256,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
painter->drawText(option.rect.translated(pixOffset, 0), Qt::AlignLeft, temp);
}
break;
case DLLISTDELEGATE_COLUMN_LASTDL:
case COLUMN_LASTDL:
if (index.data().value<QString>().isEmpty())
break;
qi64Value = index.data().value<qint64>();