Version bump
[someplayer] / src / timerdialog.cpp
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include "timerdialog.h"
21 #include "ui_timerdialog.h"
22
23 TimerDialog::TimerDialog(QWidget *parent) :
24     QDialog(parent),
25     ui(new Ui::TimerDialog)
26 {
27     ui->setupUi(this);
28     ui->disableCheckBox->setChecked(false);
29     ui->disableCheckBox->setVisible(false);
30 }
31
32 TimerDialog::~TimerDialog()
33 {
34     delete ui;
35 }
36
37 void TimerDialog::init() {
38         setTime(0, 0, 0);
39 }
40
41 void TimerDialog::setTime(int h, int m, int s) {
42         if (h < 0 || h > 12 || m < 0 || m > 59 || s < 0 || s > 59)
43                 return;
44         ui->hoursListWidget->setCurrentRow(h);
45         ui->hoursListWidget->scrollTo(ui->hoursListWidget->model()->index(h, 0));
46         ui->minutesListWidget->setCurrentRow(m);
47         ui->minutesListWidget->scrollTo(ui->minutesListWidget->model()->index(m, 0));
48         ui->secondsListWidget->setCurrentRow(s);
49         ui->secondsListWidget->scrollTo(ui->secondsListWidget->model()->index(s, 0));
50 }
51
52 void TimerDialog::getTime(int *h, int *m, int *s) {
53         (*h) = ui->hoursListWidget->currentRow();
54         (*m) = ui->minutesListWidget->currentRow();
55         (*s) = ui->secondsListWidget->currentRow();
56 }
57
58 bool TimerDialog::timerDisabled() {
59         return ui->disableCheckBox->isChecked();
60 }
61
62 void TimerDialog::showDisable() {
63         ui->disableCheckBox->setVisible(true);
64 }