mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-22 07:49:56 -05:00
reengineered the transfer list display
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2349 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
082d5732b0
commit
3014a9a233
@ -55,36 +55,36 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
qlonglong completed;
|
||||
|
||||
//set text color
|
||||
QVariant value = index.data(Qt::TextColorRole);
|
||||
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
|
||||
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
|
||||
}
|
||||
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
||||
if(option.state & QStyle::State_Selected){
|
||||
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
|
||||
} else {
|
||||
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||
}
|
||||
QVariant value = index.data(Qt::TextColorRole);
|
||||
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
|
||||
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
|
||||
}
|
||||
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
||||
if(option.state & QStyle::State_Selected){
|
||||
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
|
||||
} else {
|
||||
painter->setPen(opt.palette.color(cg, QPalette::Text));
|
||||
}
|
||||
|
||||
// draw the background color
|
||||
if(index.column() != PROGRESS) {
|
||||
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
|
||||
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
|
||||
cg = QPalette::Inactive;
|
||||
}
|
||||
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||
} else {
|
||||
value = index.data(Qt::BackgroundColorRole);
|
||||
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
|
||||
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
// draw the background color if not the progress column or if progress is not displayed
|
||||
if(index.column() != PROGRESS || ((FileProgressInfo)index.data().value<FileProgressInfo>()).nb_chunks == 0) {
|
||||
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
|
||||
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
|
||||
cg = QPalette::Inactive;
|
||||
}
|
||||
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
|
||||
} else {
|
||||
value = index.data(Qt::BackgroundColorRole);
|
||||
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
|
||||
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
switch(index.column()) {
|
||||
case SIZE:
|
||||
fileSize = index.data().toLongLong();
|
||||
if(fileSize < 0){
|
||||
temp = "Unknown";
|
||||
if(fileSize <= 0){
|
||||
temp = "";
|
||||
} else {
|
||||
multi = 1.0;
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
@ -122,8 +122,8 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
break;
|
||||
case COMPLETED:
|
||||
completed = index.data().toLongLong();
|
||||
if(completed < 0){
|
||||
temp = "Unknown";
|
||||
if(completed <= 0){
|
||||
temp = "";
|
||||
} else {
|
||||
multi = 1.0;
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
@ -140,43 +140,51 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case DLSPEED:
|
||||
dlspeed = index.data().toDouble();
|
||||
temp.clear();
|
||||
temp.sprintf("%.2f", dlspeed/1024.);
|
||||
temp += " KB/s";
|
||||
dlspeed = index.data().toDouble();
|
||||
if (dlspeed <= 0) {
|
||||
temp = "";
|
||||
} else {
|
||||
temp.clear();
|
||||
temp.sprintf("%.2f", dlspeed/1024.);
|
||||
temp += " KB/s";
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case PROGRESS:
|
||||
{
|
||||
// create a xProgressBar
|
||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||
xProgressBar progressBar(pinfo,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
||||
if(pinfo.type == FileProgressInfo::DOWNLOAD_LINE)
|
||||
{
|
||||
progressBar.setDisplayText(true); // should display % text?
|
||||
progressBar.setColorSchema(0) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
progressBar.setDisplayText(false); // should display % text?
|
||||
progressBar.setColorSchema(1) ;
|
||||
}
|
||||
progressBar.setVerticalSpan(1);
|
||||
progressBar.paint(); // paint the progress bar
|
||||
if (pinfo.nb_chunks != 0) {
|
||||
xProgressBar progressBar(pinfo,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
||||
if(pinfo.type == FileProgressInfo::DOWNLOAD_LINE)
|
||||
{
|
||||
progressBar.setDisplayText(true); // should display % text?
|
||||
progressBar.setColorSchema(0) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
progressBar.setDisplayText(false); // should display % text?
|
||||
progressBar.setColorSchema(1) ;
|
||||
}
|
||||
progressBar.setVerticalSpan(1);
|
||||
progressBar.paint(); // paint the progress bar
|
||||
}
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||
break;
|
||||
case NAME:
|
||||
// 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);
|
||||
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;
|
||||
value = index.data(Qt::DecorationRole);
|
||||
temp = index.data().toString();
|
||||
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);
|
||||
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);
|
||||
temp = " " + temp;
|
||||
}
|
||||
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, temp);
|
||||
break;
|
||||
default:
|
||||
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ void FileTransferInfoWidget::updateDisplay()
|
||||
|
||||
void FileTransferInfoWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
std::cout << "In paint event" << std::endl ;
|
||||
//std::cout << "In paint event" << std::endl ;
|
||||
QStylePainter painter(this);
|
||||
|
||||
painter.drawPixmap(0, 0, pixmap2);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,37 +46,37 @@ class QStandardItemModel;
|
||||
|
||||
class TransfersDialog : public RsAutoUpdatePage
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
TransfersDialog(QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
~TransfersDialog();
|
||||
public:
|
||||
/** Default Constructor */
|
||||
TransfersDialog(QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
~TransfersDialog();
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *) ;
|
||||
virtual void updateDisplay() ; // derived from RsAutoUpdateWidget
|
||||
virtual void keyPressEvent(QKeyEvent *) ;
|
||||
virtual void updateDisplay() ; // derived from RsAutoUpdateWidget
|
||||
|
||||
public slots:
|
||||
void insertTransfers();
|
||||
public slots:
|
||||
void insertTransfers();
|
||||
|
||||
void handleDownloadRequest(const QString& url);
|
||||
void handleDownloadRequest(const QString& url);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void downloadListCostumPopupMenu( QPoint point );
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void downloadListCostumPopupMenu( QPoint point );
|
||||
|
||||
void cancel();
|
||||
/** removes finished Downloads**/
|
||||
void clearcompleted();
|
||||
void playSelectedTransfer();
|
||||
void cancel();
|
||||
/** removes finished Downloads**/
|
||||
void clearcompleted();
|
||||
void playSelectedTransfer();
|
||||
|
||||
void copyLink();
|
||||
void copyLink();
|
||||
void pasteLink();
|
||||
|
||||
void rootdecorated();
|
||||
void rootisnotdecorated();
|
||||
// void rootdecorated();
|
||||
// void rootisnotdecorated();
|
||||
|
||||
void pauseFileTransfer();
|
||||
void resumeFileTransfer();
|
||||
@ -97,106 +97,99 @@ class TransfersDialog : public RsAutoUpdatePage
|
||||
void speedAverage();
|
||||
void speedFast();
|
||||
|
||||
void changeSpeed(int) ;
|
||||
void changeQueuePriority(int) ;
|
||||
void changeSpeed(int) ;
|
||||
void changeQueuePriority(int) ;
|
||||
|
||||
void chunkRandom();
|
||||
void chunkStreaming();
|
||||
|
||||
/** save sort indicators for next transfers display */
|
||||
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
|
||||
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
|
||||
|
||||
// void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
|
||||
// void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
|
||||
|
||||
void showDetailsDialog();
|
||||
|
||||
signals:
|
||||
void playFiles(QStringList files);
|
||||
signals:
|
||||
void playFiles(QStringList files);
|
||||
|
||||
private:
|
||||
QString getPeerName(const std::string& peer_id) const ;
|
||||
private:
|
||||
QString getPeerName(const std::string& peer_id) const ;
|
||||
|
||||
QStandardItemModel *DLListModel;
|
||||
QStandardItemModel *ULListModel;
|
||||
QItemSelectionModel *selection;
|
||||
QItemSelectionModel *selectionup;
|
||||
QStandardItemModel *DLListModel;
|
||||
QStandardItemModel *ULListModel;
|
||||
QItemSelectionModel *selection;
|
||||
QItemSelectionModel *selectionup;
|
||||
|
||||
DLListDelegate *DLDelegate;
|
||||
ULListDelegate *ULDelegate;
|
||||
qlonglong fileSize;
|
||||
double progress;
|
||||
double dlspeed;
|
||||
QString status, icon, name;
|
||||
qlonglong completed, remaining;
|
||||
DLListDelegate *DLDelegate;
|
||||
ULListDelegate *ULDelegate;
|
||||
|
||||
int _sortColDwl, _sortColUpl;
|
||||
Qt::SortOrder _sortOrderDwl, _sortOrderUpl;
|
||||
|
||||
/** Create the actions on the tray menu or menubar */
|
||||
void createActions();
|
||||
// int _sortColDwl, _sortColUpl;
|
||||
// Qt::SortOrder _sortOrderDwl, _sortOrderUpl;
|
||||
|
||||
/** Define the popup menus for the Context menu */
|
||||
QMenu* contextMnu;
|
||||
/** Defines the actions for the context menu */
|
||||
QAction* showdowninfoAct;
|
||||
QAction* cancelAct;
|
||||
QAction* clearcompletedAct;
|
||||
QAction* copylinkAct;
|
||||
/** Create the actions on the tray menu or menubar */
|
||||
void createActions();
|
||||
|
||||
/** Define the popup menus for the Context menu */
|
||||
QMenu* contextMnu;
|
||||
/** Defines the actions for the context menu */
|
||||
QAction* showdowninfoAct;
|
||||
QAction* cancelAct;
|
||||
QAction* clearcompletedAct;
|
||||
QAction* copylinkAct;
|
||||
QAction* pastelinkAct;
|
||||
QAction* rootisnotdecoratedAct;
|
||||
QAction* rootisdecoratedAct;
|
||||
QAction *pauseAct;
|
||||
QAction *resumeAct;
|
||||
QAction *openfolderAct;
|
||||
QAction *openfileAct;
|
||||
QAction *previewfileAct;
|
||||
QAction *clearQueuedDwlAct;
|
||||
QAction *clearQueueAct;
|
||||
QAction *changePriorityAct;
|
||||
QAction *prioritySlowAct;
|
||||
QAction *priorityMediumAct;
|
||||
QAction *priorityFastAct;
|
||||
QAction *priorityLowAct;
|
||||
QAction *priorityNormalAct;
|
||||
QAction *priorityHighAct;
|
||||
QAction *priorityAutoAct;
|
||||
QAction *chunkRandomAct;
|
||||
QAction *chunkStreamingAct;
|
||||
QAction *detailsfileAct;
|
||||
QAction *pauseAct;
|
||||
QAction *resumeAct;
|
||||
QAction *openfolderAct;
|
||||
QAction *openfileAct;
|
||||
QAction *previewfileAct;
|
||||
QAction *clearQueuedDwlAct;
|
||||
QAction *clearQueueAct;
|
||||
QAction *changePriorityAct;
|
||||
QAction *prioritySlowAct;
|
||||
QAction *priorityMediumAct;
|
||||
QAction *priorityFastAct;
|
||||
QAction *priorityLowAct;
|
||||
QAction *priorityNormalAct;
|
||||
QAction *priorityHighAct;
|
||||
QAction *priorityAutoAct;
|
||||
QAction *chunkRandomAct;
|
||||
QAction *chunkStreamingAct;
|
||||
QAction *detailsfileAct;
|
||||
|
||||
void getIdOfSelectedItems(std::set<QStandardItem *>& items);
|
||||
void getIdOfSelectedItems(std::set<QStandardItem *>& items);
|
||||
bool controlTransferFile(uint32_t flags);
|
||||
void changePriority(int priority);
|
||||
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
|
||||
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
|
||||
|
||||
QTreeView *downloadList;
|
||||
QTreeView *downloadList;
|
||||
|
||||
/** Adds a new action to the toolbar. */
|
||||
void addAction(QAction *action, const char *slot = 0);
|
||||
/** Adds a new action to the toolbar. */
|
||||
void addAction(QAction *action, const char *slot = 0);
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::TransfersDialog ui;
|
||||
/** Qt Designer generated object */
|
||||
Ui::TransfersDialog ui;
|
||||
|
||||
public slots:
|
||||
int addItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining);
|
||||
bool addPeerToItem(int row, const QString& symbol, const QString& name, const QString& coreID, qlonglong fileSize, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining);
|
||||
void delItem(int row);
|
||||
public slots:
|
||||
int addItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining);
|
||||
bool addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status);
|
||||
void delItem(int row);
|
||||
|
||||
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining);
|
||||
void delUploadItem(int row);
|
||||
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining);
|
||||
void delUploadItem(int row);
|
||||
|
||||
void editItem(int row, int column, QVariant data);
|
||||
void updateProgress(int value);
|
||||
void showFileDetails() ;
|
||||
void showFileDetails() ;
|
||||
|
||||
double getProgress(int row, QStandardItemModel *model);
|
||||
double getSpeed(int row, QStandardItemModel *model);
|
||||
QString getFileName(int row, QStandardItemModel *model);
|
||||
QString getStatus(int row, QStandardItemModel *model);
|
||||
QString getID(int row, QStandardItemModel *model);
|
||||
QString getPriority(int row, QStandardItemModel *model);
|
||||
qlonglong getFileSize(int row, QStandardItemModel *model);
|
||||
qlonglong getTransfered(int row, QStandardItemModel *model);
|
||||
qlonglong getRemainingTime(int row, QStandardItemModel *model);
|
||||
double getProgress(int row, QStandardItemModel *model);
|
||||
double getSpeed(int row, QStandardItemModel *model);
|
||||
QString getFileName(int row, QStandardItemModel *model);
|
||||
QString getStatus(int row, QStandardItemModel *model);
|
||||
QString getID(int row, QStandardItemModel *model);
|
||||
QString getPriority(int row, QStandardItemModel *model);
|
||||
qlonglong getFileSize(int row, QStandardItemModel *model);
|
||||
qlonglong getTransfered(int row, QStandardItemModel *model);
|
||||
qlonglong getRemainingTime(int row, QStandardItemModel *model);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -644,7 +644,7 @@ p, li { white-space: pre-wrap; }
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
@ -652,6 +652,15 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -727,8 +736,8 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>596</width>
|
||||
<height>102</height>
|
||||
<width>598</width>
|
||||
<height>99</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
@ -834,8 +843,8 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>578</width>
|
||||
<height>117</height>
|
||||
<width>98</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
@ -850,7 +859,6 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
<include location="../../../../../../../.designer/backup/images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -82,8 +82,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
switch(index.column()) {
|
||||
case USIZE:
|
||||
fileSize = index.data().toLongLong();
|
||||
if(fileSize < 0){
|
||||
temp = "Unknown";
|
||||
if(fileSize <= 0){
|
||||
temp = "";
|
||||
} else {
|
||||
multi = 1.0;
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
@ -101,8 +101,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
break;
|
||||
case UTRANSFERRED:
|
||||
transferred = index.data().toLongLong();
|
||||
if(transferred < 0){
|
||||
temp = "Unknown";
|
||||
if(transferred <= 0){
|
||||
temp = "";
|
||||
} else {
|
||||
multi = 1.0;
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
@ -119,10 +119,14 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case ULSPEED:
|
||||
ulspeed = index.data().toDouble();
|
||||
temp.clear();
|
||||
temp.sprintf("%.2f", ulspeed/1024.);
|
||||
temp += " KB/s";
|
||||
ulspeed = index.data().toDouble();
|
||||
if (ulspeed <= 0) {
|
||||
temp = "";
|
||||
} else {
|
||||
temp.clear();
|
||||
temp.sprintf("%.2f", ulspeed/1024.);
|
||||
temp += " KB/s";
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignRight, temp);
|
||||
break;
|
||||
case UPROGRESS:
|
||||
|
@ -33,6 +33,7 @@
|
||||
#define UPROGRESS 4
|
||||
#define USTATUS 5
|
||||
#define USERNAME 6
|
||||
#define UHASH 7
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user