mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added taskGraphPainterWidet
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1828 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e18167a07a
commit
e26c14573f
@ -159,6 +159,7 @@ HEADERS += rshare.h \
|
||||
gui/ShareManager.h \
|
||||
gui/StatisticDialog.h \
|
||||
gui/SoundManager.h \
|
||||
gui/taskGraphPainterWidget.h \
|
||||
gui/HelpDialog.h \
|
||||
gui/InfoDialog.h \
|
||||
gui/LogoBar.h \
|
||||
@ -376,6 +377,7 @@ SOURCES += main.cpp \
|
||||
gui/StatisticDialog.cpp \
|
||||
gui/SoundManager.cpp \
|
||||
gui/MessagesDialog.cpp \
|
||||
gui/taskGraphPainterWidget.cpp \
|
||||
gui/MessagesPopupDialog.cpp \
|
||||
gui/im_history/IMHistoryKeeper.cpp \
|
||||
gui/im_history/IMHistoryReader.cpp \
|
||||
|
@ -174,9 +174,19 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||
|
||||
connect(upheader, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorUpl(int, Qt::SortOrder)));
|
||||
|
||||
// set default column and sort order for upload
|
||||
_sortColUpl = 0;
|
||||
_sortOrderUpl = Qt::AscendingOrder;
|
||||
// set default column and sort order for upload
|
||||
_sortColUpl = 0;
|
||||
_sortOrderUpl = Qt::AscendingOrder;
|
||||
|
||||
createTaskGraphPainterWidget();
|
||||
|
||||
/*
|
||||
taskGraphDetailLayout = new QHBoxLayout();
|
||||
taskGraphDetailLayout->addWidget(taskGraphWidget);
|
||||
ui.tab_2->setLayout(taskGraphDetailLayout);
|
||||
taskGraphDetailLayout->setSpacing( 0 );
|
||||
taskGraphDetailLayout->setMargin( 0 );*/
|
||||
|
||||
|
||||
|
||||
/* Hide platform specific features */
|
||||
@ -1295,6 +1305,36 @@ void TransfersDialog::saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order
|
||||
_sortOrderUpl = order;
|
||||
}
|
||||
|
||||
void TransfersDialog::createTaskGraphPainterWidget()
|
||||
{
|
||||
taskGraphPainterWidget = new TaskGraphPainterWidget();
|
||||
//taskGraphWidget = new QScrollArea();
|
||||
ui.taskGraphWidget->setWidget(taskGraphPainterWidget);
|
||||
ui.taskGraphWidget->setWidgetResizable(true);
|
||||
ui.taskGraphWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui.taskGraphWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
ui.taskGraphWidget->viewport()->setBackgroundRole(QPalette::NoRole);
|
||||
ui.taskGraphWidget->setFrameStyle(QFrame::NoFrame);
|
||||
ui.taskGraphWidget->setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
/*void TransfersDialog::setTaskGraphPainterWidget (const QModelIndex& index)
|
||||
{
|
||||
Download *dl = (Download *) (index.model ()->
|
||||
data (index.model ()->index (index.row (), DLListDelegate::PTR)).value <quintptr > ());
|
||||
|
||||
if (!dl)
|
||||
return;
|
||||
|
||||
// call takeWidget before setWidget to avoid destruction of the widget
|
||||
QWidget* lastWidget = taskGraphWidget->takeWidget ();
|
||||
|
||||
QWidget* currentWidget = dl->getTaskGraphicWidget ();
|
||||
taskGraphWidget->setWidget (currentWidget);
|
||||
|
||||
taskGraphWidget->show ();
|
||||
}*/
|
||||
|
||||
double TransfersDialog::getProgress(int row, QStandardItemModel *model)
|
||||
{
|
||||
return model->data(model->index(row, PROGRESS), Qt::DisplayRole).toDouble();
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mainpage.h"
|
||||
#include "taskGraphPainterWidget.h"
|
||||
|
||||
#include "ui_TransfersDialog.h"
|
||||
|
||||
|
||||
@ -90,6 +92,8 @@ class TransfersDialog : public MainPage
|
||||
/** save sort indicators for next transfers display */
|
||||
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
|
||||
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
|
||||
|
||||
//void setTaskGraphPainterWidget (const QModelIndex& index);
|
||||
|
||||
signals:
|
||||
void playFiles(QStringList files);
|
||||
@ -112,6 +116,11 @@ class TransfersDialog : public MainPage
|
||||
|
||||
int _sortColDwl, _sortColUpl;
|
||||
Qt::SortOrder _sortOrderDwl, _sortOrderUpl;
|
||||
|
||||
void createTaskGraphPainterWidget();
|
||||
/*QHBoxLayout *taskGraphDetailLayout;
|
||||
QScrollArea *taskGraphWidget;*/
|
||||
TaskGraphPainterWidget *taskGraphPainterWidget;
|
||||
|
||||
|
||||
/** Create the actions on the tray menu or menubar */
|
||||
@ -153,8 +162,8 @@ class TransfersDialog : public MainPage
|
||||
Ui::TransfersDialog ui;
|
||||
|
||||
public slots:
|
||||
int addItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, QString priority, qlonglong completed, qlonglong remaining);
|
||||
bool addPeerToItem(int row, QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
||||
int addItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, QString priority, qlonglong completed, qlonglong remaining);
|
||||
bool addPeerToItem(int row, QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
||||
void delItem(int row);
|
||||
|
||||
int addUploadItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>590</width>
|
||||
<height>314</height>
|
||||
<width>620</width>
|
||||
<height>353</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -502,23 +502,8 @@
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::PreventContextMenu</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -625,71 +610,169 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QTreeView" name="uploadsList">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/up.png</pixmap>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/up.png</normaloff>:/images/up.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Uploads</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTreeView" name="uploadsList">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/blockdevice.png</normaloff>:/images/blockdevice.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>File Chunks</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="taskGraphWidget">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>596</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:9pt; font-weight:600;">Uploads:</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/graph-downloaded.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/graph-downloading.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/graph-notdownload.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Outstanding</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>368</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -63,6 +63,9 @@
|
||||
<file>images/folder16.png</file>
|
||||
<file>images/folderopen.png</file>
|
||||
<file>images/fileopen.png</file>
|
||||
<file>images/graph-downloaded.png</file>
|
||||
<file>images/graph-downloading.png</file>
|
||||
<file>images/graph-notdownload.png</file>
|
||||
<file>images/add-friend24.png</file>
|
||||
<file>images/add-share24.png</file>
|
||||
<file>images/add_24x24.png</file>
|
||||
|
BIN
retroshare-gui/src/gui/images/graph-downloaded.png
Normal file
BIN
retroshare-gui/src/gui/images/graph-downloaded.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 455 B |
BIN
retroshare-gui/src/gui/images/graph-downloading.png
Normal file
BIN
retroshare-gui/src/gui/images/graph-downloading.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 446 B |
BIN
retroshare-gui/src/gui/images/graph-notdownload.png
Normal file
BIN
retroshare-gui/src/gui/images/graph-notdownload.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 391 B |
296
retroshare-gui/src/gui/taskGraphPainterWidget.cpp
Normal file
296
retroshare-gui/src/gui/taskGraphPainterWidget.cpp
Normal file
@ -0,0 +1,296 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2009, defnax
|
||||
* Copyright (c) 2009, lsn752
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QStylePainter>
|
||||
#include <QDebug>
|
||||
#include "taskGraphPainterWidget.h"
|
||||
|
||||
TaskGraphPainterWidget::TaskGraphPainterWidget(QWidget * parent, Qt::WFlags f )
|
||||
{
|
||||
this->fileSize = 0;
|
||||
this->blockSize = 100*1024;
|
||||
notDownloadList.clear();
|
||||
|
||||
QRect TaskGraphRect = geometry();
|
||||
maxWidth = TaskGraphRect.width();
|
||||
pixmap = QPixmap(size());
|
||||
pixmap.fill(this, 0, 0);
|
||||
|
||||
downloadedPixmap.load(":images/graph-downloaded.png");
|
||||
downloadingPixmap.load(":images/graph-downloading.png");
|
||||
notDownloadPixmap.load(":images/graph-notdownload.png");
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
void TaskGraphPainterWidget::setData( qint64 fileSize, qint64 blockSize )
|
||||
{
|
||||
this->fileSize = fileSize;
|
||||
this->blockSize = blockSize;
|
||||
|
||||
int blocks = fileSize/blockSize;
|
||||
if (fileSize%blockSize == 0) blocks--;
|
||||
#ifdef WIN32
|
||||
if (blocks>=5000)
|
||||
{
|
||||
this->blockSize=this->fileSize/5000;
|
||||
}
|
||||
#else
|
||||
if (blocks>=3000)
|
||||
{
|
||||
this->blockSize=this->fileSize/3000;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void TaskGraphPainterWidget::setBlockSizeData( qint64 blockSize )
|
||||
{
|
||||
this->blockSize = blockSize;
|
||||
|
||||
int blocks = fileSize/blockSize;
|
||||
if (fileSize%blockSize == 0) blocks--;
|
||||
#ifdef WIN32
|
||||
if (blocks>=5000)
|
||||
{
|
||||
this->blockSize=this->fileSize/5000;
|
||||
}
|
||||
#else
|
||||
if (blocks>=3000)
|
||||
{
|
||||
this->blockSize=this->fileSize/3000;
|
||||
}
|
||||
#endif
|
||||
refreshAll();
|
||||
}
|
||||
void TaskGraphPainterWidget::setNotDownloadListClear()
|
||||
{
|
||||
notDownloadList.clear();
|
||||
}
|
||||
void TaskGraphPainterWidget::setNotDownloadList( int taskThreadListId, qint64 startPosition, qint64 endPosition)
|
||||
{
|
||||
NotDownload notDownload;
|
||||
notDownload.taskThreadListId = taskThreadListId;
|
||||
notDownload.startPosition = startPosition;
|
||||
notDownload.endPosition = endPosition;
|
||||
notDownloadList.append(notDownload);
|
||||
}
|
||||
void TaskGraphPainterWidget::newReceivedListClear()
|
||||
{
|
||||
newTaskReceivedList.clear();
|
||||
}
|
||||
void TaskGraphPainterWidget::setNewReceived(int taskThreadListId, QList <qint64> newReceivedList)
|
||||
{
|
||||
NewReceived newReceived;
|
||||
newReceived.taskThreadListId = taskThreadListId;
|
||||
newReceived.newThreadReceivedList = newReceivedList;
|
||||
newTaskReceivedList.append(newReceived);
|
||||
}
|
||||
void TaskGraphPainterWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QRect TaskGraphRect = geometry();
|
||||
maxWidth = TaskGraphRect.width();
|
||||
|
||||
refreshAll();
|
||||
}
|
||||
void TaskGraphPainterWidget::refreshAll()
|
||||
{
|
||||
int blocks = fileSize/blockSize;
|
||||
if (fileSize%blockSize >0) blocks++;
|
||||
int columns = maxWidth/13;
|
||||
y = blocks/columns*13;
|
||||
x = blocks%columns*13;
|
||||
maxHeight = y+15;
|
||||
pixmap = QPixmap(size());
|
||||
pixmap.fill(this, 0, 0);
|
||||
pixmap = QPixmap(maxWidth, maxHeight);
|
||||
pixmap.fill(this, 0, 0);
|
||||
setFixedHeight(maxHeight);
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.initFrom(this);
|
||||
if (fileSize>0)
|
||||
{
|
||||
drawDownloaded(&painter);
|
||||
drawNotDownload(&painter);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawNoSizeFile(&painter);
|
||||
}
|
||||
|
||||
pixmap2 = pixmap;
|
||||
update();
|
||||
}
|
||||
void TaskGraphPainterWidget::refreshPixmap()
|
||||
{
|
||||
pixmap2 = pixmap;
|
||||
QPainter painter(&pixmap2);
|
||||
|
||||
drawNewReceivedData(&painter);
|
||||
|
||||
update();
|
||||
}
|
||||
void TaskGraphPainterWidget::refreshThreadLastBlock(int newThreadReceivedListId)
|
||||
{
|
||||
pixmap2 = pixmap;
|
||||
QPainter painter(&pixmap2);
|
||||
|
||||
drawThreadLastBlock(&painter, newThreadReceivedListId);
|
||||
|
||||
repaint ();
|
||||
}
|
||||
void TaskGraphPainterWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QStylePainter painter(this);
|
||||
|
||||
painter.drawPixmap(0, 0, pixmap2);
|
||||
pixmap = pixmap2;
|
||||
}
|
||||
void TaskGraphPainterWidget::drawNotDownload(QPainter *painter)
|
||||
{
|
||||
if (this->fileSize == 0) return;
|
||||
int columns = maxWidth/13;
|
||||
int blocks = fileSize/blockSize;
|
||||
if (fileSize%blockSize == 0) blocks--;
|
||||
|
||||
QRectF source(0.0, 0.0, 12.0, 12.0);
|
||||
for (int taskThreadListId=0;taskThreadListId<notDownloadList.size();taskThreadListId++)
|
||||
{
|
||||
qint64 startPosition = notDownloadList.at(taskThreadListId).startPosition;
|
||||
qint64 endPosition = notDownloadList.at(taskThreadListId).endPosition;
|
||||
int startPositionBlocks = startPosition/blockSize;
|
||||
if (startPosition%blockSize > 0) startPositionBlocks++;
|
||||
int endPositionBlocks = endPosition/blockSize;
|
||||
if (endPositionBlocks != blocks) endPositionBlocks--;
|
||||
|
||||
for (int block=startPositionBlocks;block<=endPositionBlocks;block++)
|
||||
{
|
||||
y = block/columns*13;
|
||||
x = block%columns*13;
|
||||
QRectF target(x, y, 12.0, 12.0);
|
||||
painter->drawPixmap(target, notDownloadPixmap, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
void TaskGraphPainterWidget::drawDownloaded(QPainter *painter)
|
||||
{
|
||||
x=0;
|
||||
y=0;
|
||||
int blocks = fileSize/blockSize;
|
||||
if (fileSize%blockSize == 0) blocks--;
|
||||
QRectF source(0.0, 0.0, 12.0, 12.0);
|
||||
|
||||
for (int i=0;i<=blocks;i++)
|
||||
{
|
||||
if (x > maxWidth - 13)
|
||||
{
|
||||
x = 0;
|
||||
y += 13;
|
||||
}
|
||||
QRectF target(x, y, 12.0, 12.0);
|
||||
painter->drawPixmap(target, downloadedPixmap, source);
|
||||
x += 13;
|
||||
}
|
||||
maxHeight = y+15;
|
||||
}
|
||||
void TaskGraphPainterWidget::drawNoSizeFile(QPainter *painter)
|
||||
{
|
||||
x=0;
|
||||
y=0;
|
||||
QList <qint64> newThreadReceivedList;
|
||||
if (newTaskReceivedList.isEmpty()) return;
|
||||
newThreadReceivedList = newTaskReceivedList.at(0).newThreadReceivedList;
|
||||
if (newThreadReceivedList.isEmpty()) return;
|
||||
qint64 startPosition = newThreadReceivedList.at(newThreadReceivedList.size()-1);
|
||||
int blocks = startPosition/blockSize;
|
||||
if (fileSize%blockSize == 0) blocks--;
|
||||
QRectF source(0.0, 0.0, 12.0, 12.0);
|
||||
|
||||
for (int i=0;i<=blocks;i++)
|
||||
{
|
||||
if (x > maxWidth - 13)
|
||||
{
|
||||
x = 0;
|
||||
y += 13;
|
||||
}
|
||||
QRectF target(x, y, 12.0, 12.0);
|
||||
painter->drawPixmap(target, downloadedPixmap, source);
|
||||
x += 13;
|
||||
}
|
||||
|
||||
maxHeight = y+15;
|
||||
}
|
||||
void TaskGraphPainterWidget::drawNewReceivedData(QPainter *painter)
|
||||
{
|
||||
for (int newTaskReceivedListId=0;newTaskReceivedListId<newTaskReceivedList.size();newTaskReceivedListId++)
|
||||
{
|
||||
QList <qint64> newThreadReceivedList;
|
||||
newThreadReceivedList = newTaskReceivedList.at(newTaskReceivedListId).newThreadReceivedList;
|
||||
if (newThreadReceivedList.size() < 1) continue;
|
||||
|
||||
int columns = maxWidth/13;
|
||||
QRectF source(0.0, 0.0, 12.0, 12.0);
|
||||
|
||||
qint64 startPosition = newThreadReceivedList.at(0);
|
||||
qint64 endPosition = newThreadReceivedList.at(newThreadReceivedList.size()-1);
|
||||
int startPositionBlocks = startPosition/blockSize;
|
||||
int endPositionBlocks = endPosition/blockSize;
|
||||
if (endPosition%blockSize == 0) endPositionBlocks--;
|
||||
|
||||
for (int block=startPositionBlocks;block<=endPositionBlocks;block++)
|
||||
{
|
||||
y = block/columns*13;
|
||||
x = block%columns*13;
|
||||
QRectF target(x, y, 12.0, 12.0);
|
||||
if (block==endPositionBlocks)
|
||||
{
|
||||
if (newTaskReceivedList.at(newTaskReceivedListId).taskThreadListId>=0)
|
||||
painter->drawPixmap(target, downloadingPixmap, source);
|
||||
else
|
||||
painter->drawPixmap(target, downloadedPixmap, source);
|
||||
}
|
||||
else
|
||||
painter->drawPixmap(target, downloadedPixmap, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
void TaskGraphPainterWidget::drawThreadLastBlock(QPainter *painter, int newThreadReceivedListId)
|
||||
{
|
||||
QList <qint64> newThreadReceivedList;
|
||||
newThreadReceivedList = newTaskReceivedList.at(newThreadReceivedListId).newThreadReceivedList;
|
||||
if (newThreadReceivedList.size() < 1) return;
|
||||
|
||||
int columns = maxWidth/13;
|
||||
QRectF source(0.0, 0.0, 12.0, 12.0);
|
||||
|
||||
qint64 startPosition = newThreadReceivedList.at(0);
|
||||
qint64 endPosition = newThreadReceivedList.at(newThreadReceivedList.size()-1);
|
||||
int startPositionBlocks = startPosition/blockSize;
|
||||
int endPositionBlocks = endPosition/blockSize;
|
||||
if (endPosition%blockSize == 0) endPositionBlocks--;
|
||||
|
||||
for (int block=startPositionBlocks;block<=endPositionBlocks;block++)
|
||||
{
|
||||
y = block/columns*13;
|
||||
x = block%columns*13;
|
||||
QRectF target(x, y, 12.0, 12.0);
|
||||
painter->drawPixmap(target, downloadedPixmap, source);
|
||||
}
|
||||
}
|
88
retroshare-gui/src/gui/taskGraphPainterWidget.h
Normal file
88
retroshare-gui/src/gui/taskGraphPainterWidget.h
Normal file
@ -0,0 +1,88 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2009, defnax
|
||||
* Copyright (c) 2009, lsn752
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef __TASKGRAPHPAINTERWIDGET_H__
|
||||
#define __TASKGRAPHPAINTERWIDGET_H__
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QBitmap>
|
||||
|
||||
class TaskGraphPainterWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskGraphPainterWidget(QWidget * parent = 0, Qt::WFlags f = 0 );
|
||||
|
||||
void setData( qint64 fileSize, qint64 blockSize );
|
||||
void setBlockSizeData( qint64 blockSize );
|
||||
void setNotDownloadListClear();
|
||||
void setNotDownloadList( int taskThreadListId, qint64 startPosition, qint64 endPosition);
|
||||
void newReceivedListClear();
|
||||
void setNewReceived(int taskThreadListId, QList <qint64> newReceivedList);
|
||||
void refreshAll();
|
||||
void refreshPixmap();
|
||||
void refreshThreadLastBlock(int newThreadReceivedListId);
|
||||
|
||||
qint64 fileSize;
|
||||
qint64 blockSize;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
void drawNotDownload(QPainter *painter);
|
||||
void drawDownloaded(QPainter *painter);
|
||||
void drawNoSizeFile(QPainter *painter);
|
||||
void drawNewReceivedData(QPainter *painter);
|
||||
void drawThreadLastBlock(QPainter *painter, int newThreadReceivedListId);
|
||||
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int maxWidth;
|
||||
int maxHeight;
|
||||
QPixmap pixmap;
|
||||
QPixmap pixmap2;
|
||||
QPixmap downloadedPixmap;
|
||||
QPixmap downloadingPixmap;
|
||||
QPixmap notDownloadPixmap;
|
||||
int taskThreadListId;
|
||||
struct _NotDownload
|
||||
{
|
||||
int taskThreadListId;
|
||||
qint64 startPosition;
|
||||
qint64 endPosition;
|
||||
};
|
||||
typedef struct _NotDownload NotDownload;
|
||||
QList <NotDownload> notDownloadList;
|
||||
struct _NewReceived
|
||||
{
|
||||
int taskThreadListId;
|
||||
QList <qint64> newThreadReceivedList;
|
||||
};
|
||||
typedef struct _NewReceived NewReceived;
|
||||
QList <NewReceived> newTaskReceivedList;
|
||||
};
|
||||
#endif // __TASKGRAPHPAINTERWIDGET_H__
|
Loading…
Reference in New Issue
Block a user