summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebooksettings.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebooksettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebooksettings.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index 861e266..561dc38 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,140 +1,168 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
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> 23#include <opie2/opluginloader.h>
24#include <opie2/odebug.h> 24#include <opie2/odebug.h>
25#include <opie2/oholidaypluginif.h>
26#include <opie2/oholidayplugin.h>
27#include <opie2/oholidayplugincfgwidget.h>
25 28
26#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
27 30
28#include <qspinbox.h> 31#include <qspinbox.h>
29#include <qcheckbox.h> 32#include <qcheckbox.h>
30#include <qlistview.h> 33#include <qlistview.h>
31#include <qheader.h> 34#include <qheader.h>
35#include <qtabwidget.h>
36#include <qlayout.h>
32 37
33DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 38DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
34 const char *name, bool modal, WFlags fl ) 39 const char *name, bool modal, WFlags fl )
35 : DateBookSettingsBase( parent, name, modal, fl ), 40 : DateBookSettingsBase( parent, name, modal, fl ),
36 ampm( whichClock ) 41 ampm( whichClock )
37{ 42{
38 init(); 43 init();
39 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); 44 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) );
40 QArray<int> categories; 45 QArray<int> categories;
41 comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); 46 comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
42 m_loader = 0; 47 m_loader = 0;
43 m_manager = 0; 48 m_manager = 0;
44 m_PluginListView->header()->hide(); 49 m_PluginListView->header()->hide();
45 m_PluginListView->setSorting(-1); 50 m_PluginListView->setSorting(-1);
46} 51}
47 52
48DateBookSettings::~DateBookSettings() 53DateBookSettings::~DateBookSettings()
49{ 54{
50} 55}
51 56
52void DateBookSettings::setStartTime( int newStartViewTime ) 57void DateBookSettings::setStartTime( int newStartViewTime )
53{ 58{
54 if ( ampm ) { 59 if ( ampm ) {
55 if ( newStartViewTime >= 12 ) { 60 if ( newStartViewTime >= 12 ) {
56 newStartViewTime %= 12; 61 newStartViewTime %= 12;
57 if ( newStartViewTime == 0 ) 62 if ( newStartViewTime == 0 )
58 newStartViewTime = 12; 63 newStartViewTime = 12;
59 spinStart->setSuffix( tr(":00 PM") ); 64 spinStart->setSuffix( tr(":00 PM") );
60 } 65 }
61 else if ( newStartViewTime == 0 ) { 66 else if ( newStartViewTime == 0 ) {
62 newStartViewTime = 12; 67 newStartViewTime = 12;
63 spinStart->setSuffix( tr(":00 AM") ); 68 spinStart->setSuffix( tr(":00 AM") );
64 } 69 }
65 oldtime = newStartViewTime; 70 oldtime = newStartViewTime;
66 } 71 }
67 spinStart->setValue( newStartViewTime ); 72 spinStart->setValue( newStartViewTime );
68} 73}
69 74
70int DateBookSettings::startTime() const 75int DateBookSettings::startTime() const
71{ 76{
72 int returnMe = spinStart->value(); 77 int returnMe = spinStart->value();
73 if ( ampm ) { 78 if ( ampm ) {
74 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 79 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
75 returnMe += 12; 80 returnMe += 12;
76 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 81 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
77 returnMe = 0; 82 returnMe = 0;
78 } 83 }
79 return returnMe; 84 return returnMe;
80} 85}
81 86
82void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader) 87void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader)
83{ 88{
84 m_manager = aManager; 89 m_manager = aManager;
85 m_loader = aLoader; 90 m_loader = aLoader;
86 if (!aManager||!aLoader) return; 91 if (!aManager||!aLoader) return;
87 Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true); 92 Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true);
88 QCheckListItem *pitem = 0; 93 QCheckListItem *pitem = 0;
89 94
90 for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { 95 for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) {
91 pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox); 96 pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox);
92 pitem->setOn( (*it).isEnabled() ); 97 pitem->setOn( (*it).isEnabled() );
98
99 Opie::Datebook::HolidayPluginIf*hif = m_loader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN);
100 if (!hif) continue;
101 Opie::Datebook::HolidayPlugin*pl = hif->plugin();
102 if (!pl) continue;
103 Opie::Datebook::HolidayPluginConfigWidget*cfg = pl->configWidget();
104 if (!cfg) continue;
105 QWidget * dtab = new QWidget(TabWidget,pl->description());
106 QVBoxLayout*dlayout = new QVBoxLayout(dtab);
107 dlayout->setMargin(2);
108 dlayout->setSpacing(2);
109 cfg->reparent(dtab,0,QPoint(0,0));
110 dlayout->addWidget(cfg);
111 TabWidget->insertTab(dtab,pl->description());
112
113 m_cfgWidgets.append(cfg);
114 }
115}
116void DateBookSettings::savePlugins()
117{
118 QValueList<Opie::Datebook::HolidayPluginConfigWidget*>::Iterator it;
119 for (it=m_cfgWidgets.begin();it!=m_cfgWidgets.end();++it) {
120 (*it)->saveConfig();
93 } 121 }
94} 122}
95 123
96void DateBookSettings::pluginItemClicked(QListViewItem *aItem) 124void DateBookSettings::pluginItemClicked(QListViewItem *aItem)
97{ 125{
98 if (!aItem||!m_manager||!m_loader) return; 126 if (!aItem||!m_manager||!m_loader) return;
99 QCheckListItem*pitem = ((QCheckListItem*)aItem); 127 QCheckListItem*pitem = ((QCheckListItem*)aItem);
100 128
101 Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true ); 129 Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true );
102 for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { 130 for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
103 if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) { 131 if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) {
104 m_manager->setEnabled((*it),pitem->isOn()); 132 m_manager->setEnabled((*it),pitem->isOn());
105 break; 133 break;
106 } 134 }
107 } 135 }
108} 136}
109 137
110void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 138void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
111{ 139{
112 chkAlarmPreset->setChecked( bAlarm ); 140 chkAlarmPreset->setChecked( bAlarm );
113 if ( presetTime >=5 ) 141 if ( presetTime >=5 )
114 spinPreset->setValue( presetTime ); 142 spinPreset->setValue( presetTime );
115} 143}
116 144
117bool DateBookSettings::alarmPreset() const 145bool DateBookSettings::alarmPreset() const
118{ 146{
119 return chkAlarmPreset->isChecked(); 147 return chkAlarmPreset->isChecked();
120} 148}
121 149
122int DateBookSettings::presetTime() const 150int DateBookSettings::presetTime() const
123{ 151{
124 return spinPreset->value(); 152 return spinPreset->value();
125} 153}
126 154
127 155
128void DateBookSettings::slot12Hour( int i ) 156void DateBookSettings::slot12Hour( int i )
129{ 157{
130 if ( ampm ) { 158 if ( ampm ) {
131 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 159 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
132 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 160 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
133 spinStart->setSuffix( tr(":00 PM") ); 161 spinStart->setSuffix( tr(":00 PM") );
134 } else { 162 } else {
135 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 163 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
136 spinStart->setSuffix( tr(":00 AM") ); 164 spinStart->setSuffix( tr(":00 AM") );
137 } 165 }
138 oldtime = i; 166 oldtime = i;
139 } 167 }
140} 168}