Graph Hide... Killed the spacer that allows extra resize temporarily

This commit is contained in:
Mark Watkins 2011-07-30 14:54:22 +10:00
parent 9840976d8e
commit 4db3d773be
4 changed files with 77 additions and 18 deletions

View File

@ -39,9 +39,8 @@ void MyScrollArea::scrollContentsBy(int dx, int dy)
{
}
Daily::Daily(QWidget *parent,QGLWidget * shared) :
QWidget(parent),
ui(new Ui::Daily)
Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
:QWidget(parent),mainwin(mw), ui(new Ui::Daily)
{
ui->setupUi(this);
@ -271,13 +270,13 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) :
AddGraph(PULSE);
// AddGraph(SPO2);
spacer=new QWidget(gSplitter);
// spacer=new QWidget(gSplitter);
//spacer->setMaximumHeight(default_height);
gSplitter->addWidget(spacer);
i=gSplitter->indexOf(spacer);
gSplitter->setStretchFactor(i,1);
i=gSplitter->indexOf(FRW);
gSplitter->setStretchFactor(i,15);
//gSplitter->addWidget(spacer);
//i=gSplitter->indexOf(spacer);
//gSplitter->setStretchFactor(i,1);
//i=gSplitter->indexOf(FRW);
//gSplitter->setStretchFactor(i,15);
//gSplitter->refresh();
@ -297,6 +296,19 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) :
ui->calendar->setWeekdayTextFormat(Qt::Sunday, format);
ui->tabWidget->setCurrentWidget(ui->details);
if (mainwin) {
show_graph_menu=mainwin->CreateMenu("Graphs");
show_graph_menu->clear();
for (unsigned i=0;i<Graphs.size();i++) {
QAction * action=show_graph_menu->addAction(Graphs[i]->Title(),NULL,NULL,0);
action->setCheckable(true);
action->setChecked(true);
connect(action, SIGNAL(triggered()), this, SLOT(ShowHideGraphs()));
GraphAction.push_back(action);
}
} else show_graph_menu=NULL;
}
Daily::~Daily()
@ -453,7 +465,30 @@ void Daily::ResetGraphLayout()
gSplitter->setSizes(splitter_sizes);
}
void Daily::ShowHideGraphs()
{
int vis=0;
for (unsigned i=0;i<Graphs.size();i++) {
if (Graphs[i]->isEmpty()) {
GraphAction[i]->setVisible(false);
Graphs[i]->hide();
} else {
Graphs[i]->ResetBounds();
GraphAction[i]->setVisible(true);
if (GraphAction[i]->isChecked()) {
Graphs[i]->show();
} else {
Graphs[i]->hide();
}
vis++;
}
}
//gSplitter->setMinimumHeight(vis*default_height);
gSplitter->layout();
gSplitter->update();
RedrawGraphs();
}
void Daily::Load(QDate date)
{
static Day * lastcpapday=NULL;
@ -482,30 +517,38 @@ void Daily::Load(QDate date)
UpdateEventsTree(ui->treeWidget,cpap);
if (!cpap && !oxi) {
gSplitter->setMinimumHeight(0);
//gSplitter->setMinimumHeight(0);
NoData->setText(tr("No data for ")+date.toString(Qt::SystemLocaleLongDate));
NoData->show();
for (unsigned i=0;i<Graphs.size();i++) {
GraphAction[i]->setVisible(false);
Graphs[i]->hide();
}
spacer->hide();
//spacer->hide();
} else {
NoData->hide();
int vis=1;
int vis=0;
for (unsigned i=0;i<Graphs.size();i++) {
if (Graphs[i]->isEmpty()) {
GraphAction[i]->setVisible(false);
Graphs[i]->hide();
} else {
Graphs[i]->ResetBounds();
GraphAction[i]->setVisible(true);
if (GraphAction[i]->isChecked()) {
Graphs[i]->show();
} else {
Graphs[i]->hide();
}
Graphs[i]->show();
vis++;
}
}
gSplitter->setMinimumHeight(vis*default_height);
gSplitter->layout();
//gSplitter->setMinimumHeight(vis*default_height);
spacer->show();
//spacer->show();
}
gSplitter->update();

11
daily.h
View File

@ -9,6 +9,8 @@
#include <QScrollArea>
#include <QMenu>
#include <QAction>
#include <QSplitter>
#include <QWidget>
#include <QTreeWidget>
@ -17,6 +19,7 @@
#include <QWebPluginFactory>
#include <SleepLib/profiles.h>
#include <Graphs/graphwindow.h>
#include "mainwindow.h"
//#include <Graphs/graphdata.h>
#include "Graphs/gLineChart.h"
#include <Graphs/gFlagsLine.h>
@ -35,13 +38,13 @@ protected:
Daily *daily;
};
class MainWindow;
class Daily : public QWidget
{
Q_OBJECT
public:
explicit Daily(QWidget *parent,QGLWidget *shared=NULL);
explicit Daily(QWidget *parent,QGLWidget *shared,MainWindow *mw);
~Daily();
void ReloadGraphs();
void RedrawGraphs();
@ -61,6 +64,7 @@ private slots:
void on_treeWidget_itemSelectionChanged();
void on_JournalNotesUnderline_clicked();
void ShowHideGraphs();
protected:
virtual void resizeEvent (QResizeEvent * event);
@ -83,6 +87,7 @@ private:
list<gLayer *> OXIData;
list<gLayer *> CPAPData;
vector<gGraphWindow *> Graphs;
vector<QAction *> GraphAction;
QGLContext *offscreen_context;
QList<int> splitter_sizes;
@ -92,6 +97,7 @@ private:
void UpdateCPAPGraphs(Day *day);
void UpdateOXIGraphs(Day *day);
MainWindow * mainwin;
Ui::Daily *ui;
Profile *profile;
QDate previous_date;
@ -99,6 +105,7 @@ private:
QSplitter *gSplitter;
QLabel *NoData;
QWidget *spacer;
QMenu *show_graph_menu;
};
/*class AHIGraph:public QWebPluginFactory

View File

@ -111,7 +111,7 @@ MainWindow::MainWindow(QWidget *parent) :
if (!pref.Exists("AlwaysShowOverlayBars")) pref["AlwaysShowOverlayBars"]=true;
ui->actionOverlay_Bars->setChecked(pref["AlwaysShowOverlayBars"].toBool());
daily=new Daily(ui->tabWidget);
daily=new Daily(ui->tabWidget,NULL,this);
ui->tabWidget->insertTab(1,daily,tr("Daily"));
//overview=new Overview(ui->tabWidget,daily->SharedWidget());
@ -204,6 +204,12 @@ void MainWindow::on_action_Import_Data_triggered()
}
}
QMenu * MainWindow::CreateMenu(QString title)
{
QMenu *menu=new QMenu(title,ui->menubar);
ui->menubar->insertMenu(ui->menu_Help->menuAction(),menu);
return menu;
}
void MainWindow::on_actionView_Welcome_triggered()
{

View File

@ -24,6 +24,7 @@ namespace Ui {
extern QStatusBar *qstatusbar;
class Daily;
class MainWindow : public QMainWindow
{
Q_OBJECT
@ -32,6 +33,7 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void Log(QString s);
QMenu * CreateMenu(QString title);
private slots:
void on_action_Import_Data_triggered();
@ -85,6 +87,7 @@ private:
Oximetry * oximetry;
bool first_load;
Profile *profile;
};
#endif // MAINWINDOW_H