Replaced ScrollArea with custom that issues Redraw on Mac

This commit is contained in:
Mark Watkins 2011-08-07 16:21:09 +10:00
parent bda318bf73
commit 1655fae05e
7 changed files with 60 additions and 68 deletions

View File

@ -1,13 +1,13 @@
/********************************************************************
/*
gFooBar Implementation
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
License: GPL
*********************************************************************/
*/
#include "gFooBar.h"
gFooBar::gFooBar(int offset,QColor handle_color,QColor line_color,bool shadow,QColor shadow_color)
:gLayer(EmptyChannel),m_offset(offset),m_shadow(shadow),m_handle_color(handle_color),m_line_color(line_color),m_shadow_color(shadow_color)
:gLayer(EmptyChannel),m_offset(offset),m_handle_color(handle_color),m_line_color(line_color),m_shadow(shadow),m_shadow_color(shadow_color)
{
}
gFooBar::~gFooBar()

View File

@ -83,10 +83,13 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
EventDataType ymult=EventDataType(height)/yy; // time to pixel conversion multiplier
// Return on screwy min/max conditions
if ((xx<0) || (yy<0))
return;
if ((yy==0) && (miny==0))
if (xx<0)
return;
if (yy<=0) {
if (miny==0)
return;
int i=5;
}
EventDataType lastpx,lastpy;
EventDataType px,py;
@ -161,6 +164,9 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
if (maxx<x0) continue;
if (xL<minx) continue;
if (siz==2) {
int i=0;
}
if (x0>xL) {
if (siz==2) { // this happens on CPAP
quint32 t=el.getTime()[0];

View File

@ -32,8 +32,15 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
double maxy=w.max_y;
double dy=maxy-miny;
if (dy<=0)
return;
if (dy<=0) {
if (miny==0)
return;
else {
miny+=1;
maxy-=1;
dy=2;
}
}
int m;
if (maxy>500) {

View File

@ -932,7 +932,7 @@ EventDataType gGraphWindow::MinY()
for (QList<gLayer *>::iterator l=layers.begin();l!=layers.end();l++) {
if ((*l)->isEmpty()) continue;
tmp=(*l)->Miny();
if (tmp==(*l)->Maxy()) continue;
if (tmp==0 && tmp==(*l)->Maxy()) continue;
if (first) {
val=tmp;
first=false;
@ -949,7 +949,7 @@ EventDataType gGraphWindow::MaxY()
for (QList<gLayer *>::iterator l=layers.begin();l!=layers.end();l++) {
if ((*l)->isEmpty()) continue;
tmp=(*l)->Maxy();
if (tmp==(*l)->Miny()) continue;
if (tmp==0 && tmp==(*l)->Miny()) continue;
if (first) {
val=tmp;
first=false;

View File

@ -29,7 +29,8 @@
const int min_height=150;
const int default_height=150;
MyScrollArea::MyScrollArea(Daily * parent)
MyScrollArea::MyScrollArea(QWidget *parent, Daily * daily)
:QScrollArea(parent),m_daily(daily)
{
}
MyScrollArea::~MyScrollArea()
@ -37,6 +38,10 @@ MyScrollArea::~MyScrollArea()
}
void MyScrollArea::scrollContentsBy(int dx, int dy)
{
QScrollArea::scrollContentsBy(dx,dy);
#ifdef Q_WS_MAC
m_daily->RedrawGraphs();
#endif
}
Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
@ -51,18 +56,25 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
exit(-1);
}
//scrollArea=new MyScrollArea(this);
scrollArea=new MyScrollArea(ui->graphMainArea,this);
ui->graphLayout->addWidget(scrollArea,1);
scrollArea->setWidgetResizable(true);
//QVBoxLayout *lay=new QVBoxLayout(scrollArea);
//scrollArea->setWidget(lay);
GraphLayout=new QWidget(scrollArea);
scrollArea->setWidget(GraphLayout);
//lay->addWidget(GraphLayout,1);
//ui->webView->setStyleSheet("QWebView { background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5, stop: 0 #FF92BB, stop: 1 white); }");
//ui->treeWidget->setAlternatingRowColors(true);
GraphLayout=new QWidget();
ui->graphSizer->addWidget(GraphLayout,1);
ui->graphSizer->setMargin(0);
ui->graphSizer->setContentsMargins(0,0,0,0);
splitter=new QVBoxLayout(GraphLayout);
GraphLayout->setLayout(splitter);
splitter->setMargin(0);
splitter->setContentsMargins(0,0,0,0);
//ui->splitter->layout();
//gSplitter(Qt::Vertical,ui->scrollArea);
//splitter->setStyleSheet("QSplitter::handle { background-color: 'light grey'; }");
//splitter->setHandleWidth(3);
@ -70,20 +82,19 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
//splitter->setOpaqueResize(false);
#endif
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//ui->scrollArea->setWidget(splitter);
//this->connect(ui->scrollArea,
//ui->graphSizer->addWidget(splitter);
ui->scrollArea->setAutoFillBackground(false);
scrollArea->setAutoFillBackground(false);
//splitter->setAutoFillBackground(false);
ui->scrollArea->setWidgetResizable(true);
//splitter->setMinimumHeight(1600);
//splitter->setMinimumWidth(600);
QWidget * parental=ui->scrollArea;
QWidget * parental=GraphLayout;
SF=new gGraphWindow(parental,tr("Event Flags"),shared);
FRW=new gGraphWindow(parental,tr("Flow Rate"),SF);
PRD=new gGraphWindow(parental,tr("Pressure"),SF);
@ -337,7 +348,7 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
//OF->LinkZoom(SPO2);
// AddGraph(SPO2);
spacer=new gGraphWindow(ui->scrollArea,"",SF);
spacer=new gGraphWindow(scrollArea,"",SF);
spacer->setMinimumHeight(1);
spacer->setMaximumHeight(1);
splitter->addWidget(spacer);
@ -599,7 +610,7 @@ void Daily::Load(QDate date)
} else {
NoData->hide();
int vis=0;
ui->scrollArea->setUpdatesEnabled(false);
scrollArea->setUpdatesEnabled(false);
for (int i=0;i<Graphs.size();i++) {
Graphs[i]->setUpdatesEnabled(false);
if (Graphs[i]->isEmpty()) {
@ -641,8 +652,8 @@ void Daily::Load(QDate date)
// splitter->blockSignals(true);
splitter->layout();
ui->scrollArea->setUpdatesEnabled(true);
ui->scrollArea->update();
scrollArea->setUpdatesEnabled(true);
scrollArea->update();
//ui->scrollArea->update();
//splitter->layout();

View File

@ -30,11 +30,11 @@ class Daily;
class MyScrollArea:public QScrollArea
{
public:
MyScrollArea(Daily * parent);
MyScrollArea(QWidget * parent, Daily * daily);
virtual ~MyScrollArea();
protected:
virtual void scrollContentsBy(int dx, int dy);
Daily *daily;
Daily *m_daily;
};
class MainWindow;

View File

@ -20,20 +20,8 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -481,35 +469,15 @@
</widget>
</widget>
</widget>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaStuff">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>763</width>
<height>620</height>
</rect>
<widget class="QWidget" name="graphMainArea" native="true">
<layout class="QVBoxLayout" name="graphLayout">
<property name="spacing">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="graphSizer">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item>
</layout>
</widget>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>