Skip to content

Commit

Permalink
Refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
CountMurphy committed Feb 19, 2022
1 parent c8a20b4 commit c46cdb7
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 493 deletions.
8 changes: 4 additions & 4 deletions QTalarm.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ TEMPLATE = app
SOURCES += main.cpp\
bastardsnooze.cpp \
mainwindow.cpp \
schedulemodel.cpp \
timer.cpp \
alarm.cpp \
fileio.cpp \
schedule.cpp \
schedulecollection.cpp \
schedules.cpp \
aboutdialog.cpp \
snooze.cpp \
settingdialog.cpp

HEADERS += mainwindow.h \
bastardsnooze.h \
schedulemodel.h \
timer.h \
alarm.h \
fileio.h \
schedule.h \
schedulecollection.h \
schedules.h \
aboutdialog.h \
snooze.h \
settingdialog.h
Expand Down
2 changes: 1 addition & 1 deletion aboutdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AboutDialog : public QDialog
public:
explicit AboutDialog(QWidget *parent = 0);
~AboutDialog();
const QString version="2.3.0";
const QString version="2.3.1";

private:
Ui::AboutDialog *ui;
Expand Down
72 changes: 36 additions & 36 deletions fileio.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "fileio.h"
#include "schedule.h"
#include "schedulecollection.h"
#include "schedulemodel.h"
#include "schedules.h"
#include <QFile>
#include <QDir>
#include <QSettings>
Expand Down Expand Up @@ -29,71 +29,71 @@ bool FileIO::DelExtracted()
return QFile::remove(QDir::tempPath()+"/QTalarm.ogg");
}

QList<Schedule*> FileIO::LoadConfig()
QList<ScheduleModel*> FileIO::LoadConfig()
{
QList<Schedule*> scheduleList;
QList<ScheduleModel*> scheduleList;
QString indexStr;

for(int index=0;index<this->_Settings.value("AlarmCount").toInt();index++)
{
Schedule *sched=new Schedule(this);
ScheduleModel *sched=new ScheduleModel(this);

indexStr.setNum(index);

sched->SetTime(this->_Settings.value(indexStr+"Time").toTime());
if(sched->GetTime().isNull())
sched->AlarmTime = this->_Settings.value(indexStr+"Time").toTime();
if(sched->AlarmTime.isNull())
{
QTime reset;
reset.setHMS(0,0,0,0);
sched->SetTime(reset);
sched->AlarmTime = reset;
}

sched->setIsMonEnabled(this->_Settings.value(indexStr+"MonEnabled").toBool());
sched->setIsTueEnabled(this->_Settings.value(indexStr+"TueEnabled").toBool());
sched->setIsWedEnabled(this->_Settings.value(indexStr+"WedEnabled").toBool());
sched->setIsThurEnabled(this->_Settings.value(indexStr+"ThurEnabled").toBool());
sched->setIsFriEnabled(this->_Settings.value(indexStr+"FriEnabled").toBool());
sched->setIsSatEnabled(this->_Settings.value(indexStr+"SatEnabled").toBool());
sched->setIsSunEnabled(this->_Settings.value(indexStr+"SunEnabled").toBool());
sched->SetIsBastard(this->_Settings.value(indexStr+"Bastard").toBool());
sched->isMonEnabled = this->_Settings.value(indexStr+"MonEnabled").toBool();
sched->isTueEnabled = this->_Settings.value(indexStr+"TueEnabled").toBool();
sched->isWedEnabled = this->_Settings.value(indexStr+"WedEnabled").toBool();
sched->isThurEnabled = this->_Settings.value(indexStr+"ThurEnabled").toBool();
sched->isFriEnabled = this->_Settings.value(indexStr+"FriEnabled").toBool();
sched->isSatEnabled = this->_Settings.value(indexStr+"SatEnabled").toBool();
sched->isSunEnabled = this->_Settings.value(indexStr+"SunEnabled").toBool();
sched->isBastard = this->_Settings.value(indexStr+"Bastard").toBool();

sched->SetCustEnabled(this->_Settings.value(indexStr+"CustEnabled").toBool());
sched->SetCust(this->_Settings.value(indexStr+"CustDate").toDate());
sched->isCustomAlarmEnabled = this->_Settings.value(indexStr+"CustEnabled").toBool();
sched->CustomAlarm = this->_Settings.value(indexStr+"CustDate").toDate();

sched->SetCustomSoundEnabled(this->_Settings.value(indexStr+"CustomSoundEnabled").toBool());
sched->SetCustomSound(this->_Settings.value(indexStr+"CustomSound").toString());
sched->isCustomSoundEnabled = this->_Settings.value(indexStr+"CustomSoundEnabled").toBool();
sched->CustomSoundPath = this->_Settings.value(indexStr+"CustomSound").toString();

scheduleList.append(sched);
}
return scheduleList;
}

bool FileIO::Save(ScheduleCollection *Collection)
bool FileIO::Save(Schedules *Collection)
{
try
{
QList<Schedule*> SchedList=Collection->GetScheduleList();
Schedule *currentSche;
QList<ScheduleModel*> SchedList=Collection->GetScheduleList();
ScheduleModel *currentSche;
int index=0;

this->_Settings.setValue("AlarmCount",SchedList.count());
foreach(currentSche,SchedList)
{
QString IndexStr;
IndexStr.setNum(index);
this->_Settings.setValue(IndexStr+"MonEnabled",currentSche->isMonEnabled());
this->_Settings.setValue(IndexStr+"TueEnabled",currentSche->isTueEnabled());
this->_Settings.setValue(IndexStr+"WedEnabled",currentSche->isWedEnabled());
this->_Settings.setValue(IndexStr+"ThurEnabled",currentSche->isThurEnabled());
this->_Settings.setValue(IndexStr+"FriEnabled",currentSche->isFriEnabled());
this->_Settings.setValue(IndexStr+"SatEnabled",currentSche->isSatEnabled());
this->_Settings.setValue(IndexStr+"SunEnabled",currentSche->isSunEnabled());
this->_Settings.setValue(IndexStr+"Bastard",currentSche->isBastard());
this->_Settings.setValue(IndexStr+"Time",currentSche->GetTime());
this->_Settings.setValue(IndexStr+"CustEnabled",currentSche->GetCustomEnabled());
this->_Settings.setValue(IndexStr+"CustDate",currentSche->GetCustomDate());
this->_Settings.setValue(IndexStr+"CustomSoundEnabled",currentSche->GetCustomSoundEnabled());
this->_Settings.setValue(IndexStr+"CustomSound",currentSche->GetCustomSound());
this->_Settings.setValue(IndexStr+"MonEnabled",currentSche->isMonEnabled);
this->_Settings.setValue(IndexStr+"TueEnabled",currentSche->isTueEnabled);
this->_Settings.setValue(IndexStr+"WedEnabled",currentSche->isWedEnabled);
this->_Settings.setValue(IndexStr+"ThurEnabled",currentSche->isThurEnabled);
this->_Settings.setValue(IndexStr+"FriEnabled",currentSche->isFriEnabled);
this->_Settings.setValue(IndexStr+"SatEnabled",currentSche->isSatEnabled);
this->_Settings.setValue(IndexStr+"SunEnabled",currentSche->isSunEnabled);
this->_Settings.setValue(IndexStr+"Bastard",currentSche->isBastard);
this->_Settings.setValue(IndexStr+"Time",currentSche->AlarmTime);
this->_Settings.setValue(IndexStr+"CustEnabled",currentSche->isCustomAlarmEnabled);
this->_Settings.setValue(IndexStr+"CustDate",currentSche->CustomAlarm);
this->_Settings.setValue(IndexStr+"CustomSoundEnabled",currentSche->isCustomSoundEnabled);
this->_Settings.setValue(IndexStr+"CustomSound",currentSche->CustomSoundPath);
this->_Settings.sync();
index++;
}
Expand Down
8 changes: 4 additions & 4 deletions fileio.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef FILEIO_H
#define FILEIO_H

#include "schedulecollection.h"
#include "schedule.h"
#include "schedules.h"
#include "schedulemodel.h"
#include <QObject>
#include <QSettings>
#include <QList>
Expand All @@ -14,8 +14,8 @@ class FileIO : public QObject
explicit FileIO(QObject *parent = 0);
static bool ExtractAudio();
static bool DelExtracted();
QList<Schedule *> LoadConfig();
bool Save(ScheduleCollection*);
QList<ScheduleModel *> LoadConfig();
bool Save(Schedules*);
static int LoadVolume();
static void SaveVolume(int);
static bool LoadWindowShow();
Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
HACK THE PLANET
*/

int main(int argc, char *argv[])
Expand Down
Loading

0 comments on commit c46cdb7

Please sign in to comment.