mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 19:20:45 +00:00
Disable welcome page buttons when no cpap data, fix some Purge issues
This commit is contained in:
parent
afd74aeff3
commit
2df5987ca6
@ -88,6 +88,7 @@ const quint16 sessinfo_version = 2;
|
|||||||
bool Machine::saveSessionInfo()
|
bool Machine::saveSessionInfo()
|
||||||
{
|
{
|
||||||
if (info.type == MT_JOURNAL) return false;
|
if (info.type == MT_JOURNAL) return false;
|
||||||
|
if (sessionlist.size() == 0) return false;
|
||||||
|
|
||||||
qDebug() << "Saving" << info.brand << "session info" << info.loadername;
|
qDebug() << "Saving" << info.brand << "session info" << info.loadername;
|
||||||
QString filename = getDataPath() + "Sessions.info";
|
QString filename = getDataPath() + "Sessions.info";
|
||||||
@ -457,9 +458,12 @@ bool Machine::Purge(int secret)
|
|||||||
QFile rxcache(p_profile->Get("{" + STR_GEN_DataFolder + "}/RXChanges.cache" ));
|
QFile rxcache(p_profile->Get("{" + STR_GEN_DataFolder + "}/RXChanges.cache" ));
|
||||||
rxcache.remove();
|
rxcache.remove();
|
||||||
|
|
||||||
QFile sumfile(getDataPath()+"Summaries.xml.gz");
|
QFile sumfile(getDataPath()+"/Summaries.xml.gz");
|
||||||
sumfile.remove();
|
sumfile.remove();
|
||||||
|
|
||||||
|
QFile sessinfofile(getDataPath()+"/Sessions.info");
|
||||||
|
sessinfofile.remove();
|
||||||
|
|
||||||
// Create a copy of the list so the hash can be manipulated
|
// Create a copy of the list so the hash can be manipulated
|
||||||
QList<Session *> sessions = sessionlist.values();
|
QList<Session *> sessions = sessionlist.values();
|
||||||
|
|
||||||
@ -491,12 +495,10 @@ bool Machine::Purge(int secret)
|
|||||||
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
|
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
|
||||||
dir.setSorting(QDir::Name);
|
dir.setSorting(QDir::Name);
|
||||||
|
|
||||||
QFileInfoList list = dir.entryInfoList();
|
const QFileInfoList & list = dir.entryInfoList();
|
||||||
int could_not_kill = 0;
|
int could_not_kill = 0;
|
||||||
|
|
||||||
int size = list.size();
|
for (const auto & fi : list) {
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
QFileInfo fi = list.at(i);
|
|
||||||
QString fullpath = fi.canonicalFilePath();
|
QString fullpath = fi.canonicalFilePath();
|
||||||
|
|
||||||
QString ext_s = fullpath.section('.', -1);
|
QString ext_s = fullpath.section('.', -1);
|
||||||
@ -516,7 +518,6 @@ bool Machine::Purge(int secret)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (could_not_kill > 0) {
|
if (could_not_kill > 0) {
|
||||||
qWarning() << "Could not purge path" << could_not_kill << "files in " << path;
|
qWarning() << "Could not purge path" << could_not_kill << "files in " << path;
|
||||||
return false;
|
return false;
|
||||||
|
@ -618,13 +618,15 @@ void Profile::LoadMachineData()
|
|||||||
|
|
||||||
void Profile::removeMachine(Machine * mach)
|
void Profile::removeMachine(Machine * mach)
|
||||||
{
|
{
|
||||||
m_machlist.removeAll(mach);
|
if (m_machlist.removeAll(mach)) {
|
||||||
auto mlit = MachineList.find(mach->loaderName());
|
|
||||||
|
|
||||||
if (mlit != MachineList.end()) {
|
QHash<QString, QHash<QString, Machine *> >::iterator mlit = MachineList.find(mach->loaderName());
|
||||||
auto mit = mlit.value().find(mach->serial());
|
|
||||||
if (mit != mlit.value().end()) {
|
if (mlit != MachineList.end()) {
|
||||||
mlit.value().erase(mit);
|
QHash<QString, Machine *>::iterator mit = mlit.value().find(mach->serial());
|
||||||
|
if (mit != mlit.value().end()) {
|
||||||
|
mlit.value().erase(mit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,6 +630,8 @@ void MainWindow::finishCPAPImport()
|
|||||||
GenerateStatistics();
|
GenerateStatistics();
|
||||||
profileSelector->updateProfileList();
|
profileSelector->updateProfileList();
|
||||||
|
|
||||||
|
welcome->refreshPage();
|
||||||
|
|
||||||
if (overview) { overview->ReloadGraphs(); }
|
if (overview) { overview->ReloadGraphs(); }
|
||||||
if (daily) {
|
if (daily) {
|
||||||
// daily->populateSessionWidget();
|
// daily->populateSessionWidget();
|
||||||
@ -1939,11 +1941,6 @@ void MainWindow::on_actionPurgeMachine(QAction *action)
|
|||||||
"<p>"+tr("Are you <b>absolutely sure</b> you want to proceed?")+"</p>", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
|
"<p>"+tr("Are you <b>absolutely sure</b> you want to proceed?")+"</p>", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
|
||||||
|
|
||||||
purgeMachine(mach);
|
purgeMachine(mach);
|
||||||
|
|
||||||
p_profile->DelMachine(mach);
|
|
||||||
delete mach;
|
|
||||||
PopulatePurgeMenu();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1957,6 +1954,38 @@ void MainWindow::purgeMachine(Machine * mach)
|
|||||||
if (mach->Purge(3478216)) {
|
if (mach->Purge(3478216)) {
|
||||||
mach->sessionlist.clear();
|
mach->sessionlist.clear();
|
||||||
mach->day.clear();
|
mach->day.clear();
|
||||||
|
QDir dir;
|
||||||
|
QString path = mach->getDataPath();
|
||||||
|
path.chop(1);
|
||||||
|
|
||||||
|
p_profile->DelMachine(mach);
|
||||||
|
delete mach;
|
||||||
|
// remove the directory unless it's got unexpected crap in it..
|
||||||
|
bool deleted = false;
|
||||||
|
if (!dir.remove(path)) {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
wchar_t* directoryPtr = (wchar_t*)path.utf16();
|
||||||
|
SetFileAttributes(directoryPtr, GetFileAttributes(directoryPtr) & ~FILE_ATTRIBUTE_READONLY);
|
||||||
|
if (!::RemoveDirectory(directoryPtr)) {
|
||||||
|
DWORD lastError = ::GetLastError();
|
||||||
|
qDebug() << "RemoveDirectory GetLastError: " << lastError;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qDebug() << "Success on second attempt deleting folder with windows API " << path;
|
||||||
|
deleted = true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
qDebug() << "Couldn't remove directory" << path;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
deleted = true;
|
||||||
|
}
|
||||||
|
if (!deleted) {
|
||||||
|
qDebug() << "Leaving backup folder intact";
|
||||||
|
}
|
||||||
|
|
||||||
|
PopulatePurgeMenu();
|
||||||
|
p_profile->StoreMachines();
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, STR_MessageBox_Error,
|
QMessageBox::warning(this, STR_MessageBox_Error,
|
||||||
tr("A file permission error or simillar screwed up the purge process, you will have to delete the following folder manually:")
|
tr("A file permission error or simillar screwed up the purge process, you will have to delete the following folder manually:")
|
||||||
@ -1972,6 +2001,7 @@ void MainWindow::purgeMachine(Machine * mach)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (overview) overview->ReloadGraphs();
|
if (overview) overview->ReloadGraphs();
|
||||||
QFile rxcache(p_profile->Get("{" + STR_GEN_DataFolder + "}/RXChanges.cache" ));
|
QFile rxcache(p_profile->Get("{" + STR_GEN_DataFolder + "}/RXChanges.cache" ));
|
||||||
rxcache.remove();
|
rxcache.remove();
|
||||||
@ -1980,9 +2010,13 @@ void MainWindow::purgeMachine(Machine * mach)
|
|||||||
daily->clearLastDay(); // otherwise Daily will crash
|
daily->clearLastDay(); // otherwise Daily will crash
|
||||||
daily->ReloadGraphs();
|
daily->ReloadGraphs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
welcome->refreshPage();
|
||||||
|
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// GenerateStatistics();
|
// GenerateStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,24 +10,10 @@ Welcome::Welcome(QWidget *parent) :
|
|||||||
ui(new Ui::Welcome)
|
ui(new Ui::Welcome)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
pixmap.load(":/icons/mask.png");
|
||||||
|
|
||||||
if (!p_profile) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The SDCard warning does not need to be seen anymore for people who DON'T use ResMed S9's.. show first import and only when S9 is present
|
|
||||||
|
|
||||||
const auto & mlist = p_profile->GetMachines(MT_CPAP);
|
|
||||||
bool showCardWarning = (mlist.size() == 0);
|
|
||||||
for (auto & mach :mlist) {
|
|
||||||
if (mach->series().compare("S9") == 0) showCardWarning = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->S9Warning->setVisible(showCardWarning);
|
|
||||||
|
|
||||||
ui->cpapInfo->setHtml(GenerateCPAPHTML());
|
|
||||||
ui->oxiInfo->setHtml(GenerateOxiHTML());
|
|
||||||
|
|
||||||
|
refreshPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
Welcome::~Welcome()
|
Welcome::~Welcome()
|
||||||
@ -35,6 +21,31 @@ Welcome::~Welcome()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Welcome::refreshPage()
|
||||||
|
{
|
||||||
|
const auto & mlist = p_profile->GetMachines(MT_CPAP);
|
||||||
|
|
||||||
|
bool b = mlist.size() > 0;
|
||||||
|
bool showCardWarning = !b;
|
||||||
|
|
||||||
|
|
||||||
|
// The SDCard warning does not need to be seen anymore for people who DON'T use ResMed S9's.. show first import and only when S9 is present
|
||||||
|
for (auto & mach :mlist) {
|
||||||
|
if (mach->series().compare("S9") == 0) showCardWarning = true;
|
||||||
|
}
|
||||||
|
ui->S9Warning->setVisible(showCardWarning);
|
||||||
|
|
||||||
|
if (!b) {
|
||||||
|
ui->cpapIcon->setPixmap(pixmap);
|
||||||
|
}
|
||||||
|
ui->dailyButton->setEnabled(b);
|
||||||
|
ui->overviewButton->setEnabled(b);
|
||||||
|
ui->statisticsButton->setEnabled(b);
|
||||||
|
|
||||||
|
ui->cpapInfo->setHtml(GenerateCPAPHTML());
|
||||||
|
ui->oxiInfo->setHtml(GenerateOxiHTML());
|
||||||
|
}
|
||||||
|
|
||||||
void Welcome::on_dailyButton_clicked()
|
void Welcome::on_dailyButton_clicked()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ public:
|
|||||||
explicit Welcome(QWidget *parent = 0);
|
explicit Welcome(QWidget *parent = 0);
|
||||||
~Welcome();
|
~Welcome();
|
||||||
|
|
||||||
|
void refreshPage();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_dailyButton_clicked();
|
void on_dailyButton_clicked();
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
QString GenerateCPAPHTML();
|
QString GenerateCPAPHTML();
|
||||||
QString GenerateOxiHTML();
|
QString GenerateOxiHTML();
|
||||||
|
QPixmap pixmap;
|
||||||
Ui::Welcome *ui;
|
Ui::Welcome *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,6 +29,21 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -226,19 +241,6 @@ border: 2px solid #56789a; border-radius: 10px;
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>or</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="dailyButton">
|
<widget class="QToolButton" name="dailyButton">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
@ -529,6 +531,19 @@ p, li { white-space: pre-wrap; }
|
|||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_7">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -567,6 +582,50 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="Resources.qrc">:/icons/sdcard-lock.png</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_8">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user