mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 18:50:44 +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()
|
||||
{
|
||||
if (info.type == MT_JOURNAL) return false;
|
||||
if (sessionlist.size() == 0) return false;
|
||||
|
||||
qDebug() << "Saving" << info.brand << "session info" << info.loadername;
|
||||
QString filename = getDataPath() + "Sessions.info";
|
||||
@ -457,9 +458,12 @@ bool Machine::Purge(int secret)
|
||||
QFile rxcache(p_profile->Get("{" + STR_GEN_DataFolder + "}/RXChanges.cache" ));
|
||||
rxcache.remove();
|
||||
|
||||
QFile sumfile(getDataPath()+"Summaries.xml.gz");
|
||||
QFile sumfile(getDataPath()+"/Summaries.xml.gz");
|
||||
sumfile.remove();
|
||||
|
||||
QFile sessinfofile(getDataPath()+"/Sessions.info");
|
||||
sessinfofile.remove();
|
||||
|
||||
// Create a copy of the list so the hash can be manipulated
|
||||
QList<Session *> sessions = sessionlist.values();
|
||||
|
||||
@ -491,12 +495,10 @@ bool Machine::Purge(int secret)
|
||||
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
|
||||
dir.setSorting(QDir::Name);
|
||||
|
||||
QFileInfoList list = dir.entryInfoList();
|
||||
const QFileInfoList & list = dir.entryInfoList();
|
||||
int could_not_kill = 0;
|
||||
|
||||
int size = list.size();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
QFileInfo fi = list.at(i);
|
||||
for (const auto & fi : list) {
|
||||
QString fullpath = fi.canonicalFilePath();
|
||||
|
||||
QString ext_s = fullpath.section('.', -1);
|
||||
@ -516,7 +518,6 @@ bool Machine::Purge(int secret)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (could_not_kill > 0) {
|
||||
qWarning() << "Could not purge path" << could_not_kill << "files in " << path;
|
||||
return false;
|
||||
|
@ -618,13 +618,15 @@ void Profile::LoadMachineData()
|
||||
|
||||
void Profile::removeMachine(Machine * mach)
|
||||
{
|
||||
m_machlist.removeAll(mach);
|
||||
auto mlit = MachineList.find(mach->loaderName());
|
||||
if (m_machlist.removeAll(mach)) {
|
||||
|
||||
if (mlit != MachineList.end()) {
|
||||
auto mit = mlit.value().find(mach->serial());
|
||||
if (mit != mlit.value().end()) {
|
||||
mlit.value().erase(mit);
|
||||
QHash<QString, QHash<QString, Machine *> >::iterator mlit = MachineList.find(mach->loaderName());
|
||||
|
||||
if (mlit != MachineList.end()) {
|
||||
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();
|
||||
profileSelector->updateProfileList();
|
||||
|
||||
welcome->refreshPage();
|
||||
|
||||
if (overview) { overview->ReloadGraphs(); }
|
||||
if (daily) {
|
||||
// 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) {
|
||||
|
||||
purgeMachine(mach);
|
||||
|
||||
p_profile->DelMachine(mach);
|
||||
delete mach;
|
||||
PopulatePurgeMenu();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1957,6 +1954,38 @@ void MainWindow::purgeMachine(Machine * mach)
|
||||
if (mach->Purge(3478216)) {
|
||||
mach->sessionlist.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 {
|
||||
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:")
|
||||
@ -1972,6 +2001,7 @@ void MainWindow::purgeMachine(Machine * mach)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (overview) overview->ReloadGraphs();
|
||||
QFile rxcache(p_profile->Get("{" + STR_GEN_DataFolder + "}/RXChanges.cache" ));
|
||||
rxcache.remove();
|
||||
@ -1980,9 +2010,13 @@ void MainWindow::purgeMachine(Machine * mach)
|
||||
daily->clearLastDay(); // otherwise Daily will crash
|
||||
daily->ReloadGraphs();
|
||||
}
|
||||
|
||||
welcome->refreshPage();
|
||||
|
||||
QApplication::processEvents();
|
||||
|
||||
|
||||
|
||||
// GenerateStatistics();
|
||||
}
|
||||
|
||||
|
@ -10,24 +10,10 @@ Welcome::Welcome(QWidget *parent) :
|
||||
ui(new Ui::Welcome)
|
||||
{
|
||||
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()
|
||||
@ -35,6 +21,31 @@ Welcome::~Welcome()
|
||||
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()
|
||||
{
|
||||
|
||||
|
@ -15,6 +15,8 @@ public:
|
||||
explicit Welcome(QWidget *parent = 0);
|
||||
~Welcome();
|
||||
|
||||
void refreshPage();
|
||||
|
||||
private slots:
|
||||
void on_dailyButton_clicked();
|
||||
|
||||
@ -29,6 +31,7 @@ private slots:
|
||||
private:
|
||||
QString GenerateCPAPHTML();
|
||||
QString GenerateOxiHTML();
|
||||
QPixmap pixmap;
|
||||
Ui::Welcome *ui;
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,21 @@
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
@ -226,19 +241,6 @@ border: 2px solid #56789a; border-radius: 10px;
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QToolButton" name="dailyButton">
|
||||
<property name="styleSheet">
|
||||
@ -529,6 +531,19 @@ p, li { white-space: pre-wrap; }
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<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>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
@ -567,6 +582,50 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user