Inserted Permanent QStatusBar Widget for selection time display

This commit is contained in:
Mark Watkins 2011-07-19 15:05:02 +10:00
parent bbc0b0e6d4
commit e44f7bb6fb
3 changed files with 41 additions and 6 deletions

View File

@ -6,13 +6,13 @@
#include <math.h>
#include <QDebug>
#include <QStatusBar>
#include <QLabel>
#include <QMouseEvent>
#include "SleepLib/profiles.h"
#include "graphwindow.h"
#include "Graphs/gTitle.h"
extern QStatusBar *qstatusbar;
extern QLabel *qstatus2;
gGraphWindow::gGraphWindow(QWidget *parent, const QString & title, QGLWidget * shared,Qt::WindowFlags f)
: QGLWidget(parent,shared, f )
@ -248,6 +248,28 @@ void gGraphWindow::ZoomX(double mult,int origin_px)
min=max-q;
}
SetXBounds(min,max);
updateSelectionTime();
}
void gGraphWindow::updateSelectionTime()
{
double f;
f=max_x-min_x;
int hours,minutes,seconds;
hours=int(f*24.0);
minutes=int(f*60.0) % 60;
seconds=int(f*3600.0) % 60;
QString s;
if (f>1) {
s.sprintf("%.1f days",f);
} else if (f>(1.0/(24.0*12.0))) {
s.sprintf("%02i:%02i:%02i",hours,minutes,seconds);
} else {
int milli=int(f*3600000.0) % 1000;
s.sprintf("%02i:%02i:%02i:%04i",hours,minutes,seconds,milli);
}
qstatus2->setText(s);
}
gGraphWindow *LastGraphLDown=NULL;
@ -382,7 +404,7 @@ void gGraphWindow::mouseMoveEvent(QMouseEvent * event)
int milli=int(f*3600000.0) % 1000;
s.sprintf("%02i:%02i:%02i:%04i",hours,minutes,seconds,milli);
}
qstatusbar->showMessage(s,3000);
qstatus2->setText(s);
m_mouseRBlast=m_mouseRBrect;
m_mouseRBrect=r;
@ -660,7 +682,7 @@ void gGraphWindow::OnMouseLeftRelease(QMouseEvent * event)
if (splitter && currentWidget && LastGraphLDown) {
if (LastGraphLDown!=currentWidget) {
int newidx=splitter->indexOf(currentWidget);
int idx=splitter->indexOf(LastGraphLDown);
//int idx=splitter->indexOf(LastGraphLDown);
splitter->insertWidget(newidx,LastGraphLDown);
return;
}

View File

@ -146,6 +146,8 @@ public:
void SetSplitter(QSplitter *s) { splitter=s; }
bool isDraggingGraph() { return m_dragGraph; }
protected:
void updateSelectionTime();
void initializeGL();
QSplitter *splitter;
list<gGraphWindow *>link_zoom;

View File

@ -19,6 +19,7 @@
QProgressBar *qprogress;
QLabel *qstatus;
QLabel *qstatus2;
QStatusBar *qstatusbar;
void MainWindow::Log(QString s)
@ -53,13 +54,23 @@ MainWindow::MainWindow(QWidget *parent) :
qstatusbar=ui->statusbar;
qprogress=new QProgressBar(this);
qprogress->setMaximum(100);
qstatus2=new QLabel("Welcome",this);
qstatus2->setFrameStyle(QFrame::Raised);
qstatus2->setFrameShadow(QFrame::Sunken);
qstatus2->setFrameShape(QFrame::Box);
//qstatus2->setMinimumWidth(100);
qstatus2->setMaximumWidth(100);
qstatus2->setAlignment(Qt::AlignRight |Qt::AlignVCenter);
qstatus=new QLabel("",this);
qprogress->hide();
ui->statusbar->addPermanentWidget(qstatus);
ui->statusbar->addPermanentWidget(qprogress);
ui->statusbar->setMinimumWidth(200);
ui->statusbar->addPermanentWidget(qstatus2,0);
ui->statusbar->addPermanentWidget(qstatus,0);
ui->statusbar->addPermanentWidget(qprogress,10);
daily=NULL;
overview=NULL;
Profiles::Scan();
qstatusbar->showMessage("Foo Foo Foo",10);
//loader_progress->Show();