Remember Window Position

This commit is contained in:
Mark Watkins 2011-10-05 13:05:35 +10:00
parent 8778349e18
commit 156eb48558
8 changed files with 206 additions and 28 deletions

View File

@ -249,4 +249,4 @@ bool ChannelList::Save(QString filename)
}
typedef schema::Channel * ChannelID;
//typedef schema::Channel * ChannelID;

View File

@ -5,6 +5,16 @@
#include <QHash>
#include <QVariant>
#include <QString>
#include "machine_common.h"
namespace GraphFlags {
const quint32 Shadow=1;
const quint32 Foobar=2;
const quint32 XTicker=4;
const quint32 YTicker=8;
const quint32 XGrid=16;
const quint32 YGrid=32;
}
namespace schema {
@ -84,9 +94,98 @@ public:
QHash<QString,QHash<QString,Channel *> > groups;
QString m_doctype;
};
extern ChannelList channel;
enum LayerType {
UnspecifiedLayer, Waveform, Flag, Overlay, Group
};
class Layer
{
public:
Layer(ChannelID code, QColor colour, QString label=QString());
virtual ~Layer();
Layer *addLayer(Layer *layer);// { m_layers.push_back(layer); return layer; }
void setMin(EventDataType min) { m_min=min; m_hasmin=true; }
void setMax(EventDataType max) { m_max=max; m_hasmax=true; }
EventDataType min() { return m_min; }
EventDataType max() { return m_max; }
bool visible() { return m_visible; }
void setVisible(bool b) { m_visible=b; }
protected:
LayerType m_type;
ChannelID m_code;
QColor m_colour;
QString m_label;
EventDataType m_min;
EventDataType m_max;
bool m_hasmin;
bool m_hasmax;
bool m_visible;
QVector<Layer *> m_layers;
};
class WaveformLayer: public Layer
{
public:
WaveformLayer(ChannelID code, QColor colour, float min=0, float max=0);
virtual ~WaveformLayer();
};
enum FlagVisual { Bar, Span, Dot };
class OverlayLayer: public Layer
{
public:
OverlayLayer(ChannelID code, QColor colour, FlagVisual visual=Bar);
virtual ~OverlayLayer();
protected:
FlagVisual m_visual;
};
class GroupLayer: public Layer // Effectively an empty Layer container
{
public:
GroupLayer();
virtual ~GroupLayer();
};
class FlagGroupLayer: public GroupLayer
{
public:
FlagGroupLayer();
virtual ~FlagGroupLayer();
};
class FlagLayer: public Layer
{
public:
FlagLayer(ChannelID code, QColor colour, FlagVisual visual=Bar);
virtual ~FlagLayer();
protected:
FlagVisual m_visual;
};
class Graph
{
public:
Graph(QString name,quint32 flags=GraphFlags::XTicker | GraphFlags::YTicker | GraphFlags::XGrid);
Layer *addLayer(Layer *layer) { m_layers.push_back(layer); return layer; }
int height() { if (m_visible) return m_height; else return 0;}
int setHeight(int h) { m_height=h; }
bool visible() { return m_visible; }
void setVisible(bool b) { m_visible=b; }
protected:
QString m_name;
int m_height;
QVector<Layer *> m_layers;
bool m_visible;
};
class GraphGroup
{
public:
GraphGroup(QString name);
GraphGroup();
Graph *addGraph(Graph *graph) { m_graphs.push_back(graph); return graph; }
protected:
QVector<Graph *>m_graphs;
};
void init();
} // namespace

View File

@ -38,7 +38,7 @@ Daily::Daily(QWidget *parent,Profile * _profile,gGraphView * shared, MainWindow
QList<int> a;
a.push_back(300);
a.push_back(this->width()-300);
ui->splitter_2->setStretchFactor(0,0);
ui->splitter_2->setStretchFactor(1,1);
ui->splitter_2->setSizes(a);
ui->splitter_2->setStretchFactor(1,1);

View File

@ -1,21 +1,22 @@
<!DOCTYPE Graphs>
<Schema language="en" version="1.0">
<Graph name="Event Flags" group="Daily" master="true">
<layer type="flaglines">
<line name="CSR" func="data" type="span">
<line name="ClearAirway" func="data" type="bar">
<line name="Obstructive" func="data" type="bar">
<line name="Apnea" func="data" type="bar">
<line name="Hypopnea" func="data" type="bar">
<line name="FlowLimit" func="data" type="bar">
<line name="RERA" func="data" type="bar">
<line name="VSnore" func="data" type="bar">
<line name="VSnore2" func="data" type="bar">
</layer>
<property name="visible" type="bool" value="true"/>
<group type="flags">
<layer name="CSR" func="data" type="span">
<layer name="ClearAirway" func="data" type="bar">
<layer name="Obstructive" func="data" type="bar">
<layer name="Apnea" func="data" type="bar">
<layer name="Hypopnea" func="data" type="bar">
<layer name="FlowLimit" func="data" type="bar">
<layer name="RERA" func="data" type="bar">
<layer name="VSnore" func="data" type="bar">
<layer name="VSnore2" func="data" type="bar">
</group>
</Graph>
<Graph name="Flow Rate" group="Daily">
<layer type="overlay" data="CSR" visual="span"/>
<layer type="linechart" data="FlowRate"/>
<layer type="waveform" data="FlowRate"/>
<layer type="overlay" data="Obstructive" visual="bar"/>
<layer type="overlay" data="Hypopnea" visual="bar"/>
<layer type="overlay" data="Apnea" visual="bar"/>

View File

@ -13,6 +13,7 @@
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QTimer>
#include <QSettings>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "preferencesdialog.h"
@ -59,7 +60,10 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
this->setWindowTitle(tr("SleepyHead")+QString(" v%1.%2.%3 (%4)").arg(major_version).arg(minor_version).arg(revision_number).arg(pref["Profile"].toString()));
ui->tabWidget->setCurrentIndex(0);
//move(0,0);
overview=NULL;
daily=NULL;
oximetry=NULL;
/* QGLFormat fmt;
fmt.setDepth(false);
@ -117,6 +121,8 @@ MainWindow::MainWindow(QWidget *parent) :
first_load=true;
QSettings settings("Jedimark", "SleepyHead");
this->restoreGeometry(settings.value("MainWindow/geometry").toByteArray());
ui->tabWidget->setCurrentWidget(ui->welcome);
@ -129,6 +135,11 @@ MainWindow::MainWindow(QWidget *parent) :
extern MainWindow *mainwin;
MainWindow::~MainWindow()
{
if (!isMaximized()) {
QSettings settings("Jedimark", "SleepyHead");
settings.setValue("MainWindow/geometry", saveGeometry());
}
//QWidget::closeEvent(event);
if (daily) {
daily->close();
delete daily;
@ -149,6 +160,8 @@ MainWindow::~MainWindow()
void MainWindow::Startup()
{
qDebug() << pref["AppName"].toString().toAscii()+" v"+pref["VersionString"].toString().toAscii() << "built with Qt"<< QT_VERSION_STR << "on" << __DATE__ << __TIME__;
qstatus->setText(tr("Loading Data"));
qprogress->show();
@ -162,11 +175,11 @@ void MainWindow::Startup()
daily=new Daily(ui->tabWidget,profile,NULL,this);
ui->tabWidget->insertTab(1,daily,tr("Daily"));
overview=new Overview(ui->tabWidget,profile,daily->SharedWidget());
ui->tabWidget->insertTab(2,overview,tr("Overview"));
//overview=new Overview(ui->tabWidget,profile,daily->SharedWidget());
//ui->tabWidget->insertTab(2,overview,tr("Overview"));
oximetry=new Oximetry(ui->tabWidget,profile,daily->SharedWidget());
ui->tabWidget->insertTab(3,oximetry,tr("Oximetry"));
//oximetry=new Oximetry(ui->tabWidget,profile,daily->SharedWidget());
//ui->tabWidget->insertTab(3,oximetry,tr("Oximetry"));
if (daily) daily->ReloadGraphs();
if (overview) overview->ReloadGraphs();

View File

@ -105,7 +105,7 @@
<item>
<widget class="QPushButton" name="ImportButton">
<property name="text">
<string>&amp;Import from Device</string>
<string>&amp;Import</string>
</property>
</widget>
</item>

View File

@ -80,6 +80,23 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) :
shortformat.replace("yy","yyyy");
}*/
QTreeWidget *tree=ui->graphTree;
tree->clear();
tree->setColumnCount(1); // 1 visible common.. (1 hidden)
QTreeWidgetItem *daily=new QTreeWidgetItem((QTreeWidget *)0,QStringList("Daily Graphs"));
QTreeWidgetItem *overview=new QTreeWidgetItem((QTreeWidget *)0,QStringList("Overview Graphs"));
tree->insertTopLevelItem(0,daily);
tree->insertTopLevelItem(0,overview);
QTreeWidgetItem *it=new QTreeWidgetItem(daily,QStringList("Event Flags"));//,QTreeWidgetItem::UserType);
it->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsSelectable|Qt::ItemIsEnabled);
it->setCheckState(0,Qt::Checked);
daily->addChild(it);
//QTreeWidgetItem *root=NULL;//new QTreeWidgetItem((QTreeWidget *)0,QStringList("Stuff"));
//=new QTreeWidgetItem(root,l);
//ui->graphTree->setModel(
tree->sortByColumn(0,Qt::AscendingOrder);
}

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>264</height>
<width>527</width>
<height>291</height>
</rect>
</property>
<property name="windowTitle">
@ -29,9 +29,9 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="tab_3">
<widget class="QWidget" name="visualTab">
<attribute name="title">
<string>&amp;CPAP/Visual</string>
</attribute>
@ -177,7 +177,7 @@ It has no effect on single cpu machines.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="sessionTab">
<attribute name="title">
<string>&amp;Sessions</string>
</attribute>
@ -396,7 +396,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<widget class="QWidget" name="colourTab">
<attribute name="title">
<string>&amp;Events</string>
</attribute>
@ -404,7 +404,7 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>This doesn't work yet.. The colours shown are random.</string>
<string>This doesn't work yet..</string>
</property>
</widget>
</item>
@ -452,6 +452,54 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="graphTab">
<attribute name="title">
<string>Graphs</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Filter</string>
</property>
<property name="margin">
<number>4</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="graphTreeFilter"/>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="graphTree">
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>