diff --git a/QTalarm.pro b/QTalarm.pro index 40ed81a..d1b62bd 100644 --- a/QTalarm.pro +++ b/QTalarm.pro @@ -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 diff --git a/aboutdialog.h b/aboutdialog.h index af3a1c2..d6e79cd 100644 --- a/aboutdialog.h +++ b/aboutdialog.h @@ -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; diff --git a/fileio.cpp b/fileio.cpp index cc97f02..683e9e7 100644 --- a/fileio.cpp +++ b/fileio.cpp @@ -1,6 +1,6 @@ #include "fileio.h" -#include "schedule.h" -#include "schedulecollection.h" +#include "schedulemodel.h" +#include "schedules.h" #include #include #include @@ -29,51 +29,51 @@ bool FileIO::DelExtracted() return QFile::remove(QDir::tempPath()+"/QTalarm.ogg"); } -QList FileIO::LoadConfig() +QList FileIO::LoadConfig() { - QList scheduleList; + QList scheduleList; QString indexStr; for(int index=0;index_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 SchedList=Collection->GetScheduleList(); - Schedule *currentSche; + QList SchedList=Collection->GetScheduleList(); + ScheduleModel *currentSche; int index=0; this->_Settings.setValue("AlarmCount",SchedList.count()); @@ -81,19 +81,19 @@ bool FileIO::Save(ScheduleCollection *Collection) { 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++; } diff --git a/fileio.h b/fileio.h index 61e235b..3b4e187 100644 --- a/fileio.h +++ b/fileio.h @@ -1,8 +1,8 @@ #ifndef FILEIO_H #define FILEIO_H -#include "schedulecollection.h" -#include "schedule.h" +#include "schedules.h" +#include "schedulemodel.h" #include #include #include @@ -14,8 +14,8 @@ class FileIO : public QObject explicit FileIO(QObject *parent = 0); static bool ExtractAudio(); static bool DelExtracted(); - QList LoadConfig(); - bool Save(ScheduleCollection*); + QList LoadConfig(); + bool Save(Schedules*); static int LoadVolume(); static void SaveVolume(int); static bool LoadWindowShow(); diff --git a/main.cpp b/main.cpp index 596b14b..15a2974 100644 --- a/main.cpp +++ b/main.cpp @@ -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[]) diff --git a/mainwindow.cpp b/mainwindow.cpp index 05ce9e7..b4cf6e9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,7 +3,7 @@ #include "timer.h" #include "alarm.h" #include "fileio.h" -#include "schedulecollection.h" +#include "schedules.h" #include "aboutdialog.h" #include "settingdialog.h" #include "snooze.h" @@ -38,25 +38,24 @@ MainWindow::MainWindow(QWidget *parent) : ConfigureButtons(); //Create / load Schedule - _Schedules=new ScheduleCollection(this); + _Schedules=new Schedules(this); _Schedules->LoadSchedules(); PopulateListWidget(); DisablePanelIfNoSelection(); if(ui->listWidget->currentRow()==0) ShowActiveAlarm(0); - _isMilTime=FileIO::isMilTime(); - _WarnOnPm=FileIO::LoadWarnOnPm(); - _prevTimeWasMil=_isMilTime; - displayTimeMode(); + LoadOptions(); //Setup threading TimeKeeper=new Timer(this,_Schedules); + //set up alarm singleton CurAlarm = &Alarm::GetInstance(); TimeKeeper->StartTimer(CurAlarm); SetupVolume(); + //Tray icons QAction *QAshow=new QAction("&Show",this); QAction *QAquit=new QAction("&Quit",this); SetupTrayIcon(QAshow,QAquit); @@ -128,8 +127,8 @@ void MainWindow::SetTime() { PMWarning(); } - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->SetTime(ui->timeEdit->time()); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->AlarmTime = ui->timeEdit->time(); UpdateListWidget(); this->_Schedules->Save(); } @@ -141,11 +140,11 @@ void MainWindow::SetCustomDate() { //Update date on the display ui->CustEdit->setDate(ui->calendarWidget->selectedDate()); - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->SetTime(ui->timeEdit->time()); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->AlarmTime = ui->timeEdit->time(); QDate CustomDate=ui->calendarWidget->selectedDate(); - Active->SetCust(CustomDate); - if(Active->isCustomEnabled()) + Active->CustomAlarm = CustomDate; + if(Active->isCustomAlarmEnabled) UpdateListWidget(); this->_Schedules->Save(); } @@ -153,8 +152,8 @@ void MainWindow::SetCustomDate() void MainWindow::ToggleBastard(bool val) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->SetIsBastard(val); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isBastard = val; UpdateListWidget(); this->_Schedules->Save(); SendTrayMessage(solveNotificationTitle,solveNotification); @@ -162,53 +161,53 @@ void MainWindow::ToggleBastard(bool val) void MainWindow::ToggleMon(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->setIsMonEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isMonEnabled = isEnabled; UpdateListWidget(); } void MainWindow::ToggleTue(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->setIsTueEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isTueEnabled = isEnabled; UpdateListWidget(); } void MainWindow::ToggleWed(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->setIsWedEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isWedEnabled = isEnabled; UpdateListWidget(); } void MainWindow::ToggleThur(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->setIsThurEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isThurEnabled = isEnabled; UpdateListWidget(); } void MainWindow::ToggleFri(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->setIsFriEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isFriEnabled = isEnabled; UpdateListWidget(); } void MainWindow::ToggleSat(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->setIsSatEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isSatEnabled = isEnabled; UpdateListWidget(); } void MainWindow::ToggleSun(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->setIsSunEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isSunEnabled = isEnabled; UpdateListWidget(); } void MainWindow::ToggleCust(bool isEnabled) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->SetCustEnabled(isEnabled); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isCustomAlarmEnabled = isEnabled; UpdateListWidget(); } @@ -231,7 +230,7 @@ void MainWindow::AddRemoveAlarm(QAbstractButton *button) { if(button->text()=="&Add") { - Schedule *scheToAdd=new Schedule(this); + ScheduleModel *scheToAdd=new ScheduleModel(this); this->_Schedules->AddSchedule(scheToAdd); ui->listWidget->addItem(scheToAdd->Name()); ui->listWidget->setCurrentRow(ui->listWidget->count()-1); @@ -244,21 +243,21 @@ void MainWindow::AddRemoveAlarm(QAbstractButton *button) } else if(button->text()=="Clone") { - Schedule *toClone = this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Schedule *cloned = new Schedule(this); - cloned->SetCust(toClone->GetCustomDate()); - cloned->setIsCustomEnabled(toClone->GetCustomEnabled()); - cloned->setIsCustomSoundEnabled(toClone->GetCustomSoundEnabled()); - cloned->setIsFriEnabled(toClone->isFriEnabled()); - cloned->setIsMonEnabled(toClone->isMonEnabled()); - cloned->setIsSatEnabled(toClone->isSatEnabled()); - cloned->setIsSunEnabled(toClone->isSunEnabled()); - cloned->setIsThurEnabled(toClone->isThurEnabled()); - cloned->setIsTueEnabled(toClone->isTueEnabled()); - cloned->setIsWedEnabled(toClone->isWedEnabled()); - cloned->SetIsBastard(toClone->isBastard()); - cloned->SetTime(toClone->GetTime()); - cloned->SetCustomSound(toClone->GetCustomSound()); + ScheduleModel *toClone = this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + ScheduleModel *cloned = new ScheduleModel(this); + cloned->CustomAlarm = toClone->CustomAlarm; + cloned->isCustomAlarmEnabled = toClone->isCustomAlarmEnabled; + cloned->isCustomSoundEnabled = toClone->isCustomSoundEnabled; + cloned->isFriEnabled = toClone->isFriEnabled; + cloned->isMonEnabled = toClone->isMonEnabled; + cloned->isSatEnabled = toClone->isSatEnabled; + cloned->isSunEnabled = toClone->isSunEnabled; + cloned->isThurEnabled = toClone->isThurEnabled; + cloned->isTueEnabled = toClone->isTueEnabled; + cloned->isWedEnabled = toClone->isWedEnabled; + cloned->isBastard = toClone->isBastard; + cloned->AlarmTime = toClone->AlarmTime; + cloned->CustomSoundPath = toClone->CustomSoundPath; this->_Schedules->AddSchedule(cloned); PopulateListWidget(); } @@ -279,23 +278,23 @@ void MainWindow::ShowActiveAlarm(int index) return; } this->ui->listAlmBtn->button(QDialogButtonBox::Ignore)->setDisabled(false); - Schedule *active=this->_Schedules->GetSchedule(index); - ui->timeEdit->setTime(active->GetTime()); + ScheduleModel *active=this->_Schedules->GetSchedule(index); + ui->timeEdit->setTime(active->AlarmTime); - ui->chkCustom->setChecked(active->GetCustomEnabled()); - ui->CustEdit->setDate(active->GetCustomDate()); - ui->chkSounds->setChecked(active->GetCustomSoundEnabled()); - ui->txtSoundPath->setText(active->GetCustomSound()); + ui->chkCustom->setChecked(active->isCustomAlarmEnabled); + ui->CustEdit->setDate(active->CustomAlarm); + ui->chkSounds->setChecked(active->isCustomSoundEnabled); + ui->txtSoundPath->setText(active->CustomSoundPath); - ui->chkMon->setChecked(active->isMonEnabled()); - ui->chkTues->setChecked(active->isTueEnabled()); - ui->chkWed->setChecked(active->isWedEnabled()); - ui->chkThurs->setChecked(active->isThurEnabled()); - ui->chkFri->setChecked(active->isFriEnabled()); - ui->chkSat->setChecked(active->isSatEnabled()); - ui->chkSun->setChecked(active->isSunEnabled()); - ui->calendarWidget->setSelectedDate(active->GetCustomDate()); - ui->chkBastard->setChecked(active->isBastard()); + ui->chkMon->setChecked(active->isMonEnabled); + ui->chkTues->setChecked(active->isTueEnabled); + ui->chkWed->setChecked(active->isWedEnabled); + ui->chkThurs->setChecked(active->isThurEnabled); + ui->chkFri->setChecked(active->isFriEnabled); + ui->chkSat->setChecked(active->isSatEnabled); + ui->chkSun->setChecked(active->isSunEnabled); + ui->calendarWidget->setSelectedDate(active->CustomAlarm); + ui->chkBastard->setChecked(active->isBastard); } void MainWindow::timeCheck() @@ -323,12 +322,12 @@ void MainWindow::UpdateClock() void MainWindow::OpenDiaglog(bool isChecked) { - Schedule *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); - Active->SetCustomSoundEnabled(isChecked); + ScheduleModel *Active=this->_Schedules->GetSchedule(ui->listWidget->currentRow()); + Active->isCustomSoundEnabled = isChecked; if(isChecked) { QString AlarmLocation = QFileDialog::getOpenFileName(this,"Select Alarm File",QDir::homePath()); - Active->SetCustomSound(AlarmLocation); + Active->CustomSoundPath = AlarmLocation; ui->txtSoundPath->setText(AlarmLocation); }else{ ui->txtSoundPath->setText(""); @@ -415,7 +414,7 @@ void MainWindow::displayTimeMode() void MainWindow::PopulateListWidget() { ui->listWidget->clear(); - Schedule *sche; + ScheduleModel *sche; foreach(sche,this->_Schedules->GetScheduleList()) { ui->listWidget->addItem(sche->Name()); @@ -566,3 +565,11 @@ void MainWindow::ConfigureButtons() ui->listAlmBtn->button(QDialogButtonBox::Cancel)->setText("&Remove"); ui->listAlmBtn->button(QDialogButtonBox::Cancel)->setDisabled(true); } + +void MainWindow::LoadOptions() +{ + _isMilTime=FileIO::isMilTime(); + _WarnOnPm=FileIO::LoadWarnOnPm(); + _prevTimeWasMil=_isMilTime; + displayTimeMode(); +} diff --git a/mainwindow.h b/mainwindow.h index c77f1db..8964c72 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -24,7 +24,7 @@ class MainWindow : public QMainWindow QMenu *trayIconMenu; Timer *TimeKeeper; Alarm *CurAlarm; - ScheduleCollection *_Schedules; + Schedules *_Schedules; int _lastDeletedIndex=-1; bool _isMilTime; @@ -33,6 +33,7 @@ class MainWindow : public QMainWindow bool _WarnOnPm; bool testrun=false; void displayTimeMode(); + void LoadOptions(); void closeEvent(QCloseEvent*); void SetupClock(); diff --git a/schedule.cpp b/schedule.cpp deleted file mode 100644 index 613e609..0000000 --- a/schedule.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "schedule.h" -#include -#include -#include - -Schedule::Schedule(QObject *parent) : - QObject(parent) -{ - this->setIsMonEnabled(false); - this->setIsTueEnabled(false); - this->setIsWedEnabled(false); - this->setIsThurEnabled(false); - this->setIsFriEnabled(false); - this->setIsSatEnabled(false); - this->setIsSunEnabled(false); - - this->SetCustEnabled(false); - this->SetTime(QTime::fromMSecsSinceStartOfDay(0)); - this->_CustomAlarm=QDate::currentDate(); - this->SetCustomSound(""); - this->SetCustomSoundEnabled(false); - this->SetIsBastard(false); -} - -void Schedule::SetCustEnabled(bool isEnabled) -{ - this->setIsCustomEnabled(isEnabled); -} - -void Schedule::SetCustomSoundEnabled(bool isEnabled) -{ - this->_isCustomSoundEnabled=isEnabled; -} - -void Schedule::SetTime(QTime time) -{ - this->_AlarmTime=time; -} - -QTime Schedule::GetTime() -{ - return this->_AlarmTime; -} - - -void Schedule::SetCust(QDate Date) -{ - this->_CustomAlarm=Date; -} - -void Schedule::SetCustomSound(QString SoundPath) -{ - this->_CustomSound=SoundPath; -} - -void Schedule::SetIsBastard(bool isBast) -{ - this->_isBastard=isBast; -} - -bool Schedule::GetCustomEnabled() -{ - return this->isCustomEnabled(); -} - -bool Schedule::GetCustomSoundEnabled() -{ - return this->_isCustomSoundEnabled; -} - - - -QDate Schedule::GetCustomDate() -{ - return this->_CustomAlarm; -} - -bool Schedule::isBastard() const -{ - return this->_isBastard; -} - - -QString Schedule::GetCustomSound() -{ - return this->_CustomSound; -} - -bool Schedule::isMonEnabled() const -{ - return _isMonEnabled; -} - -void Schedule::setIsMonEnabled(bool isMonEnabled) -{ - _isMonEnabled = isMonEnabled; -} - -bool Schedule::isTueEnabled() const -{ - return _isTueEnabled; -} - -void Schedule::setIsTueEnabled(bool isTueEnabled) -{ - _isTueEnabled = isTueEnabled; -} - -bool Schedule::isWedEnabled() const -{ - return _isWedEnabled; -} - -void Schedule::setIsWedEnabled(bool isWedEnabled) -{ - _isWedEnabled = isWedEnabled; -} - -bool Schedule::isThurEnabled() const -{ - return _isThurEnabled; -} - -void Schedule::setIsThurEnabled(bool isThurEnabled) -{ - _isThurEnabled = isThurEnabled; -} - -bool Schedule::isFriEnabled() const -{ - return _isFriEnabled; -} - -void Schedule::setIsFriEnabled(bool isFriEnabled) -{ - _isFriEnabled = isFriEnabled; -} - -bool Schedule::isSatEnabled() const -{ - return _isSatEnabled; -} - -void Schedule::setIsSatEnabled(bool isSatEnabled) -{ - _isSatEnabled = isSatEnabled; -} - -bool Schedule::isSunEnabled() const -{ - return _isSunEnabled; -} - -void Schedule::setIsSunEnabled(bool isSunEnabled) -{ - _isSunEnabled = isSunEnabled; -} - -bool Schedule::isCustomEnabled() const -{ - return _isCustomEnabled; -} - -void Schedule::setIsCustomEnabled(bool isCustomEnabled) -{ - _isCustomEnabled = isCustomEnabled; -} - -bool Schedule::isCustomSoundEnabled() const -{ - return _isCustomSoundEnabled; -} - -void Schedule::setIsCustomSoundEnabled(bool isCustomSoundEnabled) -{ - _isCustomSoundEnabled = isCustomSoundEnabled; -} - -QString Schedule::Name() -{ - QString name; - name=this->GetTime().toString()+" "; - - if(this->isMonEnabled()) - name.append(" M"); - if(this->isTueEnabled()) - name.append(" T"); - if(this->isWedEnabled()) - name.append(" W"); - if(this->isThurEnabled()) - name.append(" Th"); - if(this->isFriEnabled()) - name.append(" F"); - if(this->isSatEnabled()) - name.append(" Sat"); - if(this->isSunEnabled()) - name.append(" Sun"); - if(this->isCustomEnabled()) - name.append(" "+this->_CustomAlarm.toString()); - if(this->isBastard()) - name.append(" Σ"); - - return name; -} diff --git a/schedule.h b/schedule.h deleted file mode 100644 index d74ef29..0000000 --- a/schedule.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef SCHEDULE_H -#define SCHEDULE_H - -#include -#include -#include -#include - -//ew, why did I do this this way? -//The entire scheduling class needs a rewrite. -//Left over from my jr days.... -class Schedule : public QObject -{ - Q_OBJECT -public: - explicit Schedule(QObject *parent = 0); - void SetCustEnabled(bool); - void SetTime(QTime); - void SetCust(QDate); - void SetCustomSound(QString); - void SetCustomSoundEnabled(bool); - void SetIsBastard(bool); - - bool GetCustomEnabled(); - bool GetCustomSoundEnabled(); - - QTime GetTime(); - QDate GetCustomDate(); - QString GetCustomSound(); - int Index; - - bool isMonEnabled() const; - void setIsMonEnabled(bool isMonEnabled); - - bool isTueEnabled() const; - void setIsTueEnabled(bool isTueEnabled); - - bool isWedEnabled() const; - void setIsWedEnabled(bool isWedEnabled); - - bool isThurEnabled() const; - void setIsThurEnabled(bool isThurEnabled); - - bool isFriEnabled() const; - void setIsFriEnabled(bool isFriEnabled); - - bool isSatEnabled() const; - void setIsSatEnabled(bool isSatEnabled); - - bool isSunEnabled() const; - void setIsSunEnabled(bool isSunEnabled); - - bool isCustomEnabled() const; - void setIsCustomEnabled(bool isCustomEnabled); - - bool isCustomSoundEnabled() const; - void setIsCustomSoundEnabled(bool isCustomSoundEnabled); - bool isBastard() const; - - QString Name(); - -private: - QTime _AlarmTime; - QDate _CustomAlarm; - QString _CustomSound; - bool _isMonEnabled; - bool _isTueEnabled; - bool _isWedEnabled; - bool _isThurEnabled; - bool _isFriEnabled; - bool _isSatEnabled; - bool _isSunEnabled; - bool _isCustomEnabled; - bool _isCustomSoundEnabled; - bool _isBastard; - -signals: - -public slots: - -}; - -#endif // SCHEDULE_H diff --git a/schedulecollection.cpp b/schedulecollection.cpp deleted file mode 100644 index 0fc3add..0000000 --- a/schedulecollection.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "schedulecollection.h" -#include "schedule.h" -#include "fileio.h" -#include -#include - -ScheduleCollection::ScheduleCollection(QObject *parent) : - QObject(parent){} - -void ScheduleCollection::LoadSchedules() -{ - FileIO *config=new FileIO(this); - this->_Collection = config->LoadConfig(); -} - -Schedule* ScheduleCollection::GetSchedule(int Index) -{ - return _Collection[Index]; -} - -void ScheduleCollection::Save() -{ - FileIO * configIO=new FileIO(this); - configIO->Save(this); -} - -QList ScheduleCollection::GetScheduleList() -{ - return this->_Collection; -} - -int ScheduleCollection::GetCount() -{ - return this->_Collection.count(); -} - -void ScheduleCollection::AddSchedule(Schedule *scheToAdd) -{ - this->_Collection.append(scheToAdd); -} - -void ScheduleCollection::removeScheduleByIndex(int index) -{ - this->_Collection.removeAt(index); -} diff --git a/schedulecollection.h b/schedulecollection.h deleted file mode 100644 index 9f702d4..0000000 --- a/schedulecollection.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SCHEDULECOLLECTION_H -#define SCHEDULECOLLECTION_H - -#include "schedule.h" -#include -#include - -class ScheduleCollection : public QObject -{ - Q_OBJECT -public: - explicit ScheduleCollection(QObject *parent = 0); - Schedule* GetSchedule(int); - QList GetScheduleList(); - int GetCount(); - void AddSchedule(Schedule*); - void removeScheduleByIndex(int); - void LoadSchedules(); - void Save(); -private: - QList _Collection; -signals: - -public slots: - -}; - -#endif // SCHEDULECOLLECTION_H diff --git a/schedulemodel.cpp b/schedulemodel.cpp new file mode 100644 index 0000000..3913d5a --- /dev/null +++ b/schedulemodel.cpp @@ -0,0 +1,51 @@ +#include "schedulemodel.h" +#include +#include +#include + +ScheduleModel::ScheduleModel(QObject *parent) : + QObject(parent) +{ + this->isMonEnabled = false; + this->isTueEnabled = false; + this->isWedEnabled = false; + this->isThurEnabled = false; + this->isFriEnabled = false; + this->isSatEnabled = false; + this->isSunEnabled = false; + + this->isCustomAlarmEnabled = false; + this->AlarmTime = QTime::fromMSecsSinceStartOfDay(0); + this->CustomAlarm=QDate::currentDate(); + this->CustomSoundPath = ""; + this->isCustomSoundEnabled = false; + this->isBastard = false; +} + + +QString ScheduleModel::Name() +{ + QString name; + name=this->AlarmTime.toString()+" "; + + if(this->isMonEnabled) + name.append(" M"); + if(this->isTueEnabled) + name.append(" T"); + if(this->isWedEnabled) + name.append(" W"); + if(this->isThurEnabled) + name.append(" Th"); + if(this->isFriEnabled) + name.append(" F"); + if(this->isSatEnabled) + name.append(" Sat"); + if(this->isSunEnabled) + name.append(" Sun"); + if(this->isCustomAlarmEnabled) + name.append(" "+this->CustomAlarm.toString()); + if(this->isBastard) + name.append(" Σ"); + + return name; +} diff --git a/schedulemodel.h b/schedulemodel.h new file mode 100644 index 0000000..7468803 --- /dev/null +++ b/schedulemodel.h @@ -0,0 +1,42 @@ +#ifndef SCHEDULE_H +#define SCHEDULE_H + +#include +#include +#include +#include + +class ScheduleModel : public QObject +{ + Q_OBJECT +public: + explicit ScheduleModel(QObject *parent = 0); + + QDate CustomAlarm; + bool isCustomAlarmEnabled; + + QTime AlarmTime; + + int Index; + bool isBastard; + bool isMonEnabled; + bool isTueEnabled; + bool isWedEnabled; + bool isThurEnabled; + bool isFriEnabled; + bool isSatEnabled; + bool isSunEnabled; + + QString CustomSoundPath; + bool isCustomSoundEnabled; + + QString Name(); + + +signals: + +public slots: + +}; + +#endif // SCHEDULE_H diff --git a/schedules.cpp b/schedules.cpp new file mode 100644 index 0000000..ba67dbe --- /dev/null +++ b/schedules.cpp @@ -0,0 +1,40 @@ +#include "schedules.h" +#include "schedulemodel.h" +#include "fileio.h" +#include +#include + +Schedules::Schedules(QObject *parent) : + QObject(parent){} + +void Schedules::LoadSchedules() +{ + FileIO *config=new FileIO(this); + this->_Collection = config->LoadConfig(); +} + +ScheduleModel* Schedules::GetSchedule(int Index) +{ + return _Collection[Index]; +} + +void Schedules::Save() +{ + FileIO * configIO=new FileIO(this); + configIO->Save(this); +} + +QList Schedules::GetScheduleList() +{ + return this->_Collection; +} + +void Schedules::AddSchedule(ScheduleModel *scheToAdd) +{ + this->_Collection.append(scheToAdd); +} + +void Schedules::removeScheduleByIndex(int index) +{ + this->_Collection.removeAt(index); +} diff --git a/schedules.h b/schedules.h new file mode 100644 index 0000000..e0b1267 --- /dev/null +++ b/schedules.h @@ -0,0 +1,27 @@ +#ifndef SCHEDULES_H +#define SCHEDULES_H + +#include "schedulemodel.h" +#include +#include + +class Schedules : public QObject +{ + Q_OBJECT +public: + explicit Schedules(QObject *parent = 0); + ScheduleModel* GetSchedule(int); + QList GetScheduleList(); + void AddSchedule(ScheduleModel*); + void removeScheduleByIndex(int); + void LoadSchedules(); + void Save(); +private: + QList _Collection; +signals: + +public slots: + +}; + +#endif // SCHEDULES_H diff --git a/timer.cpp b/timer.cpp index 679b6a5..6afb0ea 100644 --- a/timer.cpp +++ b/timer.cpp @@ -2,11 +2,11 @@ #include #include #include -#include "schedule.h" -#include "schedulecollection.h" +#include "schedulemodel.h" +#include "schedules.h" #include "fileio.h" -Timer::Timer(QObject *parent,ScheduleCollection *Collection) : +Timer::Timer(QObject *parent,Schedules *Collection) : QObject(parent) { this->_Schedules=Collection; @@ -25,65 +25,65 @@ void Timer::AlarmCheck() //Compare saved times with now time if(!this->_CurAlarm->isPlaying() && this->_CurAlarm->canResume) { - Schedule *cur_sche; + ScheduleModel *cur_sche; foreach(cur_sche,this->_Schedules->GetScheduleList()) { - this->_CurAlarm->isBastard=cur_sche->isBastard(); - if(cur_sche->GetCustomSoundEnabled()) + this->_CurAlarm->isBastard=cur_sche->isBastard; + if(cur_sche->isCustomSoundEnabled) { - this->_CurAlarm->SetCustomPath(cur_sche->GetCustomSound()); + this->_CurAlarm->SetCustomPath(cur_sche->CustomSoundPath); } QDateTime RightNow=QDateTime::currentDateTime();//We're in now, now... bool soundAlarm=false; - if(cur_sche->GetTime().hour()==RightNow.time().hour() && cur_sche->GetTime().minute()==RightNow.time().minute()) + if(cur_sche->AlarmTime.hour()==RightNow.time().hour() && cur_sche->AlarmTime.minute()==RightNow.time().minute()) { switch(RightNow.date().dayOfWeek()) { //WeekDay Alarms case 1: - if(cur_sche->isMonEnabled()) + if(cur_sche->isMonEnabled) { soundAlarm=true; } break; case 2: - if(cur_sche->isTueEnabled()) + if(cur_sche->isTueEnabled) { soundAlarm=true; } break; case 3: - if(cur_sche->isWedEnabled()) + if(cur_sche->isWedEnabled) { soundAlarm=true; } break; case 4: - if(cur_sche->isThurEnabled()) + if(cur_sche->isThurEnabled) { soundAlarm=true; } break; case 5: - if(cur_sche->isFriEnabled()) + if(cur_sche->isFriEnabled) { soundAlarm=true; } break; case 6: - if(cur_sche->isSatEnabled()) + if(cur_sche->isSatEnabled) { soundAlarm=true; } break; case 7: - if(cur_sche->isSunEnabled()) + if(cur_sche->isSunEnabled) { soundAlarm=true; } @@ -92,9 +92,9 @@ void Timer::AlarmCheck() } } //Check for Custom Date Alarms - if(cur_sche->GetCustomEnabled() && cur_sche->GetCustomDate()==RightNow.date() && - cur_sche->GetTime().minute()==RightNow.time().minute() - && cur_sche->GetTime().hour()==RightNow.time().hour()) + if(cur_sche->isCustomAlarmEnabled && cur_sche->CustomAlarm == RightNow.date() && + cur_sche->AlarmTime.minute() == RightNow.time().minute() + && cur_sche->AlarmTime.hour() == RightNow.time().hour()) { soundAlarm=true; } @@ -102,7 +102,7 @@ void Timer::AlarmCheck() if(soundAlarm) { //Set Condtion One! - this->_CurAlarm->Start(cur_sche->GetCustomSoundEnabled()); + this->_CurAlarm->Start(cur_sche->isCustomSoundEnabled); break; } } diff --git a/timer.h b/timer.h index bd1e11e..b76fa3f 100644 --- a/timer.h +++ b/timer.h @@ -5,18 +5,18 @@ #include #include #include "alarm.h" -#include "schedulecollection.h" +#include "schedules.h" class Timer : public QObject { Q_OBJECT public: void StartTimer(Alarm*); - explicit Timer(QObject *parent = 0,ScheduleCollection* Collection=0); + explicit Timer(QObject *parent = 0,Schedules* Collection=0); private: Alarm *_CurAlarm; - ScheduleCollection *_Schedules; + Schedules *_Schedules; signals: