connect(ui->DoneButton,SIGNAL(clicked()),this,SLOT(stop()));
connect(ui->RestartButton,SIGNAL(clicked()),this,SLOT(restart()));
connect(ui->SnoozeButton,SIGNAL(clicked()),this, SLOT(snooze()));
-
+ connect(ui->RemoveButton,SIGNAL(clicked()),this,SLOT(remove()));
// menu setup
QAction * p_SelectSoundAction = new QAction(tr("Select alert sound"),this);
connect(timer1,SIGNAL(alert(QModelIndex)),this,SLOT(alert(QModelIndex)));
- //TODO: FIND A WAY TO INFORM THE TIMERS' ALERTSOUND'S OF A CHANGE OF THE SOUND FILE THEY SHOULD USE!!!!
+
connect(this,SIGNAL(defaultSoundEnabled()),timer1,SLOT(enableDefaultSound()));
connect(this,SIGNAL(soundChanged(QString)),timer1,SLOT(changeAlertSound(QString)));
// The program is brought to front and activated when alerted
- raise();
+
activateWindow();
+// removing everything below does not solve the bug #6752!
+
+ raise(); //this may be unnecessary
+
// The alerting timer is selected
ui->ComingAlertsTableView->selectionModel()->select(QItemSelection(indexOfAlerter,indexOfAlerter),QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows );
+
+ //Scrolls the view so that the alerting timer is visible
ui->ComingAlertsTableView->scrollTo(indexOfAlerter);
- qDebug() << "Should be selected now";
+
+ // qDebug() << "Should be selected now";
//Snooze button is enabled
ui->SnoozeButton->setEnabled(true);
-
- //Debug message
-
-
-
- ui->debugLabel->setText(tr("Alert received from row %1").arg(indexOfAlerter.row()));
- qDebug() << "Wrote the debug message";
-
- //The alert sound is played
- //TESTING TO MOVE THIS OPERATION TO THE TIMER ITSELF
-// alertSound_.play();
+qDebug ("Snooze päälle hälytyksessä");
}
{
ui->DoneButton->setEnabled(true);
ui->RestartButton->setEnabled(true);
+ ui->RemoveButton->setEnabled(true);
//snooze button enabled only when alerting
if (model_.isThisTimerAlerting(index) == true)
{
ui->SnoozeButton->setEnabled(true);
+qDebug() << "Snooze päälle";
+ }
+ else
+ {
+ ui->SnoozeButton->setDisabled(true);
+qDebug() << "Snooze pois päältä";
}
- else ui->SnoozeButton->setDisabled(true);
}
}
model_.startTimer(row);
}
+
+
ui->SnoozeButton->setDisabled(true);
+ qDebug () << "disabled snooze because of restart";
// alertSound_.stop();
}
QModelIndex KitchenAlertMainWindow::selectedRow()
{
+ //Returns the cells in row 0 that have the whole row selected (the selection mode used allows only selecting whole rows
+
QModelIndexList chosenRows = ui->ComingAlertsTableView->selectionModel()->selectedRows();
//The selection mode used allows only one row to be selected at time, so we just take the first
- //There are indexes for all columns in the row in the list, but as we only use the row, it does not matter which one we take
+
return chosenRows.value(0); //gives an invalid QModelIndex if the list is empty
}
bool KitchenAlertMainWindow::event(QEvent *event)
{
- QMainWindow::event(event);
-
switch (event->type())
case QEvent::WindowActivate:
model_.setUpdateViewOnChanges(true);
-
-
- break;
+// ui->debugLabel->setText("Returned to the application!");
+ break;
case QEvent::WindowDeactivate:
model_.setUpdateViewOnChanges(false);
+// ui->debugLabel->setText("");
break;
default:
break;
-
}
+
+ return QMainWindow::event(event); // Send the event to the base class implementation (also when handling the event in this function): necessary for the program to work!
}
void KitchenAlertMainWindow::disableSelectionDependentButtons()
ui->DoneButton->setDisabled(true);
ui->SnoozeButton->setDisabled(true);
ui->RestartButton->setDisabled(true);
+ ui->RemoveButton->setDisabled(true);
}
}
}
+
+void KitchenAlertMainWindow::remove()
+{
+ QModelIndex row = selectedRow();
+ if (row.isValid()) //If there was no row selected invalid row was returned
+ {
+ QString text = tr("Are you sure you want to remove this timer from the list:\n");
+ text.append((row.data().toString()));
+ if (QMessageBox::question(this,tr("Confirm timer removal"),text,QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
+ {
+ model_.removeTimer(row);
+ }
+ }
+ ui->SnoozeButton->setDisabled(true);
+}