mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Initial hack at making QSplitter behave
This commit is contained in:
parent
38a2b18d85
commit
8723de4d36
@ -147,7 +147,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
|
||||
|
||||
|
||||
square_plot=m_square_plot;
|
||||
if (accel || num_points>1000) { // Don't square plot if too many points or waveform
|
||||
if (accel || num_points>5000) { // Don't square plot if too many points or waveform
|
||||
square_plot=false;
|
||||
}
|
||||
|
||||
|
70
Graphs/gSplitter.cpp
Normal file
70
Graphs/gSplitter.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include "gSplitter.h"
|
||||
#include "graphwindow.h"
|
||||
#include <QDebug>
|
||||
gSplitter::gSplitter(QWidget *parent) :
|
||||
QSplitter(parent)
|
||||
{
|
||||
z_timer=new QTimer(this);
|
||||
|
||||
//timer=NULL;
|
||||
// icnt=0;
|
||||
}
|
||||
gSplitter::gSplitter(Qt::Orientation orientation, QWidget *parent) :
|
||||
QSplitter(orientation,parent)
|
||||
{
|
||||
// icnt=0;
|
||||
this->connect(this,SIGNAL(splitterMoved(int,int)),SLOT(mySplitterMoved(int,int)));
|
||||
z_timer=new QTimer(this);
|
||||
}
|
||||
gSplitter::~gSplitter()
|
||||
{
|
||||
delete z_timer;
|
||||
this->disconnect(SLOT(mySplitterMoved(int,int)));
|
||||
// timer->stop();
|
||||
}
|
||||
|
||||
void gSplitter::mySplitterMoved (int pos, int index)
|
||||
{
|
||||
if (z_timer->isActive()) z_timer->stop();
|
||||
z_pos=pos;
|
||||
z_index=index;
|
||||
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->paintGL();
|
||||
}
|
||||
if (gGraphWindow *w=qobject_cast<gGraphWindow *>(widget(index))) {
|
||||
int s=sizes().at(index);
|
||||
//w->resizeGL(w->width(),s);
|
||||
//w->updateGL();
|
||||
//w->paintGL();
|
||||
}
|
||||
qDebug() << ++icnt;
|
||||
z_timer->singleShot(50,this,SLOT(doUpdateGraph()));
|
||||
tm.start();
|
||||
this->setUpdatesEnabled(false);
|
||||
}
|
||||
|
||||
void gSplitter::doUpdateGraph()
|
||||
{
|
||||
|
||||
if (tm.elapsed()<50)
|
||||
return;
|
||||
|
||||
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();
|
||||
}
|
||||
//timer->stop();
|
||||
icnt=0;
|
||||
// QSplitter::resizeEvent(&event);
|
||||
|
||||
}
|
30
Graphs/gSplitter.h
Normal file
30
Graphs/gSplitter.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef GSPLITTER_H
|
||||
#define GSPLITTER_H
|
||||
|
||||
#include <QSplitter>
|
||||
#include <QResizeEvent>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
|
||||
class gSplitter : public QSplitter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit gSplitter(QWidget *parent = 0);
|
||||
explicit gSplitter(Qt::Orientation orientation, QWidget *parent = 0);
|
||||
virtual ~gSplitter();
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void mySplitterMoved(int pos, int index);
|
||||
void doUpdateGraph();
|
||||
|
||||
protected:
|
||||
QTimer * z_timer;
|
||||
int z_pos,z_index;
|
||||
int icnt;
|
||||
QTime tm;
|
||||
|
||||
};
|
||||
|
||||
#endif // GSPLITTER_H
|
@ -91,17 +91,10 @@ bool gGraphWindow::isEmpty()
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
void gGraphWindow::resizeEvent(QResizeEvent *e)
|
||||
/*void gGraphWindow::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
this->setUpdatesEnabled(false);
|
||||
this->blockSignals(true);
|
||||
QGLWidget::resizeEvent(e);
|
||||
this->blockSignals(false);
|
||||
this->setUpdatesEnabled(true);
|
||||
//this->resizeGL(e->size().width(),e->size().height());
|
||||
//this->paintGL();
|
||||
//e->accept();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
void gGraphWindow::AddLayer(gLayer *l) {
|
||||
|
@ -132,9 +132,10 @@ public:
|
||||
bool isEmpty();
|
||||
void SetSplitter(QSplitter *s) { splitter=s; }
|
||||
bool isDraggingGraph() { return m_dragGraph; }
|
||||
void setScry(int h) { m_scrY=h; }
|
||||
protected:
|
||||
void updateSelectionTime(qint64 span);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
//virtual void resizeEvent(QResizeEvent *);
|
||||
void initializeGL();
|
||||
QSplitter *splitter;
|
||||
QList<gGraphWindow *>link_zoom;
|
||||
|
@ -55,7 +55,8 @@ SOURCES += main.cpp\
|
||||
Graphs/gBarChart.cpp \
|
||||
Graphs/gSegmentChart.cpp \
|
||||
Graphs/gSessionTime.cpp \
|
||||
qextserialport/qextserialport.cpp
|
||||
qextserialport/qextserialport.cpp \
|
||||
Graphs/gSplitter.cpp
|
||||
|
||||
unix:SOURCES += qextserialport/posix_qextserialport.cpp
|
||||
unix:!macx:SOURCES += qextserialport/qextserialenumerator_unix.cpp
|
||||
@ -104,7 +105,8 @@ HEADERS += \
|
||||
SleepLib/loader_plugins/sleep_database.h \
|
||||
qextserialport/qextserialport_global.h \
|
||||
qextserialport/qextserialport.h \
|
||||
qextserialport/qextserialenumerator.h
|
||||
qextserialport/qextserialenumerator.h \
|
||||
Graphs/gSplitter.h
|
||||
|
||||
|
||||
FORMS += \
|
||||
|
114
daily.cpp
114
daily.cpp
@ -53,38 +53,38 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
|
||||
|
||||
//scrollArea=new MyScrollArea(this);
|
||||
|
||||
gSplitter=new QSplitter(Qt::Vertical,ui->scrollArea);
|
||||
gSplitter->setStyleSheet("QSplitter::handle { background-color: 'light grey'; }");
|
||||
gSplitter->setHandleWidth(3);
|
||||
splitter=new gSplitter(Qt::Vertical,ui->scrollArea);
|
||||
splitter->setStyleSheet("QSplitter::handle { background-color: 'light grey'; }");
|
||||
splitter->setHandleWidth(3);
|
||||
#ifdef Q_WS_MAC
|
||||
gSplitter->setOpaqueResize(false);
|
||||
splitter->setOpaqueResize(false);
|
||||
#endif
|
||||
|
||||
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
ui->scrollArea->setWidget(gSplitter);
|
||||
ui->scrollArea->setWidget(splitter);
|
||||
//this->connect(ui->scrollArea,
|
||||
//ui->graphSizer->addWidget(gSplitter);
|
||||
//ui->graphSizer->addWidget(splitter);
|
||||
ui->scrollArea->setAutoFillBackground(false);
|
||||
gSplitter->setAutoFillBackground(false);
|
||||
splitter->setAutoFillBackground(false);
|
||||
ui->scrollArea->setWidgetResizable(true);
|
||||
//gSplitter->setMinimumHeight(1600);
|
||||
//gSplitter->setMinimumWidth(600);
|
||||
//splitter->setMinimumHeight(1600);
|
||||
//splitter->setMinimumWidth(600);
|
||||
|
||||
SF=new gGraphWindow(gSplitter,tr("Event Flags"),shared);
|
||||
FRW=new gGraphWindow(gSplitter,tr("Flow Rate"),SF);
|
||||
PRD=new gGraphWindow(gSplitter,tr("Pressure"),SF);
|
||||
LEAK=new gGraphWindow(gSplitter,tr("Leaks"),SF);
|
||||
MP=new gGraphWindow(gSplitter,tr("Mask Pressure"),SF);
|
||||
SNORE=new gGraphWindow(gSplitter,tr("Snore"),SF);
|
||||
FLG=new gGraphWindow(gSplitter,tr("Flow Limitation"),SF);
|
||||
MV=new gGraphWindow(gSplitter,tr("Minute Ventilation"),SF);
|
||||
TV=new gGraphWindow(gSplitter,tr("Tidal Volume"),SF);
|
||||
RR=new gGraphWindow(gSplitter,tr("Respiratory Rate"),SF);
|
||||
PTB=new gGraphWindow(gSplitter,tr("Patient Trig Breaths"),SF);
|
||||
//OF=new gGraphWindow(gSplitter,tr("Oxi-Flags"),SF);
|
||||
PULSE=new gGraphWindow(gSplitter,tr("Pulse"),SF);
|
||||
SPO2=new gGraphWindow(gSplitter,tr("SPO2"),SF);
|
||||
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);
|
||||
|
||||
TAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
|
||||
TAP_EAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
|
||||
@ -261,24 +261,24 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
|
||||
G_AHI->SetGradientBackground(false);
|
||||
G_AHI->hide();
|
||||
|
||||
NoData=new QLabel(tr("No data"),gSplitter);
|
||||
NoData=new QLabel(tr("No data"),splitter);
|
||||
NoData->setAlignment(Qt::AlignCenter);
|
||||
QFont font("FreeSans",20); //NoData->font();
|
||||
//font.setBold(true);
|
||||
NoData->setFont(font);
|
||||
NoData->hide();
|
||||
|
||||
gSplitter->addWidget(NoData);
|
||||
int i=gSplitter->indexOf(NoData);
|
||||
gSplitter->setStretchFactor(i,1);
|
||||
splitter->addWidget(NoData);
|
||||
int i=splitter->indexOf(NoData);
|
||||
splitter->setStretchFactor(i,1);
|
||||
|
||||
gGraphWindow * graphs[]={SF,FRW,MP,MV,TV,PTB,RR,PRD,LEAK,FLG,SNORE};
|
||||
int ss=sizeof(graphs)/sizeof(gGraphWindow *);
|
||||
|
||||
for (int i=0;i<ss;i++) {
|
||||
AddGraph(graphs[i]);
|
||||
//int j=gSplitter->indexOf(graphs[i]);
|
||||
//gSplitter->setStretchFactor(j,1);
|
||||
//int j=splitter->indexOf(graphs[i]);
|
||||
//splitter->setStretchFactor(j,1);
|
||||
for (int j=0;j<ss;j++) {
|
||||
if (graphs[i]!=graphs[j])
|
||||
graphs[i]->LinkZoom(graphs[j]);
|
||||
@ -297,24 +297,24 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
|
||||
//OF->LinkZoom(SPO2);
|
||||
|
||||
// AddGraph(SPO2);
|
||||
// spacer=new QWidget(gSplitter);
|
||||
// spacer=new QWidget(splitter);
|
||||
//spacer->setMaximumHeight(default_height);
|
||||
//gSplitter->addWidget(spacer);
|
||||
//i=gSplitter->indexOf(spacer);
|
||||
//gSplitter->setStretchFactor(i,1);
|
||||
//i=gSplitter->indexOf(FRW);
|
||||
//gSplitter->setStretchFactor(i,15);
|
||||
//splitter->addWidget(spacer);
|
||||
//i=splitter->indexOf(spacer);
|
||||
//splitter->setStretchFactor(i,1);
|
||||
//i=splitter->indexOf(FRW);
|
||||
//splitter->setStretchFactor(i,15);
|
||||
|
||||
|
||||
//gSplitter->refresh();
|
||||
//splitter->refresh();
|
||||
|
||||
gSplitter->setChildrenCollapsible(false); // We set this per widget..
|
||||
//gSplitter->setCollapsible(gSplitter->indexOf(SF),false);
|
||||
//gSplitter->setStretchFactor(gSplitter->indexOf(SF),0);
|
||||
splitter->setChildrenCollapsible(false); // We set this per widget..
|
||||
//splitter->setCollapsible(splitter->indexOf(SF),false);
|
||||
//splitter->setStretchFactor(splitter->indexOf(SF),0);
|
||||
|
||||
splitter_sizes=gSplitter->sizes();
|
||||
gSplitter->layout();
|
||||
gSplitter->update();
|
||||
splitter_sizes=splitter->sizes();
|
||||
splitter->layout();
|
||||
splitter->update();
|
||||
|
||||
|
||||
QTextCharFormat format = ui->calendar->weekdayTextFormat(Qt::Saturday);
|
||||
@ -344,20 +344,20 @@ Daily::~Daily()
|
||||
if (previous_date.isValid())
|
||||
Unload(previous_date);
|
||||
|
||||
delete gSplitter;
|
||||
delete splitter;
|
||||
delete ui;
|
||||
}
|
||||
void Daily::AddGraph(gGraphWindow *w)
|
||||
{
|
||||
Graphs.push_back(w);
|
||||
|
||||
gSplitter->addWidget(w);
|
||||
w->SetSplitter(gSplitter);
|
||||
splitter->addWidget(w);
|
||||
w->SetSplitter(splitter);
|
||||
}
|
||||
void Daily::resizeEvent (QResizeEvent * event)
|
||||
{
|
||||
//const QSize &size=event->size();
|
||||
// gSplitter->setMinimumWidth(size.width()-280);
|
||||
// splitter->setMinimumWidth(size.width()-280);
|
||||
}
|
||||
|
||||
void Daily::ReloadGraphs()
|
||||
@ -489,7 +489,7 @@ void Daily::on_calendar_selectionChanged()
|
||||
}
|
||||
void Daily::ResetGraphLayout()
|
||||
{
|
||||
gSplitter->setSizes(splitter_sizes);
|
||||
splitter->setSizes(splitter_sizes);
|
||||
|
||||
}
|
||||
void Daily::ShowHideGraphs()
|
||||
@ -510,10 +510,10 @@ void Daily::ShowHideGraphs()
|
||||
}
|
||||
}
|
||||
}
|
||||
gSplitter->setMinimumHeight(vis*default_height);
|
||||
//gSplitter->setMaximumHeight(vis*default_height);
|
||||
gSplitter->layout();
|
||||
gSplitter->update();
|
||||
splitter->setMinimumHeight(vis*default_height);
|
||||
//splitter->setMaximumHeight(vis*default_height);
|
||||
splitter->layout();
|
||||
splitter->update();
|
||||
RedrawGraphs();
|
||||
}
|
||||
void Daily::Load(QDate date)
|
||||
@ -544,7 +544,7 @@ void Daily::Load(QDate date)
|
||||
UpdateEventsTree(ui->treeWidget,cpap);
|
||||
|
||||
if (!cpap && !oxi) {
|
||||
gSplitter->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++) {
|
||||
@ -575,18 +575,18 @@ void Daily::Load(QDate date)
|
||||
if (!cpap) {
|
||||
SF->hide();
|
||||
}
|
||||
//gSplitter->setMinimumHeight(0);
|
||||
gSplitter->setMinimumHeight(vis*default_height);
|
||||
//splitter->setMinimumHeight(0);
|
||||
splitter->setMinimumHeight(vis*default_height);
|
||||
//if (vis>4) {
|
||||
//gSplitter->setMaximumHeight(vis*default_height);
|
||||
//splitter->setMaximumHeight(vis*default_height);
|
||||
//} //else {
|
||||
// }
|
||||
gSplitter->layout();
|
||||
splitter->layout();
|
||||
|
||||
// spacer->show();
|
||||
}
|
||||
|
||||
gSplitter->update();
|
||||
splitter->update();
|
||||
RedrawGraphs();
|
||||
|
||||
QString epr,modestr;
|
||||
|
7
daily.h
7
daily.h
@ -11,7 +11,6 @@
|
||||
#include <QScrollArea>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QSplitter>
|
||||
#include <QWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QLabel>
|
||||
@ -20,9 +19,9 @@
|
||||
#include <SleepLib/profiles.h>
|
||||
#include <Graphs/graphwindow.h>
|
||||
#include "mainwindow.h"
|
||||
//#include <Graphs/graphdata.h>
|
||||
#include "Graphs/gSplitter.h"
|
||||
#include "Graphs/gLineChart.h"
|
||||
#include <Graphs/gFlagsLine.h>
|
||||
#include "Graphs/gFlagsLine.h"
|
||||
namespace Ui {
|
||||
class Daily;
|
||||
}
|
||||
@ -102,7 +101,7 @@ private:
|
||||
Profile *profile;
|
||||
QDate previous_date;
|
||||
MyScrollArea *scrollArea;
|
||||
QSplitter *gSplitter;
|
||||
gSplitter *splitter;
|
||||
QLabel *NoData;
|
||||
QWidget *spacer;
|
||||
QMenu *show_graph_menu;
|
||||
|
Loading…
Reference in New Issue
Block a user