ui->setupUi(this);
-
-
- connect(ui->CreateNewScheduleButton, SIGNAL (pressed()), this, SLOT (newTimerSequence()));
-
-
//alerts' tableview setup
ui->ComingAlertsTableView->setModel(&model_);
ui->ComingAlertsTableView->setSelectionMode(QAbstractItemView::SingleSelection);
ui->ComingAlertsTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
- ui->ComingAlertsTableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
+ ui->ComingAlertsTableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
+ ui->ComingAlertsTableView->horizontalHeader()->resizeSection(0,460);
+ ui->ComingAlertsTableView->horizontalHeader()->resizeSection(1,140);
+ ui->ComingAlertsTableView->horizontalHeader()->resizeSection(2,100);
+
+ ui->ComingAlertsTableView->verticalHeader()->setResizeMode(QHeaderView::Fixed);
+ ui->ComingAlertsTableView->verticalHeader()->setDefaultSectionSize(40);
+
+
+
+
ui->ComingAlertsTableView->horizontalHeader()->hide();
+ ui->ComingAlertsTableView->setWordWrap(true);
- //Buttons used to reacting an alarm are hidden by default
+ //Buttons used when a timer is selected are disabled by default and enabled upon selection
disableSelectionDependentButtons();
-
connect(ui->ComingAlertsTableView->selectionModel(),SIGNAL(selectionChanged(QItemSelection,QItemSelection)),this,SLOT(timerSelected(QItemSelection,QItemSelection)));
+ //connect buttons to respective functions
+ connect(ui->CreateNewScheduleButton, SIGNAL (pressed()), this, SLOT (newTimerSequence()));
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
if (createdialog.exec() == QDialog::Accepted) //if user pressed OK
{
+ //get user input from the dialog
- QList<Timer *> alltimers = createdialog.getTimers(); //get user input from the dialog
- Timer* timer1 = alltimers.at(0); // take first timer (currently the only one!)
+ QList<Timer *> alltimers = createdialog.getTimers();
+
+ // take first timer (currently the only one!)
+
+
+ Timer* timer1 = alltimers.at(0);
+
+
+ //connect alert
- timer1->start();
connect(timer1,SIGNAL(alert(QModelIndex)),this,SLOT(alert(QModelIndex)));
+ //Disable buttons, as selection is cleared when view is refreshed to show the new timer
+
+ disableSelectionDependentButtons();
- model_.addTimers(alltimers); // give timers to the model
- // ui->ComingAlertsTableView->resizeColumnsToContents();
+ // give timers to the model
+ model_.addTimers(alltimers);
- //Disable buttons, as selection is cleared when view is refreshed to show the new timer
- disableSelectionDependentButtons();
+ //start the timer when it's safely in the model (consider moving this to the model's addTimers function)
+ timer1->start();
+
}
// if cancelled, do nothing
// The alerting timer is selected
ui->ComingAlertsTableView->selectionModel()->select(QItemSelection(indexOfAlerter,indexOfAlerter),QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows );
- qDebug() << "Should be selected now";
+// qDebug() << "Should be selected now";
//Snooze button is enabled
ui->SnoozeButton->setEnabled(true);
- //The alert sound is played
+ //The alert sound is played (consider moving this operation inside timer, as now stopping one alert will silence all alerting alerts)
alertSound_.play();
{
ui->DoneButton->setEnabled(true);
ui->RestartButton->setEnabled(true);
+ ui->RemoveButton->setEnabled(true);
//enabled only when alerting
}
ui->SnoozeButton->setDisabled(true);
alertSound_.stop();
+ qDebug() << "Stopped.";
}
QModelIndex KitchenAlertMainWindow::selectedRow()
void KitchenAlertMainWindow::openAbout()
{
- QMessageBox::about(this,tr("About KitchenAlert"),tr("<p>Version 0.1"
+ QMessageBox::about(this,tr("About KitchenAlert"),tr("<p>Version 0.1.1"
"<p>Copyright © Heli Hyvättinen 2010"
"<p>License: General Public License v3"
"<p>Bugtracker and project page: https://garage.maemo.org/projects/kitchenalert/"));
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())
+ {
+ model_.removeTimer(row);
+ alertSound_.stop();
+ ui->ComingAlertsTableView->clearSelection();
+ disableSelectionDependentButtons();
+ }
}