author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /core/pim/datebook/datebooksettings.cpp | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
Diffstat (limited to 'core/pim/datebook/datebooksettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebooksettings.cpp | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp new file mode 100644 index 0000000..c5d8ac1 --- a/dev/null +++ b/core/pim/datebook/datebooksettings.cpp | |||
@@ -0,0 +1,135 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "datebooksettings.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | #include <qspinbox.h> | ||
26 | #include <qcheckbox.h> | ||
27 | #include <qcombobox.h> | ||
28 | |||
29 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, | ||
30 | const char *name, bool modal, WFlags fl ) | ||
31 | : DateBookSettingsBase( parent, name, modal, fl ), | ||
32 | ampm( whichClock ) | ||
33 | { | ||
34 | init(); | ||
35 | QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), | ||
36 | this, SLOT( slotChangeClock( bool ) ) ); | ||
37 | } | ||
38 | |||
39 | DateBookSettings::~DateBookSettings() | ||
40 | { | ||
41 | } | ||
42 | |||
43 | void DateBookSettings::setStartTime( int newStartViewTime ) | ||
44 | { | ||
45 | if ( ampm ) { | ||
46 | if ( newStartViewTime >= 12 ) { | ||
47 | newStartViewTime %= 12; | ||
48 | if ( newStartViewTime == 0 ) | ||
49 | newStartViewTime = 12; | ||
50 | spinStart->setSuffix( tr(":00 PM") ); | ||
51 | } | ||
52 | else if ( newStartViewTime == 0 ) { | ||
53 | newStartViewTime = 12; | ||
54 | spinStart->setSuffix( tr(":00 AM") ); | ||
55 | } | ||
56 | oldtime = newStartViewTime; | ||
57 | } | ||
58 | spinStart->setValue( newStartViewTime ); | ||
59 | } | ||
60 | |||
61 | int DateBookSettings::startTime() const | ||
62 | { | ||
63 | int returnMe = spinStart->value(); | ||
64 | if ( ampm ) { | ||
65 | if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) | ||
66 | returnMe += 12; | ||
67 | else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) | ||
68 | returnMe = 0; | ||
69 | } | ||
70 | return returnMe; | ||
71 | } | ||
72 | |||
73 | |||
74 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) | ||
75 | { | ||
76 | chkAlarmPreset->setChecked( bAlarm ); | ||
77 | if ( presetTime >=5 ) | ||
78 | spinPreset->setValue( presetTime ); | ||
79 | } | ||
80 | |||
81 | bool DateBookSettings::alarmPreset() const | ||
82 | { | ||
83 | return chkAlarmPreset->isChecked(); | ||
84 | } | ||
85 | |||
86 | int DateBookSettings::presetTime() const | ||
87 | { | ||
88 | return spinPreset->value(); | ||
89 | } | ||
90 | |||
91 | |||
92 | void DateBookSettings::slot12Hour( int i ) | ||
93 | { | ||
94 | if ( ampm ) { | ||
95 | if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { | ||
96 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | ||
97 | spinStart->setSuffix( tr(":00 PM") ); | ||
98 | } else { | ||
99 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | ||
100 | spinStart->setSuffix( tr(":00 AM") ); | ||
101 | } | ||
102 | oldtime = i; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | void DateBookSettings::init() | ||
107 | { | ||
108 | if ( ampm ) { | ||
109 | spinStart->setMinValue( 1 ); | ||
110 | spinStart->setMaxValue( 12 ); | ||
111 | spinStart->setValue( 12 ); | ||
112 | spinStart->setSuffix( tr(":00 AM") ); | ||
113 | oldtime = 12; | ||
114 | } else { | ||
115 | spinStart->setMinValue( 0 ); | ||
116 | spinStart->setMaxValue( 23 ); | ||
117 | spinStart->setSuffix( tr(":00") ); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | void DateBookSettings::slotChangeClock( bool whichClock ) | ||
122 | { | ||
123 | int saveMe; | ||
124 | saveMe = spinStart->value(); | ||
125 | if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { | ||
126 | if ( saveMe == 12 ) | ||
127 | saveMe = 0; | ||
128 | } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { | ||
129 | if ( saveMe != 12 ) | ||
130 | saveMe += 12; | ||
131 | } | ||
132 | ampm = whichClock; | ||
133 | init(); | ||
134 | setStartTime( saveMe ); | ||
135 | } | ||