Skip to content

Commit c46cdb7

Browse files
committed
Refactored
1 parent c8a20b4 commit c46cdb7

17 files changed

+302
-493
lines changed

QTalarm.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ TEMPLATE = app
1515
SOURCES += main.cpp\
1616
bastardsnooze.cpp \
1717
mainwindow.cpp \
18+
schedulemodel.cpp \
1819
timer.cpp \
1920
alarm.cpp \
2021
fileio.cpp \
21-
schedule.cpp \
22-
schedulecollection.cpp \
22+
schedules.cpp \
2323
aboutdialog.cpp \
2424
snooze.cpp \
2525
settingdialog.cpp
2626

2727
HEADERS += mainwindow.h \
2828
bastardsnooze.h \
29+
schedulemodel.h \
2930
timer.h \
3031
alarm.h \
3132
fileio.h \
32-
schedule.h \
33-
schedulecollection.h \
33+
schedules.h \
3434
aboutdialog.h \
3535
snooze.h \
3636
settingdialog.h

aboutdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AboutDialog : public QDialog
1414
public:
1515
explicit AboutDialog(QWidget *parent = 0);
1616
~AboutDialog();
17-
const QString version="2.3.0";
17+
const QString version="2.3.1";
1818

1919
private:
2020
Ui::AboutDialog *ui;

fileio.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "fileio.h"
2-
#include "schedule.h"
3-
#include "schedulecollection.h"
2+
#include "schedulemodel.h"
3+
#include "schedules.h"
44
#include <QFile>
55
#include <QDir>
66
#include <QSettings>
@@ -29,71 +29,71 @@ bool FileIO::DelExtracted()
2929
return QFile::remove(QDir::tempPath()+"/QTalarm.ogg");
3030
}
3131

32-
QList<Schedule*> FileIO::LoadConfig()
32+
QList<ScheduleModel*> FileIO::LoadConfig()
3333
{
34-
QList<Schedule*> scheduleList;
34+
QList<ScheduleModel*> scheduleList;
3535
QString indexStr;
3636

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

4141
indexStr.setNum(index);
4242

43-
sched->SetTime(this->_Settings.value(indexStr+"Time").toTime());
44-
if(sched->GetTime().isNull())
43+
sched->AlarmTime = this->_Settings.value(indexStr+"Time").toTime();
44+
if(sched->AlarmTime.isNull())
4545
{
4646
QTime reset;
4747
reset.setHMS(0,0,0,0);
48-
sched->SetTime(reset);
48+
sched->AlarmTime = reset;
4949
}
5050

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

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

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

6666
scheduleList.append(sched);
6767
}
6868
return scheduleList;
6969
}
7070

71-
bool FileIO::Save(ScheduleCollection *Collection)
71+
bool FileIO::Save(Schedules *Collection)
7272
{
7373
try
7474
{
75-
QList<Schedule*> SchedList=Collection->GetScheduleList();
76-
Schedule *currentSche;
75+
QList<ScheduleModel*> SchedList=Collection->GetScheduleList();
76+
ScheduleModel *currentSche;
7777
int index=0;
7878

7979
this->_Settings.setValue("AlarmCount",SchedList.count());
8080
foreach(currentSche,SchedList)
8181
{
8282
QString IndexStr;
8383
IndexStr.setNum(index);
84-
this->_Settings.setValue(IndexStr+"MonEnabled",currentSche->isMonEnabled());
85-
this->_Settings.setValue(IndexStr+"TueEnabled",currentSche->isTueEnabled());
86-
this->_Settings.setValue(IndexStr+"WedEnabled",currentSche->isWedEnabled());
87-
this->_Settings.setValue(IndexStr+"ThurEnabled",currentSche->isThurEnabled());
88-
this->_Settings.setValue(IndexStr+"FriEnabled",currentSche->isFriEnabled());
89-
this->_Settings.setValue(IndexStr+"SatEnabled",currentSche->isSatEnabled());
90-
this->_Settings.setValue(IndexStr+"SunEnabled",currentSche->isSunEnabled());
91-
this->_Settings.setValue(IndexStr+"Bastard",currentSche->isBastard());
92-
this->_Settings.setValue(IndexStr+"Time",currentSche->GetTime());
93-
this->_Settings.setValue(IndexStr+"CustEnabled",currentSche->GetCustomEnabled());
94-
this->_Settings.setValue(IndexStr+"CustDate",currentSche->GetCustomDate());
95-
this->_Settings.setValue(IndexStr+"CustomSoundEnabled",currentSche->GetCustomSoundEnabled());
96-
this->_Settings.setValue(IndexStr+"CustomSound",currentSche->GetCustomSound());
84+
this->_Settings.setValue(IndexStr+"MonEnabled",currentSche->isMonEnabled);
85+
this->_Settings.setValue(IndexStr+"TueEnabled",currentSche->isTueEnabled);
86+
this->_Settings.setValue(IndexStr+"WedEnabled",currentSche->isWedEnabled);
87+
this->_Settings.setValue(IndexStr+"ThurEnabled",currentSche->isThurEnabled);
88+
this->_Settings.setValue(IndexStr+"FriEnabled",currentSche->isFriEnabled);
89+
this->_Settings.setValue(IndexStr+"SatEnabled",currentSche->isSatEnabled);
90+
this->_Settings.setValue(IndexStr+"SunEnabled",currentSche->isSunEnabled);
91+
this->_Settings.setValue(IndexStr+"Bastard",currentSche->isBastard);
92+
this->_Settings.setValue(IndexStr+"Time",currentSche->AlarmTime);
93+
this->_Settings.setValue(IndexStr+"CustEnabled",currentSche->isCustomAlarmEnabled);
94+
this->_Settings.setValue(IndexStr+"CustDate",currentSche->CustomAlarm);
95+
this->_Settings.setValue(IndexStr+"CustomSoundEnabled",currentSche->isCustomSoundEnabled);
96+
this->_Settings.setValue(IndexStr+"CustomSound",currentSche->CustomSoundPath);
9797
this->_Settings.sync();
9898
index++;
9999
}

fileio.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef FILEIO_H
22
#define FILEIO_H
33

4-
#include "schedulecollection.h"
5-
#include "schedule.h"
4+
#include "schedules.h"
5+
#include "schedulemodel.h"
66
#include <QObject>
77
#include <QSettings>
88
#include <QList>
@@ -14,8 +14,8 @@ class FileIO : public QObject
1414
explicit FileIO(QObject *parent = 0);
1515
static bool ExtractAudio();
1616
static bool DelExtracted();
17-
QList<Schedule *> LoadConfig();
18-
bool Save(ScheduleCollection*);
17+
QList<ScheduleModel *> LoadConfig();
18+
bool Save(Schedules*);
1919
static int LoadVolume();
2020
static void SaveVolume(int);
2121
static bool LoadWindowShow();

main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ along with this program; if not, write to the Free Software
2020
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
2121
USA
2222
23+
HACK THE PLANET
2324
*/
2425

2526
int main(int argc, char *argv[])

0 commit comments

Comments
 (0)