2008-02-07 11:36:30 -05:00
|
|
|
/*
|
|
|
|
* xProgressBar: A custom progress bar for Qt 4.
|
|
|
|
* Author: xEsk (Xesc & Technology 2008)
|
|
|
|
*
|
|
|
|
* Changelog:
|
|
|
|
*
|
|
|
|
* v1.0:
|
|
|
|
* -----
|
|
|
|
* - First release
|
2009-07-24 18:39:34 -04:00
|
|
|
*
|
|
|
|
* 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.
|
2008-02-07 11:36:30 -05:00
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#ifndef XPROGRESSBAR_H
|
|
|
|
#define XPROGRESSBAR_H
|
|
|
|
//
|
2010-01-11 11:00:42 -05:00
|
|
|
#include <stdint.h>
|
2008-02-07 11:36:30 -05:00
|
|
|
#include <QRect>
|
|
|
|
#include <QColor>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QLinearGradient>
|
|
|
|
#include <QLocale>
|
2010-01-11 11:00:42 -05:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rstypes.h>
|
2010-01-11 11:00:42 -05:00
|
|
|
|
|
|
|
class FileProgressInfo
|
|
|
|
{
|
|
|
|
public:
|
2010-01-26 18:25:00 -05:00
|
|
|
typedef enum { DOWNLOAD_LINE,UPLOAD_LINE,DOWNLOAD_SOURCE } LineType ;
|
|
|
|
|
|
|
|
LineType type ;
|
2010-01-11 11:00:42 -05:00
|
|
|
CompressedChunkMap cmap ;
|
|
|
|
float progress ;
|
2010-02-04 16:08:53 -05:00
|
|
|
uint32_t nb_chunks ;
|
2010-10-04 16:15:52 -04:00
|
|
|
|
2010-12-26 05:58:02 -05:00
|
|
|
std::vector<uint32_t> chunks_in_progress ;
|
2012-06-19 17:36:10 -04:00
|
|
|
std::vector<uint32_t> chunks_in_checking ;
|
2010-12-26 05:58:02 -05:00
|
|
|
|
2010-10-04 16:15:52 -04:00
|
|
|
bool operator<(const FileProgressInfo &other) const;
|
2011-02-07 19:41:13 -05:00
|
|
|
bool operator>(const FileProgressInfo &other) const;
|
2010-01-11 11:00:42 -05:00
|
|
|
};
|
2008-02-07 11:36:30 -05:00
|
|
|
//
|
|
|
|
class xProgressBar : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
// progress vlues
|
|
|
|
int schemaIndex;
|
|
|
|
bool displayText;
|
|
|
|
int vSpan;
|
|
|
|
int hSpan;
|
|
|
|
// painter config
|
|
|
|
QRect rect;
|
|
|
|
QPainter *painter;
|
|
|
|
// text color
|
|
|
|
QColor textColor;
|
|
|
|
// progress colors
|
|
|
|
QColor backgroundBorderColor;
|
|
|
|
QColor backgroundColor;
|
|
|
|
QColor gradBorderColor;
|
|
|
|
QColor gradColor1;
|
|
|
|
QColor gradColor2;
|
|
|
|
// configure the color
|
|
|
|
void setColor();
|
2010-01-11 11:00:42 -05:00
|
|
|
|
2010-02-04 16:08:53 -05:00
|
|
|
const FileProgressInfo& _pinfo ;
|
2008-02-07 11:36:30 -05:00
|
|
|
public:
|
2010-02-04 16:08:53 -05:00
|
|
|
xProgressBar(const FileProgressInfo& pinfo,QRect rect, QPainter *painter, int schemaIndex = 0);
|
2010-01-11 11:00:42 -05:00
|
|
|
|
2008-02-07 11:36:30 -05:00
|
|
|
void paint();
|
2010-02-04 16:08:53 -05:00
|
|
|
|
2012-12-16 11:10:43 -05:00
|
|
|
void overPaintSelectedChunks(const std::vector<uint32_t>& chunks,const QColor& gradColor_a1,const QColor& gradColor_a2, int width,uint32_t ss) const ;
|
2009-07-24 18:39:34 -04:00
|
|
|
void setColorSchema(const int value);
|
2008-02-07 11:36:30 -05:00
|
|
|
void setDisplayText(const bool display);
|
|
|
|
void setVerticalSpan(const int value);
|
|
|
|
void setHorizontalSpan(const int value);
|
|
|
|
};
|
|
|
|
#endif
|