Make statusbar selection time tab context aware

This commit is contained in:
Mark Watkins 2011-12-27 05:25:17 +10:00
parent 168b8e9843
commit 8b4983a06f
4 changed files with 47 additions and 0 deletions

View File

@ -2020,6 +2020,29 @@ void gGraphView::scrollbarValueChanged(int val)
redraw(); // do this on a timer?
}
}
void gGraphView::selectionTime()
{
qint64 xx=m_maxx - m_minx;
double d=xx/86400000L;
int h=xx/3600000L;
int m=(xx/60000) % 60;
int s=(xx/1000) % 60;
int ms(xx % 1000);
QString str;
if (d>1) {
/*QDate d1=QDateTime::fromTime_t(m_minx/1000).toUTC().date();
QDate d2=QDateTime::fromTime_t(m_maxx/1000).toUTC().date();
d=PROFILE.countDays(MT_CPAP,d1,d2); */
str.sprintf("%1.0f days",ceil(d));
} else {
str.sprintf("%02i:%02i:%02i:%03i",h,m,s,ms);
}
if (qstatus2) {
qstatus2->setText(str);
}
}
void gGraphView::ResetBounds(bool refresh) //short group)
{
Q_UNUSED(refresh)

View File

@ -765,6 +765,9 @@ public:
gToolTip * m_tooltip;
QTimer * timer;
//! \brief Show the current selection time in the statusbar area
void selectionTime();
//! \brief Add the Text information to the Text Drawing Queue (called by gGraphs renderText method)
void AddTextQue(QString & text, short x, short y, float angle=0.0, QColor color=Qt::black, QFont * font=defaultfont);

View File

@ -162,6 +162,7 @@ MainWindow::MainWindow(QWidget *parent) :
QString loadingtxt="<HTML><body style='text-align: center; vertical-align: center'><table width='100%' height='100%'><tr><td align=center><h1>Loading...</h1></td></tr></table></body></HTML>";
ui->summaryView->setHtml(loadingtxt);
on_tabWidget_currentChanged(0);
}
extern MainWindow *mainwin;
MainWindow::~MainWindow()
@ -2110,3 +2111,21 @@ void MainWindow::LinkHovered(const QString & link, const QString & title, const
Q_UNUSED(textContent);
ui->statusbar->showMessage(link);
}
void MainWindow::on_tabWidget_currentChanged(int index)
{
Q_UNUSED(index);
QWidget *widget=ui->tabWidget->currentWidget();
if ((widget==ui->summaryTab) || (widget==ui->helpTab)) {
qstatus2->setVisible(false);
} else if (widget==daily) {
qstatus2->setVisible(true);
daily->graphView()->selectionTime();
} else if (widget==overview) {
qstatus2->setVisible(true);
overview->graphView()->selectionTime();
} else if (widget==oximetry) {
qstatus2->setVisible(true);
oximetry->graphView()->selectionTime();
}
}

View File

@ -267,6 +267,8 @@ private slots:
//! \brief Display Help WebView Link in statusbar.
void LinkHovered(const QString & link, const QString & title, const QString & textContent);
void on_tabWidget_currentChanged(int index);
private:
Ui::MainWindow *ui;