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>();

View File

@ -18,31 +18,41 @@
* *
*******************************************************************************/
#ifndef DLLISTDELEGATE_H
#define DLLISTDELEGATE_H
#pragma once
#include <QAbstractItemDelegate>
#include "xprogressbar.h"
#include "FTListDelegate.h"
class QModelIndex;
class QPainter;
class DLListDelegate: public QAbstractItemDelegate {
Q_OBJECT
class DLListDelegate: public QAbstractItemDelegate
{
public:
DLListDelegate(QObject *parent=0);
virtual ~DLListDelegate(){}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const;
private:
static constexpr int COLUMN_NAME = 0;
static constexpr int COLUMN_SIZE = 1;
static constexpr int COLUMN_COMPLETED = 2;
static constexpr int COLUMN_DLSPEED = 3;
static constexpr int COLUMN_PROGRESS = 4;
static constexpr int COLUMN_SOURCES = 5;
static constexpr int COLUMN_STATUS = 6;
static constexpr int COLUMN_PRIORITY = 7;
static constexpr int COLUMN_REMAINING = 8;
static constexpr int COLUMN_DOWNLOADTIME= 9;
static constexpr int COLUMN_ID = 10;
static constexpr int COLUMN_LASTDL = 11;
static constexpr int COLUMN_PATH = 12;
static constexpr int COLUMN_COUNT = 13;
public slots:
signals:
static constexpr float PRIORITY_NULL = 0.0;
static constexpr float PRIORITY_FASTER = 0.1;
static constexpr float PRIORITY_AVERAGE = 0.2;
static constexpr float PRIORITY_SLOWER = 0.3;
};
#endif

View File

@ -55,6 +55,16 @@
#include <set>
#define SHARED_FILES_DIALOG_COLUMN_NAME 0
#define SHARED_FILES_DIALOG_COLUMN_FILENB 1
#define SHARED_FILES_DIALOG_COLUMN_SIZE 2
#define SHARED_FILES_DIALOG_COLUMN_AGE 3
#define SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS 4
#define SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR 5
#define SHARED_FILES_DIALOG_COLUMN_COUNT 6
#define SHARED_FILES_DIALOG_FILTER_STRING "filtered"
/* Images for context menu icons */
#define IMAGE_DOWNLOAD ":/icons/png/download.png"
#define IMAGE_PLAY ":/images/start.png"
@ -187,17 +197,17 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent)
tree_proxyModel->setSourceModel(tree_model);
tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
tree_proxyModel->sort(COLUMN_NAME);
tree_proxyModel->sort(SHARED_FILES_DIALOG_COLUMN_NAME);
tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
tree_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
tree_proxyModel->setFilterRegExp(QRegExp(QString(SHARED_FILES_DIALOG_FILTER_STRING))) ;
flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
flat_proxyModel->setSourceModel(flat_model);
flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
flat_proxyModel->sort(COLUMN_NAME);
flat_proxyModel->sort(SHARED_FILES_DIALOG_COLUMN_NAME);
flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
flat_proxyModel->setFilterRegExp(QRegExp(QString(SHARED_FILES_DIALOG_FILTER_STRING))) ;
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
@ -219,12 +229,12 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent)
int charWidth = ui.dirTreeView->fontMetrics().horizontalAdvance("_");
#endif
header->resizeSection ( COLUMN_NAME , charWidth*100 );
header->resizeSection ( COLUMN_FILENB , charWidth*15 );
header->resizeSection ( COLUMN_SIZE , charWidth*10 );
header->resizeSection ( COLUMN_AGE , charWidth*6 );
header->resizeSection ( COLUMN_FRIEND_ACCESS, charWidth*10 );
header->resizeSection ( COLUMN_WN_VISU_DIR , charWidth*20 );
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_NAME , charWidth*100 );
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_FILENB , charWidth*15 );
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_SIZE , charWidth*10 );
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_AGE , charWidth*6 );
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, charWidth*10 );
header->resizeSection ( SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR , charWidth*20 );
header->setStretchLastSection(true);
@ -260,7 +270,7 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
: SharedFilesDialog(false,parent)
{
// Hide columns after loading the settings
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
ui.downloadButton->hide() ;
// load settings
@ -279,14 +289,14 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
ui.titleBarPixmap->setPixmap(FilesDefs::getPixmapFromQtResourcePath(IMAGE_MYFILES)) ;
ui.dirTreeView->setItemDelegateForColumn(COLUMN_FRIEND_ACCESS,new ShareFlagsItemDelegate()) ;
ui.dirTreeView->setItemDelegateForColumn(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS,new ShareFlagsItemDelegate()) ;
}
RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent)
: SharedFilesDialog(true,parent)
{
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, true) ;
ui.checkButton->hide() ;
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected()));
@ -440,9 +450,9 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes);
QHeaderView * header = ui.dirTreeView->header () ;
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(header, SHARED_FILES_DIALOG_COLUMN_NAME, QHeaderView::Interactive);
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ;
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, SHARED_FILES_DIALOG_COLUMN_NAME, SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR) ;
// recursRestoreExpandedItems(ui.dirTreeView->rootIndex(),expanded_indexes);
FilterItems();
@ -452,9 +462,9 @@ void LocalSharedFilesDialog::showProperColumns()
{
if(model == tree_model)
{
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ;
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->hide();
ui.filterPatternLineEdit->hide();
@ -464,9 +474,9 @@ void LocalSharedFilesDialog::showProperColumns()
}
else
{
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ;
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ;
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, true) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, true) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->show();
ui.filterPatternLineEdit->show();
@ -477,9 +487,9 @@ void RemoteSharedFilesDialog::showProperColumns()
{
if(model == tree_model)
{
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ;
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ;
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, true) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, true) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->hide();
ui.filterPatternLineEdit->hide();
@ -489,9 +499,9 @@ void RemoteSharedFilesDialog::showProperColumns()
}
else
{
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ;
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FILENB, true) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_FRIEND_ACCESS, false) ;
ui.dirTreeView->setColumnHidden(SHARED_FILES_DIALOG_COLUMN_WN_VISU_DIR, false) ;
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
ui.filterLabel->show();
ui.filterPatternLineEdit->show();
@ -1337,9 +1347,9 @@ void SharedFilesDialog::indicatorChanged(int index)
ui.dirTreeView->update(ui.dirTreeView->rootIndex());
if (correct_indicator[index] != IND_ALWAYS)
ui.dirTreeView->sortByColumn(COLUMN_AGE, Qt::AscendingOrder);
ui.dirTreeView->sortByColumn(SHARED_FILES_DIALOG_COLUMN_AGE, Qt::AscendingOrder);
else
ui.dirTreeView->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
ui.dirTreeView->sortByColumn(SHARED_FILES_DIALOG_COLUMN_NAME, Qt::AscendingOrder);
updateDisplay() ;
}

View File

@ -144,7 +144,7 @@ public:
}
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const
{
return COLUMN_COUNT ;
return DLListDelegate::COLUMN_COUNT ;
}
bool hasChildren(const QModelIndex &parent = QModelIndex()) const
{
@ -176,7 +176,7 @@ public:
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const
{
if(row < 0 || column < 0 || column >= COLUMN_COUNT)
if(row < 0 || column < 0 || column >= DLListDelegate::COLUMN_COUNT)
return QModelIndex();
void *parent_ref = (parent.isValid())?parent.internalPointer():NULL ;
@ -258,19 +258,19 @@ public:
switch(section)
{
default:
case COLUMN_NAME: return tr("Name", "i.e: file name");
case COLUMN_SIZE: return tr("Size", "i.e: file size");
case COLUMN_COMPLETED: return tr("Completed", "");
case COLUMN_DLSPEED: return tr("Speed", "i.e: Download speed");
case COLUMN_PROGRESS: return tr("Progress / Availability", "i.e: % downloaded");
case COLUMN_SOURCES: return tr("Sources", "i.e: Sources");
case COLUMN_STATUS: return tr("Status");
case COLUMN_PRIORITY: return tr("Speed / Queue position");
case COLUMN_REMAINING: return tr("Remaining");
case COLUMN_DOWNLOADTIME: return tr("Download time", "i.e: Estimated Time of Arrival / Time left");
case COLUMN_ID: return tr("Hash");
case COLUMN_LASTDL: return tr("Last Time Seen", "i.e: Last Time Receiced Data");
case COLUMN_PATH: return tr("Path", "i.e: Where file is saved");
case DLListDelegate::COLUMN_NAME: return tr("Name", "i.e: file name");
case DLListDelegate::COLUMN_SIZE: return tr("Size", "i.e: file size");
case DLListDelegate::COLUMN_COMPLETED: return tr("Completed", "");
case DLListDelegate::COLUMN_DLSPEED: return tr("Speed", "i.e: Download speed");
case DLListDelegate::COLUMN_PROGRESS: return tr("Progress / Availability", "i.e: % downloaded");
case DLListDelegate::COLUMN_SOURCES: return tr("Sources", "i.e: Sources");
case DLListDelegate::COLUMN_STATUS: return tr("Status");
case DLListDelegate::COLUMN_PRIORITY: return tr("Speed / Queue position");
case DLListDelegate::COLUMN_REMAINING: return tr("Remaining");
case DLListDelegate::COLUMN_DOWNLOADTIME: return tr("Download time", "i.e: Estimated Time of Arrival / Time left");
case DLListDelegate::COLUMN_ID: return tr("Hash");
case DLListDelegate::COLUMN_LASTDL: return tr("Last Time Seen", "i.e: Last Time Receiced Data");
case DLListDelegate::COLUMN_PATH: return tr("Path", "i.e: Where file is saved");
}
}
@ -352,19 +352,19 @@ public:
switch(col)
{
default:
case COLUMN_NAME: return QVariant( QSize(factor * 170, factor*14.0f ));
case COLUMN_SIZE: return QVariant( QSize(factor * 70 , factor*14.0f ));
case COLUMN_COMPLETED: return QVariant( QSize(factor * 75 , factor*14.0f ));
case COLUMN_DLSPEED: return QVariant( QSize(factor * 75 , factor*14.0f ));
case COLUMN_PROGRESS: return QVariant( QSize(factor * 170, factor*14.0f ));
case COLUMN_SOURCES: return QVariant( QSize(factor * 90 , factor*14.0f ));
case COLUMN_STATUS: return QVariant( QSize(factor * 100, factor*14.0f ));
case COLUMN_PRIORITY: return QVariant( QSize(factor * 100, factor*14.0f ));
case COLUMN_REMAINING: return QVariant( QSize(factor * 100, factor*14.0f ));
case COLUMN_DOWNLOADTIME: return QVariant( QSize(factor * 100, factor*14.0f ));
case COLUMN_ID: return QVariant( QSize(factor * 100, factor*14.0f ));
case COLUMN_LASTDL: return QVariant( QSize(factor * 100, factor*14.0f ));
case COLUMN_PATH: return QVariant( QSize(factor * 100, factor*14.0f ));
case DLListDelegate::COLUMN_NAME: return QVariant( QSize(factor * 170, factor*14.0f ));
case DLListDelegate::COLUMN_SIZE: return QVariant( QSize(factor * 70 , factor*14.0f ));
case DLListDelegate::COLUMN_COMPLETED: return QVariant( QSize(factor * 75 , factor*14.0f ));
case DLListDelegate::COLUMN_DLSPEED: return QVariant( QSize(factor * 75 , factor*14.0f ));
case DLListDelegate::COLUMN_PROGRESS: return QVariant( QSize(factor * 170, factor*14.0f ));
case DLListDelegate::COLUMN_SOURCES: return QVariant( QSize(factor * 90 , factor*14.0f ));
case DLListDelegate::COLUMN_STATUS: return QVariant( QSize(factor * 100, factor*14.0f ));
case DLListDelegate::COLUMN_PRIORITY: return QVariant( QSize(factor * 100, factor*14.0f ));
case DLListDelegate::COLUMN_REMAINING: return QVariant( QSize(factor * 100, factor*14.0f ));
case DLListDelegate::COLUMN_DOWNLOADTIME: return QVariant( QSize(factor * 100, factor*14.0f ));
case DLListDelegate::COLUMN_ID: return QVariant( QSize(factor * 100, factor*14.0f ));
case DLListDelegate::COLUMN_LASTDL: return QVariant( QSize(factor * 100, factor*14.0f ));
case DLListDelegate::COLUMN_PATH: return QVariant( QSize(factor * 100, factor*14.0f ));
}
}
@ -374,11 +374,11 @@ public:
if(source_id == -1) // toplevel
switch(col)
{
case COLUMN_NAME: return QVariant(QString::fromUtf8(fileInfo.fname.c_str()));
case COLUMN_COMPLETED: return QVariant((qlonglong)fileInfo.transfered);
case COLUMN_DLSPEED: return QVariant((double)((fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0));
case COLUMN_PROGRESS: return QVariant((float)((fileInfo.size == 0) ? 0 : (fileInfo.transfered * 100.0 / (float)fileInfo.size)));
case COLUMN_STATUS:
case DLListDelegate::COLUMN_NAME: return QVariant(QString::fromUtf8(fileInfo.fname.c_str()));
case DLListDelegate::COLUMN_COMPLETED: return QVariant((qlonglong)fileInfo.transfered);
case DLListDelegate::COLUMN_DLSPEED: return QVariant((double)((fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0));
case DLListDelegate::COLUMN_PROGRESS: return QVariant((float)((fileInfo.size == 0) ? 0 : (fileInfo.transfered * 100.0 / (float)fileInfo.size)));
case DLListDelegate::COLUMN_STATUS:
{
QString status;
switch (fileInfo.downloadStatus)
@ -396,9 +396,9 @@ public:
return QVariant(status);
}
case COLUMN_PRIORITY:
case DLListDelegate::COLUMN_PRIORITY:
{
double priority = PRIORITY_NULL;
double priority = DLListDelegate::PRIORITY_NULL;
if (fileInfo.downloadStatus == FT_STATE_QUEUED)
priority = fileInfo.queue_position;
@ -407,18 +407,18 @@ public:
else
switch (fileInfo.priority)
{
case SPEED_LOW: priority = PRIORITY_SLOWER; break;
case SPEED_NORMAL: priority = PRIORITY_AVERAGE; break;
case SPEED_HIGH: priority = PRIORITY_FASTER; break;
default: priority = PRIORITY_AVERAGE; break;
case SPEED_LOW: priority = DLListDelegate::PRIORITY_SLOWER; break;
case SPEED_NORMAL: priority = DLListDelegate::PRIORITY_AVERAGE; break;
case SPEED_HIGH: priority = DLListDelegate::PRIORITY_FASTER; break;
default: priority = DLListDelegate::PRIORITY_AVERAGE; break;
}
return QVariant(priority);
}
case COLUMN_REMAINING: return QVariant((qlonglong)(fileInfo.size - fileInfo.transfered));
case COLUMN_DOWNLOADTIME: return QVariant((qlonglong)(fileInfo.tfRate > 0)?( (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0) ) : 0);
case COLUMN_LASTDL:
case DLListDelegate::COLUMN_REMAINING: return QVariant((qlonglong)(fileInfo.size - fileInfo.transfered));
case DLListDelegate::COLUMN_DOWNLOADTIME: return QVariant((qlonglong)(fileInfo.tfRate > 0)?( (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0) ) : 0);
case DLListDelegate::COLUMN_LASTDL:
{
qint64 qi64LastDL = fileInfo.lastTS ;
@ -437,7 +437,7 @@ public:
}
return QVariant(qi64LastDL) ;
}
case COLUMN_PATH:
case DLListDelegate::COLUMN_PATH:
{
QString strPath = QString::fromUtf8(fileInfo.path.c_str());
QString strPathAfterDL = strPath;
@ -446,7 +446,7 @@ public:
return QVariant(strPathAfterDL);
}
case COLUMN_SOURCES:
case DLListDelegate::COLUMN_SOURCES:
{
int active = 0;
//QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
@ -478,9 +478,9 @@ public:
}
case COLUMN_SIZE: return QVariant((qlonglong) fileInfo.size);
case DLListDelegate::COLUMN_SIZE: return QVariant((qlonglong) fileInfo.size);
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
case DLListDelegate::COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
default:
return QVariant("[ TODO ]");
@ -492,16 +492,16 @@ public:
switch(col)
{
default:
case COLUMN_SOURCES:
case COLUMN_COMPLETED:
case COLUMN_REMAINING:
case COLUMN_LASTDL:
case COLUMN_ID:
case COLUMN_PATH:
case COLUMN_DOWNLOADTIME:
case COLUMN_SIZE: return QVariant();
case COLUMN_PROGRESS: return QVariant( (fileInfo.size>0)?((fileInfo.peers[source_id].transfered % chunk_size)*100.0/fileInfo.size):0.0) ;
case COLUMN_DLSPEED:
case DLListDelegate::COLUMN_SOURCES:
case DLListDelegate::COLUMN_COMPLETED:
case DLListDelegate::COLUMN_REMAINING:
case DLListDelegate::COLUMN_LASTDL:
case DLListDelegate::COLUMN_ID:
case DLListDelegate::COLUMN_PATH:
case DLListDelegate::COLUMN_DOWNLOADTIME:
case DLListDelegate::COLUMN_SIZE: return QVariant();
case DLListDelegate::COLUMN_PROGRESS: return QVariant( (fileInfo.size>0)?((fileInfo.peers[source_id].transfered % chunk_size)*100.0/fileInfo.size):0.0) ;
case DLListDelegate::COLUMN_DLSPEED:
{
double peerDlspeed = 0;
if((uint32_t)fileInfo.peers[source_id].status == FT_STATE_DOWNLOADING && fileInfo.downloadStatus != FT_STATE_PAUSED && fileInfo.downloadStatus != FT_STATE_COMPLETE)
@ -509,13 +509,13 @@ public:
return QVariant((double)peerDlspeed) ;
}
case COLUMN_NAME:
case DLListDelegate::COLUMN_NAME:
{
QString iconName,tooltip;
return QVariant(TransfersDialog::getPeerName(fileInfo.peers[source_id].peerId, iconName, tooltip));
}
case COLUMN_PRIORITY: return QVariant((double)PRIORITY_NULL);
case DLListDelegate::COLUMN_PRIORITY: return QVariant((double)DLListDelegate::PRIORITY_NULL);
}
}
@ -527,7 +527,7 @@ public:
if(source_id == -1)
switch(col)
{
case COLUMN_PROGRESS:
case DLListDelegate::COLUMN_PROGRESS:
{
FileChunksInfo fcinfo;
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
@ -554,7 +554,7 @@ public:
return QVariant::fromValue(pinfo);
}
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
case DLListDelegate::COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()));
default:
@ -563,7 +563,7 @@ public:
else
switch(col)
{
case COLUMN_PROGRESS:
case DLListDelegate::COLUMN_PROGRESS:
{
FileChunksInfo fcinfo;
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
@ -582,7 +582,7 @@ public:
return QVariant::fromValue(pinfo);
}
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()) + QString::fromStdString(fileInfo.peers[source_id].peerId.toStdString()));
case DLListDelegate::COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()) + QString::fromStdString(fileInfo.peers[source_id].peerId.toStdString()));
default:
return QVariant();
@ -592,7 +592,7 @@ public:
QVariant decorationRole(const FileInfo& fileInfo,int source_id,int col) const
{
if(col == COLUMN_NAME)
if(col == DLListDelegate::COLUMN_NAME)
{
if(source_id == -1)
return QVariant(FilesDefs::getIconFromFileType(QString::fromUtf8(fileInfo.fname.c_str())));
@ -666,7 +666,7 @@ public:
if(fileInfo.downloadStatus == FT_STATE_DOWNLOADING || old_status != fileInfo.downloadStatus)
{
QModelIndex topLeft = createIndex(i,0), bottomRight = createIndex(i, COLUMN_COUNT-1);
QModelIndex topLeft = createIndex(i,0), bottomRight = createIndex(i, DLListDelegate::COLUMN_COUNT-1);
emit dataChanged(topLeft, bottomRight);
}
@ -674,7 +674,7 @@ public:
//
// if(!mDownloads.empty())
// {
// QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(mDownloads.size()-1, COLUMN_COUNT-1);
// QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(mDownloads.size()-1, DLListDelegate::COLUMN_COUNT-1);
// emit dataChanged(topLeft, bottomRight);
// mDownloads[i] = fileInfo ;
// }
@ -761,8 +761,8 @@ public:
return QStandardItem::operator<(other);
}
QStandardItem *myName = myParent->child(index().row(), COLUMN_NAME);
QStandardItem *otherName = otherParent->child(other.index().row(), COLUMN_NAME);
QStandardItem *myName = myParent->child(index().row(), DLListDelegate::COLUMN_NAME);
QStandardItem *otherName = otherParent->child(other.index().row(), DLListDelegate::COLUMN_NAME);
if (header == NULL || header->sortIndicatorOrder() == Qt::AscendingOrder) {
/* Ascending */
@ -847,41 +847,41 @@ TransfersDialog::TransfersDialog(QWidget *parent)
// /* Set header resize modes and initial section sizes Downloads TreeView*/
QHeaderView * dlheader = ui.downloadList->header () ;
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_NAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_SIZE, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_COMPLETED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_DLSPEED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PROGRESS, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_SOURCES, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_STATUS, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PRIORITY, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_REMAINING, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_DOWNLOADTIME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_ID, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_LASTDL, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, COLUMN_PATH, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_NAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_SIZE, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_COMPLETED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_DLSPEED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_PROGRESS, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_SOURCES, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_STATUS, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_PRIORITY, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_REMAINING, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_DOWNLOADTIME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_ID, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_LASTDL, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(dlheader, DLListDelegate::COLUMN_PATH, QHeaderView::Interactive);
// set default column and sort order for download
ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
ui.downloadList->sortByColumn(DLListDelegate::COLUMN_NAME, Qt::AscendingOrder);
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
/* Add filter actions */
QString headerName = DLListModel->headerData(COLUMN_NAME, Qt::Horizontal).toString();
ui.filterLineEdit->addFilter(QIcon(), headerName, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerName));
QString headerID = DLListModel->headerData(COLUMN_ID, Qt::Horizontal).toString();
ui.filterLineEdit->addFilter(QIcon(), headerID, COLUMN_ID , QString("%1 %2").arg(tr("Search"), headerID));
QString headerName = DLListModel->headerData(DLListDelegate::COLUMN_NAME, Qt::Horizontal).toString();
ui.filterLineEdit->addFilter(QIcon(), headerName, DLListDelegate::COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerName));
QString headerID = DLListModel->headerData(DLListDelegate::COLUMN_ID, Qt::Horizontal).toString();
ui.filterLineEdit->addFilter(QIcon(), headerID, DLListDelegate::COLUMN_ID , QString("%1 %2").arg(tr("Search"), headerID));
connect( ui.uploadsList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( uploadsListCustomPopupMenu( QPoint ) ) );
// Set Upload list model
ULListModel = new QStandardItemModel(0,COLUMN_UCOUNT);
ULListModel->setHeaderData(COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
ULListModel->setHeaderData(COLUMN_UPEER, Qt::Horizontal, tr("Peer", "i.e: user name / tunnel id"));
ULListModel->setHeaderData(COLUMN_USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
ULListModel->setHeaderData(COLUMN_UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
ULListModel->setHeaderData(COLUMN_ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
ULListModel->setHeaderData(COLUMN_UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded"));
ULListModel->setHeaderData(COLUMN_UHASH, Qt::Horizontal, tr("Hash", ""));
ULListModel = new QStandardItemModel(0,ULListDelegate::COLUMN_UCOUNT);
ULListModel->setHeaderData(ULListDelegate::COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
ULListModel->setHeaderData(ULListDelegate::COLUMN_UPEER, Qt::Horizontal, tr("Peer", "i.e: user name / tunnel id"));
ULListModel->setHeaderData(ULListDelegate::COLUMN_USIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
ULListModel->setHeaderData(ULListDelegate::COLUMN_UTRANSFERRED, Qt::Horizontal, tr("Transferred", ""));
ULListModel->setHeaderData(ULListDelegate::COLUMN_ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed"));
ULListModel->setHeaderData(ULListDelegate::COLUMN_UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded"));
ULListModel->setHeaderData(ULListDelegate::COLUMN_UHASH, Qt::Horizontal, tr("Hash", ""));
ui.uploadsList->setModel(ULListModel);
@ -901,22 +901,22 @@ TransfersDialog::TransfersDialog(QWidget *parent)
/* Set header resize modes and initial section sizes Uploads TreeView*/
QHeaderView * upheader = ui.uploadsList->header () ;
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UNAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UPEER, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_USIZE, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UTRANSFERRED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_ULSPEED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, COLUMN_UPROGRESS, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UNAME, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UPEER, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_USIZE, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UTRANSFERRED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_ULSPEED, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(upheader, ULListDelegate::COLUMN_UPROGRESS, QHeaderView::Interactive);
upheader->resizeSection ( COLUMN_UNAME, 260 );
upheader->resizeSection ( COLUMN_UPEER, 120 );
upheader->resizeSection ( COLUMN_USIZE, 70 );
upheader->resizeSection ( COLUMN_UTRANSFERRED, 75 );
upheader->resizeSection ( COLUMN_ULSPEED, 75 );
upheader->resizeSection ( COLUMN_UPROGRESS, 170 );
upheader->resizeSection ( ULListDelegate::COLUMN_UNAME, 260 );
upheader->resizeSection ( ULListDelegate::COLUMN_UPEER, 120 );
upheader->resizeSection ( ULListDelegate::COLUMN_USIZE, 70 );
upheader->resizeSection ( ULListDelegate::COLUMN_UTRANSFERRED, 75 );
upheader->resizeSection ( ULListDelegate::COLUMN_ULSPEED, 75 );
upheader->resizeSection ( ULListDelegate::COLUMN_UPROGRESS, 170 );
// set default column and sort order for upload
ui.uploadsList->sortByColumn(COLUMN_UNAME, Qt::AscendingOrder);
ui.uploadsList->sortByColumn(ULListDelegate::COLUMN_UNAME, Qt::AscendingOrder);
QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ;
@ -1174,18 +1174,18 @@ void TransfersDialog::processSettings(bool bLoad)
// state of splitter
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
setShowDLSizeColumn(Settings->value("showDLSizeColumn", !ui.downloadList->isColumnHidden(COLUMN_SIZE)).toBool());
setShowDLCompleteColumn(Settings->value("showDLCompleteColumn", !ui.downloadList->isColumnHidden(COLUMN_COMPLETED)).toBool());
setShowDLDLSpeedColumn(Settings->value("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(COLUMN_DLSPEED)).toBool());
setShowDLProgressColumn(Settings->value("showDLProgressColumn", !ui.downloadList->isColumnHidden(COLUMN_PROGRESS)).toBool());
setShowDLSourcesColumn(Settings->value("showDLSourcesColumn", !ui.downloadList->isColumnHidden(COLUMN_SOURCES)).toBool());
setShowDLStatusColumn(Settings->value("showDLStatusColumn", !ui.downloadList->isColumnHidden(COLUMN_STATUS)).toBool());
setShowDLPriorityColumn(Settings->value("showDLPriorityColumn", !ui.downloadList->isColumnHidden(COLUMN_PRIORITY)).toBool());
setShowDLRemainingColumn(Settings->value("showDLRemainingColumn", !ui.downloadList->isColumnHidden(COLUMN_REMAINING)).toBool());
setShowDLDownloadTimeColumn(Settings->value("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(COLUMN_DOWNLOADTIME)).toBool());
setShowDLIDColumn(Settings->value("showDLIDColumn", !ui.downloadList->isColumnHidden(COLUMN_ID)).toBool());
setShowDLLastDLColumn(Settings->value("showDLLastDLColumn", !ui.downloadList->isColumnHidden(COLUMN_LASTDL)).toBool());
setShowDLPath(Settings->value("showDLPath", !ui.downloadList->isColumnHidden(COLUMN_PATH)).toBool());
setShowDLSizeColumn(Settings->value("showDLSizeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SIZE)).toBool());
setShowDLCompleteColumn(Settings->value("showDLCompleteColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_COMPLETED)).toBool());
setShowDLDLSpeedColumn(Settings->value("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DLSPEED)).toBool());
setShowDLProgressColumn(Settings->value("showDLProgressColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PROGRESS)).toBool());
setShowDLSourcesColumn(Settings->value("showDLSourcesColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SOURCES)).toBool());
setShowDLStatusColumn(Settings->value("showDLStatusColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_STATUS)).toBool());
setShowDLPriorityColumn(Settings->value("showDLPriorityColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PRIORITY)).toBool());
setShowDLRemainingColumn(Settings->value("showDLRemainingColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_REMAINING)).toBool());
setShowDLDownloadTimeColumn(Settings->value("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME)).toBool());
setShowDLIDColumn(Settings->value("showDLIDColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_ID)).toBool());
setShowDLLastDLColumn(Settings->value("showDLLastDLColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_LASTDL)).toBool());
setShowDLPath(Settings->value("showDLPath", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PATH)).toBool());
// selected tab
ui.tabWidget->setCurrentIndex(Settings->value("selectedTab").toInt());
@ -1199,18 +1199,18 @@ void TransfersDialog::processSettings(bool bLoad)
// state of splitter
Settings->setValue("Splitter", ui.splitter->saveState());
Settings->setValue("showDLSizeColumn", !ui.downloadList->isColumnHidden(COLUMN_SIZE));
Settings->setValue("showDLCompleteColumn", !ui.downloadList->isColumnHidden(COLUMN_COMPLETED));
Settings->setValue("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(COLUMN_DLSPEED));
Settings->setValue("showDLProgressColumn", !ui.downloadList->isColumnHidden(COLUMN_PROGRESS));
Settings->setValue("showDLSourcesColumn", !ui.downloadList->isColumnHidden(COLUMN_SOURCES));
Settings->setValue("showDLStatusColumn", !ui.downloadList->isColumnHidden(COLUMN_STATUS));
Settings->setValue("showDLPriorityColumn", !ui.downloadList->isColumnHidden(COLUMN_PRIORITY));
Settings->setValue("showDLRemainingColumn", !ui.downloadList->isColumnHidden(COLUMN_REMAINING));
Settings->setValue("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(COLUMN_DOWNLOADTIME));
Settings->setValue("showDLIDColumn", !ui.downloadList->isColumnHidden(COLUMN_ID));
Settings->setValue("showDLLastDLColumn", !ui.downloadList->isColumnHidden(COLUMN_LASTDL));
Settings->setValue("showDLPath", !ui.downloadList->isColumnHidden(COLUMN_PATH));
Settings->setValue("showDLSizeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SIZE));
Settings->setValue("showDLCompleteColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_COMPLETED));
Settings->setValue("showDLDLSpeedColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DLSPEED));
Settings->setValue("showDLProgressColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PROGRESS));
Settings->setValue("showDLSourcesColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SOURCES));
Settings->setValue("showDLStatusColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_STATUS));
Settings->setValue("showDLPriorityColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PRIORITY));
Settings->setValue("showDLRemainingColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_REMAINING));
Settings->setValue("showDLDownloadTimeColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME));
Settings->setValue("showDLIDColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_ID));
Settings->setValue("showDLLastDLColumn", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_LASTDL));
Settings->setValue("showDLPath", !ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PATH));
// selected tab
Settings->setValue("selectedTab", ui.tabWidget->currentIndex());
@ -1423,18 +1423,18 @@ void TransfersDialog::downloadListHeaderCustomPopupMenu( QPoint /*point*/ )
std::cerr << "TransfersDialog::downloadListHeaderCustomPopupMenu()" << std::endl;
QMenu contextMnu( this );
showDLSizeAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_SIZE));
showDLCompleteAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_COMPLETED));
showDLDLSpeedAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_DLSPEED));
showDLProgressAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_PROGRESS));
showDLSourcesAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_SOURCES));
showDLStatusAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_STATUS));
showDLPriorityAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_PRIORITY));
showDLRemainingAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_REMAINING));
showDLDownloadTimeAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_DOWNLOADTIME));
showDLIDAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_ID));
showDLLastDLAct->setChecked(!ui.downloadList->isColumnHidden(COLUMN_LASTDL));
showDLPath->setChecked(!ui.downloadList->isColumnHidden(COLUMN_PATH));
showDLSizeAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SIZE));
showDLCompleteAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_COMPLETED));
showDLDLSpeedAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DLSPEED));
showDLProgressAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PROGRESS));
showDLSourcesAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_SOURCES));
showDLStatusAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_STATUS));
showDLPriorityAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PRIORITY));
showDLRemainingAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_REMAINING));
showDLDownloadTimeAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME));
showDLIDAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_ID));
showDLLastDLAct->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_LASTDL));
showDLPath->setChecked(!ui.downloadList->isColumnHidden(DLListDelegate::COLUMN_PATH));
QMenu *menu = contextMnu.addMenu(tr("Columns"));
menu->addAction(showDLSizeAct);
@ -1486,12 +1486,12 @@ void TransfersDialog::uploadsListHeaderCustomPopupMenu( QPoint /*point*/ )
std::cerr << "TransfersDialog::uploadsListHeaderCustomPopupMenu()" << std::endl;
QMenu contextMnu( this );
showULPeerAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPEER));
showULSizeAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_USIZE));
showULTransferredAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UTRANSFERRED));
showULSpeedAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_ULSPEED));
showULProgressAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPROGRESS));
showULHashAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UHASH));
showULPeerAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UPEER));
showULSizeAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_USIZE));
showULTransferredAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UTRANSFERRED));
showULSpeedAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_ULSPEED));
showULProgressAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UPROGRESS));
showULHashAct->setChecked(!ui.uploadsList->isColumnHidden(ULListDelegate::COLUMN_UHASH));
QMenu *menu = contextMnu.addMenu(tr("Columns"));
menu->addAction(showULPeerAct);
@ -1554,20 +1554,20 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
// change progress column to own class for sorting
//ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL));
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), fileName);
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), FilesDefs::getIconFromFileType(fileName), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash);
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash, Qt::UserRole);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UNAME), fileName);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UNAME), FilesDefs::getIconFromFileType(fileName), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UHASH), fileHash);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UHASH), fileHash, Qt::UserRole);
}
ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize));
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_USIZE), QVariant((qlonglong)fileSize));
//Reset Parent info if child present
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(QString(tr("%1 tunnels").arg(fileInfo.peers.size()))) );
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QIcon(), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(), Qt::ToolTipRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant());
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant());
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(QString(tr("%1 tunnels").arg(fileInfo.peers.size()))) );
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QIcon(), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(), Qt::ToolTipRole);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UTRANSFERRED), QVariant());
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPROGRESS), QVariant());
QStandardItem *ulItem = ULListModel->item(row);
std::set<int> used_rows ;
@ -1617,11 +1617,11 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
//Only one peer so update parent
QString iconName;
QString tooltip;
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(getPeerName(transferInfo.peerId, iconName, tooltip)));
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QIcon(iconName), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(tooltip), Qt::ToolTipRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant(completed));
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant::fromValue(peerpinfo));
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(getPeerName(transferInfo.peerId, iconName, tooltip)));
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QIcon(iconName), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPEER), QVariant(tooltip), Qt::ToolTipRole);
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UTRANSFERRED), QVariant(completed));
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_UPROGRESS), QVariant::fromValue(peerpinfo));
} else {
int row_id = addPeerToULItem(ulItem, transferInfo.peerId, hashFileAndPeerId, completed, peerULSpeed, peerpinfo);
@ -1632,7 +1632,7 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
}
// Update Parent UpLoad Speed
ULListModel->setData(ULListModel->index(row, COLUMN_ULSPEED), QVariant((double)peerULSpeedTotal));
ULListModel->setData(ULListModel->index(row, ULListDelegate::COLUMN_ULSPEED), QVariant((double)peerULSpeedTotal));
// This is not optimal, but we deal with a small number of elements. The reverse order is really important,
@ -1653,7 +1653,7 @@ int TransfersDialog::addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer
int childRow = -1;
QStandardItem *childId = NULL;
for (int count = 0; (childId = ulItem->child(count, COLUMN_UHASH)) != NULL; ++count) {
for (int count = 0; (childId = ulItem->child(count, ULListDelegate::COLUMN_UHASH)) != NULL; ++count) {
if (childId->data(Qt::UserRole).toString() == coreID) {
childRow = count;
break;
@ -1700,9 +1700,9 @@ int TransfersDialog::addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer
childRow = ulItem->rowCount() - 1;
} else {
// just update the child (peer)
ulItem->child(childRow, COLUMN_ULSPEED)->setData(QVariant((double)ulspeed), Qt::DisplayRole);
ulItem->child(childRow, COLUMN_UTRANSFERRED)->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
ulItem->child(childRow, COLUMN_UPROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
ulItem->child(childRow, ULListDelegate::COLUMN_ULSPEED)->setData(QVariant((double)ulspeed), Qt::DisplayRole);
ulItem->child(childRow, ULListDelegate::COLUMN_UTRANSFERRED)->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
ulItem->child(childRow, ULListDelegate::COLUMN_UPROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
}
return childRow;
@ -1743,7 +1743,7 @@ void TransfersDialog::insertTransfers()
int rowCount = ULListModel->rowCount();
for (int row = 0; row < rowCount; ) {
RsFileHash hash ( ULListModel->item(row, COLUMN_UHASH)->data(Qt::UserRole).toString().toStdString());
RsFileHash hash ( ULListModel->item(row, ULListDelegate::COLUMN_UHASH)->data(Qt::UserRole).toString().toStdString());
std::set<RsFileHash>::iterator hashIt = hashs.find(hash);
if (hashIt == hashs.end()) {
@ -1976,13 +1976,13 @@ void TransfersDialog::getDLSelectedItems(std::set<RsFileHash> *ids, std::set<int
if (ids) ids->clear();
if (rows) rows->clear();
QModelIndexList selectedRows = selection->selectedRows(COLUMN_ID);
QModelIndexList selectedRows = selection->selectedRows(DLListDelegate::COLUMN_ID);
int i, imax = selectedRows.count();
for (i = 0; i < imax; ++i) {
QModelIndex index = selectedRows.at(i);
if (index.parent().isValid() && index.model())
index = index.model()->index(index.parent().row(), COLUMN_ID);
index = index.model()->index(index.parent().row(), DLListDelegate::COLUMN_ID);
if (ids) {
ids->insert(RsFileHash(index.data(Qt::DisplayRole).toString().toStdString()));
@ -2010,7 +2010,7 @@ void TransfersDialog::getULSelectedItems(std::set<RsFileHash> *ids, std::set<int
foreach(index, indexes) {
if (ids) {
QStandardItem *id = ULListModel->item(index.row(), COLUMN_UHASH);
QStandardItem *id = ULListModel->item(index.row(), ULListDelegate::COLUMN_UHASH);
ids->insert(RsFileHash(id->data(Qt::DisplayRole).toString().toStdString()));
}
if (rows) {
@ -2383,72 +2383,72 @@ return 0.0 ;
double TransfersDialog::getSpeed(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_DLSPEED), Qt::DisplayRole).toDouble();
return model->data(model->index(row, DLListDelegate::COLUMN_DLSPEED), Qt::DisplayRole).toDouble();
}
QString TransfersDialog::getFileName(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_NAME), Qt::DisplayRole).toString();
return model->data(model->index(row, DLListDelegate::COLUMN_NAME), Qt::DisplayRole).toString();
}
QString TransfersDialog::getStatus(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_STATUS), Qt::DisplayRole).toString();
return model->data(model->index(row, DLListDelegate::COLUMN_STATUS), Qt::DisplayRole).toString();
}
QString TransfersDialog::getID(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_ID), Qt::UserRole).toString().left(40); // gets only the "hash" part of the name
return model->data(model->index(row, DLListDelegate::COLUMN_ID), Qt::UserRole).toString().left(40); // gets only the "hash" part of the name
}
QString TransfersDialog::getID(int row, QSortFilterProxyModel *filter)
{
QModelIndex index = filter->mapToSource(filter->index(row, COLUMN_ID));
QModelIndex index = filter->mapToSource(filter->index(row, DLListDelegate::COLUMN_ID));
return filter->sourceModel()->data(index, Qt::UserRole).toString().left(40); // gets only the "hash" part of the name
}
QString TransfersDialog::getPriority(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_PRIORITY), Qt::DisplayRole).toString();
return model->data(model->index(row, DLListDelegate::COLUMN_PRIORITY), Qt::DisplayRole).toString();
}
qlonglong TransfersDialog::getFileSize(int row, QStandardItemModel *model)
{
bool ok = false;
return model->data(model->index(row, COLUMN_SIZE), Qt::DisplayRole).toULongLong(&ok);
return model->data(model->index(row, DLListDelegate::COLUMN_SIZE), Qt::DisplayRole).toULongLong(&ok);
}
qlonglong TransfersDialog::getTransfered(int row, QStandardItemModel *model)
{
bool ok = false;
return model->data(model->index(row, COLUMN_COMPLETED), Qt::DisplayRole).toULongLong(&ok);
return model->data(model->index(row, DLListDelegate::COLUMN_COMPLETED), Qt::DisplayRole).toULongLong(&ok);
}
qlonglong TransfersDialog::getRemainingTime(int row, QStandardItemModel *model)
{
bool ok = false;
return model->data(model->index(row, COLUMN_REMAINING), Qt::DisplayRole).toULongLong(&ok);
return model->data(model->index(row, DLListDelegate::COLUMN_REMAINING), Qt::DisplayRole).toULongLong(&ok);
}
qlonglong TransfersDialog::getDownloadTime(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_DOWNLOADTIME), Qt::DisplayRole).toULongLong();
return model->data(model->index(row, DLListDelegate::COLUMN_DOWNLOADTIME), Qt::DisplayRole).toULongLong();
}
qlonglong TransfersDialog::getLastDL(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_LASTDL), Qt::DisplayRole).toULongLong();
return model->data(model->index(row, DLListDelegate::COLUMN_LASTDL), Qt::DisplayRole).toULongLong();
}
qlonglong TransfersDialog::getPath(int row, QStandardItemModel *model)
{
return model->data(model->index(row, COLUMN_PATH), Qt::DisplayRole).toULongLong();
return model->data(model->index(row, DLListDelegate::COLUMN_PATH), Qt::DisplayRole).toULongLong();
}
QString TransfersDialog::getSources(int row, QStandardItemModel *model)
{
double dblValue = model->data(model->index(row, COLUMN_SOURCES), Qt::DisplayRole).toDouble();
double dblValue = model->data(model->index(row, DLListDelegate::COLUMN_SOURCES), Qt::DisplayRole).toDouble();
QString temp = QString("%1 (%2)").arg((int)dblValue).arg((int)((fmod(dblValue,1)*1000)+0.5));
return temp;
@ -2608,25 +2608,25 @@ void TransfersDialog::collAutoOpen(const QString &fileHash)
}
}
void TransfersDialog::setShowDLSizeColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_SIZE, !show); }
void TransfersDialog::setShowDLCompleteColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_COMPLETED, !show); }
void TransfersDialog::setShowDLDLSpeedColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_DLSPEED, !show); }
void TransfersDialog::setShowDLProgressColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_PROGRESS, !show); }
void TransfersDialog::setShowDLSourcesColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_SOURCES, !show); }
void TransfersDialog::setShowDLStatusColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_STATUS, !show); }
void TransfersDialog::setShowDLPriorityColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_PRIORITY, !show); }
void TransfersDialog::setShowDLRemainingColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_REMAINING, !show); }
void TransfersDialog::setShowDLDownloadTimeColumn(bool show) { ui.downloadList->setColumnHidden(COLUMN_DOWNLOADTIME, !show); }
void TransfersDialog::setShowDLIDColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_ID, !show); }
void TransfersDialog::setShowDLLastDLColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_LASTDL, !show); }
void TransfersDialog::setShowDLPath (bool show) { ui.downloadList->setColumnHidden(COLUMN_PATH, !show); }
void TransfersDialog::setShowDLSizeColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_SIZE, !show); }
void TransfersDialog::setShowDLCompleteColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_COMPLETED, !show); }
void TransfersDialog::setShowDLDLSpeedColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_DLSPEED, !show); }
void TransfersDialog::setShowDLProgressColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_PROGRESS, !show); }
void TransfersDialog::setShowDLSourcesColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_SOURCES, !show); }
void TransfersDialog::setShowDLStatusColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_STATUS, !show); }
void TransfersDialog::setShowDLPriorityColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_PRIORITY, !show); }
void TransfersDialog::setShowDLRemainingColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_REMAINING, !show); }
void TransfersDialog::setShowDLDownloadTimeColumn(bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_DOWNLOADTIME, !show); }
void TransfersDialog::setShowDLIDColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_ID, !show); }
void TransfersDialog::setShowDLLastDLColumn (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_LASTDL, !show); }
void TransfersDialog::setShowDLPath (bool show) { ui.downloadList->setColumnHidden(DLListDelegate::COLUMN_PATH, !show); }
void TransfersDialog::setShowULPeerColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPEER, !show); }
void TransfersDialog::setShowULSizeColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_USIZE, !show); }
void TransfersDialog::setShowULTransferredColumn(bool show) { ui.uploadsList->setColumnHidden(COLUMN_UTRANSFERRED, !show); }
void TransfersDialog::setShowULSpeedColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_ULSPEED, !show); }
void TransfersDialog::setShowULProgressColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPROGRESS, !show); }
void TransfersDialog::setShowULHashColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UHASH, !show); }
void TransfersDialog::setShowULPeerColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UPEER, !show); }
void TransfersDialog::setShowULSizeColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_USIZE, !show); }
void TransfersDialog::setShowULTransferredColumn(bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UTRANSFERRED, !show); }
void TransfersDialog::setShowULSpeedColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_ULSPEED, !show); }
void TransfersDialog::setShowULProgressColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UPROGRESS, !show); }
void TransfersDialog::setShowULHashColumn (bool show) { ui.uploadsList->setColumnHidden(ULListDelegate::COLUMN_UHASH, !show); }
void TransfersDialog::expandAllDL()
{

View File

@ -25,26 +25,14 @@
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)
{
;
}
ULListDelegate::~ULListDelegate(void)
{
;
}
void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
@ -77,7 +65,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
// draw the background color
bool bDrawBackground = true;
if(index.column() == ULLISTDELEGATE_COLUMN_UPROGRESS) {
if(index.column() == COLUMN_UPROGRESS) {
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
bDrawBackground = (pinfo.type == FileProgressInfo::UNINIT);
}
@ -96,7 +84,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
switch(index.column()) {
case ULLISTDELEGATE_COLUMN_USIZE:
case COLUMN_USIZE:
fileSize = index.data().toLongLong();
if(fileSize <= 0){
temp = "";
@ -115,7 +103,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case ULLISTDELEGATE_COLUMN_UTRANSFERRED:
case COLUMN_UTRANSFERRED:
transferred = index.data().toLongLong();
if(transferred <= 0){
temp = "";
@ -134,7 +122,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case ULLISTDELEGATE_COLUMN_ULSPEED:
case COLUMN_ULSPEED:
ulspeed = index.data().toDouble();
if (ulspeed <= 0) {
temp = "";
@ -145,7 +133,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case ULLISTDELEGATE_COLUMN_UPROGRESS:
case COLUMN_UPROGRESS:
{
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
if (pinfo.type == FileProgressInfo::UNINIT)
@ -155,7 +143,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(), ULLISTDELEGATE_COLUMN_UNAME).data().toString().toStdString())).suffix();;
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), COLUMN_UNAME).data().toString().toStdString())).suffix();;
if (ext == "rsfc" || ext == "rsrl" || ext == "dist" || ext == "rsfb")
progressBar.setColorSchema( 9);
else
@ -169,8 +157,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;
case ULLISTDELEGATE_COLUMN_UNAME:
case ULLISTDELEGATE_COLUMN_UPEER:
case COLUMN_UNAME:
case 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);

View File

@ -18,30 +18,27 @@
* *
*******************************************************************************/
#ifndef ULLISTDELEGATE_H
#define ULLISTDELEGATE_H
#pragma once
#include <QAbstractItemDelegate>
class QModelIndex;
class QPainter;
class ULListDelegate: public QAbstractItemDelegate {
Q_OBJECT
class ULListDelegate: public QAbstractItemDelegate
{
public:
ULListDelegate(QObject *parent=0);
~ULListDelegate();
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
private:
public slots:
signals:
static constexpr int COLUMN_UNAME = 0;
static constexpr int COLUMN_UPEER = 1;
static constexpr int COLUMN_USIZE = 2;
static constexpr int COLUMN_UTRANSFERRED = 3;
static constexpr int COLUMN_ULSPEED = 4;
static constexpr int COLUMN_UPROGRESS = 5;
static constexpr int COLUMN_UHASH = 6;
static constexpr int COLUMN_UCOUNT = 7;
};
#endif

View File

@ -466,10 +466,8 @@ void MainWindow::initStackedPage()
}
#ifndef RS_RELEASE_VERSION
#ifdef PLUGINMGR
addPage(pluginsPage = new gui::PluginsPage(ui->stackPages), grp, NULL);
#endif
#endif
#undef GETSTARTED_GUI
#ifdef GETSTARTED_GUI

View File

@ -73,7 +73,7 @@ NetworkDialog::NetworkDialog(QWidget */*parent*/)
PGPIdItemProxy = new pgpid_item_proxy(this);
connect(ui.onlyTrustedKeys, SIGNAL(toggled(bool)), PGPIdItemProxy, SLOT(use_only_trusted_keys(bool)));
PGPIdItemProxy->setSourceModel(PGPIdItemModel);
PGPIdItemProxy->setFilterKeyColumn(COLUMN_PEERNAME);
PGPIdItemProxy->setFilterKeyColumn(pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERNAME);
PGPIdItemProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
PGPIdItemProxy->setSortRole(Qt::EditRole); //use edit role to get raw data since we do not have edit for this model.
ui.connectTreeWidget->setModel(PGPIdItemProxy);
@ -90,9 +90,9 @@ NetworkDialog::NetworkDialog(QWidget */*parent*/)
ui.onlyTrustedKeys->setMinimumWidth(20*f);
/* add filter actions */
ui.filterLineEdit->addFilter(QIcon(), tr("Name"), COLUMN_PEERNAME, tr("Search name"));
ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), COLUMN_PEERID, tr("Search peer ID"));
ui.filterLineEdit->setCurrentFilter(COLUMN_PEERNAME);
ui.filterLineEdit->addFilter(QIcon(), tr("Name"), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERNAME, tr("Search name"));
ui.filterLineEdit->addFilter(QIcon(), tr("Peer ID"), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID, tr("Search peer ID"));
ui.filterLineEdit->setCurrentFilter(pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERNAME);
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), PGPIdItemProxy, SLOT(setFilterWildcard(QString)));
}
@ -120,7 +120,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
QMenu *contextMnu = new QMenu;
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()) ;
// That's what context menus are made for
RsPeerDetails detail;
@ -179,7 +179,7 @@ void NetworkDialog::removeSelectedKeys()
return;
std::set<RsPgpId> selected;
selected.insert(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()));
selected.insert(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()));
removeKeys(selected);
}
@ -228,7 +228,7 @@ void NetworkDialog::denyFriend()
if(l.empty())
return;
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString());
RsPgpId peer_id(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString());
rsPeers->removeFriend(peer_id) ;
securedUpdateDisplay();
@ -241,7 +241,7 @@ void NetworkDialog::makeFriend()
if(l.empty())
return;
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
}
/** Shows Peer Information/Auth Dialog */
@ -251,7 +251,7 @@ void NetworkDialog::peerdetails()
if(l.empty())
return;
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
PGPKeyDialog::showIt(RsPgpId(ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()), PGPKeyDialog::PageDetails);
}
void NetworkDialog::copyLink()
@ -261,7 +261,7 @@ void NetworkDialog::copyLink()
return;
RsPgpId peer_id (ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), COLUMN_PEERID)).toString().toStdString()) ;
RsPgpId peer_id (ui.connectTreeWidget->model()->data(ui.connectTreeWidget->model()->index(l.begin()->row(), pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID)).toString().toStdString()) ;
QList<RetroShareLink> urls;
RetroShareLink link = RetroShareLink::createPerson(peer_id);

View File

@ -28,14 +28,6 @@
#define IMAGE_DENIED ":/images/denied16.png"
#define IMAGE_TRUSTED ":/images/rs-2.png"
#define PGP_ITEM_MODEL_COLUMN_CHECK 0
#define PGP_ITEM_MODEL_COLUMN_PEERNAME 1
#define PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER 2
#define PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME 3
#define PGP_ITEM_MODEL_COLUMN_PEERID 4
#define PGP_ITEM_MODEL_COLUMN_LAST_USED 5
#define PGP_ITEM_MODEL_COLUMN_COUNT 6
/*TODO:
* using list here for internal data storage is not best option
*/

View File

@ -48,6 +48,13 @@ public:
void setBackgroundColorDenied(QColor color) { mBackgroundColorDenied = color; }
void setTextColor(QColor color) { mTextColor = color; }
static constexpr int PGP_ITEM_MODEL_COLUMN_CHECK = 0;
static constexpr int PGP_ITEM_MODEL_COLUMN_PEERNAME = 1;
static constexpr int PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER = 2;
static constexpr int PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME = 3;
static constexpr int PGP_ITEM_MODEL_COLUMN_PEERID = 4;
static constexpr int PGP_ITEM_MODEL_COLUMN_LAST_USED = 5;
static constexpr int PGP_ITEM_MODEL_COLUMN_COUNT = 6;
public slots:
void data_updated(std::list<RsPgpId> &new_neighs);

View File

@ -26,17 +26,13 @@
#include <retroshare/rsdisc.h>
#include <retroshare/rsmsgs.h>
//TODO: set this defines in one place
// Defines for key list columns
#define COLUMN_CHECK 0
#define COLUMN_PEERNAME 1
#define COLUMN_I_AUTH_PEER 2
#define COLUMN_PEER_AUTH_ME 3
#define COLUMN_PEERID 4
#define COLUMN_LAST_USED 5
#define COLUMN_COUNT 6
bool pgpid_item_proxy::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
if(left.column() == pgpid_item_model::PGP_ITEM_MODEL_COLUMN_LAST_USED)
return left.data(Qt::EditRole).toUInt() < right.data(Qt::EditRole).toUInt();
else
return left.data(Qt::DisplayRole).toString().toUpper() < right.data(Qt::DisplayRole).toString().toUpper();
}
pgpid_item_proxy::pgpid_item_proxy(QObject *parent) :
@ -57,7 +53,7 @@ bool pgpid_item_proxy::filterAcceptsRow(int sourceRow, const QModelIndex &source
{
if(!rsPeers)
return false;
RsPgpId peer_id (sourceModel()->data(sourceModel()->index(sourceRow, COLUMN_PEERID, sourceParent)).toString().toStdString());
RsPgpId peer_id (sourceModel()->data(sourceModel()->index(sourceRow, pgpid_item_model::PGP_ITEM_MODEL_COLUMN_PEERID, sourceParent)).toString().toStdString());
RsPeerDetails details;
if(!rsPeers->getGPGDetails(peer_id, details))
return false;

View File

@ -34,14 +34,7 @@ class pgpid_item_proxy :
public:
pgpid_item_proxy(QObject *parent = nullptr);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
{
if(left.column() == COLUMN_LAST_USED)
return left.data(Qt::EditRole).toUInt() < right.data(Qt::EditRole).toUInt();
else
return left.data(Qt::DisplayRole).toString().toUpper() < right.data(Qt::DisplayRole).toString().toUpper();
}
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
public slots:
void use_only_trusted_keys(bool val);