Murdered QSplitter.. Sorry, no more graph resizing.. Blame Apple & Nokia! :(

This commit is contained in:
Mark Watkins 2011-08-02 20:28:29 +10:00
parent 8723de4d36
commit 13b974c9ee
8 changed files with 71 additions and 52 deletions

View File

@ -18,10 +18,10 @@ class gFooBar:public gLayer
static const int Margin=15;
protected:
int m_offset;
QColor m_line_color;
QColor m_handle_color;
QColor m_shadow_color;
QColor m_line_color;
bool m_shadow;
QColor m_shadow_color;
};
#endif // GFOOBAR_H

View File

@ -28,12 +28,12 @@ void gSplitter::mySplitterMoved (int pos, int index)
if (z_timer->isActive()) z_timer->stop();
z_pos=pos;
z_index=index;
this->setUpdatesEnabled(true);
//this->setUpdatesEnabled(true);
if (gGraphWindow *w=qobject_cast<gGraphWindow *>(widget(index-1))) {
int s=sizes().at(index-1);
w->updateGL();
//w->resizeGL(w->width(),pos);
//w->updateGL();
//w->updateGL();
//w->paintGL();
}
if (gGraphWindow *w=qobject_cast<gGraphWindow *>(widget(index))) {
@ -45,7 +45,6 @@ void gSplitter::mySplitterMoved (int pos, int index)
qDebug() << ++icnt;
z_timer->singleShot(50,this,SLOT(doUpdateGraph()));
tm.start();
this->setUpdatesEnabled(false);
}
void gSplitter::doUpdateGraph()
@ -53,13 +52,25 @@ void gSplitter::doUpdateGraph()
if (tm.elapsed()<50)
return;
//this->setUpdatesEnabled(true);
if (gGraphWindow *w=qobject_cast<gGraphWindow *>(widget(z_index-1))) {
//qDebug() << icnt << "Height" << w->height() << z_index << z_pos << w->Title();
int s=sizes().at(z_index-1);
QSize n(w->width(),s);
QSize o(w->width(),s);
//QResizeEvent e(n,o);
//w->resizeEvent(&e);
//w->resizeGL(w->width(),s);
//w->paintGL();
}
if (gGraphWindow *w=qobject_cast<gGraphWindow *>(widget(z_index))) {
qDebug() << icnt << "Height" << w->height() << z_index << z_pos << w->Title();
int s=sizes().at(z_index);
this->setUpdatesEnabled(true);
w->resizeGL(w->width(),s);
w->paintGL();
}

View File

@ -313,7 +313,8 @@ void gGraphWindow::mouseMoveEvent(QMouseEvent * event)
int i=splitter->indexOf(this);
if (i<splitter->count()-2) {
splitter->insertWidget(i+1,this);
splitter->setStretchFactor(this,1);
splitter->layout();
}
} else if (event->y()<0) {
@ -321,6 +322,8 @@ void gGraphWindow::mouseMoveEvent(QMouseEvent * event)
int i=splitter->indexOf(this);
if (i>0) {
splitter->insertWidget(i-1,this);
splitter->setStretchFactor(this,1);
splitter->layout();
}
}
}

View File

@ -7,6 +7,7 @@
#ifndef GRAPHWINDOW_H
#define GRAPHWINDOW_H
#include<QVBoxLayout>
#include <QGLContext>
#include <QGLWidget>
#include <QSplitter>
@ -130,14 +131,14 @@ public:
void SetGradientBackground(bool b) { m_gradient_background=b; }
bool GradientBackground() { return m_gradient_background; }
bool isEmpty();
void SetSplitter(QSplitter *s) { splitter=s; }
void SetSplitter(QVBoxLayout *s) { splitter=s; }
bool isDraggingGraph() { return m_dragGraph; }
void setScry(int h) { m_scrY=h; }
protected:
void updateSelectionTime(qint64 span);
//virtual void resizeEvent(QResizeEvent *);
void initializeGL();
QSplitter *splitter;
QVBoxLayout *splitter;
QList<gGraphWindow *>link_zoom;
bool m_block_zoom;

View File

@ -26,7 +26,7 @@
#include "Graphs/gBarChart.h"
#include "Graphs/gSegmentChart.h"
const int min_height=100;
const int min_height=150;
const int default_height=150;
MyScrollArea::MyScrollArea(Daily * parent)
@ -53,38 +53,40 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
//scrollArea=new MyScrollArea(this);
splitter=new gSplitter(Qt::Vertical,ui->scrollArea);
splitter->setStyleSheet("QSplitter::handle { background-color: 'light grey'; }");
splitter->setHandleWidth(3);
splitter=ui->graphSizer;
//gSplitter(Qt::Vertical,ui->scrollArea);
//splitter->setStyleSheet("QSplitter::handle { background-color: 'light grey'; }");
//splitter->setHandleWidth(3);
#ifdef Q_WS_MAC
splitter->setOpaqueResize(false);
//splitter->setOpaqueResize(false);
#endif
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setWidget(splitter);
//ui->scrollArea->setWidget(splitter);
//this->connect(ui->scrollArea,
//ui->graphSizer->addWidget(splitter);
ui->scrollArea->setAutoFillBackground(false);
splitter->setAutoFillBackground(false);
//splitter->setAutoFillBackground(false);
ui->scrollArea->setWidgetResizable(true);
//splitter->setMinimumHeight(1600);
//splitter->setMinimumWidth(600);
SF=new gGraphWindow(splitter,tr("Event Flags"),shared);
FRW=new gGraphWindow(splitter,tr("Flow Rate"),SF);
PRD=new gGraphWindow(splitter,tr("Pressure"),SF);
LEAK=new gGraphWindow(splitter,tr("Leaks"),SF);
MP=new gGraphWindow(splitter,tr("Mask Pressure"),SF);
SNORE=new gGraphWindow(splitter,tr("Snore"),SF);
FLG=new gGraphWindow(splitter,tr("Flow Limitation"),SF);
MV=new gGraphWindow(splitter,tr("Minute Ventilation"),SF);
TV=new gGraphWindow(splitter,tr("Tidal Volume"),SF);
RR=new gGraphWindow(splitter,tr("Respiratory Rate"),SF);
PTB=new gGraphWindow(splitter,tr("Patient Trig Breaths"),SF);
//OF=new gGraphWindow(splitter,tr("Oxi-Flags"),SF);
PULSE=new gGraphWindow(splitter,tr("Pulse"),SF);
SPO2=new gGraphWindow(splitter,tr("SPO2"),SF);
QWidget * parental=ui->scrollArea;
SF=new gGraphWindow(parental,tr("Event Flags"),shared);
FRW=new gGraphWindow(parental,tr("Flow Rate"),SF);
PRD=new gGraphWindow(parental,tr("Pressure"),SF);
LEAK=new gGraphWindow(parental,tr("Leaks"),SF);
MP=new gGraphWindow(parental,tr("Mask Pressure"),SF);
SNORE=new gGraphWindow(parental,tr("Snore"),SF);
FLG=new gGraphWindow(parental,tr("Flow Limitation"),SF);
MV=new gGraphWindow(parental,tr("Minute Ventilation"),SF);
TV=new gGraphWindow(parental,tr("Tidal Volume"),SF);
RR=new gGraphWindow(parental,tr("Respiratory Rate"),SF);
PTB=new gGraphWindow(parental,tr("Patient Trig Breaths"),SF);
//OF=new gGraphWindow(parental,tr("Oxi-Flags"),SF);
PULSE=new gGraphWindow(parental,tr("Pulse"),SF);
SPO2=new gGraphWindow(parental,tr("SPO2"),SF);
TAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
TAP_EAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
@ -261,7 +263,7 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
G_AHI->SetGradientBackground(false);
G_AHI->hide();
NoData=new QLabel(tr("No data"),splitter);
NoData=new QLabel(tr("No data"),parental);
NoData->setAlignment(Qt::AlignCenter);
QFont font("FreeSans",20); //NoData->font();
//font.setBold(true);
@ -269,8 +271,8 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
NoData->hide();
splitter->addWidget(NoData);
int i=splitter->indexOf(NoData);
splitter->setStretchFactor(i,1);
//int i=splitter->indexOf(NoData);
splitter->setStretchFactor(NoData,1);
gGraphWindow * graphs[]={SF,FRW,MP,MV,TV,PTB,RR,PRD,LEAK,FLG,SNORE};
int ss=sizeof(graphs)/sizeof(gGraphWindow *);
@ -278,7 +280,7 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
for (int i=0;i<ss;i++) {
AddGraph(graphs[i]);
//int j=splitter->indexOf(graphs[i]);
//splitter->setStretchFactor(j,1);
splitter->setStretchFactor(graphs[i],1);
for (int j=0;j<ss;j++) {
if (graphs[i]!=graphs[j])
graphs[i]->LinkZoom(graphs[j]);
@ -308,11 +310,11 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
//splitter->refresh();
splitter->setChildrenCollapsible(false); // We set this per widget..
//splitter->setChildrenCollapsible(false); // We set this per widget..
//splitter->setCollapsible(splitter->indexOf(SF),false);
//splitter->setStretchFactor(splitter->indexOf(SF),0);
splitter_sizes=splitter->sizes();
//splitter_sizes=splitter->sizes();
splitter->layout();
splitter->update();
@ -344,7 +346,7 @@ Daily::~Daily()
if (previous_date.isValid())
Unload(previous_date);
delete splitter;
// delete splitter;
delete ui;
}
void Daily::AddGraph(gGraphWindow *w)
@ -489,7 +491,7 @@ void Daily::on_calendar_selectionChanged()
}
void Daily::ResetGraphLayout()
{
splitter->setSizes(splitter_sizes);
//splitter->setSizes(splitter_sizes);
}
void Daily::ShowHideGraphs()
@ -510,7 +512,7 @@ void Daily::ShowHideGraphs()
}
}
}
splitter->setMinimumHeight(vis*default_height);
//splitter->setMinimumHeight(vis*default_height);
//splitter->setMaximumHeight(vis*default_height);
splitter->layout();
splitter->update();
@ -544,7 +546,7 @@ void Daily::Load(QDate date)
UpdateEventsTree(ui->treeWidget,cpap);
if (!cpap && !oxi) {
splitter->setMinimumHeight(0);
//splitter->setMinimumHeight(0);
NoData->setText(tr("No data for ")+date.toString(Qt::SystemLocaleLongDate));
NoData->show();
for (int i=0;i<Graphs.size();i++) {
@ -576,7 +578,7 @@ void Daily::Load(QDate date)
SF->hide();
}
//splitter->setMinimumHeight(0);
splitter->setMinimumHeight(vis*default_height);
//splitter->setMinimumHeight(vis*default_height);
//if (vis>4) {
//splitter->setMaximumHeight(vis*default_height);
//} //else {

View File

@ -101,7 +101,7 @@ private:
Profile *profile;
QDate previous_date;
MyScrollArea *scrollArea;
gSplitter *splitter;
QVBoxLayout *splitter;
QLabel *NoData;
QWidget *spacer;
QMenu *show_graph_menu;

View File

@ -41,10 +41,11 @@ Oximetry::Oximetry(QWidget *parent,QGLWidget * shared) :
session=new Session(mach,0);
day->AddSession(session);
gSplitter=new QSplitter(Qt::Vertical,ui->scrollArea);
gSplitter->setStyleSheet("QSplitter::handle { background-color: 'dark grey'; }");
gSplitter->setHandleWidth(2);
ui->graphLayout->addWidget(gSplitter);
splitter=ui->graphLayout;
//splitter=new QSplitter(Qt::Vertical,ui->scrollArea);
//gSplitter->setStyleSheet("QSplitter::handle { background-color: 'dark grey'; }");
//gSplitter->setHandleWidth(2);
//ui->graphLayout->addWidget(splitter);
// Create the Event Lists to store / import data
ev_plethy=new EventList(OXI_Plethysomogram,EVL_Event,1,0,0,0,1000.0/50.0);
@ -56,16 +57,17 @@ Oximetry::Oximetry(QWidget *parent,QGLWidget * shared) :
ev_spo2=new EventList(OXI_SPO2,EVL_Event,1);
session->eventlist[OXI_SPO2].push_back(ev_spo2);
QWidget * parental=ui->scrollArea;
plethy=new gLineChart(OXI_Plethysomogram,Qt::black,false,true);
AddGraph(PLETHY=new gGraphWindow(gSplitter,tr("Plethysomogram"),shared));
AddGraph(PLETHY=new gGraphWindow(parental,tr("Plethysomogram"),shared));
plethy->SetDay(day);
pulse=new gLineChart(OXI_Pulse,Qt::red,true);
AddGraph(PULSE=new gGraphWindow(gSplitter,tr("Pulse Rate"),shared));
AddGraph(PULSE=new gGraphWindow(parental,tr("Pulse Rate"),shared));
pulse->SetDay(day);
spo2=new gLineChart(OXI_SPO2,Qt::blue,true);
AddGraph(SPO2=new gGraphWindow(gSplitter,tr("SPO2"),shared));
AddGraph(SPO2=new gGraphWindow(parental,tr("SPO2"),shared));
spo2->SetDay(day);
for (int i=0;i<Graphs.size();i++) {
@ -77,7 +79,7 @@ Oximetry::Oximetry(QWidget *parent,QGLWidget * shared) :
Graphs[i]->AddLayer(new gXAxis());
//Graphs[i]->AddLayer(new gFooBar());
gSplitter->addWidget(Graphs[i]);
splitter->addWidget(Graphs[i]);
}
PLETHY->AddLayer(plethy);
PLETHY->AddLayer(new gFooBar());
@ -86,7 +88,7 @@ Oximetry::Oximetry(QWidget *parent,QGLWidget * shared) :
for (int i=0;i<Graphs.size();i++) {
Graphs[i]->setMinimumHeight(150);
Graphs[i]->SetSplitter(gSplitter);
Graphs[i]->SetSplitter(splitter);
}
on_RefreshPortsButton_clicked();

View File

@ -49,7 +49,7 @@ private:
Ui::Oximetry *ui;
Profile *profile;
QSplitter *gSplitter;
QVBoxLayout *splitter;
gLineChart *pulse,*spo2,*plethy;
gGraphWindow *PULSE,*SPO2,*PLETHY;