summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 9709324..a8a3052 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,441 +1,434 @@
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 <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32 32
33 33
34#include <libkcal/calfilter.h> 34#include <libkcal/calfilter.h>
35 35
36#include "kofilterview.h" 36#include "kofilterview.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#include <kiconloader.h> 38#include <kiconloader.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <kcolorbutton.h> 40#include <kcolorbutton.h>
41#include <kmessagebox.h> 41#include <kmessagebox.h>
42 42
43 43
44 44
45 45
46 46
47KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 47KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
48 const char* name,WFlags fl ) 48 const char* name,WFlags fl )
49 : KOFilterView_base(parent,name,fl) 49 : KOFilterView_base(parent,name,fl)
50{ 50{
51 mFilters = filterList; 51 mFilters = filterList;
52 52
53 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 53 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
54 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 54 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
55 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 55 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
56} 56}
57 57
58KOFilterView::~KOFilterView() 58KOFilterView::~KOFilterView()
59{ 59{
60 // no need to delete child widgets, Qt does it all for us 60 // no need to delete child widgets, Qt does it all for us
61} 61}
62 62
63bool KOFilterView::filtersEnabled() 63bool KOFilterView::filtersEnabled()
64{ 64{
65 return mEnabledCheck->isChecked(); 65 return mEnabledCheck->isChecked();
66} 66}
67 67
68void KOFilterView::setFiltersEnabled(bool set) 68void KOFilterView::setFiltersEnabled(bool set)
69{ 69{
70 mEnabledCheck->setChecked(set); 70 mEnabledCheck->setChecked(set);
71 emit filterChanged(); 71 emit filterChanged();
72} 72}
73 73
74 74
75void KOFilterView::updateFilters() 75void KOFilterView::updateFilters()
76{ 76{
77 mSelectionCombo->clear(); 77 mSelectionCombo->clear();
78 78
79 CalFilter *filter = mFilters->first(); 79 CalFilter *filter = mFilters->first();
80 while(filter) { 80 while(filter) {
81 mSelectionCombo->insertItem(filter->name()); 81 mSelectionCombo->insertItem(filter->name());
82 filter = mFilters->next(); 82 filter = mFilters->next();
83 } 83 }
84} 84}
85 85
86CalFilter *KOFilterView::selectedFilter() 86CalFilter *KOFilterView::selectedFilter()
87{ 87{
88 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 88 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
89 return f; 89 return f;
90} 90}
91 91
92void KOFilterView::setSelectedFilter(QString filterName) 92void KOFilterView::setSelectedFilter(QString filterName)
93{ 93{
94 int filter_num = mSelectionCombo->count(); 94 int filter_num = mSelectionCombo->count();
95 int i; 95 int i;
96 for (i=0;i<filter_num;i++) { 96 for (i=0;i<filter_num;i++) {
97 if (mSelectionCombo->text(i)==filterName) 97 if (mSelectionCombo->text(i)==filterName)
98 mSelectionCombo->setCurrentItem(i); 98 mSelectionCombo->setCurrentItem(i);
99 } 99 }
100 emit filterChanged(); 100 emit filterChanged();
101} 101}
102void KOFilterView::setSelectedFilter( int fil ) 102void KOFilterView::setSelectedFilter( int fil )
103{ 103{
104 if ( fil >= mSelectionCombo->count() ) 104 if ( fil >= mSelectionCombo->count() )
105 return; 105 return;
106 mSelectionCombo->setCurrentItem( fil ); 106 mSelectionCombo->setCurrentItem( fil );
107 emit filterChanged(); 107 emit filterChanged();
108} 108}
109 109
110 110
111 111
112KOCalEditView::KOCalEditView(QWidget* parent, 112KOCalEditView::KOCalEditView(QWidget* parent,
113 const char* name ) 113 const char* name )
114 : QScrollView(parent,name) 114 : QScrollView(parent,name)
115{ 115{
116 mw = 0; 116 mw = 0;
117 setResizePolicy( AutoOneFit ); 117 setResizePolicy( AutoOneFit );
118 setFrameStyle ( QFrame::Panel | QFrame::Plain ); 118 setFrameStyle ( QFrame::Panel | QFrame::Plain );
119 setLineWidth ( 1 ); 119 setLineWidth ( 1 );
120 setMidLineWidth ( 1 ); 120 setMidLineWidth ( 1 );
121 setFocusPolicy(NoFocus); 121 setFocusPolicy(NoFocus);
122} 122}
123 123
124KOCalEditView::~KOCalEditView() 124KOCalEditView::~KOCalEditView()
125{ 125{
126 // no need to delete child widgets, Qt does it all for us 126 // no need to delete child widgets, Qt does it all for us
127} 127}
128void KOCalEditView::selectCal(int id ,bool b) 128void KOCalEditView::selectCal(int id ,bool b)
129{ 129{
130 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 130 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
131 emit calendarEnabled ( id, b ); 131 emit calendarEnabled ( id, b );
132 emit needsUpdate(); 132 emit needsUpdate();
133 133
134} 134}
135void KOCalEditView::selectStdCal( int id, bool b ) 135void KOCalEditView::selectStdCal( int id, bool b )
136{ 136{
137 137
138 if ( !b ) { 138 if ( !b ) {
139 KOCalCheckButton* it = (KOCalCheckButton*) sender(); 139 KOCalCheckButton* it = (KOCalCheckButton*) sender();
140 if ( it ) { 140 if ( it ) {
141 it->blockSignals( true ); 141 it->blockSignals( true );
142 it->setChecked( true ); 142 it->setChecked( true );
143 it->blockSignals( false ); 143 it->blockSignals( false );
144 return; 144 return;
145 } 145 }
146 return; 146 return;
147 } 147 }
148 KOCalRadioButton* sen = (KOCalRadioButton*) sender(); 148 KOCalRadioButton* sen = (KOCalRadioButton*) sender();
149 KOCalRadioButton* it = mStdandardB.first(); 149 KOCalRadioButton* it = mStdandardB.first();
150 while ( it ) { 150 while ( it ) {
151 if ( it->isChecked() ) { 151 if ( it->isChecked() ) {
152 if ( it != sen ) { 152 if ( it != sen ) {
153 it->blockSignals( true ); 153 it->blockSignals( true );
154 it->setChecked( false ); 154 it->setChecked( false );
155 it->blockSignals( false ); 155 it->blockSignals( false );
156 break; 156 break;
157 } 157 }
158 } 158 }
159 it = mStdandardB.next(); 159 it = mStdandardB.next();
160 } 160 }
161 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 161 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
162 while ( kkf ) { 162 while ( kkf ) {
163 kkf->isStandard = false; 163 kkf->isStandard = false;
164 kkf = KOPrefs::instance()->mCalendars.next(); 164 kkf = KOPrefs::instance()->mCalendars.next();
165 } 165 }
166 KOPrefs::instance()->getCalendar( id )->isStandard = true; 166 KOPrefs::instance()->getCalendar( id )->isStandard = true;
167 emit setCalendarDefault ( id ); 167 emit setCalendarDefault ( id );
168} 168}
169 169
170void KOCalEditView::selectCalAlarm(int id ,bool b ) 170void KOCalEditView::selectCalAlarm(int id ,bool b )
171{ 171{
172 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 172 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
173 emit alarmEnabled ( id , b ); 173 emit alarmEnabled ( id , b );
174 emit needsUpdate(); 174 emit needsUpdate();
175} 175}
176void KOCalEditView::selectReadOnly(int id ,bool b ) 176void KOCalEditView::selectReadOnly(int id ,bool b )
177{ 177{
178 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 178 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
179 emit calendarReadonly ( id , b ); 179 emit calendarReadonly ( id , b );
180 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { 180 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) {
181 KOPrefs::instance()->getCalendar( id )->isStandard = false; 181 KOPrefs::instance()->getCalendar( id )->isStandard = false;
182 KOPrefs::instance()->getCalendar( 1 )->isStandard = true; 182 KOPrefs::instance()->getCalendar( 1 )->isStandard = true;
183 mStdandardB.at(0)->setChecked( true );
184 mStdandardB.at(id-1)->setChecked( false );
183 emit setCalendarDefault ( 1 ); 185 emit setCalendarDefault ( 1 );
184 } 186 }
187 mStdandardB.at(id-1)->setEnabled( !b );
185 emit needsUpdate(); 188 emit needsUpdate();
186 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
187 189
188} 190}
189void KOCalEditView::setColor( const QColor& c, int id ) 191void KOCalEditView::setColor( const QColor& c, int id )
190{ 192{
191 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 193 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
192 emit needsUpdate(); 194 emit needsUpdate();
193} 195}
194void KOCalEditView::deleteCal( int id ) 196void KOCalEditView::deleteCal( int id )
195{ 197{
196 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 198 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
197 QString name = kkf->mName; 199 QString name = kkf->mName;
198 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 200 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
199 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; 201 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;
200 if ( kkf->isStandard ) 202 if ( kkf->isStandard )
201 selectStdCal( 1, true ); 203 selectStdCal( 1, true );
202 emit removeCalendar ( id ); 204 emit removeCalendar ( id );
203 KOPrefs::instance()->mCalendars.remove ( kkf ); 205 KOPrefs::instance()->mCalendars.remove ( kkf );
204 emit needsUpdate(); 206 emit needsUpdate();
205 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 207 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
206} 208}
207void KOCalEditView::infoCal( int id ) 209void KOCalEditView::infoCal( int id )
208{ 210{
209 QString name = KOPrefs::instance()->getCalendar( id )->mName; 211 QString name = KOPrefs::instance()->getCalendar( id )->mName;
210 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); 212 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 );
211 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { 213 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
212 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) ) ) { 214 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) ) ) {
213 emit calendarAdded( id ); 215 emit calendarAdded( id );
214 emit needsUpdate(); 216 emit needsUpdate();
215 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 217 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
216 } 218 }
217 } 219 }
218 else 220 else
219 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 221 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
220} 222}
221void KOCalEditView::readConfig() 223void KOCalEditView::readConfig()
222{ 224{
223 225
224 mStdandardB.clear(); 226 mStdandardB.clear();
225 mEnabledB.clear(); 227 mEnabledB.clear();
226 mAlarmB.clear(); 228 mAlarmB.clear();
227 mROB.clear(); 229 mROB.clear();
228 230
229 if ( mw ) delete mw; 231 if ( mw ) delete mw;
230 mw = new QWidget ( viewport() ); 232 mw = new QWidget ( viewport() );
231 addChild(mw); 233 addChild(mw);
232 int ii = 0; 234 int ii = 0;
233 mainLayout = new QGridLayout ( mw , 2, 8 ); 235 mainLayout = new QGridLayout ( mw , 2, 8 );
234 mainLayout->setMargin( 2 ); 236 mainLayout->setMargin( 2 );
235 mainLayout->setSpacing( 2 ); 237 mainLayout->setSpacing( 2 );
236 QPushButton * addBut = new QPushButton ( mw ); 238 QPushButton * addBut = new QPushButton ( mw );
237 addBut->setFocusPolicy(NoFocus); 239 addBut->setFocusPolicy(NoFocus);
238 mainLayout->addWidget( addBut,0,0 ); 240 mainLayout->addWidget( addBut,0,0 );
239 addBut->setText( "D"); 241 addBut->setText( "D");
240 connect(addBut,SIGNAL(clicked()),SLOT(defaultInfo())); 242 connect(addBut,SIGNAL(clicked()),SLOT(defaultInfo()));
241 //addBut->setPixmap ( SmallIcon("greenhook16")); 243 //addBut->setPixmap ( SmallIcon("greenhook16"));
242 addBut->setMaximumWidth( addBut->sizeHint().height() ); 244 addBut->setMaximumWidth( addBut->sizeHint().height() );
243 int max = addBut->sizeHint().height(); 245 int max = addBut->sizeHint().height();
244 addBut = new QPushButton ( mw ); 246 addBut = new QPushButton ( mw );
245 addBut->setFocusPolicy(NoFocus); 247 addBut->setFocusPolicy(NoFocus);
246 mainLayout->addWidget( addBut,0,++ii ); 248 mainLayout->addWidget( addBut,0,++ii );
247 addBut->setPixmap ( SmallIcon("eye")); 249 addBut->setPixmap ( SmallIcon("eye"));
248 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 250 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
249 addBut->setMaximumWidth( addBut->sizeHint().height() ); 251 addBut->setMaximumWidth( addBut->sizeHint().height() );
250 252
251 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); 253 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw );
252 mainLayout->addWidget( lab,0,++ii ); 254 mainLayout->addWidget( lab,0,++ii );
253 //lab = new QLabel ( i18n(" "), mw ); 255 //lab = new QLabel ( i18n(" "), mw );
254 //mainLayout->addWidget( lab,0,++ii ); 256 //mainLayout->addWidget( lab,0,++ii );
255 //lab->setFixedWidth( 1 ); 257 //lab->setFixedWidth( 1 );
256 addBut = new QPushButton ( mw ); 258 addBut = new QPushButton ( mw );
257 addBut->setFocusPolicy(NoFocus); 259 addBut->setFocusPolicy(NoFocus);
258 mainLayout->addWidget( addBut,0,++ii ); 260 mainLayout->addWidget( addBut,0,++ii );
259 addBut->setPixmap ( SmallIcon("bell")); 261 addBut->setPixmap ( SmallIcon("bell"));
260 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 262 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
261 addBut->setMaximumWidth( addBut->sizeHint().height() ); 263 addBut->setMaximumWidth( addBut->sizeHint().height() );
262 264
263 addBut = new QPushButton ( mw ); 265 addBut = new QPushButton ( mw );
264 addBut->setFocusPolicy(NoFocus); 266 addBut->setFocusPolicy(NoFocus);
265 mainLayout->addWidget( addBut,0,++ii ); 267 mainLayout->addWidget( addBut,0,++ii );
266 addBut->setPixmap ( SmallIcon("pencil")); 268 addBut->setPixmap ( SmallIcon("pencil"));
267 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 269 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
268 addBut->setMaximumWidth( addBut->sizeHint().height() ); 270 addBut->setMaximumWidth( addBut->sizeHint().height() );
269 lab = new QLabel ( "", mw ); 271 lab = new QLabel ( "", mw );
270 mainLayout->addWidget( lab,0,++ii ); 272 mainLayout->addWidget( lab,0,++ii );
271 273
272 addBut = new QPushButton ( mw ); 274 addBut = new QPushButton ( mw );
273 addBut->setFocusPolicy(NoFocus); 275 addBut->setFocusPolicy(NoFocus);
274 mainLayout->addWidget( addBut,0,++ii ); 276 mainLayout->addWidget( addBut,0,++ii );
275 addBut->setPixmap ( SmallIcon("plus")); 277 addBut->setPixmap ( SmallIcon("plus"));
276 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 278 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
277 279
278 lab = new QLabel ( " ", mw ); 280 lab = new QLabel ( " ", mw );
279 mainLayout->addWidget( lab,0,++ii ); 281 mainLayout->addWidget( lab,0,++ii );
280 282
281 283
282#if 0
283 addBut = new QPushButton ( mw );
284 mainLayout->addWidget( addBut,0,6 );
285 addBut->setPixmap ( SmallIcon("minus"));
286 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
287 addBut->setMaximumWidth( addBut->sizeHint().height() );
288#endif
289
290
291 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 284 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
292 int row = 1; 285 int row = 1;
293 while ( kkf ) { 286 while ( kkf ) {
294 int iii = 0; 287 int iii = 0;
295 KOCalRadioButton* rb = new KOCalRadioButton( mw ); 288 KOCalRadioButton* rb = new KOCalRadioButton( mw );
296 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); 289 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb );
297 rb->setChecked( kkf->isStandard ); 290 rb->setChecked( kkf->isStandard );
298 rb->setNum( kkf->mCalNumber ); 291 rb->setNum( kkf->mCalNumber );
299 connect (rb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); 292 connect (rb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
300 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 293 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
301 rb->setEnabled( false ); 294 rb->setEnabled( false );
302 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 295 KOCalCheckButton* cb = new KOCalCheckButton( mw );
303 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); 296 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
304 cb->setChecked( kkf->isEnabled ); 297 cb->setChecked( kkf->isEnabled );
305 cb->setNum( kkf->mCalNumber ); 298 cb->setNum( kkf->mCalNumber );
306 if ( kkf->mErrorOnLoad ) 299 if ( kkf->mErrorOnLoad )
307 cb->setEnabled( false ); 300 cb->setEnabled( false );
308 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 301 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
309 KOCalButton* name = new KOCalButton( mw ); 302 KOCalButton* name = new KOCalButton( mw );
310 name->setNum( kkf->mCalNumber ); 303 name->setNum( kkf->mCalNumber );
311 name->setText( kkf->mName ); 304 name->setText( kkf->mName );
312 mainLayout->addWidget( name,row,++iii ); 305 mainLayout->addWidget( name,row,++iii );
313 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 306 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
314 //lab = new QLabel (" ", mw ); 307 //lab = new QLabel (" ", mw );
315 //mainLayout->addWidget( lab,row,++iii ); 308 //mainLayout->addWidget( lab,row,++iii );
316 cb = new KOCalCheckButton( mw ); 309 cb = new KOCalCheckButton( mw );
317 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); 310 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
318 cb->setChecked( kkf->isAlarmEnabled ); 311 cb->setChecked( kkf->isAlarmEnabled );
319 cb->setNum( kkf->mCalNumber ); 312 cb->setNum( kkf->mCalNumber );
320 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 313 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
321 if ( kkf->mErrorOnLoad ) 314 if ( kkf->mErrorOnLoad )
322 cb->setEnabled( false ); 315 cb->setEnabled( false );
323 cb = new KOCalCheckButton( mw ); 316 cb = new KOCalCheckButton( mw );
324 mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); 317 mainLayout->addWidget( cb,row,++iii );mROB.append( cb );
325 cb->setChecked( kkf->isReadOnly ); 318 cb->setChecked( kkf->isReadOnly );
326 cb->setNum( kkf->mCalNumber ); 319 cb->setNum( kkf->mCalNumber );
327 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 320 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
328 if ( kkf->mErrorOnLoad ) 321 if ( kkf->mErrorOnLoad )
329 cb->setEnabled( false ); 322 cb->setEnabled( false );
330 if ( row > 1) { 323 if ( row > 1) {
331 KColorButton *colb = new KColorButton( mw ); 324 KColorButton *colb = new KColorButton( mw );
332 mainLayout->addWidget( colb,row,++iii ); 325 mainLayout->addWidget( colb,row,++iii );
333 colb->setID( kkf->mCalNumber ); 326 colb->setID( kkf->mCalNumber );
334 colb->setColor( kkf->mDefaultColor ); 327 colb->setColor( kkf->mDefaultColor );
335 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 328 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
336 KOCalButton* calb = new KOCalButton( mw ); 329 KOCalButton* calb = new KOCalButton( mw );
337 mainLayout->addWidget( calb,row,++iii ); 330 mainLayout->addWidget( calb,row,++iii );
338 calb->setNum( kkf->mCalNumber ); 331 calb->setNum( kkf->mCalNumber );
339 calb->setPixmap ( SmallIcon("minus")); 332 calb->setPixmap ( SmallIcon("minus"));
340 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 333 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
341 int hei = calb->sizeHint().height(); 334 int hei = calb->sizeHint().height();
342 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 335 //calb->setMaximumSize( hei*9/10, hei*9/10 );
343 } 336 }
344 ++row; 337 ++row;
345 kkf = KOPrefs::instance()->mCalendars.next(); 338 kkf = KOPrefs::instance()->mCalendars.next();
346 } 339 }
347 lab = new QLabel ( "", mw ); 340 lab = new QLabel ( "", mw );
348 mainLayout->addWidget( lab,row,0 ); 341 mainLayout->addWidget( lab,row,0 );
349 mw->show(); 342 mw->show();
350 343
351} 344}
352 345
353 346
354void KOCalEditView::defaultInfo() 347void KOCalEditView::defaultInfo()
355{ 348{
356 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); 349 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
357} 350}
358void KOCalEditView::addCal() 351void KOCalEditView::addCal()
359{ 352{
360 bool tryagain = true; 353 bool tryagain = true;
361 QString name, file; 354 QString name, file;
362 while ( tryagain ) { 355 while ( tryagain ) {
363 KONewCalPrefs prefs ( this ); 356 KONewCalPrefs prefs ( this );
364 prefs.nameE->setText( name ); 357 prefs.nameE->setText( name );
365 prefs.url->setURL( file ); 358 prefs.url->setURL( file );
366 if ( ! prefs.exec() ) 359 if ( ! prefs.exec() )
367 return; 360 return;
368 name = prefs.calName(); 361 name = prefs.calName();
369 file = prefs.calFileName(); 362 file = prefs.calFileName();
370 tryagain = false; 363 tryagain = false;
371 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 364 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
372 while ( kkf ) { 365 while ( kkf ) {
373 if ( kkf->mName == name ) { 366 if ( kkf->mName == name ) {
374 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 367 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
375 name = ""; 368 name = "";
376 tryagain = true; 369 tryagain = true;
377 break; 370 break;
378 } 371 }
379 if ( kkf->mFileName == file ) { 372 if ( kkf->mFileName == file ) {
380 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 373 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
381 tryagain = true; 374 tryagain = true;
382 file = ""; 375 file = "";
383 break; 376 break;
384 } 377 }
385 kkf = KOPrefs::instance()->mCalendars.next(); 378 kkf = KOPrefs::instance()->mCalendars.next();
386 } 379 }
387 } 380 }
388 QFileInfo fi ( file ); 381 QFileInfo fi ( file );
389 if (!fi.exists() ) { 382 if (!fi.exists() ) {
390 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) 383 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No )
391 return; 384 return;
392 QFile fileIn( file ); 385 QFile fileIn( file );
393 if (!fileIn.open( IO_WriteOnly ) ) { 386 if (!fileIn.open( IO_WriteOnly ) ) {
394 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 387 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
395 return; 388 return;
396 } 389 }
397 QTextStream tsIn( &fileIn ); 390 QTextStream tsIn( &fileIn );
398 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 391 tsIn.setCodec( QTextCodec::codecForName("utf8") );
399 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 392 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
400 fileIn.close(); 393 fileIn.close();
401 } 394 }
402 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 395 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
403 kkf->mName = name; 396 kkf->mName = name;
404 kkf->mFileName = file; 397 kkf->mFileName = file;
405 emit calendarAdded( kkf->mCalNumber ); 398 emit calendarAdded( kkf->mCalNumber );
406 emit needsUpdate(); 399 emit needsUpdate();
407 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 400 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
408} 401}
409void KOCalEditView::enableAll() 402void KOCalEditView::enableAll()
410{ 403{
411 toggleList( mEnabledB ); 404 toggleList( mEnabledB );
412} 405}
413void KOCalEditView::enableAlarm() 406void KOCalEditView::enableAlarm()
414{ 407{
415 toggleList( mAlarmB ); 408 toggleList( mAlarmB );
416} 409}
417void KOCalEditView::disableRO() 410void KOCalEditView::disableRO()
418{ 411{
419 toggleList( mROB ); 412 toggleList( mROB );
420} 413}
421void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) 414void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
422{ 415{
423 bool dis = false; 416 bool dis = false;
424 KOCalCheckButton* it = list.first(); 417 KOCalCheckButton* it = list.first();
425 while ( it ) { 418 while ( it ) {
426 if ( !it->isChecked() ) { 419 if ( !it->isChecked() ) {
427 dis = true; 420 dis = true;
428 break; 421 break;
429 } 422 }
430 it = list.next(); 423 it = list.next();
431 } 424 }
432 it = list.first(); 425 it = list.first();
433 while ( it ) { 426 while ( it ) {
434 it->setChecked(dis); 427 it->setChecked(dis);
435 it = list.next(); 428 it = list.next();
436 } 429 }
437} 430}
438void KOCalEditView::deleteAll() 431void KOCalEditView::deleteAll()
439{ 432{
440 qDebug("delteAll"); 433 qDebug("delteAll");
441} 434}