[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/soc-iconcache/kpc_stats_viz
From: Rivo Laks <rivolaks () hot ! ee>
Date: 2007-08-31 19:53:23
Message-ID: 1188590003.693219.21625.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 707027 by rivol:
- Ignore destruct events
- Draw a line with time info where mouse cursor is
- Better categorization for different event types
M +30 -5 dataviz.cpp
M +2 -0 dataviz.h
--- branches/work/soc-iconcache/kpc_stats_viz/dataviz.cpp #707026:707027
@@ -25,6 +25,7 @@
#include <QPen>
#include <QFile>
#include <QTextStream>
+#include <QMouseEvent>
#include <kglobal.h>
#include <kstandarddirs.h>
@@ -36,12 +37,20 @@
DataViz::DataViz(QWidget* parent) : QWidget(parent)
{
+ mousePos = -1;
+ setMouseTracking(true);
}
DataViz::~DataViz()
{
}
+void DataViz::mouseMoveEvent(QMouseEvent* event)
+{
+ mousePos = event->pos().x();
+ update();
+}
+
void DataViz::load(const QString& name)
{
// FIXME: mem leak
@@ -87,6 +96,7 @@
stream >> op.elapsed;
// kDebug() << " elapsed is " << op.elapsed << endl;
+ if (op.op != "destruct") {
QString appId = QString("%1-%2").arg(appname).arg(apppid);
// kDebug() << "AppId:" << appId << endl;
AppData* app = appmap[appId];
@@ -98,6 +108,7 @@
apps.append(app);
}
app->ops.append(op);
+ }
// if (++counter >= 8) {
// break;
@@ -161,12 +172,15 @@
// Draw ops
p.setPen(QColor(255, 0, 0));
p.setBrush(QColor(255, 0, 0));
+ float third = (rowh - 4) / 3;
+ QMap<QString, float> posmap;
+ posmap["find"] = third;
+ posmap["insert"] = 2*third;
+
foreach (OpData op, app->ops) {
- if (op.op == "find") {
- p.drawLine(QPointF(op.start / 1000000.0 * sec, y), QPointF(op.start \
/ 1000000.0 * sec, y+rowh/2-2));
- } else {
- p.drawLine(QPointF(op.start / 1000000.0 * sec, y+rowh/2-2), \
QPointF(op.start / 1000000.0 * sec, y+rowh-4));
- }
+ float start = op.start / 1000000.0 * sec;
+ float end = (op.start + op.elapsed) / 1000000.0 * sec;
+ p.drawRect(QRectF(QPointF(start, y+ posmap[op.op]), QPointF(end, \
y+posmap[op.op]+third))); }
// Draw app name
@@ -178,6 +192,17 @@
}
+ // Print mouse line
+ if (mousePos >= 0 && mousePos <= (width() - 150)) {
+ p.setPen(QColor(192, 128, 128, 128));
+ p.drawLine(mousePos, 0, mousePos, height());
+ QString timestr = QString("%1").arg(mousePos / (float)(width() - 150) * \
(totalelapsed / 1000000.0), 0, 'f', 3); + if (mousePos < width() / 2) {
+ p.drawText(mousePos + 3, 12, timestr);
+ } else {
+ p.drawText(mousePos - 3 - p.fontMetrics().width(timestr), 12, timestr);
+ }
+ }
}
--- branches/work/soc-iconcache/kpc_stats_viz/dataviz.h #707026:707027
@@ -36,6 +36,7 @@
protected:
virtual void paintEvent(QPaintEvent* event);
+ virtual void mouseMoveEvent(QMouseEvent* event);
public:
struct OpData
@@ -62,6 +63,7 @@
QList<AppData*> apps;
QHash<QString, AppData*> appmap;
int totalelapsed;
+ int mousePos;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic