summaryrefslogtreecommitdiffabout
path: root/korganizer/kofilterview.cpp
Unidiff
Diffstat (limited to 'korganizer/kofilterview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index ee9c9f6..8335ba9 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,172 +1,176 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 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 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30#include <qtextstream.h> 30#include <q3textstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qwhatsthis.h> 32#include <q3whatsthis.h>
33#include <qdir.h> 33#include <qdir.h>
34//Added by qt3to4:
35#include <Q3GridLayout>
36#include <Q3Frame>
37#include <Q3PtrList>
34 38
35 39
36#include <libkcal/calfilter.h> 40#include <libkcal/calfilter.h>
37 41
38#include "kofilterview.h" 42#include "kofilterview.h"
39#include "koprefs.h" 43#include "koprefs.h"
40#include <kiconloader.h> 44#include <kiconloader.h>
41#include <kglobal.h> 45#include <kglobal.h>
42#include <kglobalsettings.h> 46#include <kglobalsettings.h>
43#include <kcolorbutton.h> 47#include <kcolorbutton.h>
44#include <kmessagebox.h> 48#include <kmessagebox.h>
45 49
46 50
47 51
48 52
49 53
50KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 54KOFilterView::KOFilterView(Q3PtrList<CalFilter> *filterList,QWidget* parent,
51 const char* name,WFlags fl ) 55 const char* name,Qt::WFlags fl )
52 : KOFilterView_base(parent,name,fl) 56 : KOFilterView_base(parent,name,fl)
53{ 57{
54 mFilters = filterList; 58 mFilters = filterList;
55 59
56 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 60 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
57 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 61 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
58 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 62 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
59} 63}
60 64
61KOFilterView::~KOFilterView() 65KOFilterView::~KOFilterView()
62{ 66{
63 // no need to delete child widgets, Qt does it all for us 67 // no need to delete child widgets, Qt does it all for us
64} 68}
65 69
66bool KOFilterView::filtersEnabled() 70bool KOFilterView::filtersEnabled()
67{ 71{
68 return mEnabledCheck->isChecked(); 72 return mEnabledCheck->isChecked();
69} 73}
70 74
71void KOFilterView::setFiltersEnabled(bool set) 75void KOFilterView::setFiltersEnabled(bool set)
72{ 76{
73 mEnabledCheck->setChecked(set); 77 mEnabledCheck->setChecked(set);
74 emit filterChanged(); 78 emit filterChanged();
75} 79}
76 80
77 81
78void KOFilterView::updateFilters() 82void KOFilterView::updateFilters()
79{ 83{
80 mSelectionCombo->clear(); 84 mSelectionCombo->clear();
81 85
82 CalFilter *filter = mFilters->first(); 86 CalFilter *filter = mFilters->first();
83 while(filter) { 87 while(filter) {
84 mSelectionCombo->insertItem(filter->name()); 88 mSelectionCombo->insertItem(filter->name());
85 filter = mFilters->next(); 89 filter = mFilters->next();
86 } 90 }
87} 91}
88 92
89CalFilter *KOFilterView::selectedFilter() 93CalFilter *KOFilterView::selectedFilter()
90{ 94{
91 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 95 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
92 return f; 96 return f;
93} 97}
94 98
95void KOFilterView::setSelectedFilter(QString filterName) 99void KOFilterView::setSelectedFilter(QString filterName)
96{ 100{
97 int filter_num = mSelectionCombo->count(); 101 int filter_num = mSelectionCombo->count();
98 int i; 102 int i;
99 for (i=0;i<filter_num;i++) { 103 for (i=0;i<filter_num;i++) {
100 if (mSelectionCombo->text(i)==filterName) 104 if (mSelectionCombo->text(i)==filterName)
101 mSelectionCombo->setCurrentItem(i); 105 mSelectionCombo->setCurrentItem(i);
102 } 106 }
103 emit filterChanged(); 107 emit filterChanged();
104} 108}
105void KOFilterView::setSelectedFilter( int fil ) 109void KOFilterView::setSelectedFilter( int fil )
106{ 110{
107 if ( fil >= mSelectionCombo->count() ) 111 if ( fil >= mSelectionCombo->count() )
108 return; 112 return;
109 mSelectionCombo->setCurrentItem( fil ); 113 mSelectionCombo->setCurrentItem( fil );
110 emit filterChanged(); 114 emit filterChanged();
111} 115}
112 116
113 117
114 118
115KOCalEditView::KOCalEditView(QWidget* parent, 119KOCalEditView::KOCalEditView(QWidget* parent,
116 const char* name ) 120 const char* name )
117 : QScrollView(parent,name) 121 : Q3ScrollView(parent,name)
118{ 122{
119 mw = 0; 123 mw = 0;
120 setResizePolicy( AutoOneFit ); 124 setResizePolicy( AutoOneFit );
121 setFrameStyle ( QFrame::Panel | QFrame::Plain ); 125 setFrameStyle ( Q3Frame::Panel | Q3Frame::Plain );
122 setLineWidth ( 1 ); 126 setLineWidth ( 1 );
123 setMidLineWidth ( 1 ); 127 setMidLineWidth ( 1 );
124 setFocusPolicy(NoFocus); 128 setFocusPolicy(Qt::NoFocus);
125} 129}
126 130
127KOCalEditView::~KOCalEditView() 131KOCalEditView::~KOCalEditView()
128{ 132{
129 // no need to delete child widgets, Qt does it all for us 133 // no need to delete child widgets, Qt does it all for us
130} 134}
131void KOCalEditView::selectCal(int id ,bool b) 135void KOCalEditView::selectCal(int id ,bool b)
132{ 136{
133 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 137 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
134 emit calendarEnabled ( id, b ); 138 emit calendarEnabled ( id, b );
135 emit needsUpdate(); 139 emit needsUpdate();
136 140
137} 141}
138void KOCalEditView::selectStdCal( int id ) 142void KOCalEditView::selectStdCal( int id )
139{ 143{
140 KOCalRadioButton* it = mStdandardB.first(); 144 KOCalRadioButton* it = mStdandardB.first();
141 while ( it ) { 145 while ( it ) {
142 it->blockSignals( true ); 146 it->blockSignals( true );
143 it->setChecked( it->num() == id ); 147 it->setChecked( it->num() == id );
144 it->blockSignals( false ); 148 it->blockSignals( false );
145 it = mStdandardB.next(); 149 it = mStdandardB.next();
146 } 150 }
147 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 151 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
148 while ( kkf ) { 152 while ( kkf ) {
149 kkf->isStandard = (kkf->mCalNumber == id ); 153 kkf->isStandard = (kkf->mCalNumber == id );
150 kkf = KOPrefs::instance()->mCalendars.next(); 154 kkf = KOPrefs::instance()->mCalendars.next();
151 } 155 }
152 emit setCalendarDefault ( id ); 156 emit setCalendarDefault ( id );
153} 157}
154 158
155void KOCalEditView::selectCalAlarm(int id ,bool b ) 159void KOCalEditView::selectCalAlarm(int id ,bool b )
156{ 160{
157 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 161 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
158 emit alarmEnabled ( id , b ); 162 emit alarmEnabled ( id , b );
159 emit needsUpdate(); 163 emit needsUpdate();
160} 164}
161void KOCalEditView::selectReadOnly(int id ,bool b ) 165void KOCalEditView::selectReadOnly(int id ,bool b )
162{ 166{
163 167
164 emit calendarReadonly ( id , b ); 168 emit calendarReadonly ( id , b );
165 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 169 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
166 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { 170 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) {
167 findNewStandard(); 171 findNewStandard();
168 } 172 }
169 if ( !b ){ 173 if ( !b ){
170 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 174 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
171 while ( kkf ) { 175 while ( kkf ) {
172 if (kkf->isReadOnly && kkf->isStandard ) { 176 if (kkf->isReadOnly && kkf->isStandard ) {
@@ -202,145 +206,145 @@ void KOCalEditView::findNewStandard()
202 206
203void KOCalEditView::setColor( const QColor& c, int id ) 207void KOCalEditView::setColor( const QColor& c, int id )
204{ 208{
205 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 209 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
206 emit needsUpdate(); 210 emit needsUpdate();
207} 211}
208void KOCalEditView::deleteCal( int id ) 212void KOCalEditView::deleteCal( int id )
209{ 213{
210 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 214 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
211 QString name = kkf->mName; 215 QString name = kkf->mName;
212 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 216 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
213 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 217 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
214 bool findnewstd = kkf->isStandard; 218 bool findnewstd = kkf->isStandard;
215 emit removeCalendar ( id ); 219 emit removeCalendar ( id );
216 KOPrefs::instance()->mCalendars.remove ( kkf ); 220 KOPrefs::instance()->mCalendars.remove ( kkf );
217 if ( findnewstd ) findNewStandard(); 221 if ( findnewstd ) findNewStandard();
218 emit needsUpdate(); 222 emit needsUpdate();
219 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 223 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
220} 224}
221void KOCalEditView::infoCal( int id ) 225void KOCalEditView::infoCal( int id )
222{ 226{
223 QString name = KOPrefs::instance()->getCalendar( id )->mName; 227 QString name = KOPrefs::instance()->getCalendar( id )->mName;
224 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); 228 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 );
225 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { 229 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
226 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { 230 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) {
227 emit calendarAdded( id ); 231 emit calendarAdded( id );
228 emit needsUpdate(); 232 emit needsUpdate();
229 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 233 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
230 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 234 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
231 } 235 }
232 } 236 }
233 else { 237 else {
234 emit requestCalendarInfo( id ); 238 emit requestCalendarInfo( id );
235 239
236 } 240 }
237} 241}
238void KOCalEditView::readConfig() 242void KOCalEditView::readConfig()
239{ 243{
240 244
241 mStdandardB.clear(); 245 mStdandardB.clear();
242 mEnabledB.clear(); 246 mEnabledB.clear();
243 mAlarmB.clear(); 247 mAlarmB.clear();
244 mROB.clear(); 248 mROB.clear();
245 249
246 if ( mw ) delete mw; 250 if ( mw ) delete mw;
247 mw = new QWidget ( viewport() ); 251 mw = new QWidget ( viewport() );
248 addChild(mw); 252 addChild(mw);
249 int ii = 0; 253 int ii = 0;
250 mainLayout = new QGridLayout ( mw , 2, 8 ); 254 mainLayout = new Q3GridLayout ( mw , 2, 8 );
251 mainLayout->setMargin( 2 ); 255 mainLayout->setMargin( 2 );
252 mainLayout->setSpacing( 2 ); 256 mainLayout->setSpacing( 2 );
253 QPushButton * addButT = new QPushButton ( mw ); 257 QPushButton * addButT = new QPushButton ( mw );
254 addButT->setFocusPolicy(NoFocus); 258 addButT->setFocusPolicy(Qt::NoFocus);
255 mainLayout->addWidget( addButT,0,0 ); 259 mainLayout->addWidget( addButT,0,0 );
256 addButT->setText( "D"); 260 addButT->setText( "D");
257 connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo())); 261 connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo()));
258 QWhatsThis::add( addButT, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); 262 Q3WhatsThis::add( addButT, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
259 //addBut->setPixmap ( SmallIcon("greenhook16")); 263 //addBut->setPixmap ( SmallIcon("greenhook16"));
260 QPushButton *addBut = new QPushButton ( mw ); 264 QPushButton *addBut = new QPushButton ( mw );
261 addBut->setFocusPolicy(NoFocus); 265 addBut->setFocusPolicy(Qt::NoFocus);
262 mainLayout->addWidget( addBut,0,++ii ); 266 mainLayout->addWidget( addBut,0,++ii );
263 addBut->setPixmap ( SmallIcon("eye")); 267 addBut->setPixmap ( SmallIcon("eye"));
264 QWhatsThis::add( addBut, i18n("In this column you can <b>set a calendar to be visible</b>. If a calendar is not visible its entries are not displayed in the views. You can add items to it and it is loaded/saved as usual.") ); 268 Q3WhatsThis::add( addBut, i18n("In this column you can <b>set a calendar to be visible</b>. If a calendar is not visible its entries are not displayed in the views. You can add items to it and it is loaded/saved as usual.") );
265 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 269 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
266 int max = addBut->sizeHint().height(); 270 int max = addBut->sizeHint().height();
267 addBut->setMaximumWidth( max ); 271 addBut->setMaximumWidth( max );
268 addButT->setFixedSize( QSize( max, max ) ); 272 addButT->setFixedSize( QSize( max, max ) );
269 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); 273 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw );
270 mainLayout->addWidget( lab,0,++ii ); 274 mainLayout->addWidget( lab,0,++ii );
271 QWhatsThis::add( lab, i18n("In this column you can see the <b>name of the calendar</b>. If you click on the name button you will get an information box about the loaded calendar file. If the file was not loaded at startup you can try to load it here again.") ); 275 Q3WhatsThis::add( lab, i18n("In this column you can see the <b>name of the calendar</b>. If you click on the name button you will get an information box about the loaded calendar file. If the file was not loaded at startup you can try to load it here again.") );
272 //lab = new QLabel ( i18n(" "), mw ); 276 //lab = new QLabel ( i18n(" "), mw );
273 //mainLayout->addWidget( lab,0,++ii ); 277 //mainLayout->addWidget( lab,0,++ii );
274 //lab->setFixedWidth( 1 ); 278 //lab->setFixedWidth( 1 );
275 addBut = new QPushButton ( mw ); 279 addBut = new QPushButton ( mw );
276 addBut->setFocusPolicy(NoFocus); 280 addBut->setFocusPolicy(Qt::NoFocus);
277 mainLayout->addWidget( addBut,0,++ii ); 281 mainLayout->addWidget( addBut,0,++ii );
278 addBut->setPixmap ( SmallIcon("bell")); 282 addBut->setPixmap ( SmallIcon("bell"));
279 QWhatsThis::add( addBut, i18n("In this column you can <b>disable the alarms of a calendar all together</b>. The alarm data in the calendar itself is not changed, the alarms are marked internally as \"do not use\". Useful if you load a calendar of another person but do not want to get notified about alarms of that person.") ); 283 Q3WhatsThis::add( addBut, i18n("In this column you can <b>disable the alarms of a calendar all together</b>. The alarm data in the calendar itself is not changed, the alarms are marked internally as \"do not use\". Useful if you load a calendar of another person but do not want to get notified about alarms of that person.") );
280 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 284 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
281 addBut->setMaximumWidth( addBut->sizeHint().height() ); 285 addBut->setMaximumWidth( addBut->sizeHint().height() );
282 286
283 addBut = new QPushButton ( mw ); 287 addBut = new QPushButton ( mw );
284 addBut->setFocusPolicy(NoFocus); 288 addBut->setFocusPolicy(Qt::NoFocus);
285 mainLayout->addWidget( addBut,0,++ii ); 289 mainLayout->addWidget( addBut,0,++ii );
286 addBut->setPixmap ( SmallIcon("pencil")); 290 addBut->setPixmap ( SmallIcon("pencil"));
287 QWhatsThis::add( addBut, i18n("In this column you can <b>set a calendar and all entries of the calendar to read only</b>. If a calendar is readonly the entries cannot be edited and no items can be added to the calendar. If you change a setting of a calendar to readonly in this column all data will be saved because the data of a readonly calendar is not saved later.") ); 291 Q3WhatsThis::add( addBut, i18n("In this column you can <b>set a calendar and all entries of the calendar to read only</b>. If a calendar is readonly the entries cannot be edited and no items can be added to the calendar. If you change a setting of a calendar to readonly in this column all data will be saved because the data of a readonly calendar is not saved later.") );
288 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 292 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
289 addBut->setMaximumWidth( addBut->sizeHint().height() ); 293 addBut->setMaximumWidth( addBut->sizeHint().height() );
290 lab = new QLabel ( "", mw ); 294 lab = new QLabel ( "", mw );
291 mainLayout->addWidget( lab,0,++ii ); 295 mainLayout->addWidget( lab,0,++ii );
292 296
293 addBut = new QPushButton ( mw ); 297 addBut = new QPushButton ( mw );
294 addBut->setFocusPolicy(NoFocus); 298 addBut->setFocusPolicy(Qt::NoFocus);
295 mainLayout->addWidget( addBut,0,++ii ); 299 mainLayout->addWidget( addBut,0,++ii );
296 addBut->setPixmap ( SmallIcon("plus")); 300 addBut->setPixmap ( SmallIcon("plus"));
297 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 301 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
298 QWhatsThis::add( addBut, i18n("Click this button to <b>add a calendar</b>. You can add an existing calendar file or you can add a new calendar and KO/Pi creates a new empty calendar file for you.") ); 302 Q3WhatsThis::add( addBut, i18n("Click this button to <b>add a calendar</b>. You can add an existing calendar file or you can add a new calendar and KO/Pi creates a new empty calendar file for you.") );
299 lab = new QLabel ( " ", mw ); 303 lab = new QLabel ( " ", mw );
300 mainLayout->addWidget( lab,0,++ii ); 304 mainLayout->addWidget( lab,0,++ii );
301 305
302 306
303 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 307 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
304 int row = 1; 308 int row = 1;
305 bool errorLoadStandard = false; 309 bool errorLoadStandard = false;
306 while ( kkf ) { 310 while ( kkf ) {
307 int iii = 0; 311 int iii = 0;
308 KOCalRadioButton* rb = new KOCalRadioButton( mw ); 312 KOCalRadioButton* rb = new KOCalRadioButton( mw );
309 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); 313 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb );
310 rb->setChecked( kkf->isStandard ); 314 rb->setChecked( kkf->isStandard );
311 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) 315 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) )
312 errorLoadStandard = true; 316 errorLoadStandard = true;
313 rb->setNum( kkf->mCalNumber ); 317 rb->setNum( kkf->mCalNumber );
314 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); 318 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) );
315 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 319 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
316 rb->setEnabled( false ); 320 rb->setEnabled( false );
317 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 321 KOCalCheckButton* cb = new KOCalCheckButton( mw );
318 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); 322 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
319 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); 323 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad );
320 cb->setNum( kkf->mCalNumber ); 324 cb->setNum( kkf->mCalNumber );
321 if ( kkf->mErrorOnLoad ) 325 if ( kkf->mErrorOnLoad )
322 cb->setEnabled( false ); 326 cb->setEnabled( false );
323 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 327 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
324 KOCalButton* name = new KOCalButton( mw ); 328 KOCalButton* name = new KOCalButton( mw );
325 name->setNum( kkf->mCalNumber ); 329 name->setNum( kkf->mCalNumber );
326 name->setText( kkf->mName ); 330 name->setText( kkf->mName );
327 mainLayout->addWidget( name,row,++iii ); 331 mainLayout->addWidget( name,row,++iii );
328 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 332 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
329 //lab = new QLabel (" ", mw ); 333 //lab = new QLabel (" ", mw );
330 //mainLayout->addWidget( lab,row,++iii ); 334 //mainLayout->addWidget( lab,row,++iii );
331 cb = new KOCalCheckButton( mw ); 335 cb = new KOCalCheckButton( mw );
332 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); 336 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
333 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); 337 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad);
334 cb->setNum( kkf->mCalNumber ); 338 cb->setNum( kkf->mCalNumber );
335 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 339 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
336 if ( kkf->mErrorOnLoad ) 340 if ( kkf->mErrorOnLoad )
337 cb->setEnabled( false ); 341 cb->setEnabled( false );
338 cb = new KOCalCheckButton( mw ); 342 cb = new KOCalCheckButton( mw );
339 mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); 343 mainLayout->addWidget( cb,row,++iii );mROB.append( cb );
340 cb->setChecked( kkf->isReadOnly ); 344 cb->setChecked( kkf->isReadOnly );
341 cb->setNum( kkf->mCalNumber ); 345 cb->setNum( kkf->mCalNumber );
342 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 346 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
343 if ( kkf->mErrorOnLoad ) 347 if ( kkf->mErrorOnLoad )
344 cb->setEnabled( false ); 348 cb->setEnabled( false );
345 if ( row > 1) { 349 if ( row > 1) {
346 KColorButton *colb = new KColorButton( mw ); 350 KColorButton *colb = new KColorButton( mw );
@@ -386,114 +390,114 @@ void KOCalEditView::addCal()
386 tryagain = false; 390 tryagain = false;
387 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 391 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
388 while ( kkf ) { 392 while ( kkf ) {
389 if ( kkf->mName == name ) { 393 if ( kkf->mName == name ) {
390 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 394 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
391 name = ""; 395 name = "";
392 tryagain = true; 396 tryagain = true;
393 break; 397 break;
394 } 398 }
395 if ( kkf->mFileName == file ) { 399 if ( kkf->mFileName == file ) {
396 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 400 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
397 tryagain = true; 401 tryagain = true;
398 file = KGlobalSettings::calendarDir()+"newCal.ics"; 402 file = KGlobalSettings::calendarDir()+"newCal.ics";
399 break; 403 break;
400 } 404 }
401 kkf = KOPrefs::instance()->mCalendars.next(); 405 kkf = KOPrefs::instance()->mCalendars.next();
402 } 406 }
403 QFileInfo fi ( file ); 407 QFileInfo fi ( file );
404 if ( fi.isDir() ) { 408 if ( fi.isDir() ) {
405 tryagain = true; 409 tryagain = true;
406 } 410 }
407 } 411 }
408 addCalendar ( name, file ); 412 addCalendar ( name, file );
409 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 413 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
410} 414}
411int KOCalEditView::addCalendar( QString name, QString file, bool ask ) 415int KOCalEditView::addCalendar( QString name, QString file, bool ask )
412{ 416{
413 file = QDir::convertSeparators( file ); 417 file = QDir::convertSeparators( file );
414 QFileInfo fi ( file ); 418 QFileInfo fi ( file );
415 QString absFile = file; 419 QString absFile = file;
416 bool isRelative = false; 420 bool isRelative = false;
417 if ( fi.isRelative() ) { 421 if ( fi.isRelative() ) {
418 isRelative = true; 422 isRelative = true;
419 absFile = QDir::convertSeparators( KGlobalSettings::calendarDir()+file ); 423 absFile = QDir::convertSeparators( KGlobalSettings::calendarDir()+file );
420 fi.setFile( absFile ); 424 fi.setFile( absFile );
421 } else { 425 } else {
422 QString cd = QDir::convertSeparators( KGlobalSettings::calendarDir() ); 426 QString cd = QDir::convertSeparators( KGlobalSettings::calendarDir() );
423 if ( file.left( cd.length() ) == cd ) { 427 if ( file.left( cd.length() ) == cd ) {
424 isRelative = true; 428 isRelative = true;
425 file = fi.fileName (); 429 file = fi.fileName ();
426 fi.setFile( absFile ); 430 fi.setFile( absFile );
427 } 431 }
428 } 432 }
429 if (!fi.exists() ) { 433 if (!fi.exists() ) {
430 if ( ask ) 434 if ( ask )
431 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) 435 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No )
432 return 0; 436 return 0;
433 QFile fileIn( absFile ); 437 QFile fileIn( absFile );
434 if (!fileIn.open( IO_WriteOnly ) ) { 438 if (!fileIn.open( QIODevice::WriteOnly ) ) {
435 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 439 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
436 return 0; 440 return 0;
437 } 441 }
438 QTextStream tsIn( &fileIn ); 442 Q3TextStream tsIn( &fileIn );
439 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 443 tsIn.setCodec( QTextCodec::codecForName("utf8") );
440 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 444 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
441 fileIn.close(); 445 fileIn.close();
442 } 446 }
443 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 447 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
444 kkf->mName = name; 448 kkf->mName = name;
445 kkf->mFileName = absFile; 449 kkf->mFileName = absFile;
446 kkf->mSavedFileName = file; 450 kkf->mSavedFileName = file;
447 kkf->isRelative = isRelative; 451 kkf->isRelative = isRelative;
448 emit calendarAdded( kkf->mCalNumber ); 452 emit calendarAdded( kkf->mCalNumber );
449 if ( ask ) 453 if ( ask )
450 emit needsUpdate(); 454 emit needsUpdate();
451 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 455 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
452 return kkf->mCalNumber; 456 return kkf->mCalNumber;
453} 457}
454int KOCalEditView::getBirtdayID() 458int KOCalEditView::getBirtdayID()
455{ 459{
456 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 460 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
457 while ( kkf ) { 461 while ( kkf ) {
458 if ( kkf->mName == i18n("Birthdays") ) 462 if ( kkf->mName == i18n("Birthdays") )
459 return kkf->mCalNumber; 463 return kkf->mCalNumber;
460 kkf = KOPrefs::instance()->mCalendars.next(); 464 kkf = KOPrefs::instance()->mCalendars.next();
461 } 465 }
462 QString file = locateLocal( "data", "korganizer/birthdays.ics" ); 466 QString file = locateLocal( "data", "korganizer/birthdays.ics" );
463 return addCalendar( i18n("Birthdays"), file, false ); 467 return addCalendar( i18n("Birthdays"), file, false );
464} 468}
465 469
466void KOCalEditView::enableAll() 470void KOCalEditView::enableAll()
467{ 471{
468 toggleList( mEnabledB ); 472 toggleList( mEnabledB );
469} 473}
470void KOCalEditView::enableAlarm() 474void KOCalEditView::enableAlarm()
471{ 475{
472 toggleList( mAlarmB ); 476 toggleList( mAlarmB );
473} 477}
474void KOCalEditView::disableRO() 478void KOCalEditView::disableRO()
475{ 479{
476 toggleList( mROB, false ); 480 toggleList( mROB, false );
477} 481}
478void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) 482void KOCalEditView::toggleList ( Q3PtrList<KOCalCheckButton> list , bool enable )
479{ 483{
480 bool dis = !enable; 484 bool dis = !enable;
481 KOCalCheckButton* it = list.first(); 485 KOCalCheckButton* it = list.first();
482 while ( it ) { 486 while ( it ) {
483 if ( !it->isChecked() == enable && it->isEnabled() ) { 487 if ( !it->isChecked() == enable && it->isEnabled() ) {
484 dis = !dis; 488 dis = !dis;
485 break; 489 break;
486 } 490 }
487 it = list.next(); 491 it = list.next();
488 } 492 }
489 it = list.first(); 493 it = list.first();
490 while ( it ) { 494 while ( it ) {
491 if ( it->isEnabled() ) 495 if ( it->isEnabled() )
492 it->setChecked(dis); 496 it->setChecked(dis);
493 it = list.next(); 497 it = list.next();
494 } 498 }
495} 499}
496void KOCalEditView::deleteAll() 500void KOCalEditView::deleteAll()
497{ 501{
498 qDebug("delteAll"); 502 qDebug("delteAll");
499} 503}