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