Diffstat (limited to 'core/pim/datebook/datebooksettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebooksettings.cpp | 124 |
1 files changed, 80 insertions, 44 deletions
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp index cb4b73b..861e266 100644 --- a/core/pim/datebook/datebooksettings.cpp +++ b/core/pim/datebook/datebooksettings.cpp | |||
@@ -15,141 +15,177 @@ | |||
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "datebooksettings.h" | 21 | #include "datebooksettings.h" |
22 | 22 | ||
23 | #include <opie2/opluginloader.h> | ||
24 | #include <opie2/odebug.h> | ||
25 | |||
23 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
24 | 27 | ||
25 | #include <qspinbox.h> | 28 | #include <qspinbox.h> |
26 | #include <qcheckbox.h> | 29 | #include <qcheckbox.h> |
30 | #include <qlistview.h> | ||
31 | #include <qheader.h> | ||
27 | 32 | ||
28 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, | 33 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, |
29 | const char *name, bool modal, WFlags fl ) | 34 | const char *name, bool modal, WFlags fl ) |
30 | : DateBookSettingsBase( parent, name, modal, fl ), | 35 | : DateBookSettingsBase( parent, name, modal, fl ), |
31 | ampm( whichClock ) | 36 | ampm( whichClock ) |
32 | { | 37 | { |
33 | init(); | 38 | init(); |
34 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); | 39 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); |
35 | QArray<int> categories; | 40 | QArray<int> categories; |
36 | comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); | 41 | comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); |
42 | m_loader = 0; | ||
43 | m_manager = 0; | ||
44 | m_PluginListView->header()->hide(); | ||
45 | m_PluginListView->setSorting(-1); | ||
37 | } | 46 | } |
38 | 47 | ||
39 | DateBookSettings::~DateBookSettings() | 48 | DateBookSettings::~DateBookSettings() |
40 | { | 49 | { |
41 | } | 50 | } |
42 | 51 | ||
43 | void DateBookSettings::setStartTime( int newStartViewTime ) | 52 | void DateBookSettings::setStartTime( int newStartViewTime ) |
44 | { | 53 | { |
45 | if ( ampm ) { | 54 | if ( ampm ) { |
46 | if ( newStartViewTime >= 12 ) { | 55 | if ( newStartViewTime >= 12 ) { |
47 | newStartViewTime %= 12; | 56 | newStartViewTime %= 12; |
48 | if ( newStartViewTime == 0 ) | 57 | if ( newStartViewTime == 0 ) |
49 | newStartViewTime = 12; | 58 | newStartViewTime = 12; |
50 | spinStart->setSuffix( tr(":00 PM") ); | 59 | spinStart->setSuffix( tr(":00 PM") ); |
51 | } | 60 | } |
52 | else if ( newStartViewTime == 0 ) { | 61 | else if ( newStartViewTime == 0 ) { |
53 | newStartViewTime = 12; | 62 | newStartViewTime = 12; |
54 | spinStart->setSuffix( tr(":00 AM") ); | 63 | spinStart->setSuffix( tr(":00 AM") ); |
55 | } | 64 | } |
56 | oldtime = newStartViewTime; | 65 | oldtime = newStartViewTime; |
57 | } | 66 | } |
58 | spinStart->setValue( newStartViewTime ); | 67 | spinStart->setValue( newStartViewTime ); |
59 | } | 68 | } |
60 | 69 | ||
61 | int DateBookSettings::startTime() const | 70 | int DateBookSettings::startTime() const |
62 | { | 71 | { |
63 | int returnMe = spinStart->value(); | 72 | int returnMe = spinStart->value(); |
64 | if ( ampm ) { | 73 | if ( ampm ) { |
65 | if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) | 74 | if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) |
66 | returnMe += 12; | 75 | returnMe += 12; |
67 | else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) | 76 | else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) |
68 | returnMe = 0; | 77 | returnMe = 0; |
69 | } | 78 | } |
70 | return returnMe; | 79 | return returnMe; |
71 | } | 80 | } |
72 | 81 | ||
82 | void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader) | ||
83 | { | ||
84 | m_manager = aManager; | ||
85 | m_loader = aLoader; | ||
86 | if (!aManager||!aLoader) return; | ||
87 | Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true); | ||
88 | QCheckListItem *pitem = 0; | ||
89 | |||
90 | for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { | ||
91 | pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox); | ||
92 | pitem->setOn( (*it).isEnabled() ); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | void DateBookSettings::pluginItemClicked(QListViewItem *aItem) | ||
97 | { | ||
98 | if (!aItem||!m_manager||!m_loader) return; | ||
99 | QCheckListItem*pitem = ((QCheckListItem*)aItem); | ||
100 | |||
101 | Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true ); | ||
102 | for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
103 | if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) { | ||
104 | m_manager->setEnabled((*it),pitem->isOn()); | ||
105 | break; | ||
106 | } | ||
107 | } | ||
108 | } | ||
73 | 109 | ||
74 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) | 110 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) |
75 | { | 111 | { |
76 | chkAlarmPreset->setChecked( bAlarm ); | 112 | chkAlarmPreset->setChecked( bAlarm ); |
77 | if ( presetTime >=5 ) | 113 | if ( presetTime >=5 ) |
78 | spinPreset->setValue( presetTime ); | 114 | spinPreset->setValue( presetTime ); |
79 | } | 115 | } |
80 | 116 | ||
81 | bool DateBookSettings::alarmPreset() const | 117 | bool DateBookSettings::alarmPreset() const |
82 | { | 118 | { |
83 | return chkAlarmPreset->isChecked(); | 119 | return chkAlarmPreset->isChecked(); |
84 | } | 120 | } |
85 | 121 | ||
86 | int DateBookSettings::presetTime() const | 122 | int DateBookSettings::presetTime() const |
87 | { | 123 | { |
88 | return spinPreset->value(); | 124 | return spinPreset->value(); |
89 | } | 125 | } |
90 | 126 | ||
91 | 127 | ||
92 | void DateBookSettings::slot12Hour( int i ) | 128 | void DateBookSettings::slot12Hour( int i ) |
93 | { | 129 | { |
94 | if ( ampm ) { | 130 | if ( ampm ) { |
95 | if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { | 131 | if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { |
96 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | 132 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) |
97 | spinStart->setSuffix( tr(":00 PM") ); | 133 | spinStart->setSuffix( tr(":00 PM") ); |
98 | } else { | 134 | } else { |
99 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) | 135 | if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) |
100 | spinStart->setSuffix( tr(":00 AM") ); | 136 | spinStart->setSuffix( tr(":00 AM") ); |
101 | } | 137 | } |
102 | oldtime = i; | 138 | oldtime = i; |
103 | } | 139 | } |
104 | } | 140 | } |
105 | 141 | ||
106 | void DateBookSettings::init() | 142 | void DateBookSettings::init() |
107 | { | 143 | { |
108 | if ( ampm ) { | 144 | if ( ampm ) { |
109 | spinStart->setMinValue( 1 ); | 145 | spinStart->setMinValue( 1 ); |
110 | spinStart->setMaxValue( 12 ); | 146 | spinStart->setMaxValue( 12 ); |
111 | spinStart->setValue( 12 ); | 147 | spinStart->setValue( 12 ); |
112 | spinStart->setSuffix( tr(":00 AM") ); | 148 | spinStart->setSuffix( tr(":00 AM") ); |
113 | oldtime = 12; | 149 | oldtime = 12; |
114 | } else { | 150 | } else { |
115 | spinStart->setMinValue( 0 ); | 151 | spinStart->setMinValue( 0 ); |
116 | spinStart->setMaxValue( 23 ); | 152 | spinStart->setMaxValue( 23 ); |
117 | spinStart->setSuffix( tr(":00") ); | 153 | spinStart->setSuffix( tr(":00") ); |
118 | } | 154 | } |
119 | } | 155 | } |
120 | 156 | ||
121 | void DateBookSettings::slotChangeClock( bool whichClock ) | 157 | void DateBookSettings::slotChangeClock( bool whichClock ) |
122 | { | 158 | { |
123 | int saveMe; | 159 | int saveMe; |
124 | saveMe = spinStart->value(); | 160 | saveMe = spinStart->value(); |
125 | if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { | 161 | if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { |
126 | if ( saveMe == 12 ) | 162 | if ( saveMe == 12 ) |
127 | saveMe = 0; | 163 | saveMe = 0; |
128 | } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { | 164 | } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { |
129 | if ( saveMe != 12 ) | 165 | if ( saveMe != 12 ) |
130 | saveMe += 12; | 166 | saveMe += 12; |
131 | } | 167 | } |
132 | ampm = whichClock; | 168 | ampm = whichClock; |
133 | init(); | 169 | init(); |
134 | setStartTime( saveMe ); | 170 | setStartTime( saveMe ); |
135 | } | 171 | } |
136 | 172 | ||
137 | void DateBookSettings::setJumpToCurTime( bool bJump ) | 173 | void DateBookSettings::setJumpToCurTime( bool bJump ) |
138 | { | 174 | { |
139 | chkJumpToCurTime->setChecked( bJump ); | 175 | chkJumpToCurTime->setChecked( bJump ); |
140 | } | 176 | } |
141 | 177 | ||
142 | bool DateBookSettings::jumpToCurTime() const | 178 | bool DateBookSettings::jumpToCurTime() const |
143 | { | 179 | { |
144 | return chkJumpToCurTime->isChecked(); | 180 | return chkJumpToCurTime->isChecked(); |
145 | } | 181 | } |
146 | 182 | ||
147 | void DateBookSettings::setRowStyle( int style ) | 183 | void DateBookSettings::setRowStyle( int style ) |
148 | { | 184 | { |
149 | comboRowStyle->setCurrentItem( style ); | 185 | comboRowStyle->setCurrentItem( style ); |
150 | } | 186 | } |
151 | 187 | ||
152 | int DateBookSettings::rowStyle() const | 188 | int DateBookSettings::rowStyle() const |
153 | { | 189 | { |
154 | return comboRowStyle->currentItem(); | 190 | return comboRowStyle->currentItem(); |
155 | } | 191 | } |