mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-14 03:52:39 -04:00
added scale and wheel-event resizing to RSGraphWidget
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8062 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
562eeaaae8
commit
3f116e0e73
2 changed files with 77 additions and 57 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QWheelEvent>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||||
|
@ -482,13 +483,6 @@ void RSGraphWidget::paintTotals()
|
||||||
/* On Mac, we don't need vertical spacing between the text rows. */
|
/* On Mac, we don't need vertical spacing between the text rows. */
|
||||||
rowHeight += 5;
|
rowHeight += 5;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// /* If total received is selected */
|
|
||||||
// y = rowHeight;
|
|
||||||
// _painter->setPen(RSDHT_COLOR);
|
|
||||||
// _painter->drawText(x, y,
|
|
||||||
// tr("RetroShare users in DHT: ")+
|
|
||||||
// " ("+tr("%1").arg(_rsDHT->first(), 0, 'f', 0)+")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a formatted string with the correct size suffix. */
|
/** Returns a formatted string with the correct size suffix. */
|
||||||
|
@ -539,6 +533,31 @@ void RSGraphWidget::paintScale()
|
||||||
|
|
||||||
/* Draw vertical separator */
|
/* Draw vertical separator */
|
||||||
_painter->drawLine(SCALE_WIDTH, top, SCALE_WIDTH, bottom);
|
_painter->drawLine(SCALE_WIDTH, top, SCALE_WIDTH, bottom);
|
||||||
|
|
||||||
|
// draw time below the graph
|
||||||
|
|
||||||
|
static const int npix = 100 ;
|
||||||
|
|
||||||
|
for(int i=_rec.width();i>SCALE_WIDTH;i-=npix)
|
||||||
|
{
|
||||||
|
pos = bottom - FONT_SIZE;
|
||||||
|
|
||||||
|
int seconds = (_rec.width()-i)/_time_scale ; // pixels / (pixels per second) => seconds
|
||||||
|
QString text = QString::number(seconds)+ " secs";
|
||||||
|
|
||||||
|
_painter->setPen(SCALE_COLOR);
|
||||||
|
_painter->drawText(QPointF(i, _rec.height()-0.5*FONT_SIZE), text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSGraphWidget::wheelEvent(QWheelEvent *e)
|
||||||
|
{
|
||||||
|
if(e->delta() > 0)
|
||||||
|
_time_scale *= 1.1 ;
|
||||||
|
else
|
||||||
|
_time_scale /= 1.1 ;
|
||||||
|
|
||||||
|
update() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSGraphWidget::paintLegend()
|
void RSGraphWidget::paintLegend()
|
||||||
|
|
|
@ -159,6 +159,7 @@ class RSGraphWidget: public QFrame
|
||||||
protected slots:
|
protected slots:
|
||||||
void updateIfPossible() ;
|
void updateIfPossible() ;
|
||||||
|
|
||||||
|
virtual void wheelEvent(QWheelEvent *e);
|
||||||
private:
|
private:
|
||||||
/** Gets the width of the desktop, the max # of points. */
|
/** Gets the width of the desktop, the max # of points. */
|
||||||
int getNumPoints();
|
int getNumPoints();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue