--- qps-1.10.16/infobar-original.cpp 2011-07-17 08:20:06.000000000 -0300
+++ qps-1.10.16/infobar.cpp 2015-12-18 03:13:46.378411055 -0300
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
+#include <string>
#include "infobar.h"
#include "proc.h"
@@ -44,6 +45,16 @@
};
VCursor vcursor;
+// Convert epoch time to HH:mm:ss
+const std::string formatTime(time_t epoch_seconds) {
+ struct tm tstruct;
+ char buf[9];
+ tstruct = *localtime(&epoch_seconds);
+ strftime(buf, sizeof(buf), "%T", &tstruct);
+
+ return buf;
+}
+
//DEL
void Infobar::hideEvent( QHideEvent * event )
{
@@ -759,7 +770,7 @@
} */
-// TODO: 1.sort 2. time(?)
+// TODO: 1.sort
QString doHistory(SysHistory *sysh)
{
QString str;
@@ -768,7 +779,8 @@
char buf[128];
//sprintf(buf,"miniHistory /* %.02f%%",sysh->load_cpu*100);
- sprintf(buf,"miniHistory CPU");
+ const std::string saved_time = formatTime(sysh->time);
+ sprintf(buf,"miniHistory CPU [%s]", saved_time.c_str());
str+=QString::fromAscii(buf);
foreach(p,sysh->procs)
@@ -849,7 +861,7 @@
update(p.x()-5 -rel_x,0,p.x()+5 -rel_x,height()); // only Vcursor update
}
-// TODO: 1.sort 2. time
+// TODO: 1.sort
QString IO_Graph::doHistoryTXT(SysHistory *sysh)
{
QString str;
@@ -858,7 +870,8 @@
char buf[64],mem_str[64];
//sprintf(buf,"miniHistory /* %.02f%%",sysh->load_cpu*100);
- sprintf(buf,"miniHistory IO");
+ const std::string saved_time = formatTime(sysh->time);
+ sprintf(buf,"miniHistory IO [%s]", saved_time.c_str());
str+=QString::fromAscii(buf);
foreach(p,sysh->procs)
The patch is for QT4 version because I do not have QT5 due to it being not quite stable in my distribution but it should not be difficult to adapt the code to your fork of the program.
By the way, my knowledge of C and C++ are quite limited so do not rule out that there are more "clean" ways to do the same.
PS: If you need to clarify, the patch is released under public domain. ;-)